0

This was part of my assignment that I already handed up. I realised I missed something. Is there a way to fix this?

sum=0 for num in range (1,7): sum +=caopoints(num) levelsix = raw_input("Is the course level 6? (y/n)") if levelsix.lower()=="y": sum*=1.25 elif sum>=90: print 'you are eligible for college.' elif sum==90: print 'you are eligible for college.' else: sum<=90: print 'you are not eligible for college.' print(sum)

14th Jan 2018, 5:16 PM
Sponge Bob
Sponge Bob - avatar
12 ответов
+ 7
@sponge bob thats life! I would hug you for comfort But sponge bobs cry tears if they are hugged. (-:
14th Jan 2018, 5:52 PM
Oma Falk
Oma Falk - avatar
+ 6
Python3 has no function raw_input() it changed to input()
14th Jan 2018, 5:33 PM
Oma Falk
Oma Falk - avatar
+ 6
@visph ah ok! Sololearn is Python3. What is connection between his assignment and sololearn?
14th Jan 2018, 5:49 PM
Oma Falk
Oma Falk - avatar
+ 4
You fail at logic of your if/elif/else blocks in addition to doing bad indentation... + Indentation is very important in Python and require to be rational: each indented lines of a same block should have the same number (and type) of spaces... each of if/elif/else lines should share the same indentation, and each of the sub-blocks (the lines excuted if the condition is true) should have a level more of indent than its if/elif/else. + logic of a if/elif/else must also be rationalisticly done to act as expected: This was part of my assignment that I already handed up. I realised I missed something. Is there a way to fix this? # this first test should be independent of the next ones if levelsix.lower()=="y": sum*=1.25 # so here we start a brand new if statement # if you first test if sum>=90 it will be true for sum==90 and so only this block will run # as we expect another behaviour for sum==90, we rather test if sum>90 ;) if sum>90: print 'you are eligible for college.' elif sum==90: print 'you are eligible for college.' # last cast, logically is necessarly sum<90, so instead: # elif sum<90 # we can do a simple else: else: #sum<=90: # without testing anything print 'you are not eligible for college.'
14th Jan 2018, 5:39 PM
visph
visph - avatar
+ 4
@Oma Falk: He right use raw_input() as he run Python2.7 and not Python3 (he doesn't need to run its code on playground and he's mandatory to write Python2.7 code by its assignement ;P
14th Jan 2018, 5:41 PM
visph
visph - avatar
+ 3
Keep concentration on Python for now (differences between 2.7 and 3.x are not numerous): Java and C/C++ are more difficult to learn, and you'll highly risk to be confused by learning many languages at once... On the opposite, improving your skill in only one language will help you to later learn others languages more quickly ^^
14th Jan 2018, 6:00 PM
visph
visph - avatar
+ 2
I guess he's here for learning and getting help... Maybe his professor give him the advice to use sololearn: I've encounter another sololearner's post highly similar ;P
14th Jan 2018, 5:52 PM
visph
visph - avatar
+ 2
You can "return the favour" by using best answer mark (I'm sorry that's too late for your assignement, but that's not enough to make my answer not deserve it ;))
14th Jan 2018, 6:02 PM
visph
visph - avatar
0
Hi, MR PROFESSOR! I did exactly what you said and It works like a CHARM. but I've already handed the assignment though. D: sum=0 for num in range (1,7): sum +=caopoints(num) levelsix = raw_input("Is the course level 6? (y/n)") if levelsix.lower()=="y": sum*=1.25 if sum>90: print 'you are eligible for college.' elif sum==90: print 'you are eligible for college.' else: sum<=90 print 'you are not eligible for college.' print(sum) raw_input("\n\nPress the enter key to exit.")
14th Jan 2018, 5:51 PM
Sponge Bob
Sponge Bob - avatar
0
I want to learn Python3 and Java and C and C++ because they're the most widely used. But Im stuck to 2.7. I just started learning 3.x in here but Im not doing much progress cuz i have to study other things aswell :(
14th Jan 2018, 5:56 PM
Sponge Bob
Sponge Bob - avatar
0
Thank you Visph and Oma Falk for helping me. I wish I could return the favor but It's me that needs the help haha. Thank you for contributing your time. You guys are Awesome !
14th Jan 2018, 6:00 PM
Sponge Bob
Sponge Bob - avatar
- 1
It sucks that I missed that part of the code in the asssignment but You helped me a lot to understand loop, while, if/else and so much more. I couldnt have done it without your help. Also, I think I did the best in class with the code because my classmates had troubles figuring out how to loop the question. One last thing, Thank you for the advice. It's very silly of me to learn to code 4 languages at once and yes, I will stick to Python so that I can get my head around other languages. I will keep learning 2.7 and 3 and I will hlep other people out like you helped me out. Thank you very Much Visph. You're AWESOME!
14th Jan 2018, 6:09 PM
Sponge Bob
Sponge Bob - avatar