Concordia University Programming Worksheet

1 Read the following problem carefully and make sure you understand it. Don’t startwriting pseudo code. Understand the problem first.
Write a Python program that reads in the following information in the given order.
a) The number of credits of classes taken by a student.
b) The tuition rate in dollars per credit. This could have fractions in it.
The program then prints the information it read in and the total tuition; the latter is
obtained by multiplying the number of credits and the tuition rate.
2 Demonstrate your understanding of the problem by writing two sets of input data and the
corresponding output. Use simple, but non-trivial, numbers, so you can easily compute
the expected output.
Set 1: Sample Input: Number of credits =.
Expected Output: Total tuition =
Tuition Rate =.
Set 2: Sample Input: Number of credits =.
Expected Output: Total tuition =
Tuition Rate =.
3 Before starting this step, ensure you have completed Step 2.
4 Write pseudo code for solving the problem using the Input-Processing-Output
approach. Proceed as follows.
a) What is the program input? In other words, what should the program read in?
Remember we are not talking about specific numbers, but the kinds of data to be read
in. If you have been able to complete Step 2, you should know it.
b) Input: For each of the inputs, write pseudo code in the following form.
Read into
c) Processing: From the examples, you know what the program should output. Some of
the information requires no computation and one requires some computing. For the
one that requires computation, what processing should be carried out? You can write
this in the following form.
Set =
d) Output: Write pseudo code for printing the data.
Print , , …
5 If you wish, you can collect the steps of the pseudo code into one chunk, and write it
below.
6
7
Start Python.
At the >>> prompt, type the following statement and then press the Enter key.
print(“This is a test of the Python interpreter”)
8
After pressing the Enter key, the interpreter will execute the statement. If you typed everything
correctly, your session should like the following.
>>> print(“This is a test of the Python interpreter”)
This is a test of the Python interpreter
>>>
9 If you see an error message, enter the statement again and make sure you type exactly as shown.
10 Exit the interpreter by pressing Ctrl+Z followed by Enter on Windows. On other systems, enter
Ctrl+D.
11 Start Python.
12 Select the File menu and within it, the New File menu item.
13 You should see a new window with “Untitled” on the title bar.
14 For each statement in the pseudo code, type the equivalent Python statement into the
window. This can be done through relatively simple translation steps examples of which
are given below.
Pseudo code
Python code
Input an integer into x
Input a number with a decimal point into x
x = int(input(‘Enter an integer: ‘))
Set x to a + b
Set x to a * b
Print a, b, c
x = a + b
x = float(input(‘Enter a number with
a decimal point: ‘))
x = a * b
print(a, b, c)
15 Remember that Python is case sensitive. Most stuff in the core language is in the lower
case. Also, make sure that parentheses match. Each Python statement should be put in a
separate line. Periodically save the file. Use a meaningful name like labe2.py for the file.
The extension will be added by the Python editor itself, so just type lab2 for the file
name.
16 After typing in the Python equivalent for all the pseudo code statements, save the file.
17 Execute the program by pressing function key F5.
18 Make sure the program runs. If it does, you should see prompts for the number of credits
and the tuition rate. For these, enter the data you created in Step 2. Check that the output
matches your expectations.
19 Once you are convinced that the program is working:
a) Zip this completed document and the Python program.
b) Make sure that the file above is in the zip format, not rar or some other compressed
format.
c) Upload the zip file to the dropbox before the deadline.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper
Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER