Python 3 Flashcards
Range based for loop with i
10 numbers
Goes up by 2 each loop
For i in range(0,10,2)
Python comments
#
X = 10
Convert to float
Y = Float(×)
X = 10
Convert to string
Y = str(×)
Boolean <=
Less than or equals to
Boolean >=
Greater than or equal to
Difference between = And ==
= is assignment operator
== is equal comparison operator
!= is
Not equal operator
If statement for x and y being equal
If( x == y):
Print(“ok”)
Else:
Print no
While loop for continuing until x = n
While (× != ‘n’ ):
Stop a loop if x == 5
If ×==5:
Break
Skip iteration if x = 9
If x==9:
Continue
To get a random # between 0 and 100
Import random
X = random.randit(0,100)
Exit a program if you is typed
Import sys
If response == “you” :
Sys.exit()
X = 5.543357
Round to 3 decimal places
X = round(x,3)