Skip to content

peternielsen112/puzzles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Puzzles 1

Have fun and give it your best shot!

These puzzles may be hard, and that's okay. Keep on giving it your best work, and you'll get it. Remember, Google and Stack Overflow are your friends.

CONTENTS

Instructions

Clone this repo either to your local machine or to Repl.it (https://repl.it/languages/python3). If you would like to save your work on Repl.it, make sure to sign in before visiting the link. Remember to use the command $ git clone https://github.com/peternielsen112/puzzles.git in Git Bash. REMEMBER TO BE IN THE PROPER DIRECTORY.

Puzzles

1: Write a Python program that:

a) Prompts the user to write a list of words (for example, ['apple', 'mango', 'cashew']).

b) Once the list has been entered, the program will ask for a word to search for.

c) The program will then say the number of times the word was found in the list, or display a message that the word wasn't found. For example: "___ was found 3 times" or "___ wasn't found."

The code for this program should be placed in the file list-check.py. You may want to check the hints on this one, because there's some complicated input logic.

2: Write another Python program that:

a) Prompts the user to give a number, an INTEGER only.

b) Prints every number up to the given number.

c) Gives the time it took to print every number up to the user's number.

The code for this program should be placed in the file number-counter.py.

3: Write a third Python program that:

a) Chooses a random number between 1 and 100

b) While the player or user has not guessed the number (use input) print if their latest guess is higher or lower

c) Counts the number of guesses the player takes

d) And finally, tells the user they were right (when they guess the right number), tells them the number, and the number of tries they needed.

The code for this program should be placed in the file guessing-game.py.

Conclusion

In these puzzles, you learned basic logic of if, else, and while. You also learned about modules, and more specifically, the time and random modules and how to use them, if at least minimally. You learned about f strings and you built three programs that created specific functions. After break, we'll do more in Python and work through how to create more complex programs.

About

Puzzles

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages