0% found this document useful (0 votes)
16 views6 pages

st1 Week 02 Tut Lab New Updated

The document outlines tutorial and computer lab activities for a Python programming course, including variable assignments, expressions, and programming problems. It provides specific tasks such as defining variables, computing averages, and writing programs for various scenarios. Additionally, it mentions assessment activities and submission deadlines for lab journals.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views6 pages

st1 Week 02 Tut Lab New Updated

The document outlines tutorial and computer lab activities for a Python programming course, including variable assignments, expressions, and programming problems. It provides specific tasks such as defining variables, computing averages, and writing programs for various scenarios. Additionally, it mentions assessment activities and submission deadlines for lab journals.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Week 02 Tutorial / Computer Lab

 TUTORIAL ACTIVITIES: All tutorial questions assume Python version 3.0 and above

1. Assign 7 to a variable named seven.

seven = 7

2.

Define a variable precise and make it refer to 1.09388641.

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.

Given the variables taxablePurchases and taxFreePurchases, write an expression


corresponding to the total amount purchased. (total amount purchased is sum of taxable and
tax free purchases). Assign the total to totalPurchases variable
taxablePurchases = 1000.0
taxFreePurchases = 1500.0
totalPurchases = taxablePurchases + taxFreePurchases
print(to

6.

Given the variables full_admission_price and discount_amount, write an


expression corresponding to the price of a discount admission. (discount admission is
defined as discount amount subtracted from full admission price). (Not the variables are not
in camel case notation). Python programmers use PEP coding style
Discount_admission = full_admission_price - discount_amount

7.

Given the variable pricePerCase, write an expression corresponding to the price of a


dozen cases, and assign it to price_dozen_cases

price_dozen_cases = pricePerCase *12

8.

Given the variables cost_of_bus_rental and max_bus_riders, write an expression


corresponding to the cost per rider (assuming the bus is full).

cost_per_rider = cost_of_bus_rental // max_bus_riders

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

examAverage = (exam1+ exam2)/2

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.

roomArea = (width1*length1) + (width2*length2)

13.

Given a variable bridge_players, write a statement that increases its value by 4.

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

 COMPUTER LABORATORY ACTIVITIES

All the programming activities can be done either using

 PyCharm IDE (https://www.jetbrains.com/pycharm/)


or
 Google Colaboratory Environment (colab.research.google.com )
or
 REPLIT Environment (https://replit.com/ )

1. Programming Problem 1:

(Display three different messages)

Write a program (both Console and GUI program) that displays

===Welcome Program===
Welcome to Python
Welcome to Computer Science
Programming is fun

Solution to Programming Problem 1(Console Program):

Solution to Programming Problem 1 (GUI program:

Programming Problem 2 (Compute expressions)

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).

Solution to Programming Problem 2 (Console):

Solution to Programming Problem 2 (GUI):


2. Programming Problem 3(Solver):

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.

Solution to Programming Problem 3 (Console):

Solution to Programming Problem 3 (GUI):

3. Programming Problem 4 (Acceleration Program):

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.

Solution to Programming Problem 4(Console):

Solution to Programming Problem 4(GUI):

Assessment 1 (Assignment 1 Activity): Continual assessment /Weekly quizzes and learning


activities

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)

The ABS projections on population is based on the following assumptions:

One birth every 7 seconds

One death every 13 seconds


One new immigrant every 45 seconds

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.

Solution to Challenge Problem 1(Console Program)

Solution to Challenge Problem 1(GUI Program)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy