-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmathsexercises.tex
160 lines (138 loc) · 7.36 KB
/
mathsexercises.tex
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
%- http://www.w3resource.com/python-exercises/math/index.php
Python Math [79 exercises with solution]
[An editor is available at the bottom of the page to write and execute the scripts.]
1. Write a Python program to convert degree to radian. Go to the editor
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 radian to degree. Go to the editor
Test Data:
Radian : .52
Expected Result : 29.781818181818185
Click me to see the sample solution
3. Write a Python program to calculate the area of a trapezoid. Go to the editor
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. Go to the editor
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 surface volume and area of a cylinder.Go to the editor
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
Click me to see the sample solution
6. Write a Python program to calculate surface volume and area of a sphere. Go to the editor
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 arc length of an angle. Go to the editor
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. Go to the editor
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. Go to the editor
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.Go to the editor
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 tje squared sum of first n natural numbers and the sum of squared first n natural numbers.(default value of number=2). Go to the editor
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.Go to the editor
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.Go to the editor
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 sum all amicable numbers from 1 to specified numbers. Go to the editor
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 returns sum of all divisors of a number. Go to the editor
Test Data:
If number = 8
If number = 12
Expected Output:
[1, 2, 4]
[1, 2, 3, 4, 6]
Click me to see the sample solution
16. Write a Python program to print all permutations of a given string (including duplicates). Go to the editor
Click me to see the sample solution
17. Write a Python program to print the first n Lucky Numbers. Go to the editor
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
18. Write a Python program to computing square roots using the Babylonian method. Go to the editor
Perhaps the first algorithm used for approximating √S is known as the Babylonian method, named after the Babylonians, or "Hero's method", named after the first-century Greek mathematician Hero of Alexandria who gave the first explicit description of the method. It can be derived from (but predates by 16 centuries) Newton's method. The basic idea is that if x is an overestimate to the square root of a non-negative real number S then S / x will be an underestimate and so the average of these two numbers may reasonably be expected to provide a better approximation.
Click me to see the sample solution
19. Write a Python program to multiply two integers without using the * operator in python. Go to the editor
Click me to see the sample solution
- See more at: http://www.w3resource.com/python-exercises/math/index.php#sthash.bB7zWmx7.dpuf