st1 Week 02 Tut Lab New Updated
st1 Week 02 Tut Lab New Updated
TUTORIAL ACTIVITIES: All tutorial questions assume Python version 3.0 and above
seven = 7
2.
precise = 1.09388641
3.
Define two variables, one named length making it refer to 3.5 and the other
named width making it refer to 1.55.
length = 3.5
width = 1.55
4.
Given two variables person1Age and person2Age, write a statement that makes the
associated value of person1Age, 4 more than that of person2Age.
person1Age = person2Age + 4
5.
6.
7.
8.
9.
Write an expression that computes the remainder of the variable principal when divided
by the variable divisor. (Assume that each is associated with an int.)
remainder = principal % divisor
10.
Write an expression that computes the average of the values 12 and 40, and assign it to the
variable avg.
avg = (12+40)/2 = 52/2 = 27
11.
Write an expression that computes the average of the variables exam1 and exam2 and
assigns it to another variable examAverage
12.
The dimensions (width and length) of room1 have been read into two
variables: width1 and length1. The dimensions of room2 have been read into two other
variables: width2 and length2. Write a single expression whose value is the total area of
the two rooms as assign it to a variable roomArea.
13.
bridge_players+=4
bridge_players = bridge_players+4
14.
Given a variable profits, write a statement that increases its value by a factor of 10.
profits *= 10
profite = profits*10
15.
Write a statement that increments total by the value associated with amount. That is, add
the value associated with amount to that associated with total and assign the result
to total.
total += amount
total = total+amount
1. Programming Problem 1:
===Welcome Program===
Welcome to Python
Welcome to Computer Science
Programming is fun
Write a program(both Console and GUI) that displays the result of an arithmetic expression (9.5 *
4.5 - 2.5 * 3) / (45.5 - 3.5).
Assuming the formula for computing the discriminant of a quadratic equation ax^2 + bx + c = 0
is b^2 – 4ac.
Write a program (Both Console and GUI) that computes the discriminant for the equation 3x^2 + 4x +
5 = 0.
Average acceleration in Physics is defined as the change of velocity divided by the time taken to
make the change, as shown in the following formula:
a = (v1 - v0) / t
Here, v0 is the starting velocity in meters/second, v1 is the ending velocity in meters/second, and t is
the time span in seconds.
Assume v0 is 5.6 meters/second, v1 is 10.5 meters/second, and t is 0.5 second, and write the code
for both Console and GUI program to display the average acceleration.
All Activities need to be submitted as the lab journal on Week 7 Friday 11.55 pm, and contributes
to Assignment 1 mark due in Week 7)
1. Challenge Problem 1:
(Population projection)
Write a program (Both Console and GUI program) to display the population for each of the next five
years. Use the current Australian population and that one year has 365 days.