0% found this document useful (0 votes)
3 views5 pages

Python Beginner Notes

This document provides beginner notes on Python programming, covering key topics such as printing output, variables, data types, operators, user input, conditional statements, loops, lists, functions, comments, string methods, dictionaries, tuples, sets, error handling, and importing modules. Each section includes basic examples to illustrate the concepts. It serves as a foundational guide for new Python learners.

Uploaded by

yuktishree11
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)
3 views5 pages

Python Beginner Notes

This document provides beginner notes on Python programming, covering key topics such as printing output, variables, data types, operators, user input, conditional statements, loops, lists, functions, comments, string methods, dictionaries, tuples, sets, error handling, and importing modules. Each section includes basic examples to illustrate the concepts. It serves as a foundational guide for new Python learners.

Uploaded by

yuktishree11
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
You are on page 1/ 5

PYTHON BEGINNER NOTES

1. PRINTING OUTPUT

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

print("Hello, world!")

Used to display text or data on the screen.

2. VARIABLES AND DATA TYPES

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

name = "Alice" # string

age = 25 # integer

height = 5.8 # float

is_student = True # boolean

Variables store data. Python automatically detects the type.

3. BASIC DATA TYPES

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

int -> Whole numbers (10, -3)

float -> Decimal numbers (3.14, 0.5)

str -> Text ("Hello")

bool -> True or False

4. OPERATORS

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

Arithmetic: +, -, *, /, %, ** (power), // (floor division)

Comparison: ==, !=, >, <, >=, <=


Logical: and, or, not

5. INPUT FROM USER

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

name = input("Enter your name: ")

print("Hello", name)

All input is read as a string by default.

6. IF-ELSE CONDITIONS

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

if age >= 18:

print("Adult")

else:

print("Minor")

elif is used for multiple conditions.

Indentation matters in Python.

7. LOOPS

--------

While loop:

count = 0

while count < 5:

print(count)

count += 1
For loop:

for i in range(5):

print(i)

8. LISTS

--------

fruits = ["apple", "banana"]

print(fruits[0])

fruits.append("cherry")

len(fruits), fruits.remove("banana")

9. FUNCTIONS

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

def greet(name):

print("Hello", name)

greet("Alice")

Use return to send back values from a function.

10. COMMENTS

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

# This is a single-line comment

'''This is a

multi-line comment'''

11. STRING METHODS


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

s = "hello"

s.upper(), s.lower(), s.title()

s.strip(), s.replace("h", "H")

12. DICTIONARIES

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

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

print(person["name"])

person["age"] = 26

13. TUPLES & SETS

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

Tuples: immutable list -> t = (1, 2)

Sets: unique items -> s = {1, 2, 3}

14. ERROR HANDLING

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

try:

x = int("abc")

except ValueError:

print("Invalid input")

15. IMPORTING MODULES

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

import math

print(math.sqrt(16))
import random

print(random.randint(1, 10))

You might also like