+ 2

Chaining Multiple Conditions traceback error

Can anyone help me to see the error? I am getting "traceback error" in line 3 all the time, i tried already in thE jupiter notebook and it runs ok... This is one of the exercises in the the app "chaining multiple conditions" The university gives students discounts on tuition fees depending on their performance: 90-100 => 50% 80-89 => 30% 70-79 => 10% 0-69 => 0% Write a program that will take the scores from the first and second semesters, then calculate the average score, and output the result, depending on the score. Sample Input 67 83 Sample Output 10 My code: name = input() sem1_score = int(input()) sem2_score = int(input()) average = (sem1_score + sem2_score )/2 if average >=90 and average <= 100: print(50) elif average >=80 and average <= 89: print(30) elif average >= 70 and average <=79: print(10) elif average >=0 and average <=69: print(0)

7th Sep 2020, 8:15 AM
Fernando
Fernando - avatar
11 Respostas
+ 4
I have just copypasted that code snippet into Playground and run it. It worked without issues! What I meant was that you need to give the user input in three different lines in that submit window.
7th Sep 2020, 8:25 AM
HonFu
HonFu - avatar
+ 2
Does it change when you enter the three inputs in separate lines?
7th Sep 2020, 8:20 AM
HonFu
HonFu - avatar
+ 1
I tried but if I move the line 3 "sem2_score=int(input())" to line 5 for example the traceback error goes to line 5
7th Sep 2020, 8:23 AM
Fernando
Fernando - avatar
+ 1
Great, thanks. Maybe it has to be with the app... I will report it to the team and see if they can help
7th Sep 2020, 8:27 AM
Fernando
Fernando - avatar
+ 1
Ok, I think that I saw the issue. By default the code written came with the name, sem1_score, and sem2_score as input variables. And the test was only given 2 inputs, sem1_score and sem2_score. I just commented the first line and sorted :). Thanks a lot for the help
7th Sep 2020, 8:41 AM
Fernando
Fernando - avatar
+ 1
Good you found it! :) BTW, in Python you can also write conditions like this: if 90 <= average <= 100: ...
7th Sep 2020, 8:46 AM
HonFu
HonFu - avatar
+ 1
Great to now, thanks!
7th Sep 2020, 8:47 AM
Fernando
Fernando - avatar
0
I encountered the same issue with the name input. I wrote mine a little differently below but there are multiple ways to get the job done. #name = input() sem1_score = int(input()) sem2_score = int(input()) #your code goes here average = ((sem1_score + sem2_score)/2) if (average >= 90): print("50") elif (average >= 80 and average <= 89): print("30") elif (average >= 70 and average <= 79): print("10") else: print ("0")
18th Oct 2020, 1:47 PM
Zachary Osborne
Zachary Osborne - avatar
0
Hi guys, i'm new here :) I have a syntax error and can’t find it... My code: score1 = int(input()) score2 = int(input()) avgscore = (score1+score2)/2 if (avgscore >= 90 and avgscore <= 100): print("50") elif (avgscore >= 80 and avgscore <= 89): print("30") elif (avgscore >= 90 and avgscore <= 100): print("50") elif (avgscore >= 70 and avgscore <= 79): print("10") elif (avgscore >= 0 and avgscore <= 69) print("0") Thanks!
28th Jan 2021, 12:04 AM
Tsvetelin Anastasov
Tsvetelin Anastasov - avatar
0
Looks like you are missing a colon on line 12 after 69.
28th Jan 2021, 2:21 AM
Zachary Osborne
Zachary Osborne - avatar
0
score1 = int(input()) score2 = int(input()) #your code goes here Total = (score1 + score2) Avg = (Total/2) if (Avg >= 90 and Avg <= 100): print ("50") elif (Avg >= 80 and Avg <= 89): print ("30") elif (Avg >= 70 and Avg <= 79): print ("10") else: print ("0")
30th Sep 2021, 10:47 AM
Matt Webb