0% found this document useful (0 votes)
25 views3 pages

Learn Python Syntax Beginner Intermediate

This document provides a comprehensive overview of Python syntax for beginners to intermediate learners, covering key topics such as variables, data types, conditions, loops, functions, data structures (lists, tuples, dictionaries), file I/O, common libraries, and object-oriented programming. Each section includes code examples to illustrate the concepts. The document serves as a practical guide for understanding and applying Python programming fundamentals.

Uploaded by

freyalivanna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views3 pages

Learn Python Syntax Beginner Intermediate

This document provides a comprehensive overview of Python syntax for beginners to intermediate learners, covering key topics such as variables, data types, conditions, loops, functions, data structures (lists, tuples, dictionaries), file I/O, common libraries, and object-oriented programming. Each section includes code examples to illustrate the concepts. The document serves as a practical guide for understanding and applying Python programming fundamentals.

Uploaded by

freyalivanna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Learn Python Syntax: Beginner to Intermediate

1. Variables and Data Types

---------------------------

x=5 # Integer

y = 3.14 # Float

name = "Alice" # String

is_active = True # Boolean

2. Conditions and Loops

------------------------

if x > 3:

print("x is greater than 3")

elif x == 3:

print("x is 3")

else:

print("x is less than 3")

for i in range(5):

print(i)

while x > 0:

x -= 1

3. Functions

------------
def greet(name):

return f"Hello, {name}!"

print(greet("Alice"))

4. Lists, Tuples, Dictionaries

------------------------------

my_list = [1, 2, 3]

my_tuple = (1, 2, 3)

my_dict = {"name": "Alice", "age": 25}

my_list.append(4)

print(my_dict["name"])

5. File I/O

-----------

with open("[Link]", "w") as f:

[Link]("Hello, file!")

with open("[Link]", "r") as f:

print([Link]())

6. Common Libraries

-------------------

import math

print([Link](16))
import pandas as pd

df = [Link]({'a': [1, 2], 'b': [3, 4]})

7. Object-Oriented Programming (OOP)

------------------------------------

class Person:

def __init__(self, name, age):

[Link] = name

[Link] = age

def greet(self):

print(f"Hi, I'm {[Link]} and I'm {[Link]} years old.")

p = Person("Alice", 25)

[Link]()

You might also like