+ 1
Addition Help at the end
def module(number): mod = int(input('Module'+str(number)+'grade achieved: ')) if mod >=80 and mod <=100: print ('Distinction') elif mod >=60 and mod <=79: print ('Merit') elif mod >=40 and mod<=59: print ('Pass') else: print ('You have not passed this Module') for num in range (6): module(num+1)
25 Answers
+ 5
# "yes/no break code" is not very descriptive :P
# Do you mean something like:
while True:
inp = input("Continue (Yes/No)? ")
if inp.lower() == "no":
break
else:
print("Ok, lets do it once again...")
+ 3
Already asked and answered: please don't post more than once time a question, and avoid deleting the thread with good answered questions: I did notice that you often post questions, but that they quickly disappear after you get answer ^^
+ 3
If you're in Python 2, make the upgrade to Python 3! Python 3 has awesome new features! 😄
+ 3
@Pegasus: Python3 has some new features, but Python2.x is still widely enough good, and use of new functionalities in Python3 will make you aware of wich Python3 it is (ie: each minor version comes with new features, not supported by previous, so by using them, you will be stuck at minimal version 3.x where x is the minor version required for a particular function you use in your code, so you'll get more compatibility by writing Python2.7/3.0 only)
+ 2
Your code posted in your last post will work, if you write same 'maths' (not once 'Maths' and another 'maths', as they refer to 2 different variables)
+ 2
@visph The Python Organisation gave businesses this extended time to let the switch from Python 2.x to 3.x, only 2 years left
+ 2
What are you meaning by "isolate the value at the end"?
Anyway, 'break' and 'continue' only operate inside a loop (by breaking the loop, you exit it), and indentation is not right after line assigning Levelsix: next lines need to have same indentation (in this case, no indentation -- appart from the indentation after line if and line else, obviously)
+ 2
I must admit, I don't understand Python 2 as well
+ 2
# Something like that maybe?
def module(number):
mod = int(input('Module'+str(number)+'grade achieved: '))
if mod >=80 and mod <=100:
print ('Distinction')
elif mod >=60 and mod <=79:
print ('Merit')
elif mod >=40 and mod<=59:
print ('Pass')
else:
print ('You have not passed this Module')
sum = 0
for num in range (1,7):
sum += module(num)
Levelsix = raw_input("Is the course level 6? (y/n)")
if inp.lower()=="y":
sum *= 1.25
print(sum)
+ 2
(little correction on my previous post)
+ 1
oh thank you, Sorry for spamming. Im in a panick because this is due in 2 hours.. I have to write a document aswell. Im really screwed. This isn't also the only thing im stuck on. Im also stuck on a yes/no break code. I dont know how to do it ahah
+ 1
Did you get "name 'y' is not defined" error?
So, you're using Python2.x, and you must use raw_input() instead of input()
+ 1
yes i got ''name 'y' is not defined"
+ 1
hahahaha ! I WOULD if I could but unfortunately my school uses 2.7 so Im basically stuck to 2.7 :'( and I cant do anything about it unless they decide to change it to Python 3. :(
+ 1
Hi visph. I have another problem. I cant seem to Isolate the value at the end. the code looks like this:
sum=0
for num in range (1,7):
sum +=module(num)
print(sum)
if sum >=90:
print "You are eligible to go progress to Third Level."
elif sum ==90:
print "You are eligible to go to college."
else sum <=90:
print "Sorry, a minimum points of 90 points must be achieved to progress to Third Level."
sum +=module(num)
Levelsix = raw_input("Is the course level 6? (y/n)")
if inp.lower()=="y":
sum +=module(num)*1.25
break
else:
print ("")
continue
+ 1
I've tried doing "sum +=module(num)>90:" it doesnt work
and when I try to isolate the value using sum/sum +=module(num)>90 *1.25 it doesnt work.
+ 1
oh i meant after they all add up. I want to be able to multiply it by 1.25 only if its a lvl6 course which I tried to do, and failed miserably.
+ 1
maybe it's just the way I explained it. What I want the code to do is to say that if the user gets points above 90, they can progress to go to college. if they dont have the points, they cant go to college. But Also I want the code to multiply their points at the end IF the user is doing a course that is level 6. So I need them to answer a Yes/No question and if they say Yes I multiply it by 1.25 which I have no clue how to do.
+ 1
Hey! It works!
+ 1
THAANK YOU THANK YOU THANK YOU THANK YOU! I have yet to put it all together and Im finally done with this project. Its suppose to be due now but Its not finished so I have to make a delay. I couldnt have done this without your help Visph.