Python Programming Essentials: Input, Conditionals, Data Structures, and 2D Lists
User Input and Data Type Conversion
input()Function: Displays an optional prompt string on the console, pauses program execution, and waits for user input. Execution resumes when the user presses Enter.Default Data Type: The
input()function always returns user input as a string (String).Typecasting: Converts input data types using built-in functions such as
int(),float(), orstr()to perform arithmetic operations.height = input("Enter the giraffe's height: ")stores input as a string.height = int(input("Enter the giraffe's height: "))converts and stores input as an integer.
Conditional Logic
Branching Statements: Uses
if,elif, andelseblocks to direct program execution paths based on evaluated conditions.elifClause: Allows testing of multiple sequential conditions if precedingiforelifstatements evaluate to false.

Data Structures Comparison
Lists:
Enclosed in square brackets
[](e.g.,Class_8A = ["Choenjur", "Choki", "Tshering", "Tshewang"]).Ordered and mutable collections; elements can be modified, added, or removed.
Tuples:
Enclosed in parentheses
()(e.g.,new_colors = ("blue", "yellow", "brown", "red")).Ordered and immutable collections; elements cannot be modified, added, or deleted after creation.
Sets:
Enclosed in curly braces
{}.Unordered collections of unique elements; duplicate values are automatically ignored.
Set methods:
add(): Inserts an element into the set if it is not already present.pop(): Removes and returns an arbitrary element from the set.remove(): Removes a specified element from the set.

Dictionaries:
Enclosed in curly braces
{}containingkey : valuepairs.Keys must be unique; duplicate keys are not permitted.
Two-Dimensional Lists
Definition & Access: A 2D list is a list of lists representing a grid. Elements are accessed using row and column coordinates in the format
list[row][column].Memory Representation: Variables act as pointers in computer memory. Indexing a 2D list follows pointers from the outer list to the targeted inner list.
Chained Assignment: Multiple variable locations can be updated simultaneously using continuous assignment operators.
The
NoneKeyword: Represents a missing value or empty state in memory (distinct from numerical or empty lists).

Row Iteration: Iterating over elements in a single row is accomplished using a loop over
range(len(list[0])).