Louie will help you learn what a computer program is. You can read a Louie tutorial .
Here are some sample programs.
The program asks for the user's name, then displays it with the word Hello in front of it.
name = input(What is your name?)
Shows the text 'What is your name?' and waits for input. Whatever the user types is put in the variable name.
output(Hello, #name.)
Outputs the text 'Hello, ' and then the contents of the variable name.
This program computes the area of a circle. The user enters the circle's radius, and the program outputs the area.
output(This program computes the area of a circle.)
Explains what the program does.
radius = prompt(Radius?)
Outputs the text 'Radius?' and waits for the user to type something. Whatever the user types is put in the variable radius.
area = 3.14159 * radius * radius
Computes the area of the circle, using the radius the user entered. The result goes into the variable area. * means multiply.
output(Area: #area)
Outputs the area. #area is replaced with the contents of the variable area.
The program computes the total price for a product, including applicable sales tax.
taxRate = 0.06
Store the sales tax rate in the variable taxRate. Change it to the tax rate in your region.
name = input(Product name?)
Ask the user for the name of the product. The name the user types is stored in the variable name.
price = input(Product price?)
Ask the user for the price of the product. The number the user types is stored in the variable price.
taxable = input(Is #name taxable (y/n)?)
Ask the user whether the product is taxable. When the computer asks the user the question, #name is replaced by the name of the product, entered earlier. Whatever the user types is stored in the variable taxable.
if taxable = y then
Tests whether the product is taxable. If it is, then we want to add sales tax to it. If the product is not taxable, then we don't want to add sales tax.
taxable = y means that the test will be true if the variable taxable contains a y.
total = price + price*taxRate
This line is executed if the product is taxable. It computes the total price with tax. It stores the result in total.
This line is executed if the product is not taxable. It puts the value of the variable price into the variable total, without changing the value. This means that the variable total has the right value for the output statement (coming next), no matter whether the product is taxable or not.output(Total for #name: #total)
Shows the result to the user. The value of the variable name is substituted for #name. The value of the variable total is substituted for #total. taxRate
sample
in the variable name.
To start writing your own programs, click the Statements tab. Drag statements into the program area. Then fill in the slots in each statement.
Use the import and export tabs to load and save programs. You'll get encoded versions of programs you can cut and paste.
Here are the statements you have trashed. Drag them back into the program to restore them.
To import a program, paste its coded version here, and click the Import button.
Click the Encode button to show a coded version of your program. You can copy it onto the clipboard, and then save it into a file. Paste the coded version into the import area to restore the program.
Louie was designed to help nontechnical students learn what a computer program is.
Louie is part of MIS-Book.Com. MIS-Book.Com is a textbook for an introductory management information systems (MIS) course.
Louie is copyright, 2009, by Kieran Mathieson. You may use it freely for noncommercial purposes.
If you find any bugs or have ideas for improvements, please let Kieran know at kieran@mis-book.com.
Computer jokes are also appreciated. For example:
Why did the programmer die in the shower?
The instructions on the shampoo said: Lather, rinse, repeat.