Question: Problem 16 This is testing if you can learn something new with Python on your own. You are going to make a tkinter GUI (or

Problem 16

This is testing if you can learn something new with Python on your own.

You are going to make a tkinter GUI (or any compatible gui framework you choose) which will have a label Enter your favorite song , a text input box, and a button called Three. Type your favorite song into the text box. When you click the button it should pop up a pop up message that prints the song three times, i.e. if you enter Let it Be, the popup message should be :Let it be, Let it be, Let it be.

Take a jpg of your gui with the pop up showing and paste it into your pdf with your source code.

https://www.youtube.com/watch?v=x5AHtW9UuVo&t=300s (button)

https://www.youtube.com/watch?v=Au6FPjkgbUE (popup)

https://www.youtube.com/watch?v=atBeNqFJ9SY (gui example)

Problem 17

This question tests whether you can learn a bit about something new (a popular Python library called Pandas) given your basic Python skills. You can find an example of how to do this problem in the class notes: I have a directory called Pandas and if you look in the Dataframes doc you can see how to do this. You create a dictionary and then turn that into a Pandas dataframe.

Suppose you have three lists that contain the height in meter, the corresponding weight in kilogram, and the body mass index (bmi) of the

height and weight as follow:

height = [1.47, 1.5, 1.52, 1.55, 1.57, 1.6, 1.63, 1.65, 1.68, 1.7, 1.73, 1.75, 1.78, 1.8, 1.83]

weight = [52.21, 53.12, 54.48, 55.84, 57.2, 58.57, 59.93, 61.29, 63.11, 64.47, 66.28, 68.1, 69.92, 72.19, 74.46]

bmi = [24.16, 23.61, 23.58, 23.24, 23.21, 22.88, 22.56, 22.51, 22.36, 22.31, 22.15, 22.24, 22.07, 22.28, 22.23]

Store the three lists in a pandas DataFrame. Call the DataFrame bmi_table. Call the columns height, weight, bmi.

Show the first 6 rows of the table

Problem 18

Two new people are added to these height (in meters) and weight (in kilogram) lists. They are the numbers in red below.

height = [1.47, 1.5, 1.52, 1.55, 1.57, 1.6, 1.63, 1.65, 1.68, 1.7, 1.73, 1.75, 1.78, 1.8, 1.83, 1.81, 2.20]

weight = [52.21, 53.12, 54.48, 55.84, 57.2, 58.57, 59.93, 61.29, 63.11, 64.47, 66.28, 68.1, 69.92, 72.19, 74.46, 49.12, 85.65]

Calculate the bmi of the last person added

Calculate the bmi of the second to last person added

Hint: to get the last person's height and weight you can use range -1 trick

Hint: to get the second to last persons height and weight you can use range -2 trick

Hint: The formula for BMI is weight in kilograms divided by height in meters squared.

https://www.google.com/search?q=bmi+formula&rlz=1C1CHBF_enUS763US763&sxsrf=ALiCzsZfHc7ceF5I_IE2ABWqn0vuyfqQ2A:1671093503530&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjDgai1nPv7AhV4H0QIHcBQDEIQ_AUoAXoECAEQAw&biw=1325&bih=892&dpr=1

Problem 19

You will use the dataframe you created in Problem 17 (more Pandas this shows me if you are good enough in basic Python At this point that you actually can tackle something new and not fall apart). If you like solving this problem you could consider getting into data science.

Write a function get_sample_mean that takes in two input arguments: the desired sample_size and a dataframe called data. In the function pull a random sample of the specified sample_size of rows and save those as another dataframe. Now Calculate and return the mean of the sample dataframe.

Call your function on the height column with a sample size of 5 and print the mean

Call your function on the weight column with a sample size of 5 and print the mean

Call your function on the bmi column with a sample size of 5 and print the mean.

Hint: you can call the function with bmi_table.height, 5

Hint: you can call the function with bmi_table.weight, 5

Hint: you can call the function with bmi_table.bmi, 5

Hint: in the function you can pull a random 5 rows using data.sample(n=5)

Ie sampledata = data.sample(n=5)

Hint: in the function to get the mean you can do

samplemean = sampledata.mean()

Or

sum(sample) / len(sample)

Hint: you can look in my pandas folder in class notes or just search google for examples on how to pull a specific column from a data frame, how to get a sample (a random number of rows pulled out) and get the mean etc.

Problem 20

Give two sets

set1={1,2,3,4,5}

set2={4,5,6,7,8}

Run each of the four Python set operations (union, intersection, difference and symmetric difference) on these and print the result. Explain briefly in a few of your own words what each operation is doing.

Hint: look about half way down in this article and it shows you exactly how to do it

https://www.programiz.com/python-programming/set

Look at this page and also tell me in a few of your own words what modules are about

https://www.w3schools.com/python/python_modules.asp

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!