Back to marketplace

2 Introduction to Python (II)

No description yet. This curated deck is ready for daily study.

Total cards: 24•Content version: v4•Public deck•Updated: 8/1/2026

Card preview (24)

#1
Front (Question)

1 What is Matplotlib?

Back (Answer)

A plotting library for the Python programming language and its numerical mathematics extension NumPy. It provides an object-oriented API for embedding plots into applications using general-purpose GUI

#2
Front (Question)

2 Complete code: import matplot… as …

Back (Answer)

import matplotlib.pyplot as plt

#3
Front (Question)

3 Make a line plot (year x-axis, pop y-axis) year=[‘1975’,’1976’,’1977’] pop=[2340,2405,2890]

Back (Answer)

import matplotlib.pyplot as plt plt. plot(year,pop) plt. show()

#4
Front (Question)

4 How to display a matplotlib plot?

Back (Answer)

plt.show()

#5
Front (Question)

5 Print the last item of the list year: year=[‘1975’,’1976’,’1977’]

Back (Answer)

print(year[-1]) print(year[2])

#6
Front (Question)

6 What is a scatter plot?

Back (Answer)

A type of plot or mathematical diagram using Cartesian coordinates to display values for typically two variables for a set of data

#7
Front (Question)

7 Complete code (scatter plot): x = [1,3,5] y= [2,6,7] ’'’import mat…. … plt.show()’’’

Back (Answer)

import matplotlib.pyplot as plt plt. scatter(x,y) plt. show()

#8
Front (Question)

8 Change the line plot below to a scatter plot year=[‘1975’,’1976’,’1977’] pop=[2340,2405,2890] import matplotlib.pyplot as plt plt. plot(year,pop) plt. show()

Back (Answer)

plt. scatter(year,pop) plt. show()

#9
Front (Question)

9 Put the x-axis on a logarithmic scale day=[‘1’,’2’,’3’] virus=[18,55,320] import matplotlib.pyplot as plt plt. scatter(day,virus) plt. show()

Back (Answer)

plt. scatter(day,virus) plt. xscale(‘log’) plt. show()

#10
Front (Question)

10 What is a correlation coefficient?

Back (Answer)

A value that indicates the strength of the relationship between variables. The coefficient can take any values from -1 to 1.

#11
Front (Question)

11 What is a histogram?

Back (Answer)

An approximate representation of the distribution of numerical or categorical data

#12
Front (Question)

12 Create histogram years = [1975,1976,1978,1975]

Back (Answer)

import matplotlib.pyplot as plt plt. hist(years) plt. show()

#13
Front (Question)

13 Create histogram with 5 bins using data (list) data = [random.randint(1, 5) for _ in range(100)]

Back (Answer)

plt.hist(data,bins=5)

#14
Front (Question)

14 What is the use of plt.clf() ?

Back (Answer)

Cleans a plot up again so you can start afresh

#15
Front (Question)

15 You want to visually assess if the grades on your exam follow a particular distribution. Which plot do you use?

Back (Answer)

Histogram

#16
Front (Question)

16 You want to visually assess if longer answers on exam questions lead to higher grades. Which plot do you use?

Back (Answer)

Scatter plot

#17
Front (Question)

17 Add labels year =list(range(1975,2000)) scores = list(range(1,26)) plt.scatter(year,scores) …

Back (Answer)

plt. xlabel(‘year’) plt. ylabel(‘scores’) plt. show()

#18
Front (Question)

18 Add ‘scores’ as a title data = [int(random.randint(1, 5)) for _ in range(100)] plt.hist(data,bins=5) … plt.plot()

Back (Answer)

plt.title(‘years’)

#19
Front (Question)

19 Add log scale year =list(range(1975,2000)) scores= [2**n for n in range(25)] plt.scatter(year,scores) …

Back (Answer)

plt. yscale(‘log’) plt. show()

#20
Front (Question)

20 What are ticks in matplotlib?

Back (Answer)

Ticks are the values used to show specific points on the coordinate axis. It can be a number or a string.

#21
Front (Question)

21 What is a legend in matplotlib?

Back (Answer)

The legend of a graph reflects the data displayed in the graph’s Y-axis

#22
Front (Question)

22 Change the ticks in the x-axis to strings x=[1, 3, 5] y=[1, 5, 9] import matplotlib.pyplot as plt plt.scatter(x,y)

Back (Answer)

plt. xticks(x, [“one”,”three”,”five”]) plt. show()

#23
Front (Question)

23 Write a scatter plot with gdp as independent variable and population size as the size argument gdp=[100, 200, 300] life_exp=[50, 70, 82] pop_size=[30,20,40]

Back (Answer)

import matplotlib.pyplot as plt plt. scatter(gdp, life_exp, s =pop_size) plt. show()

#24
Front (Question)

24 What is a dependent variable?

Back (Answer)

A variable (often denoted by y ) whose value depends on that of another.