Python Computing Problem Set by Abhijit Kar Gupta
Python Computing Problem Set by Abhijit Kar Gupta
1. Write a Python script which accepts the radius of a sphere from the user and compute the volume.
2. Write a Python script to compute the distance between two points: and .
3. Given some data: , find the (arithmetic) mean and r.m.s.
value of the variable .
4. Given the following numbers:
Find the maximum, minimum and range of the numbers.
5. A set of 20 numbers are given: 1, 0.1, 5, 3, 10, -1, 4, 20, 1000, -9, 2, 14, 4.5, 0.9, 30, 9.8, 11, 22,
48, -10 . Write a computer program to count how many numbers are there between 0 to 10.
6. Write a computer program to compute , where .
7. Compute ( ) for ,
8. Write a Python script to verify Stirling’s approximation: .
9. Write a Python Script for the function and then
evaluate from that.
10. Use python random number generator to evaluate the value of with the level of accuracy of
.
11. Write a computer program to find out the sum of digits of 87694.
12. Given the recursion relation: , with . Write a suitable python script
to generate all the values up to .
13. Given a function, , generate two lists for data points for the
range (0, 20), and store data in a file.
14. Find the value of from the infinite series: up to 6th decimal of
accuracy.
15. Write a Python script to compute the variance of the following numbers: -2.0, 0, 1.2, 6.1, 4.2,
3.5, -1.9, -3.2, 2.8, 5.3, -0.8
16. Given a list of numbers: 3, 2, 1, 0, 3, -5, 10, 3, 2, 1, 3, 5, 3, find how many times 3 appeared in
the list.
17. Calculate the following sum: ∑ for with an accuracy level of 4 decimal places.
18. Show the validity of the trigonometric identity: for and
.
19. Given the list of numbers: ], write a
python script to read the list and print two separate lists consisting of positive and negative
numbers.
20. Write a python script to evaluate where √ .
21. Compute the following logarithmic series up to an accuracy of 3 decimal places:
( )
22. Given 10 numbers: . Write a python script to
find out the number of numbers that are in between 0 and 50.
Page 2 of 3
23. For the string ‘123456809’, print the characters evaluate the sum of the characters.
24. Write a Python Script to count how many vowels are there in the string: ‘university’.
25. Read as input from outside and then as another set of input from
outside. Make two lists. Add the two lists. Sort the joint list by system function.
26. You have taken a loan from Bank of the amount of Rs. 1 Lakh with compound interest 10% for
10 years. Equated Monthly Interest (EMI) is paid at the rate of Rs. 1000. How many years will it
take to repay the entire loan? Write a python program to find out the solution.
27. Write a computer program to compute the standard deviation ( ) of the numbers:
46. Write a Python script to print the alphabet pattern ‘E’ with *.
*****
*
*
*****
*
*
*****
47. Take any positive integer number, large or small. If the number is even, divide it by 2. If the
number is odd, multiply it by 3 and add 1. Go on doing this way and check where you end up.
You will get a sequence of numbers. This is Collatz sequence. Print the list of the sequence of
numbers.
48. Play a probabilistic game: Start with Rs. 1000. With win, capital is increased by RS. 1 and with
losing it goes down by Rs. 1. Toss a biased coin no. 1 with win probability = (1/10) – 0.01 if
the capital at hand is multiple of 3. If not, toss another biased coin with win probability = (3/4)
– 0.01. Print for 10 steps, how the capital goes with number of coin tossing’s.
49. Import date() function from the datetime module. Find the number of days between (2019,
18, 3) and (2019, 29, 3).
50. Consider two dictionaries: d1 = {‘a’:10, ‘b’:20, ‘c’:30} and d2 = {‘a’:100,
‘b’:200, ‘c’:300}. Prepare a combined dictionary where the values for the same keys are
added.
[First try an elementary code. Then you may use the function Counter() from the module
‘collections’ or any other suitable module. ]