Mini Project - Basic Syntax

Ticket Machine

Assignment & User Input

For our first mini project, you will need to create a new python program that takes in as input, a number of movie tickets and outputs a total cost in sentence form. Each ticket costs $11.99. To do this, you will need to use the input() function. Basically, set a variable’s value to input() and in between the ‘()’, type the question in quotes. Then, you can use the user’s input throughout the program using the assigned variable. For example,

age = input("Enter your age: ")
print("You are " + age + " years old!")    

When the code is run:

Enter your age: 

When input is given:

Enter your age: 6
You are 6 years old!    

NOTE: The input() function always gives you a string value, not an integer or float, even if you enter only a number as input. To change the datatype to an integer or float from a string, use int() or float() functions and put the value to be converted (can be a variable) between the ‘()’.