Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit026379d

Browse files
authored
Add number guessing exercise solution
1 parent9d61225 commit026379d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎ch08-conditional-logic/3-control-the-flow-of-your-program.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Solutions to review exercises
33

44

5+
# --- Exercise 1
56
# Display whether the length of user input is <, > or = 5 characters
67

78
my_input=input("Type something: ")
@@ -12,3 +13,15 @@
1213
print("Your input is greater than 5 characters long.")
1314
else:
1415
print("Your input is 5 characters long.")
16+
17+
18+
# --- Exercise 2
19+
# Number guessing program ("guess" the number 3)
20+
21+
print("I'm thinking of a number between 1 and 10. Guess which one.")
22+
my_guess=input("Type in your guess: ")
23+
24+
ifmy_guess=="3":
25+
print("You win!")
26+
else:
27+
print("You lose.")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp