Question
PLEASE I NEED HELP RUNNING THESE CODES. I CANNOT SEEM TO UNDERSTAND WHAT'S REALLY WRONG. PLEASE HELP. RANDOM NUMBER SORTER PROGRAM # Python Randon Sorter
PLEASE I NEED HELP RUNNING THESE CODES. I CANNOT SEEM TO UNDERSTAND WHAT'S REALLY WRONG. PLEASE HELP.
RANDOM NUMBER SORTER PROGRAM
# Python Randon Sorter program # Generate 25 random numbers between the numbers 1 and 100, # and append them into the appropriate odd or even list
import random
even_list =[] odd_list = []
for n in range(25) : r = random.randint (1,100) if r % 2 == 0: even_list.append(r) else: odd_list.append(r) #display odd and even lists print ("Even numbers are ", even_list) print ("odd numbers are ", odd_list)
******************************************************************************************************************************
CALCULATOR PROGRAM
# python calculator program
def add (n1, n2) : return n1 + n2
def substract (n1, n2) : return n1 - n2 def multiply (n1, n2) : return n1 * n2 def divide (n1, n2) : if n2 == 0: return "INVALID" else: return n1/n2
# main loop
continu = "y" while (True) :
print (" Select operation l. add 2. substract 3. multiply 4. divide") choice = input ("Enter choice(1, 2, 3, 4) : ") num1 = float(input("Enter first number: ")) num2 = float (input("Enter second number: ")) if choice == '1': print(num1, "+",num2,"=", add(num1,num2)) elif choice == '2': print(num1, "-", num2,"=" substract(num1,num2)) elif choice == '3': print(num1, "*", num2,"=" multiply(num1,num2)) elif choice == '4' print(num1, "/", num2,"=" divide(num1,num2)) else: print("Invalid operation!") continu = input ("Continue? y/n: ") if continu == "n" break
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started