0% found this document useful (0 votes)
2 views3 pages

Python Prog

The document outlines a series of Python programming tasks, including conversions between degrees and radians, area calculations for various geometric shapes, and mathematical operations such as discriminants and abundant numbers. Each task includes test data and expected results to guide implementation. The tasks range from basic arithmetic to more complex number theory concepts.

Uploaded by

raneerizal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Python Prog

The document outlines a series of Python programming tasks, including conversions between degrees and radians, area calculations for various geometric shapes, and mathematical operations such as discriminants and abundant numbers. Each task includes test data and expected results to guide implementation. The tasks range from basic arithmetic to more complex number theory concepts.

Uploaded by

raneerizal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

1. Write a Python program to convert degrees to radians.

Note : The radian is the standard unit of angular measure, used in many areas of
mathematics. An angle's measurement in radians is numerically equal to the length
of a corresponding arc of a unit circle; one radian is just under 57.3 degrees
(when the arc length is equal to the radius).
Test Data:
Degree : 15
Expected Result in radians: 0.2619047619047619
Click me to see the sample solution
2. Write a Python program to convert radians to degrees.
Test Data:
Radian : .52
Expected Result : 29.781818181818185
3. Write a Python program to calculate the area of a trapezoid.
Note : A trapezoid is a quadrilateral with two sides parallel. The trapezoid is
equivalent to the British definition of the trapezium. An isosceles trapezoid is a
trapezoid in which the base angles are equal so.
Test Data:
Height : 5
Base, first value : 5
Base, second value : 6
Expected Output: Area is : 27.5
Click me to see the sample solution
4. Write a Python program to calculate the area of a parallelogram.
Note : A parallelogram is a quadrilateral with opposite sides parallel (and
therefore opposite angles equal). A quadrilateral with equal sides is called a
rhombus, and a parallelogram whose angles are all right angles is called a
rectangle.
Test Data:
Length of base : 5
Height of parallelogram : 6
Expected Output: Area is : 30.0
Click me to see the sample solution
5. Write a Python program to calculate the surface volume and area of a cylinder.
Note: A cylinder is one of the most basic curvilinear geometric shapes, the surface
formed by the points at a fixed distance from a given straight line, the axis of
the cylinder.
Test Data:
volume : Height (4), Radius(6)
Expected Output:
Volume is : 452.57142857142856
Surface Area is : 377.1428571428571
volume = pi * radian * radian * height
sur_area = ((2*pi*radian) * height) + ((pi*radian**2)*2)
6. Write a Python program to calculate the surface volume and area of a sphere.
Note: A sphere is a perfectly round geometrical object in three-dimensional space
that is the surface of a completely round ball.
Test Data:
Radius of sphere : .75
Expected Output :
Surface Area is : 7.071428571428571
Volume is : 1.7678571428571428
Click me to see the sample solution
7. Write a Python program to calculate the arc length of an angle.
Note: In a planar geometry, an angle is the figure formed by two rays, called the
sides of the angle, sharing a common endpoint, called the vertex of the angle.
Angles formed by two rays lie in a plane, but this plane does not have to be a
Euclidean plane.
Test Data:
Diameter of a circle : 8
Angle measure : 45
Expected Output :
Arc Length is : 3.142857142857143
Click me to see the sample solution

8. Write a Python program to calculate the area of the sector.


Note: A circular sector or circle sector, is the portion of a disk enclosed by two
radii and an arc, where the smaller area is known as the minor sector and the
larger being the major sector.
Test Data:
Radius of a circle : 4
Angle measure : 45
Expected Output:
Sector Area: 6.285714285714286
Click me to see the sample solution

9. Write a Python program to calculate the discriminant value.


Note: The discriminant is the name given to the expression that appears under the
square root (radical) sign in the quadratic formula.
Test Data:
The x value : 4
The y value : 0
The z value : -4
Expected Output:
Two Solutions. Discriminant value is : 64.0
Click me to see the sample solution

10. Write a Python program to find the smallest multiple of the first n numbers.
Also, display the factors.
Test Data:
If n = (13)
Expected Output :
[13, 12, 11, 10, 9, 8, 7]
360360
Click me to see the sample solution

11. Write a Python program to calculate the difference between the squared sum of
the first n natural numbers and the sum of squared first n natural numbers.(default
value of number=2).
Test Data:
If sum_difference(12)
Expected Output :
5434
Click me to see the sample solution

12. Write a Python program to calculate the sum of all digits of the base to the
specified power.
Test Data:
If power_base_sum(2, 100)
Expected Output :
115
Click me to see the sample solution

13. Write a Python program to find out if the given number is abundant.
Note: In number theory, an abundant number or excessive number is a number for
which the sum of its proper divisors is greater than the number itself. The integer
12 is the first abundant number. Its proper divisors are 1, 2, 3, 4 and 6 for a
total of 16.
Test Data:
If is_abundant(12)
If is_abundant(13)
Expected Output:
True
False
Click me to see the sample solution

14. Write a Python program to find out if the given number is abundant.
Note: Amicable numbers are two different numbers so related that the sum of the
proper divisors of each is equal to the other number. (A proper divisor of a number
is a positive factor of that number other than the number itself. For example, the
proper divisors of 6 are 1, 2, and 3.)
Test Data:
If amicable_numbers_sum(9999)
If amicable_numbers_sum(999)
If amicable_numbers_sum(99)
Expected Output:
31626
504
0
Click me to see the sample solution

15. Write a Python program to return the sum of all divisors of a number.
Test Data:
If number = 8
If number = 12
Expected Output:
7
16
Click me to see the sample solution

16. Write a Python program to print all permutations of a given string (including
duplicates).
Click me to see the sample solution

17. Write a Python program to print the first n lucky numbers.


Lucky numbers are defined via a sieve as follows.
Begin with a list of integers starting with 1 :
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, . . . .
Now eliminate every second number :
1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, ...
The second remaining number is 3, so remove every 3rd number:
1, 3, 7, 9, 13, 15, 19, 21, 25, ...
The next remaining number is 7, so remove every 7th number:
1, 3, 7, 9, 13, 15, 21, 25, ...
Next, remove every 9th number and so on.
Finally, the resulting sequence is the lucky numbers.
Click me to see the sample solution

You might also like