Skip to content

Commit 75b2e9d

Browse files
Create pg.77.t.or.f.py
1 parent f5b9a09 commit 75b2e9d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

pg.77.t.or.f.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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.'''

0 commit comments

Comments
 (0)