Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A compact Python cheatsheet that revisits the fundamentals of the language in less than 20 lines of code. Covers variables, data structures, conditionals, loops, functions, and classes — all in a minimal and beginner-friendly format. Perfect for quick revision or as a lightweight starting point for new learners.

Notifications You must be signed in to change notification settings

RonaldLopes/python20lines

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Python in 20 Lines

A compact Python cheatsheet that revisits the fundamentals of the language in less than 20 lines of code.
It covers variables, data structures, conditionals, loops, functions, and classes — all in a minimal and beginner-friendly format.


📌 Code Example

# Variables and types
name, age, active = "Python", 30, True

# Structures
fruits = ["apple", "banana"]
user = {"name": "Ana", "age": 25}

# Conditional
print("Adult" if age >= 18 else "Minor")

# For loop
for f in fruits: print(f)

# While loop
c = 0
while c < 2: print("Loop", c); c += 1

# Function
def add(a, b=0): return a + b
print(add(5, 3))

# Class
class Person:
    def __init__(self, name): self.name = name
    def speak(self): print(f"I am {self.name}")

Person("John").speak()

🎯 What You’ll Learn

  • Variables, strings, numbers, booleans
  • Lists and dictionaries
  • If/else conditionals
  • For and while loops
  • Functions with default arguments
  • A simple class (OOP basics)

🚀 Why This Repo?

  • Perfect for beginners as a quick overview
  • Great for revision before interviews
  • A fun challenge: learn Python’s core in 20 lines only

📖 Next Steps

After mastering these basics, try exploring:

  • File handling (open, read, write)
  • Popular libraries like pandas, numpy, and requests
  • Best practices for writing clean and maintainable code

📝 License

This project is licensed under the MIT License.

About

A compact Python cheatsheet that revisits the fundamentals of the language in less than 20 lines of code. Covers variables, data structures, conditionals, loops, functions, and classes — all in a minimal and beginner-friendly format. Perfect for quick revision or as a lightweight starting point for new learners.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages