TASK 2 – Constants and Variables

1.Create a variable named name and assign your name to it. Then print the value of the variable. Create a variable age and assign your age to it. Later, reassign the variable with a new value and print the new value. Assign the values 5, 10, and 15 to three variables a, b, and c in a single line. Print their values. Swap the values of two variables x and y without using a third variable. Print their values before and after swapping. Define constants PI with appropriate values and print them. Write a program that calculates the area of a circle using the constant PI and a variable radius. Print the area. Define constants for the length and width of a rectangle. Calculate and print the area. Define a constant for π (pi) and a variable for the radius. Calculate and print the circumference of the circle.

Apr 20, 2025 - 05:33
 0
TASK 2 – Constants and Variables

1.Create a variable named name and assign your name to it. Then print the value of the variable.

Create a variable age and assign your age to it. Later, reassign the variable with a new value and print the new value.
Assign the values 5, 10, and 15 to three variables a, b, and c in a single line. Print their values.
Swap the values of two variables x and y without using a third variable. Print their values before and after swapping.
Define constants PI with appropriate values and print them.
Write a program that calculates the area of a circle using the constant PI and a variable radius. Print the area.
Define constants for the length and width of a rectangle. Calculate and print the area.
Define a constant for π (pi) and a variable for the radius. Calculate and print the circumference of the circle.