Skip to content

luutanhung/everything-about-python

Repository files navigation

Python logo

Everything About Python

Python 3.13

Table of Contents

Recipes

This section provides practical code snippets for various common programming tasks, serving as a quick reference guide.

Lists

State you want to hold a bunch of items

  1. Adopt square bracket []
# Empty list
ops_empty = []
print(ops_empty) # []

# List of whole numbers
nums = [20, 8, 2002]
print(nums) # [20, 8, 2002]

# List of well-known car manufacturers
manufacturers = ["Honda", "Cadillac", "Volkswagen Beetle", "TOYOTA"]
print(manufacturers) # ["Honda", "Cadillac", "Volkswagen Beetle", "TOYOTA"]
  1. Use list() constructor
# Empty list
ops_empty = []
print(ops_empty) # []

# Transform the name of Elon Musk to a list of characters
chrs = list("Elon Musk")
print(chrs) # ['E', 'l', 'o', 'n', ' ', 'M', 'u', 's', 'k']

Pay a visit to each elements

# Go through each neighborhoods' house and give a greet
intimate_neighborhoods = ["Phương", "Anh", "Lâm", "Khoa"]
for neighborhood in intimate_neighborhoods:
    print(f"🙋 Hi {neighborhood}. Have a good day!")
🙋 Hi Phương. Have a good day !
🙋 Hi Anh. Have a good day!
🙋 Hi Lâm. Have a good day!
🙋 Hi Khoa. Have a good day!

Order in a Chaotic World

# Declare a list of well-known scientists
scientists: list[str] = ["Issac Newton", "Albert Einstein", "Niels Bohr", "Michael Faraday", "Max Born", "Johannes Kepler"]

# Arrange elements in ascending order
print(sorted(scientists))

# Rearrange items in descending order
print(sorted(scientists, reverse=True))
['Albert Einstein', 'Issac Newton', 'Johannes Kepler', 'Max Born', 'Michael Faraday', 'Niels Bohr']
['Niels Bohr', 'Michael Faraday', 'Max Born', 'Johannes Kepler', 'Issac Newton', 'Albert Einstein']

Regex

This section contains examples of regular expressions question to practice and solutions.

Algorithm Problems

This section provides a dedicated collection of algorithm problems I've successfully navigated. Consider this a practical reference for your coding interview preparation.

Two Pointers

License

This project is distributed under MIT License. See License.txt for more details.

Authors

About

This repository contains concise knowledge I absored about Python

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published