The document defines various Python programming concepts including logical operators, loops, functions, classes, exceptions, and more. Each concept includes a brief description and examples of syntax and code. Some key concepts covered include if/else statements, for/while loops, functions, classes, exceptions, comparison operators, and logical operators.
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 ratings0% found this document useful (0 votes)
17 views16 pages
Python Fundamentals
The document defines various Python programming concepts including logical operators, loops, functions, classes, exceptions, and more. Each concept includes a brief description and examples of syntax and code. Some key concepts covered include if/else statements, for/while loops, functions, classes, exceptions, comparison operators, and logical operators.
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
You are on page 1/ 16
Package/Method Description Syntax and Code Example
AND Returns `True` if both
statement1 and statement2 are `True`. Otherwise, returns `False`. Class Definition Defines a blueprint for creating objects and defining their attributes and behaviors.
Function A `function` is a reusable
Definition block of code that performs a specific task or set of tasks when called. Equal(==) Checks if two values are equal. For Loop A `for` loop repeatedly executes a block of code for a specified number of iterations or over a sequence of elements (list, range, string, etc.).
While Loop A `while` loop repeatedly
executes a block of code as long as a specified condition remains `True`. Loop Control `break` exits the loop prematurely. `continue` skips the rest of the current iteration and moves to the next iteration. Function Call A function call is the act of executing the code within the function using the provided arguments.
Greater Than(>) Checks if the value of
variable1 is greater than variable2. Greater Than or Checks if the value of Equal To(>=) variable1 is greater than or equal to variable2.
IF statement Executes code block `if` the
condition is `True`. If-Else Statement Executes the first code block if the condition is `True`, otherwise the second block. IF-Elif-Else Executes the first code block if condition1 is `True`, otherwise checks condition2, and so on. If no condition is `True`, the else block is executed. Less Than(<) Checks if the value of variable1 is less than variable2. Less Than or Checks if the value of Equal To(<=) variable1 is less than or equal to variable2.
NOT Returns `True` if the variable
is `False`, and vice versa. Not Equal(!=) Checks if two values are not equal.
Object Creation Creates an instance of a class
(object) using the class constructor. OR Returns `True` if either statement1 or statement2 (or both) are `True`. Otherwise, returns `False`.
range() Generates a sequence of
numbers within a specified range. Return Statement `Return` is a keyword used to send a value back from a function to its caller.
Try-Except Block Tries to execute the code in
the try block. If an exception of the specified type occurs, the code in the except block is executed. Try-Except with Code in the `else` block is Else Block executed if no exception occurs in the try block. Try-Except with Code in the `finally` block Finally Block always executes, regardless of whether an exception occurred.