0% found this document useful (0 votes)
1 views9 pages

Python Basics

This document provides a comprehensive overview of Python basics, covering topics such as its features, data types, control statements, functions, object-oriented programming, and exception handling. It includes key definitions and differences between concepts like lists and tuples, as well as practical advice for interviews regarding Python proficiency. Overall, it serves as a foundational guide for understanding Python programming.

Uploaded by

pragati.garje123
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)
1 views9 pages

Python Basics

This document provides a comprehensive overview of Python basics, covering topics such as its features, data types, control statements, functions, object-oriented programming, and exception handling. It includes key definitions and differences between concepts like lists and tuples, as well as practical advice for interviews regarding Python proficiency. Overall, it serves as a foundational guide for understanding Python programming.

Uploaded by

pragati.garje123
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

Python Basics (1–10)

What is Python?
Answer:
Python is a high-level, interpreted, object-oriented programming
language known for its readability and simplicity.

Is Python compiled or interpreted?


Answer:
Python is an interpreted language. Code is executed line by line.

What are the features of Python?


Answer:
Easy to learn, high-level, portable, object-oriented, large standard
library.

What is PEP 8?
Answer:
PEP 8 is the style guide for Python code formatting.

What is dynamically typed language?


Answer:
Variable type is decided at runtime, not at compile time.

What is indentation in Python?


Answer:
Indentation defines blocks of code instead of brackets {}.
What are comments in Python?
Answer:
Comments explain code.
Single-line: # comment
Multi-line: ''' comment '''

What is Python used for?


Answer:
Automation, web development, data analysis, AI/ML, scripting.

What are Python keywords?


Answer:
Reserved words like if, else, for, while, def.

What is Python script?


Answer:
A Python file with .py extension containing Python code.

Data Types (11–20)


What are data types in Python?
Answer:
int, float, string, list, tuple, set, dictionary, boolean.

Difference between list and tuple?


Answer:
List is mutable, tuple is immutable.

What is dictionary?
Answer:
Key-value pair data structure.

What is set?
Answer:
Unordered collection with unique elements.

What is type() function?


Answer:
Returns the data type of a variable.

What is None?
Answer:
Represents absence of value.

What is string slicing?


Answer:
Extracting part of string using index.

Mutable vs immutable?
Answer:
Mutable → list
Immutable → string, tuple

What is Boolean?
Answer:
True or False values.

What is casting?
Answer:
Converting one data type into another.

Control Statements (21–30)


What are conditional statements?
Answer:
if, elif, else.

What are loops?


Answer:
for loop and while loop.

Difference between for and while?


Answer:
for → fixed iterations
while → condition-based
What is break?
Answer:
Stops loop execution.

What is continue?
Answer:
Skips current iteration.

What is pass?
Answer:
Placeholder statement.

What is range()?
Answer:
Generates sequence of numbers.

What is nested loop?


Answer:
Loop inside another loop.

What is else with loop?


Answer:
Runs if loop completes normally.

What is input()?
Answer:
Takes user input.

Functions & OOP (31–40)


What is function?
Answer:
Reusable block of code.

How to define function?


Answer:
Using def keyword.

What is return?
Answer:
Returns value from function.

What is lambda function?


Answer:
Anonymous one-line function.

What is class?
Answer:
Blueprint for creating objects.

What is object?
Answer:
Instance of a class.

What is constructor?
Answer:
__init__() method initializes object.

What is inheritance?
Answer:
One class acquiring properties of another.

What is polymorphism?
Answer:
Same function name, different behavior.

What is encapsulation?
Answer:
Binding data and methods together.

Exception, Files & Misc (41–50)


What is exception?
Answer:
Runtime error.

How to handle exception?


Answer:
Using try-except block.

What is finally?
Answer:
Always executes.

What is file handling?


Answer:
Reading/writing files using Python.

Difference between read() and readline()?


Answer:
read() → whole file
readline() → one line

What is module?
Answer:
Python file containing functions.

What is package?
Answer:
Collection of modules.

What is pip?
Answer:
Python package installer.

What is virtual environment?


Answer:
Isolated Python environment.

Why Python for automation?


Answer:
Simple syntax, fast development, large libraries.

Interview Tip (IMPORTANT)


If asked:
“How good are you in Python?”
Say:
“I have strong basics in Python and I am comfortable writing,
understanding, and debugging code. I am continuously improving my
skills.”

You might also like