18.1k views
1 vote
Why isnt this code working in PyCharm?

Directions:
A social center is setting up a new mentoring program. The aim of the program is to match older
people with younger people in order to build mentor/mentee relationships. Several rooms have
been set up to serve as meeting spaces. When a person arrives at the social center, that person
is asked his name and then his age. Based on the age, that person will be directed to the
appropriate room as follows:
● Room A - Ages 10 and under and 80 and over
● Room B - Ages 11 to 20 and ages 70 to 79
● Room C - Ages 21 to 30 and ages 60 to 69
● Room D - Ages 31 to 40 and ages 50 to 59
● Room E - Ages 41 to 49

Code:

name = input("Hello! What is your name? ")
age = int(input("How old are you? "))

if age = 80:
print("Welcome " + name + ", you will be going to Room A")
elif (age > 11 or age 70 or age 21 and age = 60 or age <= 69):
print("Welcome " + name + ", you will be going to Room C")

User Melba
by
6.1k points

1 Answer

0 votes

In python:

name = input("Hello! What is your name? ")

age = int(input("How old are you? "))

if age <= 10 or age >= 80:

print(f"Welcome {name}, you will be going to room A")

elif 11 <= age <= 20 or 70 <= age <= 79:

print(f"Welcome {name}, you will be going to room B")

elif 21 <= age <= 30 or 60 <= age <= 69:

print(f"Welcome {name}, you will be going to room C")

elif 31 <= age <= 40 or 50 <= age <= 59:

print(f"Welcome {name}, you will be going to room D")

elif 41 <= age <= 49:

print(f"Welcome {name}, you will be going to room E")

I hope this helps!

User Shabirmean
by
5.6k points