Printing Variables
Printing Variables
name = "Alice"
age = 10
print(name) # Output: Alice
print(age) # Output: 10
Output:
-----
Alice 10 True
Name: Alice
Age: 10 , Is Student: True
Output:
-----
My name is Alice. I'm 10 years old.
Another way to place variables into a string.
{} are replaced with variable values in the same order as they are provided in format().
Output:
-----
My name is Alice. I'm 10 years old.
Variables are joined with Strings using + .
Other data types are converted to strings using str() function. This is called type conversion or type casting.
Output:
-----
My name is Alice. I'm 10 years old.