-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConditionalLogicPrograms.py
More file actions
55 lines (46 loc) · 1.73 KB
/
Copy pathConditionalLogicPrograms.py
File metadata and controls
55 lines (46 loc) · 1.73 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
def checkEvenOdd():
num = int(input("Enter a number: "))
print("Even" if num % 2 == 0 else "Odd")
def checkDivisibleBy2And3():
num = int(input("Enter a number: "))
print("Divisible by 2 and 3" if num % 2 == 0 and num % 3 == 0 else "Not divisible")
def checkDivisibleBy3Or5():
num = int(input("Enter a number: "))
print("Divisible by 3 or 5" if num % 3 == 0 or num % 5 == 0 else "Not divisible")
def findGreatestOfThree():
a, b, c = map(int, input("Enter three numbers separated by space: ").split())
print(f"Greatest: {max(a, b, c)}")
def checkLeapYear():
year = int(input("Enter year: "))
if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
print("Leap Year")
else:
print("Not a Leap Year")
def calculateElectricBill():
units = float(input("Enter units consumed: "))
if units <= 100: bill = units * 5
elif units <= 200: bill = units * 7
elif units <= 300: bill = units * 10
else: bill = units * 15
print(f"Total Bill: {bill}")
def calculateGrade():
perc = float(input("Enter percentage: "))
if perc > 85: print("Grade: A")
elif perc >= 75: print("Grade: B")
elif perc >= 50: print("Grade: C")
elif perc > 30: print("Grade: D")
else: print("Fail")
def checkVowelOrConsonant():
char = input("Enter an alphabet: ").lower()
if char in 'aeiou': print("Vowel")
else: print("Consonant")
def checkCharType():
char = input("Enter a character: ")
if char.isalpha(): print("Alphabet")
elif char.isdigit(): print("Digit")
else: print("Special Character")
def checkCase():
char = input("Enter a character: ")
if char.isupper(): print("Uppercase")
elif char.islower(): print("Lowercase")
else: print("Not an alphabet")