0% found this document useful (0 votes)
4 views3 pages

Python Notes Mechanical

This document provides an overview of Python's core features, syntax, and applications, particularly in engineering and automation. It highlights Python's ease of use, versatility, and wide range of applications, including web development and data science. Additionally, it covers installation steps, common IDEs, syntax rules, data types, and input/output operations with examples.

Uploaded by

hellomaggie010
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)
4 views3 pages

Python Notes Mechanical

This document provides an overview of Python's core features, syntax, and applications, particularly in engineering and automation. It highlights Python's ease of use, versatility, and wide range of applications, including web development and data science. Additionally, it covers installation steps, common IDEs, syntax rules, data types, and input/output operations with examples.

Uploaded by

hellomaggie010
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

PYTHON NOTES (Diploma Mechanical Students)

Unit-1: Core Features, Syntax, and Engineering Applications

1. Features of Python
Python is a high-level, versatile programming language known for its simplicity, readability, and wide range of applications. It is widely used
in web development, data science, artificial intelligence, and automation. Python is one of the most popular programming languages because
of its simplicity and powerful features.

• 1. Easy to Learn and Use

• Simple and readable syntax.

• Suitable for beginners.

• 2. Interpreted Language

• Code is executed line by line without compilation.

• 3. High-Level Language

• Hides complex details of the computer hardware.

• 4. Object-Oriented

• Supports classes, objects, inheritance, polymorphism, etc.

• 5. Platform Independent

• Python programs can run on Windows, Linux, and macOS with little or no modification.

• 6. Open Source

• Free to download, use, and modify.

• 7. Dynamically Typed

• No need to declare variable data types explicitly.

• 8. Large Standard Library

• Provides built-in modules for file handling, networking, databases, web development, and more.

• 9. Extensible and Embeddable

• Can be integrated with languages like C and C++.

• 10. Supports Multiple Programming Paradigms

• Object-Oriented Programming (OOP)

• Procedural Programming

• Functional Programming

• 11. Automatic Memory Management

• Uses garbage collection to manage memory automatically.

• 12. Wide Range of Applications

• Web development, Data Science, Artificial Intelligence & Machine Learning, Automation and Scripting, Game Development.

2. Applications of Python in Automation and Engineering


In Automation:

• Automatic file handling – Rename, move, copy, or delete files automatically.

• Sending emails – Send emails and notifications without doing it manually.

• Web automation – Fill online forms, download data, and perform website tasks automatically.

• Report generation – Create reports from data automatically.

• Software testing – Test applications automatically to save time.


In Engineering:
• Calculations – Solve mathematical and engineering problems quickly.

• Data analysis – Analyze and organize engineering data.

• Graphs and charts – Create visual representations of data.

• Robotics – Control robots and automated machines.

• IoT projects – Work with sensors and smart devices.

• Simulations – Test designs and systems on a computer before building them.

• Machine monitoring – Track machine performance and detect problems.

3. Python Installation and Development Environments (IDE)


Before writing Python programs, it must be installed on the system. Steps to Install:

1. Visit the official Python website.

2. Download the latest version suitable for your operating system (Windows, Linux, or macOS).

3. Run the installer and select "Add Python to PATH".

4. Click Install Now and complete the installation.

5. Verify the installation by opening Command Prompt and typing python --version or python3 --version.
Common Python IDEs:

• IDLE: Default IDE with Python, simple and lightweight.

• PyCharm: Powerful IDE with debugging and code completion features.

• Visual Studio Code (VS Code): Lightweight editor with Python extensions and debugging support.

• Jupyter Notebook: Interactive environment mainly used for data science and machine learning.

• Spyder: Scientific Python IDE with built-in tools for analysis and visualization.

• Thonny: Beginner-friendly IDE with simple interface.

4. Python Syntax and Keywords


• Use Proper Indentation: Python uses indentation (spaces) instead of curly braces {} to define blocks of code.

• Statements End Without a Semicolon: Python does not require a semicolon (;) at the end of each statement.

• Python is Case-Sensitive: Treats uppercase and lowercase letters as different (e.g., name and Name are unique).

• Comments: Denoted by #, ignored during execution to explain code.

• Proper Use of Quotes: Strings must be written inside single (' ') or double (" ") quotes.
Common Python Keywords:

Keyword Purpose
if / else / elif Decision making / conditional checking
for / while Looping structure / repetitive blocks
break / continue Exit loop / skip current iteration
def / return Define function / return value from function
class / import Create a class / import external modules
True / False / None Boolean values / represents empty or no value
and / or / not Logical boolean operators
try / except / pass Exception handling / error catching / placeholder

5. Variables and Data Types


Variables are named memory locations used to store data, created automatically upon value assignment (Syntax: variable_name = value).
Rules: Can contain letters, digits, underscores; must start with a letter/underscore; case-sensitive; keywords cannot be identifiers.

Category Data Types & Examples


Numeric int (x = 10), float (y = 3.14), complex (z = 2 + 3j)
Text / Boolean str (name = "Python"), bool (is_active = True)
Sequence list ([10, 20]), tuple (('A', 'B')), range (range(5))
Set / Mapping set ({1,2}), frozenset, dict ({"key": "val"})
Binary bytes (b'Hello'), bytearray, memoryview

6. Input and Output Operations & Automation Examples


Python uses input() to read entries as text (convert via int()/float() for math) and print() to show output, following the Input-Process-Output
(IPO) Cycle.

Code Example: Area of Rectangle


length = float(input())
width = float(input())
print('Area =', length * width)

Code Example: Check Even/Odd


num = int(input())
if num % 2 == 0: print('Even')
else: print('Odd')

Code Example: Temp Converter


c = float(input())
f = (c * 9/5) + 32
print('F =', f)

You might also like