Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question B 1 ( Python ) ( i ) Given the following code defining Sam's age, can you write code using an f - string

Question B1(Python)
(i) Given the following code defining Sam's age, can you write code using an f-string to print "Sam is 20 years old"?
age =20
(5 marks)
(ii) Given the following code defining Sam's age and number of pets in the object Sam_info, can you write code using either an f-string or string format method to print "Sam is 20 years old and has 2 pets"?
Saminfo ={ 'age':20, 'pets': 2}
(5 marks)
(iii) Given a DataFrame df, can you write code to select the rows "a" and "b" and the columns "x" and "y"?
(5 marks)
(iv) Write a line of code to read a csv file "mydata.csv" into a DataFrame df, assuming that the first row of the csv file contains the column names.
Write code to plot the first column of df against the second column using the plot function from pyplot (only partial credit will be given for other approaches, even if the approach is superior).
(10 marks)
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

1. To what extent do you think it is possible to measure stress?

Answered: 1 week ago

Question

9. Describe the characteristics of power.

Answered: 1 week ago

Question

10. Describe the relationship between communication and power.

Answered: 1 week ago