-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConditional statement practice
More file actions
114 lines (88 loc) · 2.34 KB
/
Conditional statement practice
File metadata and controls
114 lines (88 loc) · 2.34 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
print("Enter three values:")
no1=float(input())
no2=float(input())
no3=float(input())
#compare three values
if no1>no2 and no1>no3:
print("max value is:",no1)
elif no2>no3:
print("max value is:",no2)
else:
print("max value is:",no3)
#compare
if no1>no2:
if no1>no3:
print("max value is ",no1)
else:
print("max value is",no3)
elif no2>no3:
print("max value is ",no2)
else:
print("max value is:",no3
cv=input("Enter any character:")
cv=cv[0]
cv=ord(cv)
#if cv>='a' and cv<='z':
#if cv>=97 and cv<=122:
if cv>=97 and cv<=122:
print("its lowercase alphabet")
#elif cv>='A' and cv<='Z':
elif cv>=65 and cv<=90:
print("Its uppercase alphabet")
else:
cv=input("Enter any character:") #str
print("value of cv",cv,"type of cv=",type(cv),"id of cv=",id(cv))
cv=cv[0] #new object
print("value of cv",cv,"type of cv=",type(cv),"id of cv=",id(cv))
cv=ord(cv) #new object
print("value of cv",cv,"type of cv=",type(cv),"id of cv=",id(cv))
#if cv>='a' and cv<='z':
#if cv>=97 and cv<=122:
if cv>=97 and cv<=122:
print("its lowercase alphabet")
#elif cv>='A' and cv<='Z':
elif cv>=65 and cv<=90:
print("Its uppercase alphabet")
else:
print("its not alphabet")
print("its not alphabet")
cv=input("Enter any character:") #str
cv=cv[0] #new object
if cv=='a' or cv=='e' or cv=='i' or cv=='o' or cv=='u' or cv=='A' or cv=='E' or cv=='I' or cv=='O' or cv=='U':
print("its vowel")
else:
print("its consonant")
if cv=='a':
print("its vowel")
elif cv=='e':
print("its vowel")
elif cv=='i':
print("its vowel")
elif cv=='o':
print("its vowel")
elif cv=='u':
print("its vowel")
else:
print("its consonant")
NESTED IF
1.sum 2.sub 3.mul 4.division
print("1.sum")
print("2.sub")
print("3.mul")
print("4.division")
ch=int(input("Enter your choice:"))
num1=0
num2=0
if ch>=1 and ch<=4:
num1=float(input("Enter first value:"))
num2=float(input("Enter second value:"))
if ch==1:
print("Sum=",num1+num2)
elif ch==2:
print("Sub=",num1-num2)
elif ch==3:
print("mul=",num1*num2)
elif ch==4:
print("div=",num1/num2)
else:
print("wrong choice")