-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelse-if.py
More file actions
99 lines (68 loc) · 2.88 KB
/
Copy pathelse-if.py
File metadata and controls
99 lines (68 loc) · 2.88 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
### Questions:
# 1. **Odd or Even**: Write a program that takes an integer as input and checks whether it is odd or even.
# 2. **Age Group**: Write a program that checks a person's age and categorizes them into a group:
# * Child (0–12)
# * Teen (13–19)
# * Adult (20–64)
# * Senior (65+)
# 3. **Leap Year Check**: Write a program that checks if a given year is a leap year. A year is a leap year if:
# * It is divisible by 4, but not divisible by 100, unless it is also divisible by 400.
# 4. **Greatest of Three**: Write a program that takes three numbers as input and prints the greatest one.
# 5. **Vowel or Consonant**: Write a program that checks whether a given letter is a vowel or consonant.
# 6. **Positive, Negative, or Zero**: Write a program that checks if a given number is positive, negative, or zero.
# 7. **Divisibility Check**: Write a program that checks if a given number is divisible by both 3 and 5.
# 8. **Temperature Checker**: Write a program that takes a temperature in Celsius as input and checks whether it’s too cold, normal, or too hot:
# * Below 0°C: Too Cold
# * 0–30°C: Normal
# * Above 30°C: Too Hot
# 9. **Multiple of 7 and 5**: Write a program that checks if a number is a multiple of both 7 and 5.
# 10. **Grade Checker**: Write a program that takes a student's grade and prints a message:
# * A: Excellent
# * B: Good
# * C: Average
# * D: Below Average
# * F: Fail
# Answers
# 1. **Odd or Even**: Write a program that takes an integer as input and checks whether it is odd or even.
# num = int(input("Enter a Number : "))
# if num%2 ==0 :
# print("Number is Even")
# else:
# print("Number is Odd")
# 2. **Age Group**: Write a program that checks a person's age and categorizes them into a group:
# * Child (0–12)
# * Teen (13–19)
# * Adult (20–64)
# * Senior (65+)
# age = int(input('Enter Your Age : '))
# if 0<=age<=12:
# print("Child")
# elif 13<= age <=19:
# print("Teen")
# elif 20<= age <=64:
# print("Adult")
# elif age >=65:
# print("Senior")
# else:
# print("Not a Valid Number")
#3. **Leap Year Check**: Write a program that checks if a given year is a leap year. A year is a leap year if:
# year = int(input("Enter a year: "))
# if year % 4 == 0:
# if year % 100 != 0 or year % 400 == 0:
# print(f"{year} is a Leap Year")
# else:
# print(f"{year} is not a Leap Year")
# else:
# print(f"{year} is not a Leap Year")
# 4. **Greatest of Three**: Write a program that takes three numbers as input and prints the greatest one.
a= int(input("Enter a Number"))
b= int(input("Enter another Number"))
c= int(input("Enter another Number"))
if a>b and a>c :
print("A is greater than b and c",)
elif b>a and b>c:
print("B is greater than a and c")
elif c>a and c>b:
print("C is greater than a and b")
else:
print("All are equal")