Thursday, December 31, 2015

Intro: Easygui

Easygui (GUI stands for "graphical user interface") is a module that comes with Python and allows you to create programs with graphics instead of silly command prompts. It seems to me that more people who program with python prefer silly command prompts instead, but I don't. Remember that Mad Libs game that I talked about? That used Easygui. All you need to do to have Easygui in your program is to type in import easygui at the beginning of your program.


Program: New-Year countdown.

Since it's really close to the end of the year, I decided to program a new year countdown. It uses the keyword raw_input a lot. I will explain that in a diffrant post.

raw_input("count-down to new year in...")
raw_input("10")
raw_input("9")
raw_input("8")
raw_input("7")
raw_input("6")
raw_input("5")
raw_input("4")
raw_input("3")
raw_input("2")
raw_input("1")
print "Happy New-Year!"



Program: Python in big letters

This program isn't a word game. All it is is a command prompt that shows "PYTHON" in big letters made out of stars 

print           "           ***********                                                                                     "
print           "           *          *                                                                                    "
print           "           *          *  *        *                                                                        "
print           "           ***********    *     *   ****************   *       *                                           " 
print           "           *               *   *          *            *       *                                           "
print           "           *                 *            *            *       *         *********       **         *      "
print           "           *                 *            *            *       *        *         *      *  *       *      " 
print           "           *                 *            *            *********       *           *     *    *     *      "
print           "           *                 *            *            *       *      *             *    *      *   *      "
print           "           *                 *            *            *       *      *             *    *       *  *      " 
print           "           *                 *            *            *       *      *             *    *        * *      "
print           "           *                 *            *            *       *      *             *    *         **      " 
print           "           *                 *            *            *       *       *           *     *          *      "    
print           "                                                                        **********       *          *      "




Keyword: Print

If you learn Python, the first keyword (a keyword is a piece of code you use in programming)
you will ever learn is print. It is the simplest one too. All it means is display text on the screen, not printing words on a piece of paper. If you type in >>> print "Hello World!" in interactive mode (Interactive mode in python is like a python command prompt that allows you to tell it what to do. not actual programming) it will say Hello World! (by the way, it's a tradition in Python and other languages that the first thing you make the computer do is  >>> print "Hello World!". don't ask me why). you can also do something like this: >>> print 45 + 69
and it will say: 114. Don't be surprised, computers are good at math. 


Program: Mad-Libs word game

The first things I'm programming on my own are Mad Libs  word games. They are fun to program and funny to play. I'll give out the code:

import easygui
easygui.msgbox("Hi, let's have a game of Mad Libs!")
word_1 = easygui.enterbox("Give me an adjective")
word_2 = easygui.enterbox("Give me a number - from 1 to 1000")
word_3 = easygui.enterbox("Give me a verb(ending in 'ing')or a noun(ending in 'es')")
word_4 = easygui.enterbox("Give me a number - from 1 to 1000")
word_5 = easygui.enterbox("Give me a verb(ending in 'ed')")
word_6 = easygui.enterbox("Give me a noun")
word_7 = easygui.enterbox("Give me another noun") 
word_8 = easygui.enterbox("Give me a verb(ending in 'ing')")
word_9 = easygui.enterbox("Give me a noun")
word_10 = easygui.enterbox("Give me an adverb")
easygui.msgbox("I went to tell my " + word_1)
easygui.msgbox("freinds that I just bought " + word_2)
easygui.msgbox("kite(s)! and asked them to fly them with me but the had to do their " + word_3)
easygui.msgbox("first, but said they could do it in " + word_4)
easygui.msgbox("hours, so I " + word_5)
easygui.msgbox("while I waited")
easygui.msgbox("then when they were ready we went to a " + word_6)
easygui.msgbox("to fly them, but when we were flying them one of the kites slipped out of one of the freind's hands and fell on top of a " + word_7)
easygui.msgbox("so I went to tell my dad who was " + word_8)
easygui.msgbox("and then he came out with a " + word_9)
easygui.msgbox("to get the kite so we could all enjoy flying them " + word_10)

The spacing might look messed up but I tested it and it works anyway.
I'll explain what the code mans in a few other posts I make.









Introduction

This is the introduction to this blog. I'm still learning Python programming but I've made a few programs including easy GUI word games I made on my own. And I'll make more and post them on here. Remember, it's okay to copy and paste my programs to your computer to try them out but just don't put them on your blogs and say things like "I made this program myself.".
I'll also teach about certain keywords and give out tips.