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

Python Complete Guide

This document serves as a comprehensive guide to Python programming, covering fundamental concepts such as variables, data types, operators, and control structures. It includes definitions, examples, and practice questions for each topic to aid learning. The guide emphasizes Python's features and provides insights into its syntax and programming environment.

Uploaded by

arnavshukla519
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)
19 views5 pages

Python Complete Guide

This document serves as a comprehensive guide to Python programming, covering fundamental concepts such as variables, data types, operators, and control structures. It includes definitions, examples, and practice questions for each topic to aid learning. The guide emphasizes Python's features and provides insights into its syntax and programming environment.

Uploaded by

arnavshukla519
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 – Complete Babes Guide

1. Python
• Definition: High-level, interpreted programming language.
• English term: Language to talk to computers easily.
• Features: Easy to read/write, Portable, Dynamically typed.
• Example:

print("Hello Babes")

• Practice Question: Print your name.

2. Program
• Definition: Set of instructions for a computer.
• Example: Add two numbers.

a = 5
b = 10
print(a + b)

• Practice Question: Find the square of a number.

3. Variables
• Names that store data. Storage box for data.
• Rules: Cannot be a keyword, letters/digits/_, cannot start with digit.
• Example:

name = "Babes"
age = 16

• Practice Question: Store and print your age.

4. Comments
• Notes ignored by Python. Sticky notes for humans.
• Types: Single-line # , Multi-line """""" , Docstring inside function.

1
def greet():
"""This prints hello"""
print("Hello")

• Practice Question: Add comments explaining a program that adds two numbers.

5. Operators
• Symbols performing operations. Types: Arithmetic, Comparison, Logical.
• Example:

x = 5 + 3
y = 10 / 2

• Practice Question: Check if a number is even or odd using % .

6. Keywords
• Reserved words Python understands.
• Examples: if, else, for, while, def
• Practice Question: List 5 Python keywords.

7. IDLE
• Integrated Development and Learning Environment.
• Modes: Interactive (test line by line), Script (save programs).
• Features: Shell, Editor, Debugger, Syntax highlighting, Auto-indentation
• Practice Question: Write a program to print your name in IDLE.

8. Python Character Set


• Letters A-Z/a-z, digits 0-9, symbols + - * / %, whitespace (space, tab, newline)
• Practice Question: Identify type of each character in "Hello123!".

9. Tokens
• Smallest unit of a program. Types: keywords, identifiers, literals, operators, separators
• Practice Question: Identify tokens in x = 10 + 5 .

10. Identifiers
• Names for variable/function/object. Rules: No keywords, letters/digits/_, cannot start with digit
• Valid: _sum, value1; Invalid: 1sum, @var
• Practice Question: Write 3 valid and 3 invalid identifiers.

2
11. Data Types
• Numeric: int, float; Non-numeric: str, list, tuple, set, dict
• Example:

a = 10 # int
b = 3.14 # float
c = "Babes" # str

• Practice Question: Identify data types: 10, 3.5, "Hi", [1,2]

12. type()
• Shows data type of variable
• Example: print(type("Python"))
• Practice Question: Check type of 5.5 and "Python".

13. Type Conversion


• Implicit: automatic, Explicit: manual int(), float(), str()
• Example:

x = "100"
y = int(x)

• Practice Question: Convert float 3.5 to int.

14. Input
• Takes input from user. Always string.
• Convert to number: int(input())
• Practice Question: Take 2 numbers and print their sum.

15. Comments
• Already covered. Practice Question: Comment a program.

16. Features of Python


• Portable, Dynamically typed, Garbage collection
• Practice Question: List 2 features of Python.

17. Functions
• Block of code performing task. Built-in vs User-defined

3
• Arguments: Values passed, Calling: Running function
• Example:

def greet(name):
print("Hello", name)
greet("Babes")

• Practice Question: Function to print square of a number.

18. Expressions
• Combination of values/variables/operators producing result
• Example: a = 5 + 3 * 2
• Practice Question: Calculate (5+3)/4.

19. Conditional Statements


• if, else, elif, nested if
• Example:

x = 10
if x > 0:
print("Positive")
elif x == 0:
print("Zero")
else:
print("Negative")

• Practice Question: Check grade based on marks.

20. Loops
• for: known repetitions; while: unknown; nested: loop inside loop
• Example: for i in range(3): print(i)
• Practice Question: Print numbers 1-5 using while loop.

21. Basic Programs


• Add numbers, square/cube, swap numbers, even/odd, grade, vowel/consonant
• Practice Question: Swap two numbers without third variable.

22. Data Structures & Conversions


• List, Tuple, Set, Dictionary
• Conversions: list(), tuple(), set(), hex(), oct(), bin()

4
• Example:

s = "Python"
print(list(s))

• Practice Question: Convert "Python" to tuple and set.

23. Indentation
• Space at line start defining blocks
• Rules: 4 spaces, required after if/for/while/def/class
• Example:

x = 10
if x > 5:
print("x>5")

• Practice Question: Predict output of nested if program.

You might also like