UNIVERSITY INSTITUTE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING PYTHON PROGRAMMING (24CSP-203) Unit No. 1 Chapter No. 1.1 Lecture No. 1 Topic : Basics of Python Programming Academic Session 2025-26 ODD Semester Jul-Dec 2025 Dr. Gitanjali – E16525 Assistant Professor
Learning Objectives 1. Understand the purpose and features of Python as a programming language. 2. Write and execute basic Python programs using correct syntax and indentation. 3. Identify and apply various Python data types (int, float, str, bool, etc.). 4. Utilize built-in functions like print(), type(), id(), and range(). 1 Dr. Gitanjali – E16525 Assistant Professor
Topics Covered • Writing simple Python programs • Python basic data types: int, float, complex, bool, str • Declaring and using variables • Built-in functions: id(), type(), range() 2 Dr. Gitanjali – E16525 Assistant Professor
Introduction to Python What is Python? • Python is a high-level, interpreted, and general-purpose programming language. • It was created by Guido van Rossum and released in 1991. • Known for its simple and readable syntax, making it beginner-friendly. 3 Dr. Gitanjali – E16525 Assistant Professor
Introduction to Python Key Features of Python • Easy to Learn & Use – Uses English-like syntax (e.g., print("Hello, World!")). • Interpreted Language – No need for compilation, executes line by line. • Dynamically Typed – No need to declare variable types (x = 10 works directly). 4 Dr. Gitanjali – E16525 Assistant Professor
Introduction to Python Hello World in Python print() is a built-in function to display output. "Hello, World!" is a string that gets printed. 5 Dr. Gitanjali – E16525 Assistant Professor
Introduction to Python Why Learn Python? • Python works on different platforms (Windows, Mac, Linux, etc). • Python has a simple syntax similar to the English language. • Python has syntax that allows developers to write programs with fewer lines than some other programming languages. 6 Dr. Gitanjali – E16525 Assistant Professor
Identifiers: Identifiers are the names that identify the elements such as variables and functions in a program. All identifiers must obey the following rules: An identifier is a sequence of characters that consists of letters, digits, and underscores (_). 7 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
An identifier must start with a letter or an underscore. It cannot start with a digit. An identifier cannot be a keyword. An identifier can be of any length. Python is case sensitive, area, Area, and AREA are all different identifiers. 8 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
Named Constants: A named constant is an identifier that represents a permanent value. The value of a variable may change during the execution of a program, but a named constant (or simply constant) represents permanent data that never changes. 9 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
Python does not have a special syntax for naming constants. If you have to change the constant’s value (e.g., from 3.14 to 3.14159 for PI), you need to change it only in a single location in the source code. Descriptive names make the program easy to read. 10 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
What is a Variable? In Python, variables are used to store data that can be referenced and manipulated during program execution. A variable is essentially a name that is assigned to a value. Unlike many other programming languages, 11 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
Python variables do not require explicit declaration of type. The type of the variable is inferred based on the value assigned. Variables act as placeholders for data. They allow us to store and reuse values in our program. 12 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
Rules for Naming Variables To use variables effectively, we must follow Python’s naming rules: Variable names can only contain letters, digits and underscores (_). A variable name cannot start with a digit. Variable names are case-sensitive (myVar and myvar are different). 13 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
Data Types in Python Python Data types are the classification or categorization of data items. It represents the kind of value that tells what operations can be performed on a particular data. Since everything is an object in Python programming, Python data types are classes and variables are instances (objects) of these classes. 14 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
15 Writing Python Program
Python Functions Python Functions is a block of statements that return the specific task. The idea is to put some commonly or repeatedly done tasks together and make a function so that instead of writing the same code again and again for different inputs, we can do the function calls to reuse code contained in it over and over again. 16 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
Some Benefits of Using Functions • Increase Code Readability • Increase Code Reusability • Improves Maintainability • Simplifies Testing 17 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
Types of Functions in Python Below are the different types of functions in Python: Built-in library function: These are Standard functions in Python that are available to use. User-defined function: We can create our own functions based on our requirements. 18 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
19 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
Built-in Functions: id():The id() function returns a unique identifier for a given object. This identifier is unique and constant for the object during its lifetime. 20 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
type(): The type() function in Python is used to determine the type of an object. This function returns the type of the specified object. 21 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
range(): The range() function generates a sequence of numbers, which is often used for looping a specific number of times in for loops. 22 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
Applications of the Topic • Calculator Programs • Student Grade Evaluators Application • Text-Based Games and Quizzes • Data Entry Forms (CLI-based) • Simple Automation Scripts 23 Dr. Gitanjali – E16525 Assistant Professor
Summary of the Lecture 6 1. Python is a high-level, interpreted language created by Guido van Rossum. 2. Features: easy syntax, dynamically typed, portable. Covered: writing basic Python programs using print(), identifiers, variables, and naming rules. 3. Discussed built-in functions: id(), type(), and range(). 4. Introduced constants and basic data types: int, float, str, bool, etc. Dr. Gitanjali – E16525 Assistant Professor
Next Lecture 7 Dr. Gitanjali – E16525 Assistant Professor Topic(s) • Operators in Python • Control structures: if, if-else, if-elif-else, loops (for, while) • Logical thinking through real-life examples
1. What is the correct way to display output in Python? A. echo "Hello, World!" B. output("Hello, World!") C. print("Hello, World!") D. display("Hello, World!") 26 Quiz/ FAQ’s Dr. Gitanjali – E16525 Assistant Professor
Which of the following is NOT a rule for naming identifiers in Python? A. Identifiers can contain letters, digits, and underscores. B. Identifiers can start with a digit. C. Identifiers are case-sensitive. D. Identifiers cannot be Python keywords. 27 Quiz/ FAQ’s Dr. Gitanjali – E16525 Assistant Professor
What is the purpose of using functions in Python? A. To store large amounts of data B. To print outputs repeatedly C. To reuse blocks of code and improve readability D. To assign memory addresses 28 Quiz/ FAQ’s Dr. Gitanjali – E16525 Assistant Professor
References/ Articles/ Videos 29 Dr. Gitanjali – E16525 Assistant Professor Suggestive Readings • Think Python How to Think Like a Computer Scientist (Allen B. Downey) • Fundamentals of Python First Programs, 2nd Edition (Kenneth A. Lambert) • Programming and Problem Solving with Python (Ashok Namdev Kamthane , Amit Ashok Kamthane)
Faculty-curated videos, NPTEL, Coursera, LinkedIn, or other relevant learning resources 30 Dr. Gitanjali – E16525 Assistant Professor • https://www.coursera.org/specializations/python • https://www.coursera.org/learn/python-crash-cour se • https://nptel.ac.in/courses/106106182
Class-Wise Feedback 29 Dr. Gitanjali – E16525 Assistant Professor
Thank You 32

