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

Python Answers

The document provides an overview of key Python programming concepts including variables, data types, string operations, dictionary methods, error types, tuple characteristics, built-in functions, data conversion, control statements, string methods, and the distinction between call by value and reference. It highlights examples for clarity, such as variable assignments, string concatenation, and the use of operators. Additionally, it explains the differences between user-defined variables and reserved keywords.

Uploaded by

adilshaikh0207
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 views2 pages

Python Answers

The document provides an overview of key Python programming concepts including variables, data types, string operations, dictionary methods, error types, tuple characteristics, built-in functions, data conversion, control statements, string methods, and the distinction between call by value and reference. It highlights examples for clarity, such as variable assignments, string concatenation, and the use of operators. Additionally, it explains the differences between user-defined variables and reserved keywords.

Uploaded by

adilshaikh0207
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

Q1. Define variables and data types in Python.

Variables are containers to store data values. Python has data types like int, float, str, list, tuple, set,
dict. Example: x=10 (int), y=3.5 (float), name='Ali' (str)

Q2. Explain string concatenation and repetition.

Concatenation joins strings using '+'. Repetition uses '*'. Example: 'Hi'+'All'='HiAll', 'Hi'*3='HiHiHi'.
Methods like isdigit() and isalnum() check content.

Q3. Dictionary methods.

keys() returns keys, values() returns values, items() returns key-value pairs, get() fetches value
safely.

Q4. Difference between variables and keywords.

Variables are user-defined names. Keywords are reserved words like if, else, while. Built-in
functions: input(), print(), type().

Q5. Define errors.

Errors are mistakes in code. Types: Syntax error, Runtime error, Logical error.

Q6. Tuple creation and access.

Tuple is immutable. Example: t=(1,2,3). Access using index t[0].

Q7. Built-in functions.

min(), max(), sum(), abs() are used for calculations. Example: min([1,2])=1.

Q8. Data types and conversion.

Implicit conversion is automatic. Explicit uses functions like int(), float().

Q9. Decision control statement.

if-else is used. Example: if x>0: print('Positive').

Q10. String methods.

upper(), lower(), split(), replace(), strip() modify strings.

Q11. Call by value vs reference.

Value passes copy, reference passes original. Python uses object reference.

Q12. Operators.

Arithmetic (+,-), Logical (and,or), Relational (>,<) used in expressions.

You might also like