Prelim Lab Exercise 01 It Elec02 - Ite Elective 02 (Vb2010)
Prelim Lab Exercise 01 It Elec02 - Ite Elective 02 (Vb2010)
Prelim Lab Exercise 01 It Elec02 - Ite Elective 02 (Vb2010)
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: "))
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:
True
Test case 2:
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:
True
Test Case 4:
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.
Expected Output:
Input the base : 7
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
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
The sum is 12
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
The sum is 9
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!