File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change
1
+ '''There are some values in other data types that conditions will consider equivalent
2
+ to True and False. When used in conditions, 0, 0.0, and '' (the empty
3
+ string) are considered False, while all other values are considered True. For
4
+ example, look at the following program:'''
5
+
6
+ name = ''
7
+ while not name :u
8
+ print ('Enter your name:' )
9
+ name = input ()
10
+ print ('How many guests will you have?' )
11
+ numOfGuests = int (input ())
12
+ if numOfGuests :v
13
+ print ('Be sure to have enough room for all your guests.' )w
14
+ print ('Done' )
15
+
16
+ '''If the user enters a blank string for name, then the while statement’s condition
17
+ will be True u, and the program continues to ask for a name. If the value for
18
+ numOfGuests is not 0 v, then the condition is considered to be True, and the
19
+ program will print a reminder for the user w.
20
+ You could have typed not name != '' instead of not name, and numOfGuests
21
+ != 0 instead of numOfGuests, but using the truthy and falsey values can make
22
+ your code easier to read.'''
You can’t perform that action at this time.
0 commit comments