File tree 5 files changed +69
-0
lines changed
5 files changed +69
-0
lines changed Original file line number Diff line number Diff line change
1
+ greeting = input ("Greeting : " ).lower ().strip ()
2
+
3
+ if "hello" in greeting :
4
+ print ("$0" )
5
+ elif 'h' == greeting [0 ]:
6
+ print ("$20" )
7
+ else :
8
+ print ("$100" )
Original file line number Diff line number Diff line change
1
+ answer = input ("What is the answer to everything? " ).lower ().strip ()
2
+
3
+ if answer == "42" or answer == "forty two" or answer == "forty-two" :
4
+ print ("Yes" )
5
+ else :
6
+ print ("No" )
Original file line number Diff line number Diff line change
1
+ filename = input ("Filename : " ).lower ().strip ()
2
+ filename = '.' + filename .split ('.' )[- 1 ]
3
+
4
+ match filename :
5
+ case ".gif" :
6
+ print ("image/gif" )
7
+ case ".jpg" | ".jpeg" :
8
+ print ("image/jpeg" )
9
+ case ".png" :
10
+ print ("image/png" )
11
+ case ".pdf" :
12
+ print ("application/pdf" )
13
+ case ".txt" :
14
+ print ("text/plain" )
15
+ case ".zip" :
16
+ print ("application/zip" )
17
+ case _:
18
+ print ("application/octet-stream" )
Original file line number Diff line number Diff line change
1
+ x , y , z = input ("Expression : " ).split ()
2
+ x = int (x )
3
+ z = int (z )
4
+ match y :
5
+ case "+" :
6
+ print (f"{ x + z :.1f} " )
7
+ case "-" :
8
+ print (f"{ x - z :.1f} " )
9
+ case "*" :
10
+ print (f"{ x * z :.1f} " )
11
+ case "/" :
12
+ print (f"{ x / z :.1f} " )
Original file line number Diff line number Diff line change
1
+ def main ():
2
+ time = input ("What time is it? " )
3
+ time = convert (time )
4
+ if 7 <= time <= 8 :
5
+ print ("breakfast time" )
6
+ elif 12 <= time <= 13 :
7
+ print ("lunch time" )
8
+ elif 18 <= time <= 19 :
9
+ print ("dinner time" )
10
+
11
+ def convert (time ):
12
+ if time .endswith (" a.m." ):
13
+ time = time .split (' a.m.' )
14
+ time = time [0 ].split (':' )
15
+ return round (int (time [0 ]) + int (time [1 ])/ 60 , 2 )
16
+ elif time .endswith (" p.m." ):
17
+ time = time .split (' p.m.' )
18
+ time = time [0 ].split (':' )
19
+ return round (12 + int (time [0 ]) + int (time [1 ])/ 60 , 2 )
20
+ else :
21
+ time = time .split (":" )
22
+ return round (int (time [0 ]) + int (time [1 ])/ 60 , 2 )
23
+
24
+ if __name__ == "__main__" :
25
+ main ()
You can’t perform that action at this time.
0 commit comments