-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Simple Output
Quick Reference x in y results in True if x is a member of sequence y. print(x) print the value in x and a new line.
x not in y results in True if x is not a member of sequence y. prin(x, y) print the value in x and a space.
print(x,y, sep=“...”) prints the values of x, y separated by “...”
stores the integer in x Identity Operators instead of the default space. print(x, y, sep=“ ’’, end = “::”)
x is y Evaluates to True if the variables on either side of the prints the values of x, y seperated by a tab and instead of
stores the float in y
operator point to the same object. ending with a newline
s = “Hello World” stores string Hello World in s
x is not y Evaluates to False if the variables on either side
of the op-erator point to the same object.
The Boolean constants are True and False. print ( ‘ ‘ positive ’ ’ )
Note the capitalization. gives the integer
gives the integer
gives the float
Arithmetic Operations gives the float
gives the string print ( ‘ ‘ positive ’ ’ )
x + y computes the sum of x and y
gives the string else :
x - y computes the value of y subtracted from x
p r i n t ( ’ ' not p o s i t i v e ’ ’ )
x * y computes the product of x and y
x ** y computes x raised to y
x % y computes the remainder when x is divided by y
x / y computes the float value of x divided by y. I n P y t h o n b l o c k s a r e i d e n t i fi e d by
/ gives indentation .
x // y computes the quotient when x is divided by y print ( ‘ ‘ positive ’ ’ )
// gives
print ( ‘ ‘ negative )
else :
statement must end in a colon. It can be an if p r i n t ( ‘ ‘ Zero ’ ’ )
Returns Boolean values True or False statement, while statement, for statement or a def statement
x == y checks if x is equal to y Similarly,
x != y checks if x is not equal to y statement
x > y checks if value in x is greater than y
x > y checks if value in x is greater than that in y p r i n t ( ‘ ‘ The v a l u e o f x i s ’ ’ , x )
x ≥ y checks if x is greater than or equal to y
x < y checks if value in x is less than that in y
x ≤ y checks if value in x is less than or equal to y Prints x
x < y < z checks if y is in between x and z
s = "I am a string"
enclosed in double quotes.
returns True if both conditions are True Simple Input s = 'He said "Good Morning", to the class’
returns True if either condition is True x = input() for taking input. use single quotes if there is a double quote in the string.
not x > negates the condition x = input("Enter number: ") display a prompt while taking s = "It's time"
input. use double quotes if there is a single quote in the string.
The value given by input is always a string.