Coding questions Flashcards

1
Q

What is the difference between list and tuples in Python?

A

Lists are mutable, can be edited. Tuples are immutable.
Lists are slower than tuples.
Lists use [] tuples use ()

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

What are the key features of python?

A
  • its an interpreted language, does not need to be compiled before its run.
  • you don’t need to tell it what type of variables you’re making.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What type of language is python? programming or scripting?

A
  • capable of scripting, but in general it is considered programming.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Explain how python is an interpreted language

A

any programming language which is not in machine-level code before runtime.

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

what is pep 8?

A

Python Enhancement Proposal. a set of rules that specify how to format python code for maximum readability.

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

Benefits of using python

A
  • easy to use.
  • interpreted language i.e. executes the code line by line and stops if an error occurs in any line.
  • free and open source
  • python has vast libraries that contain almost any function needed.
  • portable i.e. can run on any platform.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what are python namespaces?

A
the name which is assigned to each object in python.  the objects are variables and functions. 
4 types of namespaces:
1. built in 
2. global 
3. enclosing
4. local
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the common built in data types in python/

A
numbers - integers, floats, complex numbers. 
list 
tuple
string
set
dictionary
boolean
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the difference between .py and .pyc files?

A

.py files are python source code files.

.pyc files contain the btyecode of the python files.

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

What is slicing in python

A

used to access parts of sequences like lists, tuples, strings. [start:end:step]

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

how to combine data frames in pandas?

A
  1. concatenating by stacking vertically
  2. concatenating by stacking horizontally
  3. combining on a common column. (joining)
    pd. concat()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what are python modules

A
files containing python code. 
os
sys
math
random
data time
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

what is type conversion

A

conversion of one data type into another
int()
float()

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

difference between arrays and lists

A

have the same way of storing data.

Arrays can hold a single data type whereas lists can old any data type.

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

What does [::-1] do?

A

reverses the order of an array

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

how can you randomise the items of a list in place

A

from random import shuffle
x = []
shuffle(x)

17
Q

how can you generate random numbers

A

import random

random.random

18
Q

What process happens after you type in a website’s URL?

A

browser looks up IP address for domain name
browser sends a HTTP request to server
server sends back HTTP response

19
Q

Big O notation

A

describes the limiting behaviour of a function, either its runtime or space-complexity. Used for seeing how much work has to be done by the function when the input increases