This loop executes statements repeatedly as long as the tested condition remains true
What is a while loop?
What is a variable?
A variable is something that can store information
It can be used or changed later
What symbol do we use for multplication?
*
What is input?
Input is when the user who runs the code gives a value for the program to use.
If an if statement is false, what statement is usually added on to it to do something else?
Else statement
Describe syntax of a while loop.
Variables are used to store ______ so that whoever is writing the code use it later or change it later
What is information?
What symbol do we use for division?
What line of code gets you the input?
var = input()
What statement is used when we want to write multiple if statements but only do statements from one?
Elif Statement
What loop:
Occurs when the condition will never be false
Can cause computer crashing
What is an infinite loop?
What are some naming rules for variables?
1. Variable names can only consist of letters, numbers, and underscores.
2. Names must start with an underscore or a letter
3. Names can NOT be started with a number
If you want to save the sum of two numbers in a variable, what line of code would you use? And what about to get division or multiplication? (Use any numbers you want)
sum = x + y
sum = x / y
sum = x * y
Which commands can you use around what you want to cast?
1. int()
2. float()
3. str()
4. bool()
What are the three types of logical operators in order of precedence?
Not, and, & or
What is a special input value that signifies the end of a loop?
What is a sentinel value?
What can variables be set to?
Integers, floats, strings, and booleans
What line of code is used to save the exponents of two numbers?
exponent = x ** y
What do you have to add to be able to get a random number?
import random
What symbol is used with each logical operator?
And: and
Or: or
Not: not
What is the main reason why while loops are useful?
They help us stop being repetitive and more efficient
What two values can a boolean have?
True and False
What are the three types of errors? (make sure you know the definition of each as well)
1. Compiler Errors
2. Run-time Errors
3. Logic Errors
How do you get random floats from a certain range?
1. Using random.random(), multiply that with the end value (will not include end). This will give you a value from 0-the end value.
2. To start from a different number, multiply instead by end number minus start number, and then at the end add the start number.
Write a program that takes three integer inputs and then checks to find the biggest of the three.
int1 = input()
int2 = input()
int3 = input()
if int1 > int2 and int1 > int3:
print("Int 1 is greatest")
elif int2 > int1 and int2> int3:
print("Int 2 is the greatest")
elif int3 > int1 and int3 > int2:
print("Int 3 is the greatest")
else:
print("They are all equal to each other")