0% found this document useful (0 votes)
2 views7 pages

Full Python Syllabus QA Notes

The document covers fundamental concepts in Python programming, including conditional statements ('if', 'if-else', 'elif', nested ifs), looping structures (while and for loops, break and continue statements, nested loops), and data structures (strings, lists, tuples, sets, dictionaries). It also introduces object-oriented programming concepts such as classes, objects, methods, attributes, and inheritance. Each concept is explained with definitions and examples for clarity.

Uploaded by

drdoom4922
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)
2 views7 pages

Full Python Syllabus QA Notes

The document covers fundamental concepts in Python programming, including conditional statements ('if', 'if-else', 'elif', nested ifs), looping structures (while and for loops, break and continue statements, nested loops), and data structures (strings, lists, tuples, sets, dictionaries). It also introduces object-oriented programming concepts such as classes, objects, methods, attributes, and inheritance. Each concept is explained with definitions and examples for clarity.

Uploaded by

drdoom4922
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/ 7

Unit 1: Conditional Statements and Looping

What is an 'if' statement in Python?

Used to check a condition. If it's true, the code inside runs.

Example:

if x > 0:

print("Positive")

What is an 'if-else' statement?

Checks a condition. Runs one block if true, another if false.

Example:

if x > 0:

print("Positive")

else:

print("Not Positive")

What is an 'elif' statement?

Stands for 'else if'. Used for multiple conditions.

Example:

if x > 0:

print("Positive")

elif x == 0:

print("Zero")

else:

print("Negative")

What is a nested if statement?

An if inside another if block.

Example:

if x >= 0:
if x == 0:

print("Zero")

What is a while loop?

Repeats code while the condition is true.

Example:

i=1

while i <= 5:

print(i)

i += 1

What is a for loop?

Used to loop over a sequence.

Example:

for i in range(5):

print(i)

What does 'break' do?

Exits the loop immediately.

Example:

for i in range(5):

if i == 3:

break

What does 'continue' do?

Skips current loop iteration.

Example:

for i in range(5):

if i == 2:

continue
What is a nested loop?

A loop inside another loop.

Example:

for i in range(2):

for j in range(2):

print(i, j)
Unit 2: Strings and Functions

What is a string in Python?

A string is a sequence of characters in quotes. Example: "Hello" or 'Python'

What is string slicing?

Accessing parts of a string using indexes. Example: s[0:3]

What are string functions?

Built-in methods like upper(), lower(), find(), replace().

Example: 'hello'.upper() returns 'HELLO'

What is a function?

A reusable block of code. Defined using def.

Example:

def greet():

print("Hi")

What are built-in functions?

Functions already provided by Python. Example: print(), len(), type()

What are user-defined functions?

Functions created by the user using def keyword.

What is the difference between return and print?

return sends back a value; print just displays it on screen.

What is function argument?

Input passed to a function. Example:

def add(a, b):

return a + b
Unit 3: Lists, Tuples, Sets, Dictionaries

What is a list?

A collection of ordered, changeable items. Written in []. Example: [1, 2, 3]

What is a tuple?

An ordered, unchangeable collection. Written in (). Example: (1, 2, 3)

What is a set?

An unordered, unique items collection. Written in {}. Example: {1, 2, 3}

What is a dictionary?

A collection of key-value pairs. Example: {'name': 'John', 'age': 25}

What are list functions?

append(), remove(), sort(), etc. Example: mylist.append(4)

What are tuple functions?

count(), index(). Example: mytuple.count(2)

What are set functions?

add(), remove(), union(), intersection()

What are dictionary functions?

get(), keys(), values(), update(). Example: mydict.get('name')


Unit 4: Object Oriented Programming

What is Object-Oriented Programming?

A way to structure code using classes and objects.

What is a class?

A blueprint for creating objects.

Example:

class Dog:

def __init__(self, name):

self.name = name

What is an object?

An instance of a class. Example: d = Dog('Tommy')

What is the __init__ method?

The constructor that runs when an object is created.

What are self and attributes?

'self' refers to the instance. Attributes are variables inside the class.

What are methods in a class?

Functions defined inside a class. They usually take self as first argument.

What is inheritance?

When a class takes properties from another class.

Example:

class Animal:

class Dog(Animal):

You might also like