Prelim Lab Exercise 01 It Elec02 - Ite Elective 02 (Vb2010)

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

COLEGIO DE DAGUPAN

Arellano St., Dagupan City


PRELIM LAB EXERCISE 01
IT ELEC02 - ITE ELECTIVE 02 (VB2010) SET 01

LAB EXERCISE: SELECTION STRUCTURES

1. Install the Python interpreter located at D or E:\ SITE Installer\python-3.4.4.amd64.msi.exe

2. After installation, run the Python IDLE (Python 3.4 GUI) usually located at the Start Menu

3. In the Python shell, we will use the Script Mode Programming. Click File->New File and code the
following:

Problem: Write a Python program which will return true if the two entered integer values
are equal or their sum or difference is 5.
x=int(input("Enter first integer number: "))

y=int(input("Enter second integer number: "))

if x == y or abs(x-y) == 5 or (x+y) == 5:

print("True")

else:

print("False")

4. Save the file by pressing Ctrl+S, then use the filename sample1.py

5. Run the program. Click Run->Run Module or simple press F5. The output is presented below with
different test cases.

Test case 1:

Enter first integer number: 2

Enter second integer number: 2

True

Test case 2:

Enter first integer number: 10

Enter second integer number: 5

1 | Page
Education is a key to success!
COLEGIO DE DAGUPAN
Arellano St., Dagupan City
PRELIM LAB EXERCISE 01
IT ELEC02 - ITE ELECTIVE 02 (VB2010) SET 01

True

Test case 3:

Enter first integer number: 2

Enter second integer number: 3

True

Test Case 4:

Enter first integer number: 25

Enter second integer number: 5

False

Name : ____________________________
Course, Year and Block : ____________________________
Subject Code : ____________________________
Date : ____________________________
Name of Instructor : ____________________________

Problem 1
Write a Python program that will accept the base and height of a triangle and compute the area.

A triangle is a polygon with three edges and three vertices. It is one of the basic shapes in
geometry. A triangle with vertices A, B, and C is denoted triangle ABC.

Vertex of a triangle : The point at which two sides of a triangle meet.


Altitude of a triangle : The perpendicular segment from a vertex of a triangle to the line
containing the opposite side.
Base of a triangle : The side of a triangle to which an altitude is drawn.
Height of a triangle : The length of an altitude.

Expected Output:
Input the base : 7

Input the height : 5

2 | Page
Education is a key to success!
COLEGIO DE DAGUPAN
Arellano St., Dagupan City
PRELIM LAB EXERCISE 01
IT ELEC02 - ITE ELECTIVE 02 (VB2010) SET 01

area = 17.5

Write your solution in problem 1 below:

Problem 2
Write a Python program to compute the sum of three entered integers. However, if two
values are equal sum will be zero.

Expected output:
Input first integer : 5

Input second integer: 4

Input third integer: 3

The sum is 12

Write your solution in problem 2 below:

3 | Page
Education is a key to success!
COLEGIO DE DAGUPAN
Arellano St., Dagupan City
PRELIM LAB EXERCISE 01
IT ELEC02 - ITE ELECTIVE 02 (VB2010) SET 01

Problem 3
Write a Python program to compute the sum of two entered integers. However if the sum is between 15 to 20 it will
return 20. Use the range() function to solve this problem.

Expected output:
Input first integer : 5

Input second integer: 4

The sum is 9

Write your solution in problem 3 below:

4 | Page
Education is a key to success!
COLEGIO DE DAGUPAN
Arellano St., Dagupan City
PRELIM LAB EXERCISE 01
IT ELEC02 - ITE ELECTIVE 02 (VB2010) SET 01

Scoring Rules:
100% If the problem is solved within 70 minutes.
70% If the problem is solved between 71-80 minutes.
50% If the problem is solved between 81-120 minutes.
30% If the problem is solved past 121 minutes but with runtime errors or bugs.
0 zero for non running program.

5 | Page
Education is a key to success!

You might also like