Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Python Computing Course (Association SNAP)

Problem Set I

Group A

1. Check the datatypes of (i) 346.89, (ii) 14/5, (iii) 20/3.0, (iv) 2(3+6j), (v) ‘12345’
2. Are the following statements alright? Type and check. Find the errors, if any. (i) 6x = 6x, (ii) x8
= x8, (iii) x5 = x*5, (iv) x*3 = 3*x
3. Import the module ‘sys’ on your namespace. Check the directory and find out a possible
function there in the directory to check your Python version.
4. Print the calendar of March 2022.
5. Print the The Zen of Python poem.
6. Print 0.000053 in exponential format.
7. There is a module called, ‘platform’ in core Python. Import this module and use a function
system() from it to check which operating system you are using.
8. Import the time module and find out the python object to print out local date time.
9. Take three numbers: integer, float and complex: 34, -56.98, 5 + 2j. Take the product
of the three numbers and find out the type of the output.
10. Suppose we have three strings, x = ‘Hello friends!’, y = ‘That is why I feel good.’, z = ‘I learnt
Python.’ Can you print the three strings together to have a meaningful conversation?
11. Convert the decimal number 5983 into a (i) binary, (ii) hexadecimal, and (ii) octal number.
12. Use the built-in function to find the maximum and minimum among the following numbers: −1,
2, 10, 13, 3.5, 71.9, 23, −34, 0, 0.98, 11.3, 10
13. Write a Python script which accepts the first and last name of the user and print them in reverse
order with a gap between them.

Group B

14. Import the special numbers 𝑒 and 𝜋 from math module. Round off each number up to 3 decimal
points and then find the value of 𝑒𝜋 2 .
15. Check the famous Euler identity: 𝑒 𝑖𝜋 = −1. [Take 𝜋 from math module.]
16. Verify: ln 100! ≈ 100 ln 100 − 100.
√5+1
17. Evaluate the Golden ratio 2
in decimal fraction and print that up to 5 decimal points.
18. Write a Python program to compute 𝑧, where 𝑧 = 𝑥(𝑥 − 𝑦)/(𝑥 + 𝑦) with 𝑥 = 5, 𝑦 = 9. Print
the output and check the datatype of 𝑧.
𝑁!
19. Compute for 𝑁 = 7, 𝑛 = 3 [Use function factorial() from math module.]
𝑛!(𝑁−𝑛)!
20. Prove the following identity numerically for the angle 𝜃 = 470 :
cos 5𝜃 = 16 cos5 𝜃 − 20 cos3 𝜃 + 5 cos 𝜃
tan 𝛼+tan 𝛽
21. Check the trigonometric identity: tan(𝛼 + 𝛽) = 1−tan 𝛼 tan 𝛽 for 𝛼 = 42𝑜 and 𝛽 = 340 .
22. Given, the Cartesian coordinates of two points: 𝑝1 = (2, 3, 5) and 𝑝2 = (9, 0, −1). Write a
Python code to compute the distance between the two points.
23. A square is inscribed inside a circle of radius 5 unit. Compute the areas of the circle and the
square and find the ratio between them to find out the value of pi.

Abhijit Kar Gupta, kg.abhi@gmail.com


24. Accept three numbers as user input and then find the mean of them.

Group C

25. Create 5 random numbers from a normal distribution with 𝜇 = 0.5, 𝜎 = 1.


26. Create 3 random fractions between 2 and 3 and find out the mean of those numbers.
27. Create all the odd integers between 3 and 27 with a number generator.
28. Consider the following 10 numbers: 0.2, 0.4, 0.9, 0.1, −0.3, −0.4, 0.6, 0.4, −0.5, −0.1.
Take a random sample of 5 numbers from this and find the maximum out them.
29. The real and imaginary parts of a complex number 𝑧 are 3.5 and 1.8 respectively. Construct the
complex number and find the value of 𝑧𝑧 ∗ .
30. If 𝑧1 = 2 + 𝑖 and 𝑧2 = 3 − 2𝑖, compute |3𝑧1 − 4𝑧2 |.
[Ignore the problems involving complex numbers if you are not familiar with.]
31. If 𝑧1 = 4 − 3𝑗 and 𝑧2 = −1 + 2𝑗, evaluate: (a) |𝑧1 + 𝑧2 |, (b) 𝑧1 ∗ + 𝑧2 ∗ and find out the real and
imaginary components in each case.
−1 𝑝 𝑝𝑗+1 𝑚
32. Check that for any real numbers 𝑝 and 𝑚, 𝑒 2𝑚𝑗 cot (𝑝𝑗−1) = 1.

[You may use appropriate built-in functions to verify or compute. Disregard the problems in Group C
until some further modules and concepts are introduced.]

Abhijit Kar Gupta, kg.abhi@gmail.com

You might also like