Python Arithmetic Coding Questions
Python Arithmetic Coding Questions
1. Write a program that initializes `a = 5`, `b = 10`, then increases `a` by 2 and prints `a + b`.
3. Assign `m = 4`, `n = 2`. Multiply both by 2 and print the product of `m` and `n`.
4. Write code to add 5 to a variable `a = 20` and subtract 3 from `b = 8`, then print `a - b`.
6. Take `x = 3`, `y = 4`. Raise `x` to the power of `y` and print the result.
7. Assign `a = 10`, then do `a += 10`, then `a -= 5`. Print the final value.
9. Write a program to swap two numbers `a = 5` and `b = 10`, then print their values.
13. Assign `a = 14`, `b = 6`, then find the average of `a` and `b`.
16. Assign `x = 3.5`, `y = 1.2`, add them and print the sum.
18. Write a program to increase `a = 2` five times using `a += 1` in each step and print `a`.
19. Given `x = 8`, decrement it by 1 and multiply the result by 3. Print it.
20. Assign `a = 100`, subtract 40 and then divide the result by 2. Show the result.
24. Create a variable `temp = 30`, convert it to Fahrenheit using `F = (temp * 9/5) + 32`.
Page 1
Python Variable & Arithmetic Practice Questions
28. Set `a = 9`, increase by 10%, then print the new value.
29. Set `price = 100`, apply 18% GST, print final amount.
30. If `a = 25`, subtract 5, multiply the result by 4, and add 2. Print the final output.
31. Write a program to calculate `simple interest = (P*T*R)/100` where `P=1000, T=2, R=5`.
33. Take two variables and print whether their sum is even or odd.
34. Assign `num = 153`, break it into digits and print their sum.
36. Set `x = 20`, `y = 3`, perform all five basic operations and print results.
38. Write a program that multiplies two numbers and subtracts a third number.
41. If `length = 10`, `breadth = 5`, calculate the perimeter of the rectangle.
42. Assign `base = 6`, `height = 4`, calculate the area of triangle.
45. Assign `a = 8`, use only `*` operator to find the square.
46. Create a program to compute `volume = length * breadth * height` with inputs.
47. Write a program to calculate BMI using `BMI = weight/(height*height)` with dummy values.
Page 2