1)write a python program to admit a student based on gender and the number of points
2) write a python program that would make use of try/except the user input for the following inputs a) strings only b)numeric values
Program 1
gender=int(input("Enter gender (1 - for female), (2 - for male): "))
points=int(input("Enter the number of points: "))
if(points>=60 and gender==1):
print("Student is admited")
else:
print("Student is NOT admited")
Program 2
try:
name = input("Enter name: ")
if not name:
raise ValueError('Empty string')
except ValueError as e:
print(e)
while True:
try:
age = int(input("Please enter an age: "))
break
except ValueError:
print("No valid age! Please try again ...")
print("Name: "+name)
print("Age: "+str(age))
Comments
Thank you so much
Leave a comment