Repository navigation
Expand file tree
/
Copy pathmenudriven.py
More file actions
68 lines (50 loc) · 1.5 KB
/
Copy pathmenudriven.py
File metadata and controls
68 lines (50 loc) · 1.5 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
60
61
62
63
64
65
66
while True:
print("\n--- numbers operation ---")
print("1. Add numbers")
print("2. check even odd")
print("3. count vowels")
print("4. find factorial")
print("5. reverse string")
print("6. check palindrome")
print("7. exit")
choice = int(input('enter option: '))
if choice == 1:
num1 = int(input('enter number1:'))
num2 = int(input('enter number2:'))
print("addition is:", num1 + num2)
elif choice == 2:
n = int(input('enter number:'))
if n % 2 == 0 :
print('even')
else:
print('odd')
elif choice == 3:
string1 = input("Enter string: ")
vowels = 'aeiouAEIOU'
count = 0
for ch in string1:
if ch in vowels:
count += 1
print("Vowel count:", count)
elif choice == 4:
n = int(input("Enter a number: "))
fact = 1
for i in range(1, n+1):
fact = fact * i
print("Factorial of", n, "is", fact)
elif choice == 5:
string2 = input('enter string:')
print('reverse:',string2[::-1])
elif choice == 6:
numb1 = input("Enter number: ")
numb2 = numb1[::-1]
if numb2 == numb1 :
print('palindrome')
else:
print('not a palindrome ')
elif choice == 7:
print("Thank you......")
print("exiting...")
break
else:
print("choose valid option")