New course! Every coder should learn Generative AI!
Try a free lesson+ 1
Please Checkout the Error in my program
s = input("Your marks: ") T=print(s) Total=print(T/2)
4 Answers
+ 8
DINESH reddy, First, remember this important point: input() always produces a string. If you want to do math on it, you have to convert it to a number first - either an integer by
s = int(input("Your marks: "))
or a float by
s = float(input("Your marks: "))
Second, the print function is not a thing. It's just a way to display something on your screen (That's why you got the NoneType error). Just use it as a command, don't assign it to a variable.
I'm not sure what you wanted your code to do. It looks like you wanted the user to enter a number and then you wanted to display half of that number.
s = int(input("Your marks: "))
print("Total =", s/2)
+ 3
I am not sure what you mean but you can try this
s = input("Your marks: ")
print(s)
T=int(s)/2
print(T)
input:8
output: Your marks: 8
4.0
+ 3
What are you trying to accomplish by doing
T = print(s)
?
Print statements do not return a value and should not be assigned to variables. You can do
s = int(input())
t = s
total = t/2
print(total)
+ 3
S=int(input('your marks'))
print(S/2)