Computer Science
Find the errors in following code fragment:
a = input("value")
b = a/2
print (a, b)
Python Funda
36 Likes
Answer
The input( ) function always returns a value of String type so variable
a
is a string. This statement b = a/2
is trying to divide a string with an integer which is invalid operation in Python.Answered By
19 Likes
Related Questions
Find the errors in following code fragment:
y = x + 5 print (x, Y)
Find the errors in following code fragment:
print (x = y = 5)
Find the errors in following code fragment : (The input entered is XI)
c = int (input ( "Enter your class") ) print ("Your class is", c)
Consider the following code :
name = input ("What is your name?") print ('Hi', name, ',') print ("How are you doing?")
was intended to print output as
Hi
, How are you doing ? But it is printing the output as:
Hi
, How are you doing? What could be the problem ? Can you suggest the solution for the same ?