Python Forum
If, if else, Boolean statements
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If, if else, Boolean statements
#1
I am having trouble with this code and would like to know if someone can help me. I did what I could but please let me know if it needs to be edited.

2b) if else statement
# for each comment below, add the code

# create a bool type variable called hasValidID and set its value to be True

# create an int type variable called age and set its value to 35

# set up an if else statement that checks both the hasStudentID and age values
# if the hasStudentID value is True or the age is at least 65,
# print the message "eligible for discount"
# otherwise print the message "not eligible for discount"

print("Exercise 2b.")

hasValidID = True
age = int(input(35))



# 2c) if elif else statement
# for each comment below, add the code

# take input for a variable called grade, converting it to an int type

# set up a series of if / elif / else statements
# if the value of grade is at least 90, print "A"
# otherwise if the value of grade is at least 80, print "B"
# otherwise if the value of grade is at least 70, print "C"
# otherwise if the value of grade is at least 60, print "D"
# otherwise, print "F"
Reply
#2
This is your assignment, so what have you tried so far?
We're glad to offer help, but will not do the work for you.
Reply
#3
What precisely is it that you are struggling to understand about the exercise? I'd like to help, but I'm not doing your work for you either. If you have a specific problem related to this exercise tell me what it is and I'll try and assist you as much as I can.

Also, it would help to see your workings so far.
Reply
#4
I was having trouble setting up a statement that verifies both age and if they have the ID. I figured it out elsewhere. Thank you. It wasn’t for grading but thank you. It was a practice assignment.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020