Skip to content

This repository contains my code used for the playlist "Python tips and tricks", which is available on my Youtube channel YUNIKARN.

License

Notifications You must be signed in to change notification settings

GerhardKling/PythonTipsAndTricks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PythonTipsAndTricks

This repository contains my code used for the playlist "Python tips and tricks", which is available on my Youtube channel YUNIKARN. Visit Our website for more content.

P1: Virtual Environments in Python: Essential Basics

You wrote your code relying on Python packages. It runs perfectly - but after a while, you get error messages! Well, Python packages keep changing. How do you address this issue? This video introduces virtual environments (VE) and demonstrates how they can be created, activated and deactivated. Finally, we illustrate the problem based on recent changes to PyPDF2.

Chapters

  • 0:00 Introduction
  • 0:41 Why use a VE?
  • 2:10 Creating a VE
  • 3:51 Activate
  • 4:46 Pip installer
  • 5:10 PyPDF2

P2: The Sum of Even Numbers: Python Interview Questions

This is my favourite interview question: "Write a function called sum_of_even_numbers. The function should accept a list of integers. It returns the sum of all even numbers in the list. Finally, print this number." I will discuss two ways to address this question using for loops and list comprehension.

P3: Fitting Circles into a Square: Python Interview Questions

This is a more challenging interview question: "Select a point P inside the square of length q randomly (2D). Each point P is the centre of a circle of radius r. Note that circles must be inside the square and cannot overlap. Determine the probability of drawing a point in N draws, which is the centre of a permitted circle." Complicated? This video illustrates how to tackle complex questions step-by-step.

P4: Why should you use a requirements.txt in Python?

You might have seen a requirements.txt in a GitHub repository. Why do people use it? Moving virtual environments into other folders or uploading to other machines is usually a bad idea (paths can break, security concerns etc.). This video shows you how to make a requirements.txt. Then we demonstrate how to install packages in your virtual environment using a requirements.txt.

P5: How to change directory in Python?

We explore the os module, which offers many useful methods to interact with your operating system. I show you how to obtain and change your current working directory. However, it is often better to avoid using a machine-specific path.

P6: Import data from CSV files using Python

We explore importing data from CSV files to Python. In addition, important options, including variable names and indices, are discussed. Finally, we select columns from Pandas DataFrames and briefly cover Pandas Series.

P7: An introduction to Pulp

We introduce the Python package Pulp, which is used for optimisation problems. Using a simple example, we build our first model and find solutions. This is a linear programming exercise.

P8: Route optimisation with Pulp

Pulp offers excellent tools to model optimisation problems based on finding optimal routes (e.g., delivery, transportation, supply chains). We explore a simple example where a company has the choice to outsource production, which might lower delivery costs.

About

This repository contains my code used for the playlist "Python tips and tricks", which is available on my Youtube channel YUNIKARN.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages