-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProblem15to21.py
77 lines (51 loc) · 1.8 KB
/
Problem15to21.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
# problem 15
from math import pi
radius = float(raw_input("Enter Radius of the Sphere: "))
print("Area of the Sphere with Radius " + str(radius) + " is: " + str((4.0 / 3.0) * pi * radius ** 3))
print("--------------Problem 15 End--------------------------")
# problem 16
sampleNumber = int(raw_input("Enter a Number: "))
def difference(sampleNumber):
if sampleNumber > 17:
return (sampleNumber - 17) * 2
else:
return 17 - sampleNumber
print(difference(sampleNumber))
print("--------------Problem 16 End--------------------------")
# problem 17
sampleNumber = int(raw_input("Enter a Number: "))
def nearThousand(sampleNumber):
return (abs(1000 - sampleNumber) <= 100) or (abs(2000 - n) <= 100)
print(nearThousand(sampleNumber))
print("--------------Problem 17 End--------------------------")
# problem 18
def sumThrice(x, y, z):
if x == y == z:
return x * 9
else:
return x + y + z
x = int(raw_input("Enter a number:"))
y = int(raw_input("Enter a number:"))
z = int(raw_input("Enter a number:"))
print(sumThrice(x, y, z))
print("--------------Problem 18 End--------------------------")
# problem 19
stringContent = raw_input("Enter any string: ")
if stringContent.startswith("is"):
print(stringContent)
else:
print("is" + stringContent)
print("--------------Problem 19 End--------------------------")
# problem 20
stringContent = raw_input("Enter any string to be repeated: ")
sampleNumber = int(raw_input("Enter a number:"))
stringContent = stringContent * 3
print(stringContent)
print("--------------Problem 20 End--------------------------")
# problem 21
sampleNumber = int(raw_input("Enter a number: "))
if sampleNumber % 2 == 0:
print("Number is Even")
else:
print("Number is Odd")
print("--------------Problem 21 End--------------------------")