Advertisement
Adehumble

Week6 Coding Exercise 6

Mar 8th, 2020
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. #6
  2. print("This program is written to return True if the sum of your number choices is greater than 100 and return False otherwise.\n\nFeel free to enter any range of numbers.")
  3.  
  4. #FUNCTION PROGRAM
  5. def plenty_arguments(a,b,*args):
  6.     result=a+b
  7.    
  8.     for arg in args:
  9.         result=result+arg
  10.        
  11.     if result>100:
  12.         print(f"The sum of your numbers is greater than 100. Hence, it's: \n\n{True}")
  13.     else:
  14.         print(f"The sum of your numbers is not not greater than 100. Hence, it's: \n\n{False}")
  15.  
  16.  
  17. #MAIN PROGRAM
  18. user_list=[]
  19.  
  20. while True:
  21.     try:
  22.         number=abs(int(float(input("\nHow many numbers would you like to enter? "))))
  23.         break
  24.     except ValueError:
  25.         print("That was a wrong input! You must enter an integer value. Please, try again!\n")
  26.  
  27. print("\n")
  28. for num in range(number):              
  29.  
  30.     while True:
  31.         try:
  32.             user_num=int(input("Enter those numbers you would like to check for their sum  one after the other: "))
  33.             break
  34.         except ValueError:
  35.             print("That was pretty wrong. You must enter any integer. Please, try again! \n")
  36.     user_list.append(user_num)
  37.  
  38.  
  39. print(f"\nYour number choices are: {user_list}\n")
  40. plenty_arguments(*user_list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement