Variables Are Used To Store Values. A String Is A Series of
Variables Are Used To Store Values. A String Is A Series of
Your programs can prompt the user for input. All input
finishers = ['sam', 'bob', 'ada', 'bea'] is stored as a string.
first_two = finishers[:2]
last_two = finishers[-2:] Prompting for a value
Variables are used to store values. A string is a series of two_and_three = finishers[1:3]
name = input("What's your name? ")
characters, surrounded by single or double quotes. Copying a list print("Hello, " + name + "!")
Hello world copy_of_bikes = bikes[:] Prompting for numerical input
print("Hello world!") #remember – we need int() and float()
Hello world with a variable to convert the input from a STRING
msg = "Hello world!" If statements are used to test for particular conditions age = int(input("How old are you? "))
print(msg) and respond appropriately. pi = float(input("What's the value of pi? "))
A list stores a series of items in a particular order. Conditional test with lists
You access items using an index, or within a loop. bikes=['kona', 'merida', 'scott', 'giant']
Make a list 'trek' in bikes
'surly' not in bikes
bikes = ['trek', 'redline', 'giant']
Assigning boolean values
Get the first item in a list game_active = True
first_bike = bikes[0] can_edit = False