0% found this document useful (0 votes)
2 views

cs125_sample_midterm

The document outlines three Python programming tasks for a course on data analysis in social sciences. The first task involves creating a script to analyze employee email addresses and calculate employment duration, the second task requires a script to compute a customer's bill for spa services with potential discounts, and the third task focuses on calculating a semester GPA based on course grades and credits. Each task includes sample runs to illustrate expected input and output.

Uploaded by

karagolbeyzanur
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

cs125_sample_midterm

The document outlines three Python programming tasks for a course on data analysis in social sciences. The first task involves creating a script to analyze employee email addresses and calculate employment duration, the second task requires a script to compute a customer's bill for spa services with potential discounts, and the third task focuses on calculating a semester GPA based on course grades and credits. Each task includes sample runs to illustrate expected input and output.

Uploaded by

karagolbeyzanur
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CS125 Introduction to Data Analysis for Social Sciences

Duration: 100 minutes


1) (30 points) Write a python script, yourname_q1.py, that inputs string email addresses for 4 employees.
The email address is in the following format: [email protected].

Your program should add the names of all employees who have been with the company for mor than 10 years to
a list. The program should output the list of names of employees who have worked for the company for more
than 10 years as well as the average number of years they have been employed. Display an appropriate
message (see sample run below) if no employees have worked for the company for over 10 years.

Hint: the email address contains the employee’s start year.

Sample Run 1:
Enter email address: [email protected]

Enter email address: [email protected]

Enter email address: [email protected]

Enter email address: [email protected]

Employees over 10 years: ['ali_ozer', 'ela_altun']


Average employment years over 10: 11.5

Sample Run 2:

Enter email address: [email protected]

Enter email address: [email protected]

Enter email address: [email protected]

Enter email address: [email protected]


No employees employed over 10 years found

1
2. (30 points) A spa offers the services listed below. Write a python script, yourname_q2.py, that inputs the
service requested by a customer and calculates and displays the customer’s bill. For massages and facials only,
if the customer is a VIP customer, they will receive a 15% discount on their bill. Note: the service type can be
entered in any case (upper/lower) and the program should accept either input. Assume one of the following
options will be entered:

Service Type Price

Massage (m) 250

Facial (f) 175

Pedicure (p) 150

Manicure (mc) 90

Sample Run 1:
Enter service (m/f/p/mc): m

Are you a vip customer (y/n): y


Your bill is: $ 212.5

Sample Run 2:
Enter service (m/f/p/mc): f
Are you a vip customer (y/n): n
Your bill is: $ 175

Sample Run 3:
Enter service (m/f/p/mc): mc
Your bill is: $ 90

Sample Run 4:
Enter service (m/f/p/mc): h
Invalid choice

2
2) (40 points) Write a python script, yourname_q3.py, that calculates a semester GPA. The GPA is calculated by
multiplying the grade points by the credits for each course and summing them. Dividing the sum by the total
credits will give the GPA. For example, if a student takes ENG101, a 3-credit course and gets an A (4 points) and
TURK101, a 2 credit course, and gets a B (3 points), GPA is calculated as follows: (3 * 4 + 3 * 2) / (3 + 2)

Your script should do the following:


a. Using the data in the table below, create a dictionary with the course codes as the keys and credits as the
values.

Course Code Credits


ENG101 3
ENG102 3
MATH105 3
MATH106 4
MBG110 3
PSYC103 3
TURK101 2
TURK102 2
CS125 3

b. Prompt the user to input the number of courses they would like to enter.
c. For each course, input the course code and grade points.
d. Find the sum of the credits multiplied by the grade points for the input courses that appear in the dictionary.
e. Display the result.

Sample Run 1:
Enter number of courses: 3

Enter course code: CS125

Enter grade points: 3.6

Enter course code: ENG102

Enter grade points: 2.9

Enter course code: MBG110

Enter grade points: 3


Semester gpa: 3.2

Sample Run 2:
Enter number of courses: 2

Enter course code: MATH106

Enter grade points: 2

Enter course code: HUM101

Enter grade points: 4


HUM101 not found
Semester gpa: 2.0

You might also like