Python Day 1
Python Day 1
Introduction to computer systems, Algorithms and flowcharts, History and application areas
of Python, Features of Python, Setting up Python and IDEs, Understanding the Python
programming cycle, Simple Programming Problems.
This is a basic outline and notes on the fundamental concepts of computer systems designed
for first-year undergraduate students.
1. Hardware
○ Central Processing Unit (CPU): Executes instructions and processes data.
■ Control Unit (CU): Directs operations within the computer.
■ Arithmetic Logic Unit (ALU): Performs arithmetic and logical operations.
○ Memory:
■ Primary Memory (RAM, ROM): Stores data and instructions temporarily.
■ Secondary Memory (Hard drives, SSDs): Permanent storage of data.
○ Input Devices: Keyboard, mouse, microphone, etc.
○ Output Devices: Monitor, printer, speakers, etc.
○ Storage Devices: USB drives, optical disks, etc.
2. Software
○ System Software: Operating systems (Windows, macOS, Linux), utilities.
○ Application Software: Word processors, web browsers, games.
○ Programming Software: Tools like compilers, interpreters, and debuggers.
3. Data
○ Raw facts and figures processed into meaningful information.
○ Represented in binary (0s and 1s).
4. Users
○ End-users interact with the system to perform tasks.
○ Developers and system administrators maintain and enhance systems.
● Binary System: Computers use the binary number system (0s and 1s).
● Bits and Bytes:
○ 1 bit = smallest unit of data (0 or 1).
○ 1 byte = 8 bits (e.g., 10101100).
● Data Units: Kilobyte (KB), Megabyte (MB), Gigabyte (GB), Terabyte (TB).
● A critical system software that manages hardware, software, and user interaction.
● Functions:
1. Process Management: Scheduling and execution of processes.
2. Memory Management: Allocating and freeing memory.
3. File System Management: Organizing and accessing files.
4. Device Management: Controlling input/output devices.
5. Security and Access Control: Protecting data and resources.
● Examples: Windows, Linux, macOS, Android.
8. Computer Networks
9. Evolution of Computers
● Generations of Computers:
1. First Generation (1940-1956): Vacuum tubes, large and slow.
2. Second Generation (1956-1963): Transistors replaced vacuum tubes.
3. Third Generation (1964-1971): Integrated Circuits (ICs).
4. Fourth Generation (1971-Present): Microprocessors and personal computers.
5. Fifth Generation (Present and Beyond): AI and quantum computing.
ALGORITHM
● Algorithm refers to the logic of the program. It is a step by step description of how to
arrive at the solution of the problem.
● An algorithm is a complete, detailed and precise step by step method for solving a
problem independently of the hardware and software.
1. Begin
2. Input the value of A and B
3. SUM= A+B
4. Display SUM
5. End.
FLOWCHART
● A flowchart is a pictorial representation of an algorithm or process.
Symbols used:
Example: Flow-Chart to find sum of two numbers
Installing Python
1. Download Python:
○ Go to the official website: https://www.python.org/.
○ Download the latest version for your operating system.
2. Install Python:
○ Follow the installation wizard and ensure the "Add Python to PATH" option is
selected.
3. Verify Installation:
python --version
or
python3 --version
1. IDLE:
○ Comes pre-installed with Python.
○ Lightweight, suitable for beginners.
2. PyCharm:
○ Advanced IDE with features like debugging, testing, and version control.
3. Visual Studio Code (VS Code):
○ Lightweight and extensible editor with Python plugins.
4. Jupyter Notebook:
○ Ideal for data science and interactive computing.
5. Spyder:
○ Popular among scientific computing users.
6. Thonny:
○ Beginner-friendly IDE with simple debugging tools.
Example:
print("Hello, World!")
In a terminal:
python hello.py
print("Hello, World!")
5. Testing:
○ Test your code with various inputs to ensure reliability.
Example:
def add(a, b):
return a + b
print(add(2, 3)) # Output: 5
6. Iterating:
○ Modify and refine the code based on requirements or errors.
Example:
a = 5
b = 10
print(a + b) # Outputs: 15
Basic Programs:
# Displaying results
print("Addition:", addition)
Perimeter:
The perimeter is the sum of all three sides of the triangle:
Perimeter=a+b+c
import math
# Area calculation
area = math.sqrt(s * (s - a) * (s - b) * (s - c))
# Conversion formula
c= (f - 32) * 5 / 9
# Displaying the result
print(f"{f}°F is equal to {c:.2f}°C")
import math
surface_area = 2 * math.pi * r * (r + h)
import math
h= math.sqrt(side1**2 + side2**2)