-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBeginner - Conditional applications (practice code series)
More file actions
59 lines (52 loc) · 1.44 KB
/
Beginner - Conditional applications (practice code series)
File metadata and controls
59 lines (52 loc) · 1.44 KB
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
# Take operation name from input
operation = input()
if operation == "odd_num_check":
# Odd number checker
number = int(input())
if number % 2 == 0:
print("no")
else:
print("yes")
elif operation == "perfect_square_check":
# Perfect square checker
number = int(input())
if int(number**0.5)**2 == number:
print("yes")
else:
print("no")
elif operation == "vowel_check":
# Vowel checker
string = input().lower()
if ("a" in string or "e" in string or "i" in string or "o" in string or "u" in string) :
print("yes")
else:
print("no")
elif operation == "divisibility_check":
# Divisibility checker
number = int(input())
if number % 2 == 0:
if number % 3 == 0:
print("divisible by 2 and 3")
else:
print("divisible by 2")
elif number % 3 == 0:
print("divisible by 3")
else:
print("not divisible by 2 and 3")
elif operation == "palindrominator":
# Palindrominator
string = input()
palindrome = string + string[-2::-1]
print(palindrome)
elif operation == "simple_interest":
# Simple interest calculator
principal_amount = float(input())
n_years = int(input())
if n_years < 10:
interest_rate = 0.05
else:
interest_rate = 0.08
simple_interest = principal_amount * interest_rate * n_years
print(int(simple_interest))
else:
print("Invalid Operation")