EXAMPLE
Write a program to print simple integer variable.
# Declare and initialize integer variables
age = 25
height = 180
# Print the values of the variables
print("Age:", age)
print("Height:", height)
Write a program to print string variable and concatenation.
# Declare and initialize a string variable
name = "Alice"
# Concatenate string variables
greeting = "Hello, " + name + "!"
# Print the greeting
print(greeting)
Write a program to print float and airthmatic operation.
# Declare and initialize float variables
price = 19.99
tax_rate = 0.08
# Perform arithmetic operations
total_price = price + (price * tax_rate)
# Print the total price
print("Total Price:", total_price)
Write a program to print boolean variable and logical operation.
# Declare and initialize boolean variables
is_sunny = True
is_raining = False
# Perform logic operations
bring_umbrella = is_raining or is_sunny
# Print the decision
print("Should I bring an umbrella?", bring_umbrella)
Write a program to print multiple assignment.
# Assign values to multiple variables in a single line
x, y, z = 10, 20, 30
# Print the values of the variables
print("x:", x)
print("y:", y)
print("z:", z)
Write a program to print constant convention.
# Constants are conventionally named in uppercase
PI = 3.14
# Calculate the area of a circle
radius = 5
area = PI * (radius ** 2)
# Print the area
print("Area of the circle:", area)