Output
Output is anything that your program shows on the computer screen. A python program shows or outputs a message such as Hello World on the computer screen, using the command print
print ( "Hello World" )
firstNname = "Alex S."
print ( "Hello" , firstName) # shows message "Hello Alex S"
print ( "Hello %s" %firstName) # shows message "Hello Alex S"
% tells the computer to output a variable type of data, that can either be a number or a string
Variables are names for information that is temporarily stored in your computer memory (RAM).
Variable is a name such as firstName that holds a certain Data Type. Python Variables can change their own data types.
Python Data Types:
Compiler - the program which turns your code into an actual program
Multiline Comment - comments that can go on multiple lines. Start and End these with three single quotes ''' '''
< Example > Output, Variables, and Data Types

Output is anything that your program shows on the computer screen. A python program shows or outputs a message such as Hello World on the computer screen, using the command print
print ( "Hello World" )
firstNname = "Alex S."
print ( "Hello" , firstName) # shows message "Hello Alex S"
print ( "Hello %s" %firstName) # shows message "Hello Alex S"
% tells the computer to output a variable type of data, that can either be a number or a string
- %f - outputs a float number. < Ex > print ("Pi = %f, e=%f " %(3.1416, 2.71828) )
- %.2f outputs a float number rounded to two decimals. < Ex > print (" e= %.2f , Pi= %.2f " %(2.71828, 3.1416))
- %i outputs an integer. < Ex > print ("num = %i" %3)
- %s outputs a String. < Ex > print ("Hello %s, good morning!" %firstName)
- the message above will read: Hello Alex S. , good morning!
Variables are names for information that is temporarily stored in your computer memory (RAM).
Variable is a name such as firstName that holds a certain Data Type. Python Variables can change their own data types.
Python Data Types:
- whole numbers ( int ) < Ex > 3 , 101, 15...
- decimal numbers ( float ) < Ex > 3.14, 2.72, 101.181...
- strings (" ") < Ex > "Alex S" , "Hello World!"
- lists ( [ ] ) < Ex > [ 1, 2, 3, 4, "Alex", 'c' ]
Compiler - the program which turns your code into an actual program
Multiline Comment - comments that can go on multiple lines. Start and End these with three single quotes ''' '''
< Example > Output, Variables, and Data Types
No comments:
Post a Comment