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

Applied Python Programming Viva

Uploaded by

Ss
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Applied Python Programming Viva

Uploaded by

Ss
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

APPLIED PYTHON PROGRAMMING

VIVA QUESTION AND ANSWERS

1. What is Python, and how is it different from other programming languages?

2. Explain the difference between Python 2 and Python 3.

3. What are the advantages of using Python for programming?

4. Describe the process of installing Python on a computer.

5. What is a Python interpreter, and how does it work?

6. How do you write a comment in Python, and why are comments useful?

7. Explain the concept of Python's indentation and its significance.

8. What is the purpose of the "print" function in Python, and how is it used?

9. Describe the role of variables in Python. How are they declared and assigned values?

10. Explain the difference between mutable and immutable data types in Python.

11. What are the basic data types in Python? Provide examples for each.

12. How do you perform type conversion (casting) in Python?

13. What are operators in Python, and what are the different types of operators?

14. How does Python handle arithmetic operations involving different data types?

15. Explain the use of logical operators in Python.

16. What is the difference between "if," "elif," and "else" statements in Python?

17. Describe the purpose of loops in programming and provide examples of "for" and "while" loops

in Python.

18. How do you exit a loop prematurely using "break" and "continue" statements?

Answers

1. Python is a high-level, interpreted programming language known for its simple and readable
syntax.

2. Python 3 is the latest version with improved features, while Python 2 is outdated and no
longer supported.

3. Python is easy to learn, versatile, portable, and has a large standard library.

4. Install Python by downloading it from the official website, running the installer, and adding it
to the system PATH.

5. A Python interpreter reads and executes Python code line by line.

6. Comments are written using # (or triple quotes for multi-line text) and help explain the code.
7. Indentation defines code blocks in Python and is mandatory for proper program structure.

8. The print() function displays output on the screen.

9. Variables store data and are created by assigning values using the = operator.

10. Mutable data types can be changed after creation, while immutable data types cannot.

11. Basic Python data types include int, float, str, bool, list, tuple, set, and dict.

12. Type conversion is performed using functions like int(), float(), str(), and bool().

13. Operators perform operations on data and include arithmetic, comparison, logical,
assignment, bitwise, identity, and membership operators.

14. Python automatically converts compatible data types during arithmetic operations (type
promotion).

15. Logical operators (and, or, not) are used to combine or negate conditions.

16. if checks a condition, elif checks additional conditions, and else executes when all conditions
are false.

17. Loops repeat a block of code, with for used for sequences and while used for condition-
based repetition.

18. break exits a loop immediately, while continue skips the current iteration and proceeds to
the next one.

Applied Libraries (NumPy, Pandas, Matplotlib)

 What is NumPy and why use it over Python lists?


NumPy provides multi-dimensional, homogeneously-typed array objects. It uses contiguous
memory blocks to execute vector operations dramatically faster than raw Python loops.

 What is vectorization in NumPy?


The practice of applying mathematical operations to an entire array at once rather than
looping over separate elements.

 What is the core difference between a Pandas Series and a DataFrame?


A Series is a one-dimensional labeled array. A DataFrame is a two-dimensional, size-mutable
tabular data structure containing labeled rows and columns.

 How do you read a CSV file using Pandas?


By invoking the pandas.read_csv('[Link]') function, which automatically parses the file
formatting into a structured DataFrame object.

 What is Matplotlib used for?


An external visualization and plotting library used to construct static histograms, scatter
plots, line graphs, and bar charts from array-like inputs

Core Hardware & OS Fundamentals

 What does GPIO stand for and what is its primary function?

o Answer: GPIO stands for General Purpose Input/Output. These programmable pins
act as physical switches allowing the Raspberry Pi to interact with external hardware,
either sending signals out to components like LEDs or receiving signals from input
hardware like sensors.

 How many pins are on a standard modern Raspberry Pi GPIO header?

o Answer: Modern versions (like Raspberry Pi 3, 4, and 5) feature a standard 40-pin


header.

 What logic voltage level do the Raspberry Pi GPIO pins operate on?

o Answer: They operate at 3.3V logic levels. Supplying 5V to an input pin can
permanently destroy the Raspberry Pi's processor.

 What is Raspberry Pi OS, and what IDE comes pre-installed for Python programming?

o Answer: Raspberry Pi OS is a Linux-based operating system (formerly known as


Raspbian). It comes pre-installed with the Thonny IDE or IDLE for writing and
debugging Python scripts.

 How do you access system hardware and interface settings on Raspberry Pi OS via
terminal?

o Answer: By running the command sudo raspi-config, which opens a utility tool to
easily enable peripheral interfaces like I2C, SPI, and Serial.

Python Programming for GPIO Interfacing

 Which fundamental Python libraries are used to control GPIO hardware?

o Answer: The [Link] library is historically the most widespread framework. For
modern Python scripts, gpiozero is widely preferred for its simpler, object-oriented
approach.

 Explain the difference between [Link] and [Link] numbering modes.

o Answer: [Link] references pins by their physical plug positions (1 through 40)
sequentially on the board. [Link] references pins by their Broadcom SoC
channel numbers (e.g., GPIO17), which do not line up sequentially with physical
positions

 Why must you include [Link]() at the end of a hardware control script?

o Answer: It safely resets all modified pins back to default, safe states (input mode).
This prevents short-circuits or unexpected states when starting a different Python
application next time.

 What function configures whether a specific pin behaves as an input or an output?

o Answer: The [Link](pin, mode) function, where mode is set to either [Link]
or [Link].

 How do you transmit a high or low digital state to an active component in code?

o Answer: By calling [Link](pin, state), sending either a [Link] (3.3V) or


[Link] (0V) signal to the target node.

Practical Scenarios & Advanced Interfacing


 How do you read the current digital state of an interactive push-button?

o Answer: Use the function [Link](pin), which yields a boolean-like binary return
of True (High) or False (Low).

 What are pull-up and pull-down resistors, and why do input circuits need them?

o Answer: They prevent floating pin states when an input switch is left open. Pulling a
pin internally to a clean reference (GPIO.PUD_UP or GPIO.PUD_DOWN) prevents
random electrical noise from triggering false-positive readings in your loop.

 What is PWM, and what hardware components is it used for?

o Answer: Pulse Width Modulation mimics an analog voltage signal by rapidly pulsing
a digital pin on and off. It is commonly implemented in Python to dim LEDs, adjust
DC motor speeds, or drive servo motor angles.

 What standard serial communication protocols are supported on the GPIO block?

o Answer: The header natively exposes hardware pins optimized for I2C, SPI, and
UART (serial) protocols, which allow the Pi to parse complex data arrays from
external displays or multi-channel sensors.

 How do you generate an artificial time delay between blinking states in Python?

o Answer: By importing the native system module time and executing the
[Link](seconds) function inside your loop.

You might also like