Posts

Hangman Part 2

Hangman Part 2 In coding there is strings and lists, strings are only one and lists are groups of strings. Like strings lists can be added together, but a string and a list cannot be added together. There was a new function I learned which was called the in function which tells you if there is a certain string in the list. It can also be used to check if one string exists in the other. Another function I have learned is the delete function which deletes a string from a list according to its index value. You can join a couple of lists together by using a list of lists function. There is a lower () function and the upper () function. The lower function calls all the characters of the string to lower case. The upper function calls all the characters of the string to an upper case.

Hangman Game

Hangman Game Part 1 Last week I was doing the flowchart of the game hangman, now I am going to write the code for it. I will do this using the book I use called invent with python.           I am using ASCII drawing to do the hangman drawings that will change when the user guesses the word incorrect. To do so I need to use multi-line strings which uses three quotes. Constant variables are variables that do not change from the first assignment number. A list value can contain several values inside of it, it uses a square bracket and is separated in commas. We can index the lists by using number.

Hangman flowcharts

Image
          In this new chapter it teaches me about flowcharts which is a diagram that explains the algorithm of the program. In this chapter it uses the flowchart hangman code and taking you how to do the flowchart step-by-step.            In the flowchart you start with coming up with the word bank to choose from which the computer uses the random.randint function to choose from your word bank. It asks the player to guess a letter from the secret word, that is from the word bank. After asking the player for the letter it goes under two options: it is in the secret word or it is not. If it is in the secret word it branches another arrow that would be has guessed all and wins, vice versa if he did not guess it correctly. The flowchart is recommended for advanced programs such as visual games.

Debugging

Image
In this week, I started a new chapter called debugging which teaches you how to debug with python. Debugging is checking through each line of code to see for bugs and then remove the bugs (in other words ‘errors’).   In python there is a debugger to do the debugging for you, and in this debugger you can step through the lines of code using the step tool. The chapter also talks about debugging local area and global area. local area means the functions in your program, and global means the code outside the functions. I later knew that programming is not only writing lines of code, you must debug the lines. Programming is just like literature, first you write then, you review for mistakes. Here is a video to teach you about debugging in python:

Dragon Realm Part 1 & 2

Image
Recently in my twenty percent project, I have reached chapter six in invent with python. This chapter talks about the first game. Part 1 talks about the basis of the code and how complex it is to make and you must learn several things, to remind you of what you use and when you use it. In this circumstances the def block is one of the important ones, where you learn about the global scope and the local scope. In part 2, essential piece of information is that you can put code inside the parentheses, this is called a parameter. By using the parameters, we can use it to call old functions. In the recent project, we were creating our own functions and calling them by parentheses, by making your own functions coding is easier and more simple.  The Code I used: import random import time def displayIntro():     print('You are in a land full of dragons. In front of you,')     print('you see two caves. In one cave, the dragon is friendly')     print('and will

Chapter 5 - Jokes

Image
In my 20 percent project, I am learning the python language, ( http://adf.ly/1Z4ZDi ) which I am using a book called 'invent with python' to help me in learning the language ( http://adf.ly/1Z4ZFm ). I have recently finished chapter 5 which talks about how to use escape characters, single and double quotes, end function in the print function. To teach you these functions the book uses a game called jokes the source code is found on this site ( http://adf.ly/1Z4ZHB ).