var = "145" result = var + 4 print(result) # Traceback (most recent call last): # File "main.py", line 2, in <module> # result = var + 4 # TypeError: can only concatenate str (not "int") to str
str() - converts to stringint() - converts to integerfloat() - converts to floatint()
function:
var = int("145")
result = var + 4
print(result)
# 149
radius = float(input("Enter a radius: "))
area = 3.14 * radius ** 2
print(f"The area of a circle with radius {radius} is {area}.")
Your code
Your code
Your code
width = 15
length = input("Enter the length: ")
area = length * width
print(f"The area is {area}.")
Your code
age = input("How old are you? ")
future_age = age + 20
print(f"In 20 years, you will be {future_age} years old.")
Your code
result = "21" / 7 print(result)
Your code