Back to marketplace

DataCamp Python

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)

If you wanna use a package and you want to use it in your code what do you do?

Back (Answer)

first, import it at the beginning of your code then if you want to use it write it with a dot at the end and then attach what you want to extract from the package say you want to extract pi from the math package, math.pi

#2
Front (Question)

How do you bring add something to your script from package in a general way?

Back (Answer)

from math import pi

#3
Front (Question)

Why is the NumPy array useful ?

Back (Answer)

You can perform calculations over entire arrays

#4
Front (Question)

How can you simply a package name for use in your script

Back (Answer)

write as after your import e.g. import numpy as np

#5
Front (Question)

Whats the difference between when you add lists normally and when you add them using NumPy?

Back (Answer)

When you add them normally, it just combines the lists, one after the other. With NumPy the lists will add

#6
Front (Question)

What is one thing you can’t do with numpy arrays which you can do with regular arrays?

Back (Answer)

numpy arrays cannot contain arrays with different types. If you try to build such a list, some of the elements’ types are changed to end up with a homogeneous list. This is known as type coercion.

#7
Front (Question)

what package do you use to plot in python? And how would you add it to your code?

Back (Answer)

import matplotlib.pyplot as plt

#8
Front (Question)

How do you create a plot in python with matplotlib imported? and how do you print it ?

Back (Answer)

plt. plot() plt. show (remember plt is a subset of matplot lib, you have to call it when doing operations)

#9
Front (Question)

How do you convert an axis on a plot into log ?

Back (Answer)

plt.xscale(‘log’)

#10
Front (Question)

what are the inputs of the histogram function?

Back (Answer)

hist(x, bins = ‘ ‘) x is the list of values bins refer to the list should be divided, if you don’t specify it will be 10 by default. Remember you need to write bins = ‘your value’.

#11
Front (Question)

How to add labels to plots python?

Back (Answer)

plt.xlabel()

#12
Front (Question)

How do you customise the range/length of the

Back (Answer)

plot. yticks() plot. xticks()

#13
Front (Question)

how would you customise the value of plt.yticks() shows?

Back (Answer)

You have an array after you ticks array to specify the value each tick should represent. plt.yticks( [0,1,2,3,4], [‘0’,’1B’, ‘2B’, ‘3B’, ‘4B’, ‘5B’]

#14
Front (Question)

how do you add text to a plot?

Back (Answer)

plt.text(1550, 71, ‘India’) corresponding coordinates and name

#15
Front (Question)

How do you create dictionaries?

Back (Answer)

use { } Use a : to separate the key and the value. call out a value using your_dict_name[key]

#16
Front (Question)

How do you get all the keys from a dictionary?

Back (Answer)

europe.keys() europe being your dictionary in this case.

#17
Front (Question)

Why can you not use a list as a dictionary key?

Back (Answer)

because it isn’t an immutable object it’s mutable - in other words it can be changed.

#18
Front (Question)

When to use a dictionary and when to use a list?

Back (Answer)

Use a list when you have a collection of values were order matters and you want to be able to select entire subsets. Use a dictionary when you want a table that allows you to lookup up values very easily and quickly using unique keys.

#19
Front (Question)

How do you add a value in a dictionary?

Back (Answer)

europe[‘iceland’] = ‘reykjavik’ dict[key] = ‘what you want to set the key to’

#20
Front (Question)

How do you create a table starting from dictionaries and using pandas?

Back (Answer)

create your dict, remember keys are the column labels and the values are the data for each column.

Card back image
#21
Front (Question)

what is csv short for ?

Back (Answer)

comma separated values.

#22
Front (Question)

How can you read a csv file using panda what do you really need to remember?

Back (Answer)

that the csv file name or directory needs to be written within qoutes.

Card back image
#23
Front (Question)

How can you change the index of csv file you are reading ?

Back (Answer)

cars = pd.read_csv(‘cars.csv’, index_col = 0 ) this sets the first column is used as the row labels

Card back image
#24
Front (Question)

What is the diff between loc and iloc

Back (Answer)

only difference is how you refer to columns and rows iloc uses integers