CPE0007L
MODULE 2
EXERCISE
2
INTRODUCTION TO PYTHON PROGRAMMING
STUDENTNAME:Daniel Rudiger P. Joseph
STUDENT NUMBER:202210991
DATE: 14/09/2024
SIGNATURE:
I. OBJECTIVES
At the end of this exercise, students must be able to:
• Understand the python program structure
• Discuss literals, variables and data types
II. BACKGROUND INFORMATION
Simple Python program structure
>>>print (“Hello, World”)
Hello, World
• print () function, allows you to display Strings, numbers and characters. • String
argument “Hello, World” should be enclosed in either double or single quotes
• To create a python file using the .py file extension, and run it in the Command line.
Example: C:\Users>python myprogram.py
III. LABORATORY ACTIVITY
Directions: Write the Python program to display the required output
Write the code here.. Required output
A = “Welcome to Python programming” Welcome to Python programming
print (A)
a = "\nWelcome to Python programming" Welcometo Python
b = "Thank you!" programming Welcome to
Python programming Welcome
print (3 * a)
to Python programming Thank
print (2 * b) you!
Directions: Determine the output of the following program code.
a = “Juan” Juan
print(a) Juan
#double quotes are similar to single
quotes a = ‘Juan’
print(a)
var1, var2, var3 =” Apple”,” Banana”, Apple
“Avocado” Banana
print(var1) Avocadpo
print(var2)
print(var3) Apple
a = b = c = “Apple” Apple
print(a) Apple
print(b)
print(c)
msg=” Nice” Python is Nice
print (“Python is “+ msg)
fname=” Juan ” N/A
lname=”dela Cruz”
msg=fname + lname
B. Create a python program that will perform the following mathematical operations, to produce
the required output.
Given the following values:
Salary_rate=800/day
Salary = Salary_rate * 15 (days)
Taxable_amount = 30% of salary
Net_pay=Salary – Taxable_amount
Required Output:
Salary Computation and Results
Salary rate = 800
Salary = 12000
Taxable amount=3600
Net Pay = 8400