CIS122-Introduction to Programming
Programming in Jython - using JES
Installing JES on your computer - Download from here
4th Edition Media Sources (free images and sounds, as used in the book): -Zip file containing resources
- Program – A larger file of code that may contain one or more functions.
- Comments – These are notes, just like in HTML, that are ignored by the computer. In Python, comments start with a hash mark (#) and end at the end of the line.
- Variable – Just like in algebra, these are names (in Python, often relevant words) that you can assign values to, allowing you to reuse them later on.
- Operators – Mathematical symbols, like +, -, *, and /, but also ** (“to the power of”, for exponents).
- Keyword – Words that have already been giving some meaning/purpose in Python. Examples include “and”, “print”, and “if”.
- Function – A chunk of code that performs an action. Functions are given names and are reusable. There are two kinds of functions: built-in ones, and “user-defined” ones (functions that you create).
- Expression – Statements that produce values. Examples include 3 + 5, "Hello world!", and (a variable called) name.
- Error – When your program has a problem, the command area will provide an error message that attempts to tell you where the error is. JES will often also highlight the problem line in yellow.
Writing a program involves combining a bunch of the techniques explained below, depending on your goal for the program. At minimum, your program file should contain a header with some basic information, and the description of your program. Headers are written using comments, and should include information like the file name, author, and a description of what the program does. It can have other information as well. A good example of a header:
# file name: tri.py
# author: John Doe (firstname.lastname@example.org)
# description: a program to calculate the area of a right triangle