
Python Programming Concepts and Basics Review
Discover key Python programming concepts such as variables, data types, syntax, and conditionals in this comprehensive review. Dive into the fundamentals of Python and prepare yourself for coding success.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
CSE1300 Review
NOTE: Please note that I have added the review materials of only for topics after the Midterm exam as we had one slide deck of review slides for all the topics Please make sure to read all the materials before the midterm as well for your final exam. before the midterm.
Introduction to Python - What is Python? Python is a high-level, interpreted programming language created by Guido van Rossum. Emphasizes code readability with a syntax similar to English. General-purpose: Used in web development, data science, scripting, automation, and more. Has a vast ecosystem with libraries like NumPy, Pandas, and frameworks like Django, Flask. Python uses indentation instead of brackets to define blocks of code. Example Scenario: Writing a script to automate email notifications using Python is more readable and concise than other languages.
Input, Output, and Variables input() reads user input as a string. print() displays output. Variables store data; no need to declare types. Example: name = input("Enter your name: ") print("Welcome,", name) Example Scenario: Creating a user-friendly greeting interface for a simple application.
Data Types and Type Conversion Primitive: int, float, str, bool, NoneType Collections: list, tuple, dict, set Type conversion: int("5"), float("3.14") Example Scenario: Asking for age and calculating eligibility for voting.
Python Syntax, Comments, and Errors Python is case-sensitive: Name != name Use # for comments; triple quotes (''') for docstrings. Common Errors: SyntaxError, IndentationError, NameError, TypeError Example: # This is a comment x = 10 print(x) Debugging Tip: Use print statements or IDE debuggers to track variable values
Conditionals (if, elif, else) if age >= 18: print("Adult") elif age > 12: print("Teen") else: print("Child") Logical Operators: and, or, not Nesting allows complex decision logic. Example Scenario: Age verification for an online service. Used for decision-making.
Loops (for, while) for loops iterate over sequences (lists, strings). while loops run as long as a condition is true. break exits loop; continue skips to next iteration. Example: for i in range(5): print(i) Example Scenario: Creating a countdown timer or menu loop.
Built-In Libraries math: Math functions (sqrt, pow, pi) random: Random values (choice, randint) datetime: Date and time operations os: File system access sys: System parameters and CLI args Example Scenario: Using random.choice() to simulate a dice roll.
Raspberry Pi and GPIO Basics Raspberry Pi: Affordable, compact computer with GPIO pins. GPIO (General Purpose Input/Output) allows hardware control. Python and GPIO library used for automation and control projects. Example: Blink an LED connected to GPIO pin 18.
Robotics with Artie 3000 Robots sense, move, and use energy to function. Sensors include light, sound, and touch. Artie 3000 is a drawing robot programmable via loops and commands. Example Scenario: Draw a star using loops and angles.