Python Flashcards

1
Q

What are diffierent type of datatypes in python?

A

integer, float, string, boolean, list, dictionary, sets, tuples

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

How to calculate mode and power in python?

A

%, **

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

Is it possible to assign different data types to same variable?

A

yes

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

How to reverse string?

A
s = hardik
s_reversed = s[::-1]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to get every alternate character?

A
s = hardik
s_alternate = s[::2]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Indexes in string? are they mutable?

A

yes

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

How to split a sentence?

A

Split()

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

What are different methods for a string?

A

None

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

explain what is .format and f’ format? What is the difference?

A

None

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

Can we store different datatypes in list? How to add a value to a list

A

None

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

Explain indexing in list

A

None

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

List at least five methods for list

A

None

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

How do I index a nested list? For example if I want to grab 2 from [1,1,[1,2]]?

A

None

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

Define Dictionaries? Write one dictionary

A

None

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

How to assign values in dictionary

A

None

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

List key mehtonds for dictionary

A

None

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

What is set in python and how to create a sets?

A

None

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

Explain use of boolean datatypes

A

None

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

How to create file inside Jupyter notebook?

A

None

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

How to read a file? What happens if you read again?

A

None

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

What is the use of myfile.seek() method?

A

None

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

Why to use readlines() method?

A

None

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

In windows why there are to back slash?

A

None

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

What is the use of myfile.close()? How to avoid it? (with open)

A

None

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What are different modes for opening file?
None
26
List all comparison operators
None
27
Write example if statement
None
28
Write example for loop
None
29
Write example while?
None
30
When to use for loop vs While loop?
None
31
What is unpacking? Which function can be used?
None
32
Explain Enumerate
None
33
Explain Zip
None
34
Explain Range
None
35
what happens if list length is uneven
None
36
What is the use of "IN" operator?
None
37
How to input some values? What is data type of input value?
None
38
Random library - shuffle, randint functions
None
39
Write sqaure of in a range?
None
40
Write list comprehension to find prime numbers
None
41
Write if else in list comprehension
None
42
Assign default value to a function.
None
43
How to pass unlimted arguments as list and dictionary?
None
44
Nested statement and scope - LEGB
None
45
What is global keyword? How is it used?
None
46
explain - def __init__ method in class
None
47
What is self method,? why is it passed to class
None
48
Explain inheritance? Give example of it.
``` class dog(Animal): def __init__(self): Animal. __init__(self) ```
49
Explain a scenario where you would use inheritance?
None
50
Is it possible to pass multiple classes?
None
51
polymorphism - Explain a scenairo where you would use it..
exaple of animal classes .. cat, dog making different sound
52
Explain abstract class
None
53
Explain special/dunder/magic methods in class.. why is it used
``` def __str__(): def__len__() etc ```
54
What is use of pypi pakcage
None
55
how to install new python package?
None
56
List the keywords used for handling exceptions
try, except, else, finally
57
how to catch all other exceptions
None
58
List atleast five builtin exceptions
None
59
What are decorators in python? Explain its use.
None
60
Explain use of generators. Create one Generator
None