-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMathamatics.py
84 lines (60 loc) · 2.74 KB
/
Mathamatics.py
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
#27 Ask the user to enter a number with lots of decimal places. Multiply this number by two and display the answer.
#introduce float
# num = float(input("Enter a number with a lot of decimal places :"))
# answer = 2 * num
# print(answer)
#28 Update program 27 so that it will display the answer to two decimal places.
# num = float(input("Enter a number :"))
# answer = num*2
# print(answer)
# print(round(answer, 2)) #introduce round
#29 Ask the user to enter an integer that is over 500. Work out the square root of that number and display it to two decimal places.
# import math
# num = int(input("Enter an integer that is over 500 : "))
# answer = math.sqrt(num) #introduce of square root
# print(round(answer, 2))
#30 Display pi to five decimal places
#without importing math
# pie = 22/7
# print(round(pie, 5))
#with importing math
# import math
# print(round(math.pi,5))
#31 Ask the user to enter the radius of a circle (measurement from the center point to the edge). Work out the area of the circle (pir*r square)
# import math
# radius = float(input("Enter the radius of the circle : "))
# area = math.pi * radius * radius
# print(round(area,2))
#32 Ask for the radius and the depth of a cylinder and work out the total volume(circle area*depth) rounded to three decimal places.
# import math
# radius = int(input("Enter the radius :"))
# depth = int(input("Enter the depth :"))
# area = math.pi * (radius**2)
# volume = area*depth
# print(round(volume,3))
#33 Ask the user to enter two numbers. Use whole number division to divide the first number by the second and also work out the remainder and display the answer in a user-friendly way(e.g. if they enter 7 and 2 display "7 divide by 2 is 3 with 1 remaining")
# num1 = int(input("Enter first number: "))
# num2 = int(input("Enter second number: "))
# division = num1//num2
# remainder = num1%num2
# print(num1, "divided by", num2, "is", division, "with", remainder, "remaining")
#34 Display the following message :
# (1) Square
# (2) Triangle
# Enter a number :
# If the user enters 1, then it should ask them for the length of one of its sides and display the area. If they select 2, it should give them a suitable error message.
# print("1) Square")
# print("2) Triangle")
# print()
# menuselection = int(input("Enter a number :"))
# if menuselection==1:
# side = int(input("Enter the length of one side: "))
# area = side*side
# print("The area of your chosen shape is ", area)
# if menuselection==2:
# base = int(input("Enter the length of the base : "))
# height = int(input("Enter the height of the triangle : "))
# area = (base*height)/2
# print("The area of your chosen shape is ", area)
# else:
# print("Incorrect option selected. Please! check and try again !")