0% found this document useful (0 votes)
8 views

python-unit-i-2

This document provides an introduction to Python programming, covering essential computer components, input and output devices, and the Central Processing Unit (CPU). It also highlights the applications of programming in mechanical engineering, program design tools like algorithms and flowcharts, and key features of Python as a programming language. Additionally, it discusses the installation and use of Integrated Development Environments (IDEs) for Python development.

Uploaded by

sayalipawar757
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

python-unit-i-2

This document provides an introduction to Python programming, covering essential computer components, input and output devices, and the Central Processing Unit (CPU). It also highlights the applications of programming in mechanical engineering, program design tools like algorithms and flowcharts, and key features of Python as a programming language. Additionally, it discusses the installation and use of Integrated Development Environments (IDEs) for Python development.

Uploaded by

sayalipawar757
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Unit - I Introduction to Python Programming

Introduction
In last few year Python has been priority of many software developers. Its
importance as programming point of view is always growing. Python has already introduced
in India by various university. So to develop python program we first know various
terminology related to python.in next some sub point we first introduce some terminologies
related to Hardware & Software part also we can revise some part of computer in unit I then
in next unit we introduce some python basics & some python programming skill.

1.1Revision of Computer Components (CPU, I/O devices):-


1.1.1 Definition of Computer system:
Computer system is an electronic device which can perform various arithmetic
& logical operation within microsecond of time. Now to understand more about
computer and its working following diagram give some sort of detail about computer
& its peripherals.

Now if we discuss about above block diagram there are various part of computer system.
Generally known as components of computer system. In above diagram we can see,
various components of computer system all these components are explain as below.
1.1.2 Computer Components:
1.1.2.1 Input Device:-
Input Unit: An input device is a hardware component used to provide data and
control signals to a computer or other electronic system. Input devices allow users to interact
with the computer, enter information, and command the computer to perform specific tasks.

Characteristics of Input Devices

 User Interface: Facilitates interaction between the user and the computer.
 Data Entry: Captures user input in various forms (text, audio, visual, etc.).
 Control Signals: Sends commands to the computer to execute actions.

Common Examples of Input Devices

1. Keyboard: A peripheral device used to input text and commands through keys.
Keyboards typically have alphanumeric keys, function keys, and control keys.
2. Mouse: A pointing device used to interact with graphical elements on a screen. It
detects two-dimensional motion relative to a surface, translating it into cursor
movement.
3. Touchscreen: A display that also serves as an input device, allowing users to interact
with the computer by touching the screen directly.
4. Scanner: Converts physical documents and images into digital form, allowing the
computer to process and store them.
5. Microphone: Captures audio input for voice commands, recording, or
communication.
6. Webcam: Captures video input for video calls, recording, and streaming.
7. Game Controller: Used primarily for gaming, providing input through buttons,
joysticks, and other controls.
8. Barcode Scanner: Reads barcodes and converts them into digital data that the
computer can process.
9. Digital Camera: Captures and inputs digital photographs and videos.

How Input Devices Work

Input devices convert physical actions (such as typing on a keyboard or clicking a mouse)
into electronic signals that a computer can understand and process. These signals are then
translated into appropriate responses by the computer's software, enabling tasks such as text
entry, navigation, and command execution.

Importance of Input Devices

 User Interaction: They are essential for user interaction with computers, enabling
tasks ranging from simple text entry to complex data manipulation.
 Accessibility: Provide various ways for users to input data, catering to different needs
and preferences.
 Productivity: Enhance productivity by allowing efficient and precise control over
computer functions.
1.1.2.2 Output Device:-

Definition of an Output Device

An output device is a hardware component used to communicate the results of data


processing carried out by a computer to the user or another device. These devices take digital
data from the computer and convert it into a form that humans can perceive, such as visual,
auditory, or physical output.

Characteristics of Output Devices

 User Interface: Presents information and feedback to the user.


 Data Conversion: Converts digital data into human-readable or perceivable forms.
 Response and Interaction: Provides a means for the computer to respond to user
inputs and actions.

Common Examples of Output Devices

