Showing posts with label While loop. Show all posts
Showing posts with label While loop. Show all posts
Tuesday, August 4, 2015
Importing Module
This simple program imports the module created earlier. This program utilizes the class and functions in the module.
Tuesday, May 5, 2015
Monday, March 30, 2015
Saturday, March 28, 2015
Functions with Return
Simple program below demonstrates functions that are created to return values back to main program. The while loop is utilized to ask a question until an appropriate response is given.
Friday, February 13, 2015
Character Creator Program
The following program is a simple character creator found in many RPG games. The user can assign point values to attributes from a pool of points. The user can also subtract values from attributes and put those points back in a pool.
Hangman Game
Saturday, January 17, 2015
Reversing a String
The simple program below demonstrates reversing a user inputted string.
Basic outline:
Basic outline:
- User inputs a string
- An empty reverse string variable is created
- A while loop is utilized to create the reverse string by starting at the end of the user inputted string, using indexing.
- The reverse message is printed.
Tuesday, January 13, 2015
Word Jumble Game (Creating a new string from a given string)
The following program demonstrates the creation of a new string from a given string that is randomly selected from a Tuple. This program creates a "jumbled" version of the word and then asks the player to guess the word. See program below.
Labels:
If,
if statement,
new string,
not equal,
random,
strings,
tuples,
while,
While loop
Thursday, January 1, 2015
Using the not Logical Operator and Compound Conditions
In the program below, username is initialized as an empty
string so it starts out as False, making not username True. The not username is
True as long the string is empty. This forces the username to enter a username,
or the loop will continue to ask for username until something is entered. Once
an input is entered for username the not username is False and the loop stops,
moving the program forward to password, which is set up in a similar manner. The table below summarizes the logic:
|
Username
|
not username
|
|
True
|
False
|
|
False
|
True
|
The program also demonstrates the use of and / or compound conditions. See examples below.
Tuesday, September 23, 2014
Subscribe to:
Posts (Atom)