0% found this document useful (0 votes)
4 views2 pages

Python Input Validation Activities

The document outlines three activities involving user input in Python. Activity 1 checks if a number is even or odd, Activity 2 evaluates grades and categorizes them, and Activity 3 performs basic arithmetic operations based on user choice. Each activity includes error handling and continues prompting the user until a specific condition is met.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Python Input Validation Activities

The document outlines three activities involving user input in Python. Activity 1 checks if a number is even or odd, Activity 2 evaluates grades and categorizes them, and Activity 3 performs basic arithmetic operations based on user choice. Each activity includes error handling and continues prompting the user until a specific condition is met.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Set F

# Set F

# Activity 1

# while True:
# num = int(input("Enter a number: "))
#
# if num == 0:
# break
# elif num % 2 == 0:
# print("Even number")
# else:
# print("Odd number")

Activity 2

# while True:
# grade = int(input("Enter a number (0-100): "))
#
# if grade < 0 or grade > 100:
# print("Invalid input")
# continue
# else:
# if grade < 75:
# print("Failed")
# elif grade >= 75 and grade < 80:
# print("Satisfactory")
# elif grade >= 80 and grade < 90:
# print("Very Satisfactory")
# else:
# print("Outstanding")

Activity 3

# num1 = float(input("Enter 1st number: "))


# num2 = float(input("Enter 2nd number: "))
#
# while True:
# choice = int(input("Enter your choice (1-5 only): "))
#
# if choice == 1:
# result = num1 + num2
# print("\nAddition: ", result, "\n")
# elif choice == 2:
# result = num1 - num2
# print("Subtraction: ", result, "\n")
# elif choice == 3:
# result = num1 * num2
# print("Multiplication: ", result, "\n")
# elif choice == 4:
# if num1 == 0 or num2 == 0:
# print("Invalid! Cannot divide by zero.")
# else:
# result = num1 / num2
# print("Division: ", result, "\n")
# elif choice == 5:
# break
# else:
# print("Invalid choice! Enter 1-5 only.")

You might also like