1. Monitor: A display screen that presents visual output from the computer. Monitors
can display text, images, videos, and the graphical user interface (GUI) of the
operating system and applications.
2. Printer: Produces physical copies of digital documents and images on paper or other
media. Common types include inkjet, laser, and dot matrix printers.
3. Speakers: Output devices that produce sound, allowing users to hear audio from the
computer, such as music, voice, or sound effects.
4. Headphones: Personal audio output devices that provide sound directly to the user's
ears, often used for private listening.
5. Projector: Projects visual output from the computer onto a larger screen or surface,
commonly used for presentations and large displays.
6. Plotter: A specialized printer used for printing vector graphics, such as engineering
drawings and architectural plans.
7. Braille Display: Converts text into Braille characters, allowing visually impaired
users to read digital text through tactile feedback.
8. LED Indicators: Simple output devices that provide visual feedback using light-
emitting diodes, often used in hardware interfaces to indicate status.

How Output Devices Work:-Output devices receive processed data from the computer
and convert it into a form that can be perceived by humans or used by other devices. For
example, a monitor converts digital signals into images and text, while speakers convert
digital audio signals into sound.

Importance of Output Devices

 Communication: Essential for the computer to communicate results and feedback to


the user.
 Interaction: Enable interaction with the computer by providing responses to user
inputs.
 Accessibility: Offer various means for users to perceive and interact with computer
data, catering to different needs and preferences.
1.1.2.3 Definition of CPU

The Central Processing Unit (CPU), often referred to as the "brain" of the computer, is a
critical component responsible for executing instructions and processing data. It performs the
basic arithmetic, logic, control, and input/output operations specified by the instructions in
the program.

Key Components of the CPU

1. Control Unit (CU)


o Function: Directs the operation of the processor by telling the computer's
memory, arithmetic/logic unit, and input and output devices how to respond to
the instructions that have been sent to the processor.
o Role: It interprets the instructions from the computer’s memory and converts
them into signals to activate other parts of the computer.
2. Arithmetic Logic Unit (ALU)
o Function: Performs arithmetic operations (such as addition and subtraction)
and logic operations (such as comparison operations).
o Role: Handles all the mathematical calculations and logical decision-making
processes.
3. Registers
o Function: Small, fast storage locations within the CPU that temporarily hold
data and instructions.
o Role: Used to quickly store, transfer, and retrieve data and instructions needed
during the execution of programs.

CPU Performance Factors

1. Clock Speed
o Measured in gigahertz (GHz), it indicates the number of cycles the CPU can
execute per second. Higher clock speeds generally mean faster processing
times.
2. Cores
o Modern CPUs contain multiple cores, each capable of executing instructions
independently. More cores can significantly improve performance for
multitasking and parallel processing.
3. Threads
o Threads are the smallest sequence of programmed instructions that the CPU
can manage independently. CPUs with more threads can handle more tasks
simultaneously, improving efficiency and speed.
4. Cache Memory
o A small-sized type of volatile computer memory that provides high-speed data
access to the CPU and improves processing speed by storing frequently used
instructions and data.
Functions of the CPU

 Instruction Fetching: Retrieves instructions from the computer’s memory.


 Instruction Decoding: Interprets and converts the instructions into signals that direct
other parts of the computer.
 Instruction Execution: Performs the operations indicated by the instructions.
 Data Processing: Handles data manipulation through arithmetic and logic operations.
 Data Transfer: Moves data between the CPU, memory, and other components.

Importance of the CPU

 Primary Processor: As the central component, it manages all operations of the


computer, making it crucial for system performance.
 Task Management: Executes and manages tasks from running applications and
operating systems, ensuring the system functions smoothly and efficiently.

1.2Applications of computer and programming languages in Mechanical


engineering domain.:- Now in current days there is tremendous changes
done in the field of mechanical engineering. Mechanical Engineering
leverages computers and programming languages extensively for design,
analysis, and optimization of mechanical systems.

Here are some key applications that involve programming language.

1.2.1 Computer-Aided Design (CAD):

Software: AutoCAD, Solid Works, CATIA, PTC Creo

