1117BT1
1117BT1
Tutorial objectives:
• To take note of the tutorial arrangement for the course.
• To understand different ways to run a Python program.
• To practice the use variables and operators in Python.
• To try to use VPL in Moodle.
• To practice Python Basics.
• Deadline: 23:59 Feb 17, 2025
1. Tutorial arrangement
- Tutorial on every Tuesday 12:30pm – 1:20pm. Completion of tutorial exercises count
towards the assessment for the tutorials.
- You are encouraged to ask questions on the forum on Moodle if you need help.
- No attendance will be counted for the tutorials.
- If you have difficulties in finishing the tutorial exercises, you should attend the tutorial to get
some ideas.
- You are required to save your program and press the “Evaluate” button of the tutorial
exercises on time.
- You can evaluate as many times as you want for each exercise before the deadline but
only the last evaluated marks would be counted.
- Late work is NOT accepted.
2. Introducing IDLE
- There are many ways to run a Python program. One easiest way is to install Python on your
machine. (Download URL: https://www.python.org/downloads/ ) Instruction for different OS
can be found in https://docs.python.org/3/using/index.html .
- In this course we will be using Python 3.8.10.
- While we will be mostly using VPL on Moodle in this course, you are encouraged to install
Python on your own machine to run your own programs.
3. Interactive mode
- In IDLE, we can run simple code in the interactive console called “Python Shell”.
- Interactive mode is very useful to test-run Python code quickly.
- To complete this exercise, type print("Hello World")in the Python Shell in IDLE, you
should see the message printed when you press ENTER.
4. Script mode
- While interactive mode is convenient, we should always write our program in a file
(filename ending with .py) so that we can save it and run it when needed.
- In IDLE, you can start an editor by choosing File → New File (or File → Open… to open
an existing file).
- We can then write our program in the editor and save it in a file to run in script mode.
- To complete this exercise, type the following code in the editor:
# Exercise 1.2
print("lololo")
print("ololol")
print("lololo")
- Save it in a file (filename ending with .py), then select Run → Run Module or simply press
F5 to run it.
- Check if you get the correct pattern printed.
5. VPL on Moodle
- VPL on Moodle is a platform that can be used to automatically evaluate your code
and feedback immediately.
- In the Moodle page, there will be one VPL activity setup for each question in the tutorial.
- To write a program in VPL, first enter the VPL activity and start writing your code.
- To complete this exercise, enter the activity “Exercise 1.1 Hello World” on Moodle, then
click on “Edit”.
- In the editor of VPL, type in the same program as in part 3 above. Click the Save
- Once you think you have well completed the task, use the Evaluate button to
evaluate it. Revise your code if it does not pass the evaluation.
- Now, try to finish Exercise 1.2 in VPL.
Sample Input Expected Output
Hello World
- In the worksheet, we try to add tips and hints from time to time, so it is very important to
read the worksheet!
- To complete the task, we set two variables to keep the base and height of a triangle:
# Exercise 1.3
base = 10
height = 4
- Try your best to give a meaningful name to the variables. Don’t be lazy! For example, this is
not acceptable:
# DON’T DO THIS!!!
a = 10
b = 4
- Or you can calculate the area and print immediately without storing it:
- Both methods are fine. The first one is easier to read especially with the variable name.
The second one is also clear especially if we add comments to explain it.