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

Laboratory 3


Laboratory 3: Expressions

LAST NAME, FIRST NAME

R00000000

ENGR 1330 Laboratory 3 - In-Lab

In [3]:
# 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, Jun  2 2021, 10:49:15) 
[GCC 9.4.0]
sys.version_info(major=3, minor=8, micro=10, releaselevel='final', serial=0)

Example 1: Calculate the sum of two numbers

Given two integer numbers return their sum.

In [3]:
number1 = 11
number2 = 12
result = number1+number2
print(result)
23

Example 2: Calculate the product of two numbers

Given two integer numbers return their product.

In [ ]:
number1 = 11
number2 = 12
result = number1*number2
print(result)

Exercise 1: Given two integer numbers return their product only if the product is greater than 1000, else return their sum.

  • Apply the principles of problem solving in the lesson (the yield stress example).
  • Using the same approach link the two examples above to complete the exercise
  • Use the following inputs
  • Case 1: number1 = 20 and number2 = 30
  • Case 2: number1 = 40 and number2 = 30
In [4]:
# put your Case 1 code here
In [5]:
# put your Case 2 code here

Exercise 2: Write a program to check if the given number is a palindrome number. A palindrome number is a number that is same after reverse. For example 545, is a palindrome number.

In [ ]:
# put your Case 1 code here
In [ ]:
# put your Case 2 code here

Readings

Here are some great reads on this topic:

Here are some great videos on these topics: