Download (right-click, save target as ...) this page as a jupyterlab notebook from:

Laboratory 3 - TH


Exercise Set 3: Expressions and Problem Solving

LAST NAME, FIRST NAME

R00000000

ENGR 1330 ES-3 - Homework

In [2]:
# Preamble script block to identify host, user, and kernel
import sys
! hostname
! whoami
print(sys.executable)
print(sys.version)
print(sys.version_info)
atomickitty
sensei
/opt/jupyterhub/bin/python3
3.8.10 (default, Nov 26 2021, 20:14:08) 
[GCC 9.3.0]
sys.version_info(major=3, minor=8, micro=10, releaselevel='final', serial=0)

Exercise 1: Odd/Even

Depending on whether the number is even or odd, print out an appropriate message to the user.

Use the following cases to test your script:

  • Case 1: number=33
  • Case 2: number=44

Bonus(Optional):

  • If the number is a multiple of 4, print out a different message.
  • Supply two numbers: one number to check (call it num) and one number to divide by (check). If check divides evenly into num, tell that to the user. If not, print a different appropriate message.
In [3]:
# put your Case 1 code here
In [4]:
# put your Case 2 code here

Exercise 2: Number Manipulation

Create a script that accepts an integer (n) as input and computes the value of n+nn+nnn. For example for an input value of n = 5 the required result is 615

Use the following cases to test your script:

  • Case 1: n=1
  • Case 2: n=6

Bonus(Optional):

  • Modify the script to accept multi-digit values, and test with n=33
In [ ]:
# put your Case 1 code here
In [1]:
# put your Case 2 code here