Group1-Project

You might also like

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

IT 121 – Computer Programming 2

Problem Set 1

Python Function
1. Write a function named calculator, that takes three parameters, two numbers and a string
representing an operation (add, subtract, multiply and divide). The function should
perform the operation and return the result.
Sample Output:
Enter number 1: 10
Enter number 2: 5
Enter operator: +
The sum of 10 and 5 is: 15

2. Write a function named count_words that takes a string as a parameter and returns the
number of words in the string. Assume that words are separated by spaces.

Sample output:

Enter String 1: Hello world


Enter String 2: This is a sample statement
The total number of words in statement 1 is: 2
The total number of words in statement 2 is:5

Python Text File


3. Create a text file named ‘programming.txt’, the program must read the file and display
the text in the console or output window.

programming.txt

Programming refers to a technological process for telling a computer which tasks to


perform in order to solve problems. You can think of programming as a collaboration
between humans and computers, in which humans create instructions for a computer to
follow (code) in a language computer can understand.

4. Create a text file named ‘multimedia.txt’, the program must read the file and display the
text in the console or output window.

multimedia.txt
Multimedia refers to the integration of various forms of media, such as text, graphics, audio,
video, and animation, in a digital format. It involves the combination of different elements to
create interactive and dynamic content that engages the senses.

Python List
5. Write a program that calculates the sum of all the elements in a list of numbers, supposed
the list of numbers is [5,3,7,8,9,10,6,12]

Sample output:
The sum of all the elements in a list is: 60

6. Write a program that calculates the average of all the elements in a list of numbers,
supposed the list of numbers is [7,5,23,12,45,6,9,8,14]

Sample output:
The sum of all the elements in a list is: 129
The average of all elements in a list is: 14.3333

7. Write a Python program that will find the maximum element in a list of numbers,
supposed the list of numbers is [7,5,23,12,45,6,9,8,14].

Sample output:
The maximum element in a list is: 45

Python OOP
8. Create a class named Person with attributes name, age, address, and gender. Write a
method named display that prints the name, age, address and gender of the person then
create an object or instance of the Person class and call the display method.
9. Create a python program that defines a basic class and create an object with the following
steps.
a. Define a class named ‘Computer’ with attributes (casing, processor, processor,
monitor and HDD)
b. Add a method to display the computer information.
c. Create objects of the class and display their information

Python Turtle
10. Create a python turtle to draw a star pattern on the screen.
Python TKinter
11. Write a python Tkinter to compute salary of individual employee with the given formula:

Gross income = rate per day + Overtime + Work days


Deduction = pagibig + philhealth + SSS + cash advance
Net Income = Gross income – Deduction

12. Write a python Tkinter to calculates and displays the area of a parallelogram.

Formula: Area = Base * Height

13. Write a python program using Tkinter to compute price of a tarpaulin using the formula:
Price = (Length * Widht * 25)

You might also like