int()
float()
str()
distance
is assigned 252.5
, the interpreter converts it from int to float as needed.
int(x)
→ integer (fractional part removed). Ex: int(5.9)
→ 5
.float(x)
→ floating-point. Ex: float(2)
→ 2.0
.str(x)
→ string. Ex: str(3.14)
→ "3.14"
.quantity = int(input())
,price = float(input())
,total = quantity * price
→ float.
/
always yields a float.round()
to mitigate output issues.round()
1.8×10308
−1.8×10308
, respectively.
/
→ converts to floats, e.g., 7/4 = 1.75
.//
→ quotient only, e.g., 7//4 = 1
.%
→ remainder, e.g., 7%4 = 3
. Pronounced “mod”.//
for whole units and %
for the remainder (modulus m).193 cm
→ meters: 193//100 = 1
, remainder: 193%100 = 93
.math
module.math
math
module
name = input("Enter someone's name: ")
place = input("Enter a famous place: ")
print(name, "should visit", place + "!")
name=input ("Enter someone's name: " )
place =input("Enter a famous place: ")
print( name,"should visit" , place+ "!")