File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Open terminal > python3 default.py
2
+ # Start typing below commands and see the output
3
+
4
+ # Function with default values for arguments, and while loop examples
5
+ # Note: The default value is evaluated only once.
6
+
7
+ def askme (prompt , retries = 3 , reminder = 'Invalid response, please try again!' ):
8
+ while True :
9
+ ok = input (prompt )
10
+
11
+ if ok in ('y' , 'yes' ):
12
+ return True
13
+
14
+ if ok in ('n' , 'no' ):
15
+ return False
16
+
17
+ retries = retries - 1
18
+
19
+ if retries < 0 :
20
+ raise ValueError ('System is auto locked!' )
21
+
22
+ print (reminder )
23
+
24
+ askme ('Are you sure you want to quit? ' )
25
+
26
+
27
+ # Annotations example
28
+ def hello (name : str ) -> str :
29
+ print ('Annotations: ' , hello .__annotations__ )
30
+
31
+ hello ('Ashwin' )
You can’t perform that action at this time.
0 commit comments