Answer to Question #277463 in Visual Basic for gwen

Question #277463

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


1
Expert's answer
2021-12-08T16:29:32-0500
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))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Gwen
11.12.21, 17:36

Thank you so much

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS