Gallery
Solution Lotto Ticket
Share
Explore
Solution Lotto Ticket

icon picker
Solution

solution

# Lotto Ticket
import time

# set initial values
numberOfTickets = 0
ticketCost = 1.0
numOne = 0
numTwo = 0
numThree = 0
numFour = 0
numFive = 0
age = 0
totalCost = 0.0

# prints welcome message
print('\n')
print("Welcome to Lotto Ticket App")
print("===========================")
print('\n')

# gets and stores age from user
age = int(input('Please enter your age: '))

# checks if age is more than or equal to 16
if age >= 16:
# gets and stores the number of tickets they'd like to buy from user
numberOfTickets = int(input('How many tickets are you buying?: '))
# clears the screen
print('\033[H\033[2J')


# repeats for the number of tickets
for i in range(0, numberOfTickets, 1):

# prints ticket number
print('Ticket ' + str(i + 1) + ':')
print('\n')
# gets and stores first number from user
numOne = int(input('Pick your first number: '))
# gets and stores second number from user
numTwo = int(input('Pick your second number: '))
# gets and stores third number from user
numThree = int(input('Pick your third number: '))
# gets and stores fourth number from user
numFour = int(input('Pick your fourth number: '))
# gets and stores fifth number from user
numFive = int(input('Pick your fifth number: '))

# prints processing ticket message
print('\n')
print('Processing Ticket...')
# pauses program for 3 seconds
time.sleep(3);
# prints blank lines
print('\n')
# display ticket confirmation message
print('LOTTO TICKET: CONFIRMATION')
print('--------------------------------------')
# prints out numbers picked
print('Numbers picked: ' + str(numOne) + ', ' + str(numTwo) + ', ' + str(numThree) + ', ' + str(numFour) + ', ' + str(numFive) )
print('--------------------------------------')
print('\n\n')
#end loop

# calculates total cost of ticket
totalCost = numberOfTickets * ticketCost
# print out number of tickets bought and total cost

print('LOTTO TICKET: Ticket costs')
print('--------------------------------------')
print('You have bought ' + str(numberOfTickets) + ' this will be ' + '£' + str(totalCost))
print('--------------------------------------')

# if user is not old enough print appropriate message
else:
print('Sorry you are not old enough to buy a lotto ticket.')

original



# set initial values


# input data


# process results


# display output

Share
 
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.