Unit 1- 1.1 python.pptx for also python you

  • 1.
    UNIVERSITY INSTITUTE OFENGINEERING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING PYTHON PROGRAMMING (24CSP-203) Unit No. 1 Chapter No. 1.1 Lecture No. 1 Topic : Basics of Python Programming Academic Session 2025-26 ODD Semester Jul-Dec 2025 Dr. Gitanjali – E16525 Assistant Professor
  • 2.
    Learning Objectives 1. Understandthe purpose and features of Python as a programming language. 2. Write and execute basic Python programs using correct syntax and indentation. 3. Identify and apply various Python data types (int, float, str, bool, etc.). 4. Utilize built-in functions like print(), type(), id(), and range(). 1 Dr. Gitanjali – E16525 Assistant Professor
  • 3.
    Topics Covered • Writingsimple Python programs • Python basic data types: int, float, complex, bool, str • Declaring and using variables • Built-in functions: id(), type(), range() 2 Dr. Gitanjali – E16525 Assistant Professor
  • 4.
    Introduction to Python Whatis Python? • Python is a high-level, interpreted, and general-purpose programming language. • It was created by Guido van Rossum and released in 1991. • Known for its simple and readable syntax, making it beginner-friendly. 3 Dr. Gitanjali – E16525 Assistant Professor
  • 5.
    Introduction to Python KeyFeatures of Python • Easy to Learn & Use – Uses English-like syntax (e.g., print("Hello, World!")). • Interpreted Language – No need for compilation, executes line by line. • Dynamically Typed – No need to declare variable types (x = 10 works directly). 4 Dr. Gitanjali – E16525 Assistant Professor
  • 6.
    Introduction to Python HelloWorld in Python print() is a built-in function to display output. "Hello, World!" is a string that gets printed. 5 Dr. Gitanjali – E16525 Assistant Professor
  • 7.
    Introduction to Python WhyLearn Python? • Python works on different platforms (Windows, Mac, Linux, etc). • Python has a simple syntax similar to the English language. • Python has syntax that allows developers to write programs with fewer lines than some other programming languages. 6 Dr. Gitanjali – E16525 Assistant Professor
  • 8.
    Identifiers: Identifiers arethe names that identify the elements such as variables and functions in a program. All identifiers must obey the following rules: An identifier is a sequence of characters that consists of letters, digits, and underscores (_). 7 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
  • 9.
    An identifier muststart with a letter or an underscore. It cannot start with a digit. An identifier cannot be a keyword. An identifier can be of any length. Python is case sensitive, area, Area, and AREA are all different identifiers. 8 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
  • 10.
    Named Constants: Anamed constant is an identifier that represents a permanent value. The value of a variable may change during the execution of a program, but a named constant (or simply constant) represents permanent data that never changes. 9 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
  • 11.
    Python does nothave a special syntax for naming constants. If you have to change the constant’s value (e.g., from 3.14 to 3.14159 for PI), you need to change it only in a single location in the source code. Descriptive names make the program easy to read. 10 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
  • 12.
    What is aVariable? In Python, variables are used to store data that can be referenced and manipulated during program execution. A variable is essentially a name that is assigned to a value. Unlike many other programming languages, 11 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
  • 13.
    Python variables donot require explicit declaration of type. The type of the variable is inferred based on the value assigned. Variables act as placeholders for data. They allow us to store and reuse values in our program. 12 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
  • 14.
    Rules for NamingVariables To use variables effectively, we must follow Python’s naming rules: Variable names can only contain letters, digits and underscores (_). A variable name cannot start with a digit. Variable names are case-sensitive (myVar and myvar are different). 13 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
  • 15.
    Data Types inPython Python Data types are the classification or categorization of data items. It represents the kind of value that tells what operations can be performed on a particular data. Since everything is an object in Python programming, Python data types are classes and variables are instances (objects) of these classes. 14 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
  • 16.
  • 17.
    Python Functions Python Functionsis a block of statements that return the specific task. The idea is to put some commonly or repeatedly done tasks together and make a function so that instead of writing the same code again and again for different inputs, we can do the function calls to reuse code contained in it over and over again. 16 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
  • 18.
    Some Benefits ofUsing Functions • Increase Code Readability • Increase Code Reusability • Improves Maintainability • Simplifies Testing 17 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
  • 19.
    Types of Functionsin Python Below are the different types of functions in Python: Built-in library function: These are Standard functions in Python that are available to use. User-defined function: We can create our own functions based on our requirements. 18 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
  • 20.
    19 Writing Python Program Dr.Gitanjali – E16525 Assistant Professor
  • 21.
    Built-in Functions: id():The id()function returns a unique identifier for a given object. This identifier is unique and constant for the object during its lifetime. 20 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
  • 22.
    type(): The type()function in Python is used to determine the type of an object. This function returns the type of the specified object. 21 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
  • 23.
    range(): The range()function generates a sequence of numbers, which is often used for looping a specific number of times in for loops. 22 Writing Python Program Dr. Gitanjali – E16525 Assistant Professor
  • 24.
    Applications of theTopic • Calculator Programs • Student Grade Evaluators Application • Text-Based Games and Quizzes • Data Entry Forms (CLI-based) • Simple Automation Scripts 23 Dr. Gitanjali – E16525 Assistant Professor
  • 25.
    Summary of theLecture 6 1. Python is a high-level, interpreted language created by Guido van Rossum. 2. Features: easy syntax, dynamically typed, portable. Covered: writing basic Python programs using print(), identifiers, variables, and naming rules. 3. Discussed built-in functions: id(), type(), and range(). 4. Introduced constants and basic data types: int, float, str, bool, etc. Dr. Gitanjali – E16525 Assistant Professor
  • 26.
    Next Lecture 7 Dr. Gitanjali– E16525 Assistant Professor Topic(s) • Operators in Python • Control structures: if, if-else, if-elif-else, loops (for, while) • Logical thinking through real-life examples
  • 27.
    1. What isthe correct way to display output in Python? A. echo "Hello, World!" B. output("Hello, World!") C. print("Hello, World!") D. display("Hello, World!") 26 Quiz/ FAQ’s Dr. Gitanjali – E16525 Assistant Professor
  • 28.
    Which of thefollowing is NOT a rule for naming identifiers in Python? A. Identifiers can contain letters, digits, and underscores. B. Identifiers can start with a digit. C. Identifiers are case-sensitive. D. Identifiers cannot be Python keywords. 27 Quiz/ FAQ’s Dr. Gitanjali – E16525 Assistant Professor
  • 29.
    What is thepurpose of using functions in Python? A. To store large amounts of data B. To print outputs repeatedly C. To reuse blocks of code and improve readability D. To assign memory addresses 28 Quiz/ FAQ’s Dr. Gitanjali – E16525 Assistant Professor
  • 30.
    References/ Articles/ Videos 29 Dr.Gitanjali – E16525 Assistant Professor Suggestive Readings • Think Python How to Think Like a Computer Scientist (Allen B. Downey) • Fundamentals of Python First Programs, 2nd Edition (Kenneth A. Lambert) • Programming and Problem Solving with Python (Ashok Namdev Kamthane , Amit Ashok Kamthane)
  • 31.
    Faculty-curated videos, NPTEL, Coursera,LinkedIn, or other relevant learning resources 30 Dr. Gitanjali – E16525 Assistant Professor • https://www.coursera.org/specializations/python • https://www.coursera.org/learn/python-crash-cour se • https://nptel.ac.in/courses/106106182
  • 32.
    Class-Wise Feedback 29 Dr. Gitanjali– E16525 Assistant Professor
  • 33.