Create a virtual environment for your Python app in a few steps. (For Linux and OS X). Go inside the directory where you want your virtual environment and type in the terminal:
This command will create a directory called myvenv with the virtual environment.
Start your virtual environment by running:
Now that you inside the virtual environment (you will know it because the prompt of the console is prefixed with ( myenv )) you can install whatever you need using pip. To get the latest version of pip type:
python -m pip install --upgrade pip
When working within a virtual environment, python will automatically refer to the correct version so you don’t need to specify anything.
Create a requirements.text file and add packages inside.
Run the following to install them:
pip install -r requirements.txt
The end! Happy coding!
I am looking for my first job as a Junior developer and during my interviews I was asked the following:
- Difference between === and ==:
- === Compares the value ad the type (true / false).
- == Compares only type.
- Difference between slack and heap memories:
- Slack memory: local variables and function call.
- Heap memory: store objects.
- Difference between data type and data structure:
- Data type: the most basic classification. (int, string, var).
- Data structure: collection of data types. (stacks (LIFO(last in first out)), queues, linked lists, binary tree)
- Difference between padding and margin:
padding is the space between the content and the
margin is the space outside the border.
- You can get it counting the number of operations
- Time complexity is defined as a function using Big O notation.
- n is the size of the input.
- O is the worst case scenario.
- The O function is the growth rate in function of the input size n.
O(1) Constant : odd or even / look up table / check if item in array is null / print first element from a list / find on a map.
O(log n) Logarithmic: find in sorted array with binary search.
O(n) Linear: find max in unsorted array / duplicate elements in array with Hash map / find / print all values.
Algorithms running times:
Factorial complexity(no good),
exponential complexity(no good),
polinomial complexity (no good),
linearithmic complexity (middle point),
linear time complexity (good)(for loop in one level array, searching, printing) O(n),
logarithmic complexity (good) O(log n),
constant time complexity (best one)(swap variables). O(1)
Problem from Hackerranck.
I am practising algorithms and tried this one today.
I first get the two first characters of the string ‘s’, the ones that represent the hour and change them to a number with parseInt and assign them to the variable hour.
If this variable hour is bigger than 12 I rest 12, if it is equals 12, hour would be the string ’00’ and for the rest of the cases I add 12.
Then I add hour to a substring of the argument without the two first characters and delete the two last characters too, the one that should be “AM” or “PM”.