Applications:

3D Modelling: Creating detailed 3D models of mechanical components and


assemblies.

Simulation: Testing mechanical designs under various conditions (e.g., stress,


strain).

Drafting: Generating technical drawings and schematics for manufacturing.

2. Finite Element Analysis (FEA)

Software: ANSYS, Abaqus, COMSOL Multiphysics

Applications:

Structural Analysis: Assessing how mechanical parts withstand forces and


loads.
Thermal Analysis: Evaluating heat transfer and temperature distribution in
components.

Fluid Dynamics: Simulating the behavior of fluids in mechanical systems (e.g.,


airflow, fluid flow).

3. Computational Fluid Dynamics (CFD)


Software: Fluent, Open FOAM, STAR-CCM+

Applications:

Flow Analysis: Studying the behaviour of fluids around objects and within
systems.

Heat Transfer: Analysing thermal interactions and efficiencies in heat


exchangers and other devices.

Design Optimization: Improving designs for better aerodynamic or


hydrodynamic performance.

4. Manufacturing and Process Simulation

Software: MATLAB, Simulink, Tecnomatix

Applications:

Process Simulation: Modelling and optimizing manufacturing processes (e.g.,


machining, welding).

Robotics: Designing and programming robotic systems for automation and


manufacturing tasks.

Supply Chain Management: Optimizing logistics and production schedules.

5. Control Systems and Automation

Software: MATLAB/Simulink, LabVIEW, PLC programming tools

Applications:

System Design: Developing control systems for machinery and automated


systems.
Simulation: Testing control strategies and system responses before
implementation.

Monitoring and Diagnostics: Creating systems for real-time monitoring and


troubleshooting.

6. Optimization and Algorithms

Software: MATLAB, Python (with libraries such as SciPy), GAMS

Applications:

Design Optimization: Using algorithms to find optimal design parameters and


configurations.

Resource Management: Optimizing resource allocation and operational


efficiency in manufacturing.

Structural Optimization: Refining designs to minimize weight and material


usage while maintaining performance.

7. Data Analysis and Visualization

Software: Python (with libraries like Pandas, Matplotlib), Excel, MATLAB

Applications:

Data Processing: Analyzing experimental data from tests and simulations.

Visualization: Creating graphs, charts, and plots to interpret data and


communicate results.

Machine Learning: Applying algorithms to predict performance and identify


patterns.

8. Virtual and Augmented Reality

Software: Unity, Unreal Engine, VR/AR toolkits

Applications:

Design Visualization: Creating immersive 3D models and simulations for


design review and validation.

Training and Simulation: Developing VR/AR training modules for operating


machinery and systems.
1.3 Program Designing Tools: Algorithm, Flow Chart.

While doing programming is part of software system. To developing any


software require some programming skill . when to develop program
required some algorithm and flow chart concept for the same, so in this
section first we study about meaning of algorithm and flow chart.

1.3.1 Algorithm:

Algorithm means step by step solution to provide any problem .so when to write
any program there is certain process to complete program. According to process
first we have to write problem statement of program then we can create
algorithm for the program and after algorithm we can design flow chart of
program . for above discussion let us one example of to write program of
addition of two number following are step to write algorithm. In other word ,An
algorithm is a finite sequence of well-defined, step-by-step instructions
designed to perform a specific task or solve a particular problem. Algorithms
can be implemented in various forms, including natural language, pseudo code,
or programming languages, and they provide a systematic approach to
processing data or performing computations.

Ex- Algorithm to add two no.

1.Start

2 Declare three variable namely a,b,c.

3 Perform operation on variable.

4 c=a+b

5 Show result ( c )

6 Stop
1.3.2 Flow Chart

A flowchart is a Pictorial representation of an algorithm . Flow chart uses


various symbols to depict the sequence of steps involved, illustrating how
different components of a process interact. Flowcharts are commonly used in
programming, engineering, and business processes to visually represent
workflows, processes, and decision-making sequences.

ll the most common flowchart symbols you need to know, and how to use
them.

Flowchart is a very intuitive method to describe processes. As such, in most


cases, you don’t need to worry too much about the standards and rules of all
the flowchart symbols. In fact, a simple flowchart, constructed with just
rectangular blocks and flow lines, can already get most jobs done.
1.4 Introduction and Features of Python:

Python is a high-level, interpreted programming language known for its


simplicity and versatility. It is widely used in various fields, including web
development, data analysis, artificial intelligence, and more. Below are some of
the key features of Python:

Key Features of Python

1.4.1 Open Source

Definition: Python is released under an open-source license, meaning its source


code is freely available for anyone to view, modify, and distribute.

Benefits: Promotes community collaboration, innovation, and extensive


libraries developed by the community.

1.4.2 Interactive

Definition: Python supports an interactive mode, allowing users to test code


snippets and perform calculations directly in a REPL (Read-Eval-Print Loop)
environment.

Benefits: Facilitates experimentation and quick testing of code, making it easier


to learn and debug.

1.4.3 Interpreted

Definition: Python code is executed line by line by an interpreter rather than


being compiled into machine code.

Benefits: Enhances portability and ease of debugging, as errors are detected at


runtime.

1.4.4 Object-Oriented

Definition: Python supports object-oriented programming (OOP) principles,


including encapsulation, inheritance, and polymorphism.

Benefits: Promotes code reuse, modularity, and a clear organizational structure.

Platform Independent

Definition: Python code can run on any platform without modification,


provided the Python interpreter is available.
Benefits: Ensures that code is portable across different operating systems such
as Windows, macOS, and Linux.

1.4.5 Easy to Read and Write

Definition: Python emphasizes readability and simplicity, using clear and


concise syntax.

Benefits: Reduces the learning curve and makes it easier to maintain and
understand code.

1.4.6 Extensive Standard Library

Definition: Python includes a rich standard library with modules and packages
for a wide range of tasks (e.g., file I/O, networking, web services).

Benefits: Provides built-in functionality that reduces the need for third-party
libraries.

1.4.6 Dynamic Typing

Definition: Python determines the type of variables at runtime, rather than at


compile-time.

Benefits: Increases flexibility and allows for more concise code.

1.4.7 High-Level Language

Definition: Python abstracts low-level details of the computer's operation,


providing a higher level of programming abstraction.

Benefits: Simplifies complex programming tasks and accelerates development.

Installation and Working with IDEs


1.5 Integrated Development Environments (IDEs) are tools that provide
comprehensive facilities for software development. For Python, several IDEs
and code editors are available to enhance productivity and streamline the
development process.

Installation of Python

Download Python:

Visit the official Python website: python.org.

Choose the appropriate version for your operating system (Windows, macOS,
Linux).

Install Python:

Run the installer and follow the prompts. Ensure that the option to add Python
to your system PATH is checked.

Verify Installation:

Open a terminal or command prompt.

Type python --version or python3 --version to check the installed version of


Python.

Working with IDEs

IDEs for Python:

PyCharm: A popular IDE with a comprehensive set of features, including code


completion, debugging, and integrated tools for version control.

Website: jetbrains.com/pycharm

Visual Studio Code (VS Code): A lightweight, customizable editor with


powerful extensions for Python development.

Website: code.visualstudio.com

Jupyter Notebook: An open-source web application that allows for interactive


computing with Python. It is widely used for data analysis and visualization.

Website: jupyter.org
Spyder: An IDE specifically designed for scientific and engineering
applications, offering advanced editing and debugging features.

Website: spyder-ide.org

Installation of an IDE:

PyCharm: Download and run the installer from the PyCharm website. Follow
the installation instructions and configure the Python interpreter.

VS Code: Download and install VS Code from its website. Install the Python
extension from the Extensions Marketplace within VS Code.

Jupyter Notebook: Install Jupyter using pip install notebook in the command
line. Start the notebook server by running jupyter notebook.

Using the IDE:

PyCharm/VS Code: Create a new Python project or file, write your code, and
use the built-in tools to run and debug your code.

Jupyter Notebook: Create new notebooks, write and execute Python code cells,
and visualize results interactively.

You might also like