We can use this code to print horizontally instead of printing vertically
end
file:///C:/Users/rnoppinger/Pictures/Capture.PNG
3
Print the float portion of the number 35.
print(float(35))
We use this function in a for loop to repeat a loop for a number of times
range()
A while loop repeats commands a specific number of times
Fasle
We should use this when coding an atm.
While Loop
file:///C:/Users/rnoppinger/Pictures/Capture1.PNG
hi hello
hi hello
hi hello
What is the type of the variable x?
x= "10"
String
By default we always increment by this number in a for loop.
1
Write the shortcut for increasing the variable x by 1
x += 1
During a while loop if you want to stop your code you could use this word
Break
file:///C:/Users/rnoppinger/Pictures/Capture4.PNG
0
5
10
15
25
We use a for loop to print this type of variable
list
file:///C:/Users/rnoppinger/Pictures/Capture6.PNG
Have to change 1 to 0
file:///C:/Users/rnoppinger/Pictures/Capture5.PNG
Total should equal one
A while loop checks this at the end of each run through
Condition
file:///C:/Users/rnoppinger/Pictures/Capture2.PNG
Infinite Loop
These 3 rules are applied to what type of variable:
Any string is True, except empty strings.
Any number is True, except 0.
Any list, tuple, set, and dictionary are True, except empty ones.
To skip printing a specific item you can use this word.
Continue
i = 0;
while i < 4:
if (i == 1) :
print("Speak to me \n")
elif (i == 2):
print("Breathe\n")
elif (i == 3) :
print("On the run\n")
else :
print("Time\n"
0 never increases
Using this code will occur when the for loop is finished.
Else
file:///C:/Users/rnoppinger/Pictures/Capture3.PNG
Nothing
It is always safe to go from a smaller data type to a larger one. This is called...
Upcasting
For loops can do this. Unlike a while loop that needs to do it in 3.
Combine Lines
for i in range(100,500):
if i%13==0 and i%5!=0:
print(i)
Displaying numbers through 100-550 that are divisible by 13 but not 5