Activity 1

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

Republic of the Philippines

BATANGAS STATE UNIVERSITY


The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electrical Engineering

Bachelor of Science in Computer Engineering

CpE 401: COMPUTER PROGRAMMING 1


2nd Semester A.Y. 2023 – 2024

Activity 1
DATA TYPE FAMILIARIZATION

SUBMITTED BY:
Abrigo, Renz Christian, B.

COE - 1203

SUBMITTED TO:
Sir Mark Rondol P. Abdon

Leading Innovations, Transforming Lives, Building the Nation


ACTIVITY I: Data Type Familiarization

Familiarize yourself with common operations and methods associated with each data structure.
1. Task 1: List Manipulation:
● Task: Write Python code to perform the following operations on lists:

● Create a list of anything related to computer engineering. (6 items)

● Add a new item on to the list.

● Remove an item on the list.

● Edit the item in index 0

● Print the modified list.


2. Task 2: Dictionary Practice:
● Task: Create a Python dictionary of terms you usually encounter in Computer Engineering
courses: (6 terms)
● Add/update your dictionary

● Remove an item to your dictionary

● Print your dictionary


3. Task 3: Set Operations:
● Task: Perform set operations on two sets of numbers:

● Create two sets of numbers.

● Find the union, intersection, and difference between the sets.

● Print the results.


4. Task 4: String Manipulation:
● Task: Perform string operations to manipulate text:

● Create a string containing a sentence or phrase.

● Convert the string to uppercase and print it.

● Find the length of the string.

● Print the list.


5. Reflection:
● Print your reflection about the activity. Identify areas of improvement, discuss any challenges you
encountered and how they were overcome. Summarize the key learnings from practicing with
Python data structures and strings.
Additional Notes:
● Feel free to collaborate with peers or seek assistance if needed.

● Experiment with different scenarios and data to enhance your understanding.

● Have fun exploring the versatility of Python's data structures and strings!
Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electrical Engineering

Paste your code here use comments to properly document your program.
print("Abrigo, Renz Christian B.\nCOE-1203\nACTIVITY 1: Data Type
Familiarization")

#Task 1: List Manipulation:


#Task: Write Python code to perform the following operations on lists:
#Create a list of anything related to computer engineering. (6 items)
computer_engineering = ["programming", "hardware", "software", "cloud
computing", "data","code"]

#Add a new item on to the list.


computer_engineering.append("computer")

#Remove an item on the list.


computer_engineering.remove("cloud computing")

#Edit the item in index 0


computer_engineering[0] = "system"

#Print the modified list.


print("List of anything related to Computer Engineering: ",
computer_engineering)

#Task 2: Dictionary Practice:


#Task: Create a Python dictionary of terms you usually encounter in Computer
Engineering courses: (6 terms)
compeng_terms = {"Software": "Used to refer to applications, scripts and
programs that run on a device.",
"Hardware": "The external and internal devices and equipment
that enable you to perform major functions such as input, output, storage,
communication, processing, and more.",
"Cloud Computing": "Involves providing various computing
services over the internet, including servers, storage, databases, networking,
software, analytics, and intelligence.",
"Cybersecurity": "The practice of protecting systems,
networks, and programs from digital attacks.",
"Computer Designing": "a career field where professionals
integrate, develop and change a variety of aspects of computers.",
"Computer": "An electronic machine that is used for storing,
organizing, and finding words, numbers, and pictures, for doing calculations,
and for controlling other machines."}

#Add/update your dictionary


compeng_terms.update({"Computer": "a programmable electronic device designed
to accept data, perform prescribed mathematical and logical operations at high

Leading Innovations, Transforming Lives, Building the Nation


speed, and display the results of these operations."})

#Remove an item to your dictionary


del compeng_terms["Computer Designing"]

#Print your dictionary


print("Terms I usually encounter in Computer Engineering: ")
for key in compeng_terms.keys():
print(key, "->", compeng_terms[key])

#Task 3: Set Operations:


#Task: Perform set operations on two sets of numbers:
#Create two sets of numbers.
tuple1 = (1, 4, 9, 16, 25, 36, 49, 64, 81, 100)
tuple2 = (4, 8, 12, 16, 20, 24, 28, 32, 36, 40)
set1 = set(tuple1)
set2 = set(tuple2)

#Find the union, intersection, and difference between the sets.


union = set1.union(set2)
intersection = set1.intersection(set2)
difference = set1.difference(set2)

#Print the results.


print("Set 1:", set1)
print("Set 2:", set2)
print("Set Union:", union)
print("Set Intersection:", intersection)
print("Set Difference:", difference)

#Task 4: String Manipulation:


#Task: Perform string operations to manipulate text:
#Create a string containing a sentence or phrase.
sentence = ("I can show you the world.")

#Convert the string to uppercase and print it.


print("My string in UPPERCASE: ", sentence.upper())

#Find the length of the string.


print("The length of my string is: ", len(sentence))

#Print the string.


print(sentence)

#Reflection
print("Looking back at the activity, practicing with Python's data structures
and strings really helped me understand them better. \nWhile it was helpful
overall, I did struggle with some parts, like understanding dictionaries and
sets, specifically the use \nof different brackets. But by practicing
regularly and thoroughly understanding the topics’ concepts, I managed to
figure \nthings out and finished the activity successfully. I learned that
it's important to choose the right data structure for each \ntask, get good at
working with strings, and understand how to pick out specific parts of data.
In the future, I'll focus on \ngetting better at solving problems and
exploring more advanced types of data structures. Overall, it was quite a fun
\nexperience, having to learn new things, making mistakes while also learning
from them and having to finish programs \nsuccessfully makes me feel
satisfied.")
Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electrical Engineering

Snapshot of the python code and Snapshot of the output

Task 1:

Task 2:

Leading Innovations, Transforming Lives, Building the Nation


Task 3:

Task 4:
Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electrical Engineering

Reflection:

Looking back at the activity, practicing with Python's data structures and strings really helped me understand them
better. While it was helpful overall, I did struggle with some parts, like understanding dictionaries and sets,
specifically the use of different brackets. But by practicing regularly and thoroughly understanding the topics’
concepts, I managed to figure things out and finished the activity successfully. I learned that it's important to choose
the right data structure for each task, get good at working with strings, and understand how to pick out specific parts
of data. In the future, I'll focus on getting better at solving problems and exploring more advanced types of data
structures. Overall, it was quite a fun experience, having to learn new things, making mistakes while also learning
from them and having to finish programs successfully makes me feel satisfied.

Leading Innovations, Transforming Lives, Building the Nation

You might also like