New course! Every coder should learn Generative AI!
Try a free lesson0
What is the problem ?
6 Answers
+ 1
You have to define the variable sum first
And then print it or simply just print(a+b)
+ 6
# Get input as integers
a = int(input("entrez votre nombre :\n"))
b = int(input("entrez votre nombre :\n"))
# Add a+b and assign to new variable 'sum'
sum = a+b
print(sum)
We do not need to convert sum to integer because Python does this automatically for us and is called implicit data type conversion.
https://www.geeksforgeeks.org/type-casting-in-python/amp/
+ 5
+ 4
When you take input using input(), it's stored as a string by default. You need to convert the input values to integers before performing arithmetic operations.
The assignment of sum is incorrect. You should directly calculate the sum of a and b rather than using sum = a + b. Instead, you can do sum = int(a) + int(b) to correctly calculate the sum
+ 4
Continue....
Here, is your modified code, hope it's helpful to you.
https://code.sololearn.com/cy3K2wlsSEW3/?ref=app
+ 4
Yassine welcome 👍
Happy learning and happy coding 😊