Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Problem 1
- # ver a - concatenation
- def problem_one_a():
- name = input("What is your name: ")
- print("Hello " + name) # Note the space character after 'Hello'
- # ver b - multiple arguments
- def problem_one_b():
- name = input("What is your name: ")
- print("Hello", name) # Note the lack of space character after 'Hello'
- # Problem 2
- def problem_two():
- num_one = int(input("Enter a whole number: "))
- num_two = int(input("Enter another whole number: "))
- print(num_one + num_two)
- # Problem 3
- def problem_three():
- num = int(input("Enter a whole number in the range 1 - 10: "))
- if num > 10:
- print("Number was supposed to be between 1 - 10!")
- elif num >= 6:
- print("The number is within the range 6 - 10")
- else:
- print(("The number is within the range 1 - 5"))
- # Problem 4
- def problem_four():
- age = int(input("Enter your age: "))
- if age > 60:
- print("You are old!")
- elif age >= 40:
- print("You are middle aged.")
- elif age >= 20:
- print("You are young.")
- elif age >= 13:
- print("You are a teenager.")
- else:
- print("You are a child.")
- print()
- # Problem 5
- def problem_five():
- num_1 = int(input("How old are you: "))
- if num_1 < 16 or num_1 >= 65:
- print("Your addmission fee is £5")
- else:
- print("Your addmission fee is £10")
- # Main program
- go_again_choices = ["y", "yes", "yep", "mos def", "whay eye"]
- go_again = "yes"
- while go_again in go_again_choices:
- valid_choices = ["1a", "1b", "2", "3", "4", "5"]
- choice = input("Which program do you want to run (1a, 1b, 2, 3, 4, 5): ")
- print()
- while choice not in valid_choices:
- print("Not a valid choice!")
- choice = input("Please choose from - 1a, 1b, 2, 3, 4, 5: ")
- if choice == "1a":
- problem_one_a()
- print()
- elif choice == "1b":
- problem_one_b()
- print()
- elif choice == "2":
- problem_two()
- print()
- elif choice == "3":
- problem_three()
- print()
- elif choice == "4":
- problem_four()
- elif choice == "5":
- problem_five()
- print()
- go_again = input("Do you want to go again (y / n): ").lower()
- print()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement