Question: 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)
 Question B1(Python) (i) Given the following code defining Sam's age, can

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!