Computer Science
What is the problem with the following code fragment?
a = 3
s = a + 10
a = "New"
q = a / 10
Python Funda
23 Likes
Answer
The statement
a = "New"converts a to string type from numeric type due to dynamic typing. The statement q = a / 10 is trying to divide a string with a number which is an invalid operation in Python.Answered By
11 Likes
Related Questions
What is the problem with the following code fragment?
a = 3 print(a) b = 4 print(b) s = a + b print(s)What is the problem with the following code fragment?
name = "Prejith" age = 26 print ("Your name & age are ", name + age)Predict the output:
x = 40 y = x + 1 x = 20, y + x print (x, y)Predict the output:
x, y = 20, 60 y, x, y = x, y - 10, x + 10 print (x, y)