Python I Unit Material
Python I Unit Material
Python I Unit Material
24CS101
Unit I
Introduction to Mechanical Devices and Computing
Unit I: Introduction to Mechanical Devices and Computing
Evolution of Computers
Mechanistic Devices
Mechanistic devices are tools or systems that use mechanical components to perform a specific
function or achieve a particular goal. These devices typically rely on physical principles, such
as levers, gears, and pulleys, to transmit motion, force, or energy.
1. Clocks and Watches
2. Gearboxes
3. Hydraulic systems
4. Levers and fulcrums
5. Pulley systems
6. Chain drives
7. Belt drives
Grading Machines
Devices that are used to classify items based on overall quality are termed as grading machines.
These machines are commonly used in various industries to ensure that products meet certain
standards and specifications before they reach the consumer or the next stage of processing.
Grading machines enhance productivity, ensure product quality, and reduce labor costs, making
them essential tools in many industries. These machines can handle large volumes of items
quickly, which is essential for industries with high production rates.
Example: Part graders in manufacturing: Used to grade manufactured parts based on
dimensions, weight, or other specifications to ensure quality control.
Sorters
Devices that are used to sort items based on a specific criteria or parameter are termed as
sorters. Parameters may include size, weight, color, quality, or other properties. They are
designed to provide accurate and consistent sorting or classification based on predefined
criteria. Like grading machines, these machines can also handle large volumes of items quickly,
and reduce labour costs.
Example: Fruit and Vegetable Graders: These machines sort produce by size, weight, color, or
ripeness. For example, apple sorters can sort apples into different categories based on size and
color.
Generations of Computers
First Generation Computers (1940-1956)
• Vacuum tubes were used in circuits.
• These computers are very large in size.
• Programming for this generation was done using machine language.
• They were very expensive and require a large amount of electricity.
• They produce more heat.
• Computers could calculate data in a millisecond.
• Examples: ENIAC and UNIVAC-1.
3. Storage
• Hard Disk Drive (HDD):
• Function: A traditional storage device using spinning disks to read/write
data.
• Solid-State Drive (SSD):
• Function: A newer storage device using flash memory. Faster access speeds
and more durable compared to HDDs.
4. Motherboard
• Function: The main circuit board that houses the CPU, memory, and other essential
components.
• Components:
• Chipset: Manages data flow between the processor, memory, and peripherals.
• Slots and Connectors: For additional hardware like RAM, expansion cards,
and storage devices.
7. Input Devices
• Function: Devices used to input data into the computer.
• Examples:
• Keyboard: For typing text and commands.
• Mouse: For pointing, clicking, and scrolling.
• Scanner: For digitizing physical documents and images.
8. Output Devices
• Function: Devices used to output data from the computer.
• Examples:
• Monitor: Displays visual output from the computer.
• Printer: Produces physical copies of documents and images.
• Speakers: Output sound.
Cloud computing
Cloud Computing means storing and accessing the data and programs on remote servers that
are hosted on the internet instead of the computer’s hard drive or local server. Cloud computing
is also referred to as Internet-based computing, it is a technology where the resource is provided
as a service through the Internet to the user. The data that is stored can be files, images,
documents, or any other storable document.
Key Concepts
1. Cloud Service Models:
1. Infrastructure as a Service (IaaS): Provides virtualized computing resources
over the internet.
2. Platform as a Service (PaaS): Offers a platform allowing developers to build,
deploy, and manage applications without worrying about the underlying
infrastructure.
3. Software as a Service (SaaS): Delivers software applications over the internet,
typically via a subscription model.
Example: Microsoft Office 365.
2. Cloud Deployment Models:
1. Public Cloud: Services are provided over the public internet. Examples: AWS,
2. Private Cloud: Services are maintained on a private network and used
exclusively by one organization.
3. Hybrid Cloud: Combines public and private clouds, allowing data and
applications to be shared between them.
Number Conversions
• Binary to Decimal Conversion: To convert a binary number to a decimal number, sum
the products of each binary digit and its corresponding power of 2.
• Decimal to Binary Conversion: To convert a decimal number to a binary number,
repeatedly divide the number by 2 and record the remainders. Present the remainders
in reverse order.
• Binary to Octal Conversion: To convert a binary number to an octal number, group
the binary digits in sets of three, starting from the least significant digit. Then convert
each group to its octal equivalent.
• Octal to Binary Conversion: To convert an octal number to binary, convert each octal
digit to a three-digit binary number.
• Binary to Hexadecimal Conversion: To convert a binary number to a hexadecimal
number, group the binary digits in sets of four, starting from the least significant digit.
Then convert each group to its hexadecimal equivalent.
• Hexadecimal to Binary Conversion: To convert a hexadecimal number to binary,
convert each hexadecimal digit to a four-digit binary number.
• Decimal to Octal Conversion: To convert a decimal number to an octal number,
repeatedly divide the number by 8 and record the remainders. Present the remainders
in reverse order.
• Octal to Decimal Conversion: To convert an octal number to a decimal number, sum
the products of each octal digit and its corresponding power of 8.
• Decimal to Hexadecimal Conversion: To convert a decimal number to a hexadecimal
number, repeatedly divide the number by 16 and record the remainders. Present the
remainders in reverse order.
• Hexadecimal to Decimal Conversion: To convert a hexadecimal number to a decimal
number, sum the products of each hexadecimal digit and its corresponding power of 16.
Extended ASCII: An extension of the standard ASCII that uses 8 bits (1 byte) to represent 256
characters.
• The additional characters (128-255) include special symbols, and additional control
characters.
Usage
• Communication: ASCII is widely used in data transmission protocols.
• Programming: Used in languages and systems that require text representation, such as
C, Python, and many others.
• File Formats: Text files and email headers, use ASCII encoding.
Computer languages
Machine languages and high-level languages are two categories of programming languages
Differ significantly in their level of abstraction and how they interact with hardware.
Machine Languages
Machine language is the lowest-level programming language, consisting of binary code that is
directly executed by a computer's central processing unit (CPU).
Characteristics:
1. Binary Code: Consists of 0’s and 1’s, representing on and off states of electrical
signals.
2. Hardware-Specific: Code written for one type of CPU will not work on another
without modification.
3. Fast Execution: Since machine code is executed directly by the hardware, it is
very efficient in terms of execution speed.
4. Difficult to Write and Read: because it lacks any symbolic representation and is
purely numerical.
High Level Language
High-level languages (HLLs) are programming languages that are more abstract and easier for
humans to read and write. They are closer to human languages and further from machine code.
Characteristics:
1. Abstraction: High-level languages abstract away hardware details, allowing developers
to focus on logic and functionality rather than hardware specifics.
2. Syntax: They use natural language elements, making them easier to learn and
understand.
3. Portability: High-level code can often run on multiple types of hardware with minimal
modification, as long as the appropriate compilers or interpreters are available.
4. Ease of Use: They provide features like variables, data types, control structures, and
error-handling, making it easier to write, debug, and maintain code.
Problem-Solving Strategies
• Problem-solving in programming involves a systematic approach to finding
solutions to challenges or tasks.
• Some common strategies and steps to effectively solve problems in programming:
Identifying and Defining Problems:
• Identifying Problems: The first step is to recognize that a problem exists. This involves
observing and understanding the current situation, recognizing any discrepancies
between the desired and actual outcomes, and acknowledging that a problem needs to
be solved.
• Defining Problems: Once identified, it's crucial to clearly define the problem. This
includes specifying the problem's scope, understanding the relevant details, and
determining the criteria for a successful solution. A well-defined problem statement
helps focus efforts and resources on finding an effective solution.
Breaking Down Problems into Manageable Parts with Logical Thinking
• Breaking Down Problems: Large and complex problems can be overwhelming. By
decomposing them into smaller, more manageable components, you can tackle each
part individually. This makes it easier to develop solutions and manage the problem-
solving process.
• Logical Thinking: Using logical reasoning is essential in problem-solving. It involves
analyzing the problem, identifying cause-and-effect relationships, and systematically
working through each part. Logical thinking helps in creating structured approaches,
ensuring that solutions are based on sound reasoning and are systematically developed.
2. Call
The call symbol is used to invoke procedures such as graphics routines
and other instructor-provided procedures. The call symbol is also used
to run sub charts included in a Raptor program.
3. Input
The input symbol is used to ask the user for a number or string while the
flowchart is executing. When an input symbol is executed, the user will
be prompted with a dialog to enter a value that can be interpreted as
either a number or string, depending on what the user types.
4. Output
The output symbol is used to either write a number or text to the Master
Console window.
5. Selection
The selection structure is used for decision making. The programmer
enters in the diamond an expression that evaluates to Yes (True) or No
(False). Such expressions are formally referred to as Boolean
expressions. Based on the result of the expression in the diamond,
control of the program will branch either left (Yes, or True) or right (No,
or False).
6. Loop Control
The loop structure is used to repeat a sequence of symbols until a certain
condition is met. When execution reaches the bottom of the loop, it starts
over again at the top. The loop is exited when the diamond symbol is
executed and the Boolean expression in the diamond evaluates to Yes
(True).
Scratch is a visual programming language that allows to create interactive stories, games and
animations. Scratch was created by the Lifelong Kindergarten group at MIT Media lab.
Elements of Scratch: There are four main elements of Scratch: the stage, the sprites, the script
and the programming palette. These elements can be compared to a play.
1) Stage – similar to the stage in a play. This is where everything will take place.
2) Sprites – are the actors or main characters of the project. Sprites are programmed to do
something in Scratch.
3) Script – tells the actors what to say or do. Each sprite is programmed with a script.
4) Programming palette – elements used to program the sprite to do or say something. Sprites
must be programmed to carry out every function you want them to perform.