Python Projects for Beginners a ten-Week Bootcamp Approach to Python Programming



Download 2,61 Mb.
bet71/200
Sana20.06.2022
Hajmi2,61 Mb.
#681748
1   ...   67   68   69   70   71   72   73   74   ...   200
Bog'liq
Python Projects for Beginners A Ten Week Bootcamp Approach to Python

Friday: Creating Hangman
As the weeks go on, the projects will generally get longer. Today we’re going to be building Hangman with the use of all the concepts learned from the past four weeks. As usual, new concepts will be introduced as we code along. Today’s goal is to have a fully functioning Hangman game, where we can guess, lose a life, and win or lose the game. We won’t be adding graphics, although after we complete the project together, feel free to add them yourself.
To follow along with this lesson, let’s continue from our previous notebook file
Week_04” and add a markdown cell at the bottom that says, “Friday Project: Creating Hangman.”

Final Design


As always, we want to lay out our final design before we begin coding. This week will not be based around graphics, like last week, so we’ll focus on the logic and the steps necessary to run the program. Luckily for us, the logic is essentially the steps needed to play the game:

  1. Select a word to play with.

  2. Ask user for input.

  3. Check if guess is correct.

    1. If it is, show the letter in the proper place.

    2. If it isn’t, lose a life.

  4. Continue steps 2 and 3 until one of the following occurs:

    1. The user guesses the word correctly.

    2. The user loses all their lives.

This is the main game play functionality. There are several other steps we need to perform before actually running the game, like declaring game variables; however, this is the primary functionality that we needed to lay out before we begin coding. Knowing this structure will allow us to stay on track with our program.

Previous Line Symbols Introduced


Like how we added line numbers back in Week 1, we’re going to introduce the concept of line symbols for this project and all others going forward. With the need to edit previously written lines, or even add code in the middle of the project, we’ll be introducing the concept of line symbols. These symbols will be shown by the use of three empty squares and will represent previously written code. You can see an example here:

1| if num > 1: ◻◻◻
3| # new code will go here
5| print( ◻◻◻

When we add lines in between previously written code, I will use these three squares to signify which line should be above and below the code we’re writing. It also means that you should leave the line unaltered. When we need to overwrite a previous line, I will let you know. Be sure to pay attention to line numbers when you see those three squares, as that will help to let you know if you missed a line or not.
Note turn lines on by pressing “L” after clicking the cell’s side

Download 2,61 Mb.

Do'stlaringiz bilan baham:
1   ...   67   68   69   70   71   72   73   74   ...   200




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish