""" Authors: Consulted: Date: Purpose: CS111 Lab 04 Practice using conditionals and functions to build an interactive program that asks the user information, and then calculates ticket prices according to age. Filename: conditionals.py """ import random #-----------------------# # Task 1 Heads or tails # #-----------------------# def flip(): ''' Provided function (DON'T modify); simulates a coin flip returning either heads or tails as a String ''' coin = random.randint(1, 2) if coin == 1: return 'heads' else: return 'tails' def getUsersGuess(): ''' Provided function (DON'T modify); Asks for user to guess heads or tails and returns the String ''' return input('Guess heads or tails => ') # Write the rest of your code for Task 1 here. #-------------------------------# # Task 2 Let's go to the movies # #-------------------------------# def getUsersAge(): ''' Provided function (DON'T modify); Prompts user to enter age and returns the value as an integer. Will be used in this task and also Task 3. ''' return int(input('How old are you? ')) # Write your code for Task 2 here. #----------------------------------------------# # Task 3 Automatic quiz: What element are you? # #----------------------------------------------# def askUserForAnswer(): ''' Provided function; Ask user to choose answer of 1, 2 or 3 in multiple choice question and returns selected integer ''' return int(input("Select 1, 2 or 3: ")) # Write your code for Task 3 here. #--------------# # Testing code # #--------------# # Add function calls here to test the functions you're working on above print("Start of testing.") # call your function(s) here print("Done with testing.")