print(Hello World)
print("Hello World")
Holds anything in double quotes.
String.
Write a program that tells me your name.
print("Sarah Benbrook")
(but with your name)
Reserve Word?
A word that has a fixed meaning. It can only be used for one thing, and can't be a variable name. Like 'print'.
age = int(input("How old are you?"))
print(age)
No error.
Results in only True or False.
Boolean.
Write a program that takes a user's name, and stores it in a variable.
name = input("What's your name?")
Create a program that uses the new line function.
print("Hello! \n My name is Tommy.")
hello = "hello"
print(hello + "world")
No error.
A positive or negative whole number.
Integer.
Write a program that asks the user a question. It should give the user two different responses, depending on if they say 'Yes' or 'No'.
fries = input("Do you want fries?")
if (fries == "Yes"):
print("Okay, I'll get those ready for you.")
elif (fries == "No"):
print("Alright, just the drink then.")
What is the difference between a list and a tuple?
Lists can be changed, but tuples cannot be changed.
dogs = ["spot", "tommy"; "fido"; "bill"]
print(dogs)
list should have commas, not semi-colons.
Positive or negative decimal number.
Floating point.
Make a while loop that does an infinite loop.
while (True):
print("no")
Create a program that takes user input for an integer. The program should tell the user if their number is greater than, less than, or equal to 5.
number =int( input("Give me a number: "))
if (number > 5):
print("Your number is greater than 5.")
elif (number < 5):
print("Your number is less than 5.")
else:
print("Your number is equal to 5.")
i = 0
while(i < 100):
print(i)
i = i + x
i = i + 1
i = 0
x = 4
while(i < 100):
print(i)
i = i + x
i = i + 1
Stores multiple items, and is immutable.
Tuple.
Write a program that takes user input, and uses a while loop correctly. (it should not be an infinite loop)
password = input ( “Please enter your password: ” )
while (password != “SECRET”) :
print ( “No, try again!” )
password = input ( “Please enter your password: ”)
print ( “Password Verified.” )
What is the error?
x = str(float(bool("40.5")))
print(x)
No error. :)