Computer Science Department |
CSCI 135 |
In the shell window, you can type Python commands and see the result immediately. Try typing in: print("Hello World!") and then press the Enter key.
Remember, this is a programming language, so you have to be very precise in what you type - Python will not understand typos.
You can also try typing in some math equations and use the shell as a calculator. Try typing in 3+4 and 3+4*3 and (3+4)*3, pressing the Enter key after each.
The >>> symbol in the shell where you type your commands is called the prompt. It's just a symbol that lets you know you can type in instructions at that point.
1) Select File -> New File from the top menu in the shell. This brings up an editor window where you can write your own programs and save them.
Your program will be a list of Python statements that you will save and then run, or execute.
Here you can type in the statements that make your program run as you want it to.
2) You can now start adding code to your file.
In the screenshot below, note how I've added the required header comments at the top.
We require headers on every source file you submit in the course so you want to get in the habit of doing this. You will be docked points if you don't.
You'd be surprised how quickly in real-world programming you forget what a program you wrote does.
Providing a good descriptive header is a good habit.
It also helps us keep track of who turned in what when we grade your labs.
3)
Before you can actually compile and run your program, you will have to save it. Select File -> Save from the top menu.
You will need to tell Python where to save your work.
We strongly recommend a flash drive or cloud drive because it is not guaranteed that your program will stay on the computer you're using next time you're in lab, and you may not be able to retrieve your work.
Save this particular program with the name HelloNewWorld.py. We will tell you what you should name your program files, and as programs get more complex, this will become more important. Pay attention to how the program name is capitalized.
Once you've saved your file, you can compile and run it.
Select Run -> Run Module from the top menu, or alternatively, press the F5 key (top row of the keyboard).
Your program will be compiled and will then run in the Python shell window.
Grade Item | HelloNewWorld | Greetings | Points Earned |
---|---|---|---|
Program Compiles and Runs | 2 | 2 | Header Comment | 2 | 2 |
Program Runs Correctly | 4 | 4 | |
Correctly Formatted Output | 2 | 2 | |
Page last updated: August 31, 2021