Python intro Flashcards
y:float
for decimal numbers
x:int
whole numbers
b:bool
True or False (with capitals)
s:str
string for text
%
modulus, how many times the number goes in. Looking at remainder
//
integer division, ignore decimal in division, becomes an int.
**
exponent
Cast str to float
s: str = “1.0”
x: float = (s)
cast str to int
s: str = “1”
y:int = int (s)
=
assignment/becomes
7%2
1
36%4
0
false == false
true (false is the same as false)
print (1!=2)
true (1 does not equal 2)
how toprint what type of value
print(type(…))
to show int, float, bool, ect.
how to start and end turtle graphics
import turtle, t=turtle.Turtle(), turtle.done
How to move pen
t.penup()
t.goto(x,y)
t.pendown()
How to print from multiple lines on one line
print(“A”,”B”,end=” “)
print(“E”,”F”) #A B E F
loop
repeats code
format for loop
for i range (0,10,1)
print(i)
make sure to indent otherwise won’t work
what is the meaning of (0,10,1)
(from 0, to but no including 10, incrementally by 1)
what is default increment and start
1,0
if you change print function to
print(i+1)
increases starting number by 1 making it include to number to
How do you make a loop function not run without causing error
pass