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

PPS Python All Answers

The document provides an overview of Python programming, covering topics such as control flow, functions, modules, strings, data structures (lists, tuples, sets, dictionaries), and libraries like NumPy, Pandas, and Matplotlib. It includes both short and long answers detailing features, applications, data types, operators, and various programming concepts. The document serves as a comprehensive guide for understanding Python's capabilities and functionalities.

Uploaded by

gojos3665
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)
5 views5 pages

PPS Python All Answers

The document provides an overview of Python programming, covering topics such as control flow, functions, modules, strings, data structures (lists, tuples, sets, dictionaries), and libraries like NumPy, Pandas, and Matplotlib. It includes both short and long answers detailing features, applications, data types, operators, and various programming concepts. The document serves as a comprehensive guide for understanding Python's capabilities and functionalities.

Uploaded by

gojos3665
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

UNIT I – Introduction to Python Programming & Control Flow

Short Answers
1. Features of Python: Simple, interpreted, portable, object-oriented, and rich standard library.
2. Applications of Python: Web development, data science, AI, automation, and scientific
computing.
3. Literals are fixed values, constants do not change, and variables store data.
4. Multiple assignment uses a,b=1,2; multiple statements use semicolon.
5. Identifiers name variables; reserved words are predefined keywords.
6. Indentation defines code blocks and is mandatory in Python.
7. Data types: int, float, complex, string, list, tuple, set, dictionary.
8. Operators: Arithmetic, relational, logical, assignment, bitwise.
9. Membership operators: in, not in; Identity operators: is, is not.
10. Operator precedence decides order; associativity decides direction.
11. break exits loop; continue skips iteration.
12. if–elif–else is used for multiple conditions.
13. else in loops executes when loop ends normally.
14. Comments improve readability and debugging.
15. Even/Odd program uses modulus operator.

Long Answers
Identifiers follow naming rules; variables store values dynamically; Python supports multiple built-in
data types.
Operators perform operations such as arithmetic, comparison, and logic control.
Conditional statements include if, if–else, and if–elif–else.
Iterative statements are for and while loops.
Nested if can find largest of three numbers.
Prime numbers program checks divisibility.
Leap year program checks divisibility by 4 and 400.
Loop control statements are break, continue, and pass.
Armstrong number checks sum of powers of digits.
Factorial and Fibonacci programs use loops.
UNIT II – Functions
Short Answers
1. Function is a reusable block of code; types include built-in and user-defined.
2. Scope defines visibility; lifetime defines existence.
3. Required arguments must be passed.
4. Default arguments have predefined values.
5. Keyword arguments use parameter names.
6. Recursion is a function calling itself.
7. Global variables are outside; local variables are inside function.
8. Functions reduce code duplication.
9. Lambda functions are anonymous one-line functions.
10. Parameters can be positional, keyword, default, variable-length.
11. Anonymous functions have no name.
12. Return function gives value; void does not.

Long Answers
Functions improve modularity and reuse; defined using def keyword.
Arguments include required, default, and keyword types.
Recursion uses function calls; iteration uses loops.
Anonymous functions are defined using lambda.
Parameters can be passed in different ways.
GCD program uses Euclidean algorithm.
Recursive factorial and Fibonacci follow base and recursive cases.
Exponent calculation uses recursion.
UNIT III – Modules and Strings
Short Answers
1. Module is a file containing Python code.
2. Modules can be imported using import or from.
3. Module is single file; package is collection of modules.
4. String operations include concatenation and slicing.
5. Slicing extracts substring.
6. String methods include upper(), lower(), find(), replace().
7. Reverse string uses slicing.

Long Answers
Modules help reuse code; user-defined modules are created using .py files.
Built-in modules include math and random.
Strings are immutable and cannot be changed.
Programs can count vowels, digits, and spaces.
String methods and operations manipulate text.
UNIT IV – List, Tuple, Set, Dictionary
Short Answers
1. List is mutable; tuple is immutable.
2. List comprehension creates lists concisely.
3. Dictionary stores key-value pairs.
4. Dictionary methods manage data.
5. Set stores unique elements.
6. Set operations include union and intersection.
7. Tuple slicing is similar to list slicing.

Long Answers
List methods manage elements effectively.
Dictionary operations use keys and values.
Tuples are used for fixed data and function arguments.
File handling includes open, read, write, close.
map(), filter(), reduce() process data.
Set operations follow mathematical rules.
Programs can count words and demonstrate sets.
UNIT V – NumPy, Pandas & Matplotlib
Short Answers
1. Pandas Series is one-dimensional.
2. DataFrame is two-dimensional.
3. Missing values are NaN.
4. DataFrame operations describe data.
5. CSV files are read using read_csv().
6. NumPy supports numerical computing.
7. Arrays store homogeneous data.
8. Indexing and slicing access array parts.
9. Stacking combines arrays.
10. Reshaping changes dimensions.
11. Copy creates new data; view shares data.

Long Answers
Pandas Series and DataFrames organize data efficiently.
CSV reading enables data analysis.
Descriptive statistics summarize data.
NumPy arrays support fast computations.
Array reshaping and stacking organize data.
Placeholder arrays initialize data.
Matplotlib creates visualizations like scatter and histogram plots.

You might also like