Python Coding Example Random | II

preview_player
Показать описание

This is the third video explaining a python coding example that takes the task of writing a game of battleships and breaks the problem into simple tasks to complete the goal. This python example uses random to create the ships.
#python #coding #programming

Fun and Games python series

If you want to learn to code, these Python tutorials are for you. Hi, my name is Dr Codie and I am the python coder. Codie means ‘helpful person’ and we want to help you not just learn python but to enjoy learning python.

In my experience, success with coding comes down to getting the fundamentals right. You can then move onto advanced programming concepts and skills. You will understand how to do simple coding tasks and then we will show you the simple methods of putting lines or blocks of code together using this knowledge. Practice is essential for your skills to grow but again do not fear we will help you practice as well.
Learn to understand the logic and design aspects needed to become a good programmer, let us help you practice to keep improving and don’t forget the bonus of seeing first hand how to build the code and possible stumbling blocks when we explain the answers to the tasks set within the tutorial. You do not need to watch the whole video but if you do you will improve as a python coder!
SUBSCRIBE and you will know when the videos are available! Good luck!
Рекомендации по теме
Комментарии
Автор

There is a mistake in the video. To find a number ending with a 9 we use the code below. sorry for this error, it was only seen after the video was published.The correct code should read:
elif boat[i] % 10 == 9 and i < len(boat)-1:
if boat[i+1] % 10 == 0:
boat = [-1]
break

DrCodie
Автор

Hello Dr. Codie, I am a big fan of your videos, I want to programm the battleships game for myself, but I think I missed something important in your videos, because the game won`t start. Could you please upload the code of the game to github or something else, so I can find my misstake. Sorry I am new in Python programming.

raccoon
Автор

This continues from the two python coding example videos that made a battleship game. A viewer asked about how the game could be played and we replied it needs improvements . Therefore this is the first upgrade that uses random to create the ships. Please add a comment if you have any preference to other improvements.

DrCodie
Автор

The boat = check_ok(boat) code could be written just once at the end of the function before the boat is returned - this would be faster and better code.

DrCodie
Автор

Excellent video. I have written a sb3 game with full visual n audio, what is the best approach to convert it into equivalent python 3.8 file? Thx.

caseyyeow
Автор

Can you post a link with your code? To reference

matthewaranzamendez
Автор

it confused me when you said if number ends with nine then modulus operator returns 0. but this is only in case number is divisible by 9. in other cases, say 19 % 9 will return 1, 29 % 9 will return 2 ... 99 % 9 will return 0. don't understand how this code still generats correct ships...

tanercoder