Intro To Python Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What are Strings?

A

Strings are primitive data type of the python language. You can think of a data type as a building block of a language. The content inside the print function is a string.(“word here”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are Booleans?

A

Boolean assess the truth of something. Boolean values are either true are false. Example: 5>7 is 5 greater than 7? = false, 7<5 is 5 smaller than 7? = true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Conditional Logic

A
Comparison operator, Meaning
<            Less than
<=          Less than or equal to
>            greater than
>=          greater than or equal to
==          equal
!=           not equal
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is numpy?

A

¹

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

True or Flase statement?
Num = 3
Is number > 10
Print(num)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Logical Operators?

A
And, or, not 
Can be used in conjunction with conditional logic ex:
Num = 4
print(num > 0 and num < 15)
Output: true
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The 3 main file types and the functions to load them?

A

.csv files - pd.read_csv(‘filepath’)
.xlsx files - pd.read_excel(‘filepath’)
‘Filepath’ can be remote URL if it points to .csv or.xlsx file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is df.info()

A

To get lots of info in, including data type, index, and column names

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is df.dtypes

A

To get just the data type for just all column

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What us df.[‘name’].dtypes

A

To get the data type for just one column

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is df.head()

A

This will give you the top 5 rows

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What us df.head(8)

A

To see a different number of rows such as the first 8 rows

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is df.tail()

A

To see the bottom 5 rows

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is df.tail(11)

A

To see a different number of rows such as the last 11 rows

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is df.sample(5)

A

To see 5 random rows

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are functions?

A

The syntax

17
Q

How is list used?

A

z = [3, 7, 4, 2]
index 0 1 2 3
Neg index -4 -3 -2 -1

18
Q

What does Slicing Dataframes mean?

A

Selecting specific colums

19
Q

what is df.[‘name’]

A

To select 1 column as a pandas series

20
Q

What is df[[‘name’]]

A

To select 1 column as a pandas dataframe

21
Q

What is df[[‘name’, ‘manufacturer’]]

A

To select multiple columns as a dataframe

22
Q

What is df.info()

A

To get lots of info including data type, index, and column names

23
Q

What is df.shape

A

To get the shape(rows, columns)

24
Q

What is Len(df)

A

To get the number of rows

25
Q

What is len(df.columns)

A

To get the number of columns

26
Q

What is a else statement?

A

Must be after an if or elif statement . There can be at most one else statement. Will only execute if all the “if” and “elif” statement above it are false

27
Q

What’s elif statement?

A

“elif” is the shortened code for “else if”. Must be after an if statement

28
Q

If, elif and else statements in use for catchfall condition

A
Num = 5
 if num > 50:
 print('num is larger than 50')
elif num == 21:
 print('num = 21')
else:
 print('catchfall condition')
29
Q

What is a list?

A

An ordered collection of items which can be of different types. Lists are mutable

30
Q

What is a float?

A

A number that is not a whole number, example: 0.25 or 1/2

31
Q

What is an integer?

A

A whole number inside a list

32
Q

How to perform exponentiation?

A

By using two asterisks, example: 2**5

33
Q

Quotient, what is a floor division?

A

Done by using two forward slashes and is used to determine the quotient of a division, example: print(20//6) Output: 3, because 6 goes into 20 three times

34
Q

What is a modular operator?

A

A % symbol used to get the remainder of a division. Example: print(20%6) Output-

35
Q

What does Newlines- \n represent?

A

It can be used to create multi-line output, example: print(‘one\nTwo\nThree’)

36
Q

What is stack?

A

Tacking is a Last-in-First-out (LIFO) principle. The last item you out in, is the first you you take out

37
Q

What is queue?

A

Like the name suggests, follow the First-in-First-out (FIFO) principle. First item that was put in is the first item taken out