[go: up one dir, main page]

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

Unit 1 - Notes - Py.pd

Python notes and some topics based points
Copyright
© © All Rights Reserved
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% found this document useful (0 votes)
2 views5 pages

Unit 1 - Notes - Py.pd

Python notes and some topics based points
Copyright
© © All Rights Reserved
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/ 5

Unit 1: Introduction to Computational Problem Solving & Python

Programming
1. Computational Problem Solving

 Essence of Problem Solving:

 Understanding the problem

 Clearly defining the problem

 Identifying inputs, processes, and desired outputs

 Designing a solution (algorithm)

 Creating a step-by-step plan or algorithm

 Choosing appropriate data structures and logic

 Implementing it (writing code)

 Translating the algorithm into a programming language (e.g., Python)

 Ensuring the code follows correct syntax and logic

 Testing and debugging

 Running the program with different inputs

 Fixing errors (bugs) and improving performance

2. Limits of Computation:

 Some problems are not computable.


 Some require too much time or memory to solve practically.

Key Concepts:

Algorithms: Step-by-step procedure to solve a problem.

Hardware vs Software: Hardware runs the software. Software includes OS, programs, etc.

---

2. Introduction to Python Programming

Python Features (from Mark Lutz):

Interpreted, dynamically typed

Simple syntax

Strong support for object-oriented programming

Basic Elements in Python:

a. Literals

Constants in Python:

Example: 10, 3.14, 'hello', True


b. Variables and Identifiers

Variables: Named references to data

Example: x = 5

Identifiers: Names must start with a letter or underscore, can’t be a keyword.

c. Data Types

int, float, str, bool, list, tuple, dict, set

Use type() to check types

d. Expressions and Operators

Arithmetic Operators: +, -, *, /, //, %, **

Comparison: ==, !=, <, >, <=, >=

Logical: and, or, not

e. Input/Output

Input from user: input("Enter value: ")

Output: print("Hello World")

3. Python Syntax Essentials


Whitespace/Indentation is significant in Python

No {} or ; — instead, code blocks are defined by indentation.

4. Practice Examples (from Learning Python)

# Example 1: Simple arithmetic

a = 10

b = 20

sum = a + b

print("Sum:", sum)

# Example 2: Input and type casting

name = input("Enter your name: ")

age = int(input("Enter your age: "))

print(f"Hello {name}, you are {age} years old.")

# Example 3: Expression

x=5

y=3

result = x**2 + y

print("Result:", result)

5.Summary

Topic Key Points

Problem Solving Algorithmic thinking, implementation, debugging


Python Basics Interpreted, readable syntax, supports OOP

Variables/Literals Containers for data, constants used directly

Operators Arithmetic, logical, comparison

Input/Output input() and print() for interaction

Data Types Python supports multiple built-in types

You might also like