Python Numbers and Mathematics

1) Add Two Numbers

Prompt for two numbers and print their sum.


2) Subtract Two Numbers

Ask for two numbers and print:

first – second

3) Multiply Numbers

Prompt for two numbers and print the product.


4) Divide Numbers

Ask for two numbers and print the division result.


5) Floor Division

Ask for two numbers and print:

first // second

6) Modulus Operation

Ask for two numbers and print:


7) Power Operation

Prompt for a base and exponent, then compute:


8) Average of Three Numbers

Ask for 3 numbers and print their average.


9) Swap Two Numbers

Ask for two numbers and swap their values without using a temporary variable.


10) Check Even or Odd

Prompt for an integer and print whether it’s even or odd.


11) Maximum of Two

Ask for two numbers and print the bigger one.


12) Minimum of Two

Ask for two numbers and print the smaller one.


13) Absolute Value

Ask for a number and print its absolute value (use abs()).


14) Round a Floating Number

Prompt for a decimal number and print it rounded to the nearest integer.


15) Convert to Integer

Ask for a float input and convert it to an integer (print result and type).


16) Convert to Float

Ask for an integer input and convert it to float (print result and type).


17) Simple Interest

Ask for principal, rate, and time. Calculate and print simple interest:


18) Circle Area

Ask for the radius and print the area of the circle using:

Use math.pi.


19) Distance Between Two Points

Prompt for two coordinates (x1, y1) and (x2, y2). Compute:

Use math.sqrt().


20) Loop Sum of 1–n

Ask for a number n and use a for loop to compute the sum 1 + 2 + … + n. Print result.


📝 Notes

✔ For division, handle the case where the second number is zero (optional). ✔ For math tasks, import the built-in module:

✔ Use built-in functions like:

  • abs()

  • round()

  • int(), float()


canvil: 333f6c7d-6876-4f7e-b6ad-1bdb2233f5c1

Last updated