Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 27th International Conference Dasfaa 2022 Virtual Event April 11 14 2022 Proceedings Part 2 Lncs 13246

Authors: Arnab Bhattacharya ,Janice Lee Mong Li ,Divyakant Agrawal ,P. Krishna Reddy ,Mukesh Mohania ,Anirban Mondal ,Vikram Goyal ,Rage Uday Kiran

1st Edition

3031001257, 978-3031001253

More Books

Students also viewed these Databases questions