Presentation is loading. Please wait.

Presentation is loading. Please wait.

To Start Create C:\100 folder

Similar presentations


Presentation on theme: "To Start Create C:\100 folder"— Presentation transcript:

1 To Start Create C:\100 folder
Create a shortcut on desktop or taskbar to Python IDLE

2 Values Python has a set of recognized value types
Integer (int): -10, 0, 45 Real (float): -1.25, 0.0, 4.5 String (str): ‘a’, ‘aa’, ‘11 cats’ Boolean (true, false) Python has functions to switch types int() float() str()

3 Operators Arithmetic String Operator for arithmetic expressions
+, -, *, /, ** (exponentiation), // (integer division), % (mod) String + (concatenation)

4 Division Enter the following and check results >>> 3/2
>>> 3.0/2

5 Variables Variable Holds a value after a value is assigned
>>> spam = 40 >>> spam = -2

6 Names: variables & functions
Holds a value Function We implement algorithms (recipes) Has parameters, arguments in () The order of arguments determine which values are being passed in Returns a value (mapping)

7 Naming Convention for both Variables and Functions
MUST start with a letter followed by alphanumeric aVar, cs100, … CASE matters ‘Print’ is not the same as ‘print’ ‘makePicture’ is not the same as ‘makepicture’, nor as ‘Makepicture’ Multi-word name First letter is capitalized Convention, not absolute rule Use sensible, meaningful name

8 Strings >>> print(‘a ‘+ ‘b ’ +’c’)
>>> name = “ada lovelace” >>> print(name.title()) >>> print(name.upper()) >>> print(name.strip()) >>> print(‘\t’ + name) >>> print(‘\n’ + name)

9 Strings >>> age = 23
>>> print(“Happy ” + age + “rd Birthday!”) => Error on types >>> print(“Happy “, age, “rd Birthday!”)

10 Input/Oupt Functions print(): print out the text in the argument
Input(): get Python ready to accept a response (nothing in argument) print(‘What is your age?’) myAge = input() What value will the variable myAge have ?

11 Lab 0908 print(‘What is your age?’) myAge = input()
Ask what the name is Ask what the major is Ask when you started the school Print “My name is …. studying ... from ....” the screenshot of Python Shell (IDLE) to


Download ppt "To Start Create C:\100 folder"

Similar presentations


Ads by Google