0
Help me i cant code the if they have between 24 and 53, i write credit <53 =24 but it is giving error
Write a program that asks the user how many credits they have taken. If they have taken 23 or less, print that the student is a freshman. If they have taken between 24 and 53, print that they are a sophomore. The range for juniors is 54 to 83, and for seniors it is 84 and over. https://code.sololearn.com/clOquVAHtq1E/?ref=app
9 ответов
+ 3
What's the problem you're experiencing? Could you expand on it please.
+ 3
Use **and** operator to combine more than one expression. Also, you can reply to your posts
+ 3
Ahmad Mansir carefully test your logic, step by step. In the current logic, all values 24 and above will print "sopohmore" [sic]. For example, try credit=90. After the second test, the remaining tests are unreachable code.
Also check spelling.
+ 2
Hey Ahmad Mansir you have to make the conditions as ranges between numbers: look, if you take 100 it wouldn't enter the first if, but then it is true for >=24. So even with 100 credits it says sophomore.
Like Lamron says chain your conditions to make ranges.
if x > 5 and x < 10
That would catch the range 6 to 9.
+ 2
Ahmad Mansir we don't provide already written code, but we do provide guidance😏
+ 2
Ahmad Mansir
you only need the (logical operator(and)) and make sure your code start from lower number range to the highest
if x > 9 and x < 25 ;
do something
+ 1
THIS THE QUESTION
Write a program that asks the user how many credits they have taken. If they have taken 23 or less, print that the student is a freshman. If they have taken between 24 and 53, print that they are a sophomore. The range for juniors is 54 to 83, and for seniors it is 84 and over.
0
It's important in the beginning understand and use the operators like "and, or,..."
Ahead of this Python let's you use also other ways which come in a bit more handy for the given purpose:
Like put the value yet in between two operators: if 0 < x < 11:
Or use a range: if x in range(1,11):
Both testing if x in between 1 and 10
https://code.sololearn.com/c919H1Gez8Pv/?ref=app