Parottasalna

AI, Backend Engineering & Architecture Guides

TASK 2 – Constants and Variables

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

Solutions

Discover more from Parottasalna

Subscribe now to keep reading and get access to the full archive.

Continue reading