or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
Python questions for interviews
Easy
Question 1
Can you tell the difference between unit, functional, and integration tests ?
Functional testing is defined as the testing of complete functionality of some application. Integration tests, test how parts of the system work together and unit tests test the small pieces of the application. Comments
Question 2
Given the following list:
how can you display only the unique elements of the array
Possible answer:
Question 3
What’s a list comprehension ?
Question 4
What's the difference between:
and
One create a list with 10 elements starting in 0, the other create an iterator
Question 5
Which one is better, and why use one or another
Iterator is used when you only need to calculate the next value in real time, it's faster depending on what is inside the list, the list has all the elements. Iterator is also fixed values in memory while lists increase depending on the number of elements.
Question 6
What getattr do?
Question 7
What is a decorator in python
Question 8
I have a function in python that download a very large glance image calculates the md5sum and return it, what's the best way to test this function without need to download the image
Question 9
What are local variables and global variables in Python?
Global Variables: Variables declared outside a function or in global space are called global variables. These variables can be accessed by any function in the program. Local Variables: Any variable declared inside a function is known as a local variable. This variable is present in the local space and not in the global space.
Question 10
What is the difference between Python Arrays and lists? Arrays and lists, in Python, have the same way of storing data. But, arrays can hold only a single data type elements whereas lists can hold any data type elements.
Question 11
What is monkey patching?
Dynamic modifications of a class or module at run-time refers to a monkey patch.
Medium / Advanced
Question 1
How do you sort a Python Snake sequence when the ordered is induced by another sequence? (For example, how do you sort a list of names by the age of each person?)
Example
Answer
Question 2 (tricky)
You have the following:
What's the output of this:
What would happen if you sort it with zip?
Question 3 (tricky)
What's the output of this code:
Explanation:
in
is a comparison operator, meaning the expression corresponds to 2 comparisons that have been chained, much like2 < 4 < 7
is2 < 4 and 4 < 7
.Hard (but easy)
Question 1
How can you calculate the triangular number? For example, the triangular number for 3 is 6:
Possible sollution
Better sollution
However, this is a linear function, this can be better:
But what's the issue with this?
The sum of 1 + 2 + … + N can be simplified to N * (N + 1) / 2:
But the output now is a float:
Resolving casting int:
Tends to rounding errors:
What's the sollution then? Use //: