Wednesday 13 November 2019

Python - Day Eighteen (November)

WHAT I DID TODAY:


Today I completed the 'Battleships' exercise-type lesson. I had 9 lessons left out of 19, and today I just added things like errors, and what the game would do if the person guesses wrong or misses the game board etc; I now finished 60% of the course.


60% COMPLETE

I added a couple of new things that I will be explaining. 

  • The first thing I added was errors. There were three types. The types were if the person misses the game board completely, guessing wrong, or just guessing that number already. 

"OOPS YOUR GUESS WASN'T IN RANGE" MESSAGE

On line  31-35, I used else, if, variables, and range codes to make a message that says "You missed my battleship!" if the guess wasn't in range of the game board.

YOU GUESSED THAT ONE ALREADY MESSAGE

On line 35, I added a new one that says if the user guessed that number already then, it would say "You missed my battleship" like the photo above.

"GAME OVER" AND "NUMBER OF TURNS ALLOWED"

The code I added allows the user to guess 4 times before the game states that "it's over." The work I did was on line 43-44.

As you can see, all the codes I used in this exercise were ones that I already learned before and should not seem as foreign as one may think.

And I will show photos of my overall finished codes, within this whole exercise.


PART 1 OF FINISHED PRODUCT

PART 2 OF FINISHED PRODUCT



WHAT I LEARNED:


Surprisingly, I did learn something new today. I got taught a new code/command. And that is the break code. Basically, using this code for the battleships game, it stops the game after you guess it right without using all 4 turns. 

Before, without using the break code, the game kept going even if you guessed it right. So that's what the break function's purpose is in this situation.

BREAK FUNCTION

This was the only little thing I learned today, as this was mainly a 'practice-type' lesson.



WHAT I WILL BE DOING TOMORROW / NEXT TIME:


Next time I will move onto a completely new unit. It is titled loops, and as it is a new unit I can't say much, so I will just show the description.

LOOPS UNIT




No comments:

Post a Comment

Adobe Photoshop - Day 10 (June Final Post)

WHAT I DID TODAY / WHAT I LEARNED: For my final project, I thought for a while about what I could do. Then I remembered a while back I saw ...