This document provides an overview of the Python programming language. It discusses what Python is, its key features, who uses it, common applications, and how to download and install Python. It then covers Python syntax concepts like identifiers, keywords, multiline statements, docstrings, indentation, comments, and string formatting. The document also introduces Python data types like numbers, strings, lists, tuples, dictionaries, sets and how to work with them. It describes how to convert between number types and access/update strings and lists. Finally, it discusses Python development environments like Anaconda and Spyder.
In Python, data types define the type of data that can be stored and manipulated in variables. Python is a dynamically typed language, meaning you don't need to explicitly declare the data type of a variable; Python infers it based on the value assigned to the variable.
Python is a cross-platform programming language that can run on Windows, macOS, Linux, and other platforms. It is free and open-source. While most modern operating systems come with Python pre-installed, it is generally recommended to install the latest version separately. The Thonny IDE is a simple Python IDE that bundles the latest Python version, so it can run Python programs without requiring a separate Python installation. Thonny has features like an easy-to-use debugger and code completion that make it suitable for beginners learning Python.
This document provides a high-level summary of an introduction to Python programming course. The summary includes an overview of Python basics like variables, data types, operators, conditionals, loops, functions and file handling. It also discusses commonly used Python libraries and concepts in data analytics like NumPy, Pandas, Matplotlib and statistics.
This document provides an overview and introduction to Python programming. It discusses Python basics like variables, data types, operators, conditionals, loops, functions and file handling. It also covers commonly used Python libraries and concepts in data analytics like NumPy, Pandas, Matplotlib and statistics. The document is intended as a whistle-stop tour to cover the most common aspects of Python.
Python is an interpreted, interactive, object-oriented programming language. It has a simple syntax and is used for rapid application development. Python supports procedural, object-oriented, and functional programming. It has a large standard library and can connect to existing components. Python is easy to read and maintain due to its clear syntax and structure. It is also portable and has broad library support.
Python is a high-level, interpreted, interactive and object-oriented scripting language. It is designed to be highly readable using English keywords. Python is interpreted at runtime and does not require compilation. It supports both procedural and object-oriented programming. Python is beginner friendly and supports a wide range of applications. It is portable, extensible, and has a large standard library. Variables are dynamically typed and support integers, floating point numbers, complex numbers, strings, lists, tuples and dictionaries.
This document provides an overview of Python programming in Katana for beginners. It discusses scripting languages and their advantages, different programming paradigms like procedural and object-oriented programming, and key Python concepts like data types, variables, functions, modules and packages. The document also demonstrates how to get started with Python in Katana, covering topics like syntax, comments, writing scripts and using the interactive console.
The document discusses Python programming concepts such as data types, variables, operators, and input/output. It provides examples of Python code and explains key features like:
- Python supports several data types including integers, floats, booleans, strings, and lists.
- Variables store and label values that can be of different data types. Variables are created using names.
- Operators like arithmetic, comparison, and logical operators are used to manipulate values.
- User input and output is handled through functions like print() and input().
- Comments, indentation, and quotation are syntax elements in Python code.
The document provides an introduction to Python programming and application development. It discusses that Python is an interpreted, high-level and object-oriented programming language. It then covers key Python concepts like data types, variables, operators, expressions and statements. The document also lists some common Python applications like data science, web development, AI and more.
Python can be used for a variety of applications including web development, scientific computing, education, desktop GUIs, and software development. It is commonly used to build web applications using frameworks like Django and Flask, for scientific computing tasks using libraries like NumPy and SciPy, and for general software development tasks like build automation and testing. Python supports a range of data types including integers, floats, complex numbers, lists, dictionaries, sets, and strings. It can be used to write functions and programs to solve problems across many domains.
Python is a popular programming language created in 1991 by Guido van Rossum. It can be used for web development, software development, mathematics, and system scripting. Python code can be executed immediately as it is written due to its interpreter system, allowing for quick prototyping. It works across different platforms and has a simple, English-like syntax. Common data types in Python include numeric, string, list, and tuple types.
Python is a general-purpose programming language that is highly readable. It uses English keywords and has fewer syntactical constructions than other languages. Python supports object-oriented, interactive, and procedural programming. It has various data types like numbers, strings, lists, tuples and dictionaries. Python uses constructs like if/else, for loops, functions and classes to control program flow and structure code.
python programming language Python is a high-level, interpreted, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. INTRODUCTION
HISTORY
USES OF PYTHON
FEATURES OF PYTHON
PYTHON PROJECT FOR BEGINNERS
PYTHON PROGRAM
KEY CHANGES IN PYTHON
BASIC SYNTAX
VARIABLE
NUMBERS
STANDARD TYPE HIERARCHY
STRING
CONDITIONALS
FOR LOOP
FUNCTION
KEYWORDS
WHY PYTHON ?
DIFFERENTIATE
EXAMPLES
This document outlines the objectives and content of the course GE3151 Problem Solving and Python Programming. The course is intended to teach students the basics of algorithmic problem solving using Python. It covers topics like computational thinking, Python data types, control flow, functions, strings, lists, tuples, dictionaries, files and modules. The course contains 5 units that will teach students how to define problems, develop algorithms, implement solutions in Python using conditionals, loops, functions and data structures, perform input/output with files and use modules and packages.
This document provides an introduction to variables and operators in the Python programming language. It defines key concepts like variables, data types, operators, functions, and more. It explains how to work with input and output functions like print() and input() in Python. It also covers comments, indentation, tokens, identifiers, keywords, literals and other essential building blocks of the Python language. The document is intended as a lesson for a 12th computer science class to learn the basics of variables and operators in Python.
How to Build a Maze Solving Robot Using ArduinoCircuitDigest
油
Learn how to make an Arduino-powered robot that can navigate mazes on its own using IR sensors and "Hand on the wall" algorithm.
This step-by-step guide will show you how to build your own maze-solving robot using Arduino UNO, three IR sensors, and basic components that you can easily find in your local electronics shop.
More Related Content
Similar to Python unit 2 is added. Has python related programming content (20)
Python is an interpreted, interactive, object-oriented programming language. It has a simple syntax and is used for rapid application development. Python supports procedural, object-oriented, and functional programming. It has a large standard library and can connect to existing components. Python is easy to read and maintain due to its clear syntax and structure. It is also portable and has broad library support.
Python is a high-level, interpreted, interactive and object-oriented scripting language. It is designed to be highly readable using English keywords. Python is interpreted at runtime and does not require compilation. It supports both procedural and object-oriented programming. Python is beginner friendly and supports a wide range of applications. It is portable, extensible, and has a large standard library. Variables are dynamically typed and support integers, floating point numbers, complex numbers, strings, lists, tuples and dictionaries.
This document provides an overview of Python programming in Katana for beginners. It discusses scripting languages and their advantages, different programming paradigms like procedural and object-oriented programming, and key Python concepts like data types, variables, functions, modules and packages. The document also demonstrates how to get started with Python in Katana, covering topics like syntax, comments, writing scripts and using the interactive console.
The document discusses Python programming concepts such as data types, variables, operators, and input/output. It provides examples of Python code and explains key features like:
- Python supports several data types including integers, floats, booleans, strings, and lists.
- Variables store and label values that can be of different data types. Variables are created using names.
- Operators like arithmetic, comparison, and logical operators are used to manipulate values.
- User input and output is handled through functions like print() and input().
- Comments, indentation, and quotation are syntax elements in Python code.
The document provides an introduction to Python programming and application development. It discusses that Python is an interpreted, high-level and object-oriented programming language. It then covers key Python concepts like data types, variables, operators, expressions and statements. The document also lists some common Python applications like data science, web development, AI and more.
Python can be used for a variety of applications including web development, scientific computing, education, desktop GUIs, and software development. It is commonly used to build web applications using frameworks like Django and Flask, for scientific computing tasks using libraries like NumPy and SciPy, and for general software development tasks like build automation and testing. Python supports a range of data types including integers, floats, complex numbers, lists, dictionaries, sets, and strings. It can be used to write functions and programs to solve problems across many domains.
Python is a popular programming language created in 1991 by Guido van Rossum. It can be used for web development, software development, mathematics, and system scripting. Python code can be executed immediately as it is written due to its interpreter system, allowing for quick prototyping. It works across different platforms and has a simple, English-like syntax. Common data types in Python include numeric, string, list, and tuple types.
Python is a general-purpose programming language that is highly readable. It uses English keywords and has fewer syntactical constructions than other languages. Python supports object-oriented, interactive, and procedural programming. It has various data types like numbers, strings, lists, tuples and dictionaries. Python uses constructs like if/else, for loops, functions and classes to control program flow and structure code.
python programming language Python is a high-level, interpreted, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. INTRODUCTION
HISTORY
USES OF PYTHON
FEATURES OF PYTHON
PYTHON PROJECT FOR BEGINNERS
PYTHON PROGRAM
KEY CHANGES IN PYTHON
BASIC SYNTAX
VARIABLE
NUMBERS
STANDARD TYPE HIERARCHY
STRING
CONDITIONALS
FOR LOOP
FUNCTION
KEYWORDS
WHY PYTHON ?
DIFFERENTIATE
EXAMPLES
This document outlines the objectives and content of the course GE3151 Problem Solving and Python Programming. The course is intended to teach students the basics of algorithmic problem solving using Python. It covers topics like computational thinking, Python data types, control flow, functions, strings, lists, tuples, dictionaries, files and modules. The course contains 5 units that will teach students how to define problems, develop algorithms, implement solutions in Python using conditionals, loops, functions and data structures, perform input/output with files and use modules and packages.
This document provides an introduction to variables and operators in the Python programming language. It defines key concepts like variables, data types, operators, functions, and more. It explains how to work with input and output functions like print() and input() in Python. It also covers comments, indentation, tokens, identifiers, keywords, literals and other essential building blocks of the Python language. The document is intended as a lesson for a 12th computer science class to learn the basics of variables and operators in Python.
How to Build a Maze Solving Robot Using ArduinoCircuitDigest
油
Learn how to make an Arduino-powered robot that can navigate mazes on its own using IR sensors and "Hand on the wall" algorithm.
This step-by-step guide will show you how to build your own maze-solving robot using Arduino UNO, three IR sensors, and basic components that you can easily find in your local electronics shop.
Preface: The ReGenX Generator innovation operates with a US Patented Frequency Dependent Load Current Delay which delays the creation and storage of created Electromagnetic Field Energy around the exterior of the generator coil. The result is the created and Time Delayed Electromagnetic Field Energy performs any magnitude of Positive Electro-Mechanical Work at infinite efficiency on the generator's Rotating Magnetic Field, increasing its Kinetic Energy and increasing the Kinetic Energy of an EV or ICE Vehicle to any magnitude without requiring any Externally Supplied Input Energy. In Electricity Generation applications the ReGenX Generator innovation now allows all electricity to be generated at infinite efficiency requiring zero Input Energy, zero Input Energy Cost, while producing zero Greenhouse Gas Emissions, zero Air Pollution and zero Nuclear Waste during the Electricity Generation Phase. In Electric Motor operation the ReGen-X Quantum Motor now allows any magnitude of Work to be performed with zero Electric Input Energy.
Demonstration Protocol: The demonstration protocol involves three prototypes;
1. Protytpe #1, demonstrates the ReGenX Generator's Load Current Time Delay when compared to the instantaneous Load Current Sine Wave for a Conventional Generator Coil.
2. In the Conventional Faraday Generator operation the created Electromagnetic Field Energy performs Negative Work at infinite efficiency and it reduces the Kinetic Energy of the system.
3. The Magnitude of the Negative Work / System Kinetic Energy Reduction (in Joules) is equal to the Magnitude of the created Electromagnetic Field Energy (also in Joules).
4. When the Conventional Faraday Generator is placed On-Load, Negative Work is performed and the speed of the system decreases according to Lenz's Law of Induction.
5. In order to maintain the System Speed and the Electric Power magnitude to the Loads, additional Input Power must be supplied to the Prime Mover and additional Mechanical Input Power must be supplied to the Generator's Drive Shaft.
6. For example, if 100 Watts of Electric Power is delivered to the Load by the Faraday Generator, an additional >100 Watts of Mechanical Input Power must be supplied to the Generator's Drive Shaft by the Prime Mover.
7. If 1 MW of Electric Power is delivered to the Load by the Faraday Generator, an additional >1 MW Watts of Mechanical Input Power must be supplied to the Generator's Drive Shaft by the Prime Mover.
8. Generally speaking the ratio is 2 Watts of Mechanical Input Power to every 1 Watt of Electric Output Power generated.
9. The increase in Drive Shaft Mechanical Input Power is provided by the Prime Mover and the Input Energy Source which powers the Prime Mover.
10. In the Heins ReGenX Generator operation the created and Time Delayed Electromagnetic Field Energy performs Positive Work at infinite efficiency and it increases the Kinetic Energy of the system.
Preface: The ReGenX Generator innovation operates with a US Patented Frequency Dependent Load
Current Delay which delays the creation and storage of created Electromagnetic Field Energy around
the exterior of the generator coil. The result is the created and Time Delayed Electromagnetic Field
Energy performs any magnitude of Positive Electro-Mechanical Work at infinite efficiency on the
generator's Rotating Magnetic Field, increasing its Kinetic Energy and increasing the Kinetic Energy of
an EV or ICE Vehicle to any magnitude without requiring any Externally Supplied Input Energy. In
Electricity Generation applications the ReGenX Generator innovation now allows all electricity to be
generated at infinite efficiency requiring zero Input Energy, zero Input Energy Cost, while producing
zero Greenhouse Gas Emissions, zero Air Pollution and zero Nuclear Waste during the Electricity
Generation Phase. In Electric Motor operation the ReGen-X Quantum Motor now allows any
magnitude of Work to be performed with zero Electric Input Energy.
Demonstration Protocol: The demonstration protocol involves three prototypes;
1. Protytpe #1, demonstrates the ReGenX Generator's Load Current Time Delay when compared
to the instantaneous Load Current Sine Wave for a Conventional Generator Coil.
2. In the Conventional Faraday Generator operation the created Electromagnetic Field Energy
performs Negative Work at infinite efficiency and it reduces the Kinetic Energy of the system.
3. The Magnitude of the Negative Work / System Kinetic Energy Reduction (in Joules) is equal to
the Magnitude of the created Electromagnetic Field Energy (also in Joules).
4. When the Conventional Faraday Generator is placed On-Load, Negative Work is performed and
the speed of the system decreases according to Lenz's Law of Induction.
5. In order to maintain the System Speed and the Electric Power magnitude to the Loads,
additional Input Power must be supplied to the Prime Mover and additional Mechanical Input
Power must be supplied to the Generator's Drive Shaft.
6. For example, if 100 Watts of Electric Power is delivered to the Load by the Faraday Generator,
an additional >100 Watts of Mechanical Input Power must be supplied to the Generator's Drive
Shaft by the Prime Mover.
7. If 1 MW of Electric Power is delivered to the Load by the Faraday Generator, an additional >1
MW Watts of Mechanical Input Power must be supplied to the Generator's Drive Shaft by the
Prime Mover.
8. Generally speaking the ratio is 2 Watts of Mechanical Input Power to every 1 Watt of Electric
Output Power generated.
9. The increase in Drive Shaft Mechanical Input Power is provided by the Prime Mover and the
Input Energy Source which powers the Prime Mover.
10. In the Heins ReGenX Generator operation the created and Time Delayed Electromagnetic Field
Energy performs Positive Work at infinite efficiency and it increases the Kinetic Energy of the
system.
"Zen and the Art of Industrial Construction"
Once upon a time in Gujarat, Plinth and Roofs was working on a massive industrial shed project. Everything was going smoothlyblueprints were flawless, steel structures were rising, and even the cement was behaving. That is, until...
Meet Ramesh, the Stressed Engineer.
Ramesh was a perfectionist. He measured bolts with the precision of a Swiss watchmaker and treated every steel beam like his own child. But as the deadline approached, Rameshs stress levels skyrocketed.
One day, he called Parul, the total management & marketing mastermind.
Ramesh (panicking): "Parul maam! The roof isn't aligning by 0.2 degrees! This is a disaster!"
Parul (calmly): "Ramesh, have you tried... meditating?"
、 Ramesh: "Meditating? Maam, I have 500 workers on-site, and you want me to sit cross-legged and hum Om?"
Parul: "Exactly. Mystic of Seven can help!"
Reluctantly, Ramesh agreed to a 5-minute guided meditation session.
He closed his eyes.
鏝 He breathed deeply.
He chanted "Om Namah Roofaya" (his custom version of a mantra).
When he opened his eyes, a miracle happened!
ッ His mind was clear.
The roof magically aligned (okay, maybe the team just adjusted it while he was meditating).
And for the first time, Ramesh smiled instead of calculating load capacities in his head.
Lesson Learned: Sometimes, even in industrial construction, a little bit of mindfulness goes a long way.
From that day on, Plinth and Roofs introduced tea breaks with meditation sessions, and productivity skyrocketed!
Moral of the story: "When in doubt, breathe it out!"
#PlinthAndRoofs #MysticOfSeven #ZenConstruction #MindfulEngineering
Engineering at Lovely Professional University (LPU).pdfSona
油
LPUs engineering programs provide students with the skills and knowledge to excel in the rapidly evolving tech industry, ensuring a bright and successful future. With world-class infrastructure, top-tier placements, and global exposure, LPU stands as a premier destination for aspiring engineers.
Welcome to the March 2025 issue of WIPAC Monthly the magazine brought to you by the LinkedIn Group WIPAC Monthly.
In this month's edition, on top of the month's news from the water industry we cover subjects from the intelligent use of wastewater networks, the use of machine learning in water quality as well as how, we as an industry, need to develop the skills base in developing areas such as Machine Learning and Artificial Intelligence.
Enjoy the latest edition
EXPLORE 6 EXCITING DOMAINS:
1. Machine Learning: Discover the world of AI and ML!
2. App Development: Build innovative mobile apps!
3. Competitive Programming: Enhance your coding skills!
4. Web Development: Create stunning web applications!
5. Blockchain: Uncover the power of decentralized tech!
6. Cloud Computing: Explore the world of cloud infrastructure!
Join us to unravel the unexplored, network with like-minded individuals, and dive into the world of tech!
Lecture -3 Cold water supply system.pptxrabiaatif2
油
The presentation on Cold Water Supply explored the fundamental principles of water distribution in buildings. It covered sources of cold water, including municipal supply, wells, and rainwater harvesting. Key components such as storage tanks, pipes, valves, and pumps were discussed for efficient water delivery. Various distribution systems, including direct and indirect supply methods, were analyzed for residential and commercial applications. The presentation emphasized water quality, pressure regulation, and contamination prevention. Common issues like pipe corrosion, leaks, and pressure drops were addressed along with maintenance strategies. Diagrams and case studies illustrated system layouts and best practices for optimal performance.
Python unit 2 is added. Has python related programming content
1. UNIT 02: BASICS OF PYTHON
PROGRAMMING
Introduction-Python Interpreter-Interactive and
script mode -Values and types, variables,
operators, expressions, statements, precedence
of operators, Multiple assignments, comments,
input function, print function, Formatting
numbers and strings, implicit/explicit type
conversion.
2. Introduction to PYTHON
Python is a general-purpose interpreted, interactive, object-oriented,
and high level programming language.
It was created by Guido van Rossum during 1985- 1990.
Python is interpreted: Python is processed at runtime by the
interpreter. You do not need to compile your program before
executing it.
Python is Interactive: You can actually sit at a Python prompt and
interact with the interpreter directly to write your programs.
Python is Object-Oriented: Python supports Object-Oriented style or
technique of programming that encapsulates code within objects.
Python is a Beginner's Language: Python is a great language for the
beginner level programmers and supports the development of a
wide range of applications.
3. Python Features
Easy-to-learn: Python is clearly defined and easily readable. The structure of the
program is very simple. It uses few keywords.
Easy-to-maintain: Python's source code is fairly easy-to-maintain.
Portable: Python can run on a wide variety of hardware platforms and has the
same interface on all platforms.
Interpreted: Python is processed at runtime by the interpreter. So, there is no
need to compile a program before executing it. You can simply run the program.
Extensible: Programmers can embed python within their C,C++,Java
script ,ActiveX, etc.
Free and Open Source: Anyone can freely distribute it, read the source code, and
edit it.
High Level Language: When writing programs, programmers concentrate on
solutions of the current problem, no need to worry about the low level details.
Scalable: Python provides a better structure and support for large programs than
shell scripting.
4. Python Interpreter
A python interpreter is a computer program that converts each
high-level program statement into machine code.
Translating it one line at a time
Compiler: To translate a program written in a high-level language
into a low-level language all at once
5. Difference between Interpreter and
Compiler
Compilers Interpreters
Compilers translate the entire source code into
machine code before execution.
Interpreters translate and execute the source
code line by line.
Compiled code runs faster because it's already
translated into machine code.
Interpreted code runs slower because it must be
translated on the fly.
Compilers generate an executable file that can
be run independently.
Interpreters require the source code to be
present at runtime.
Compilers display all errors at once after
compilation.
Interpreters display errors one at a time during
execution.
Compiled languages include C, C++, and Java. Interpreted languages include Python, Ruby, and
JavaScript.
Compilers have a longer development cycle due
to the compilation step.
Interpreters have a shorter development cycle as
code can be tested immediately.
Compiled code is platform-dependent. Interpreted code is platform-independent.
7. Interactive mode
Interactive Mode, as the name suggests, allows us to interact with
OS.
When we type Python statement, interpreter displays the result(s)
immediately.
Advantages:
Python, in interactive mode, is good enough to learn, experiment or
explore.
Working in interactive mode is convenient for beginners and for
testing small pieces of code.
Drawback:
We cannot save the statements and have to retype all the statements
once again to re-run them
9. Script mode
In script mode, we type python program in a file and then use
interpreter to execute the content of the file.
Scripts can be saved to disk for future use. Python scripts have the
extension .py, meaning that the filename ends with .py
Save the code with filename.py and run the interpreter in script
mode to execute the script.
12. Integrated Development Learning Environment (IDLE):
Is a graphical user interface which is completely written in Python.
It is bundled with the default implementation of the python language and
also comes with optional part of the Python packaging.
Features of IDLE:
Multi-window text editor with syntax highlighting.
Auto completion with smart indentation.
Python shell to display output with syntax highlighting.
13. Values and types
Value: Value can be any letter ,number or string.
Eg, Values are 2, 42.0, and 'Hello, World!'. (These values belong to
different data types.)
Data type: Every value in Python has a data type. It is a set of values,
and the allowable operations on those values.
15. Numeric Data Types
type() function is used to determine the type of Python data type.
Integers This value is represented by int class. It contains positive or
negative whole numbers (without fractions or decimals). In Python,
there is no limit to how long an integer value can be.
Float This value is represented by the float class. It is a real number
with a floating-point representation. It is specified by a decimal point.
Optionally, the character e or E followed by a positive or negative
integer may be appended to specify scientific notation.
Complex Numbers A complex number is represented by a complex
class. It is specified as (real part) + (imaginary part)j . For example 2+3j
17. Sequence
A sequence is an ordered collection of items, indexed by positive
integers.
It is a combination of mutable (value can be changed) and
immutable (values cannot be changed) data types.
1.Strings (Immutable)
2. Lists( mutable)
3. Tuples(Immutable)
18. Strings
A String in Python consists of a sequence of characters - letters, numbers, and special
characters.
Strings are marked by quotes:
single quotes (' ') Eg, 'This a string in single quotes'
double quotes (" ") Eg, "'This a string in double quotes'"
triple quotes(""" """) Eg, This is a paragraph. It is made up of multiple lines and
sentences.""
Individual character in a string is accessed using a subscript (index).
Characters can be accessed using indexing and slicing operations.
Strings are immutable i.e. the contents of the string cannot be changed after it is
created.
19. Indexing
String A H E L L 0
Positive Index 0 1 2 3 4
Negative Index -5 -4 -3 -2 -1
Example: A[0] or A[-5] will display H
Example: A[1] or A[-4] will display E
Str=Python Program
Str[-3]
Str[3]
Str[6]
Str[7]
21. Indexing Accessing the item in the position
Slicing Slice operator is used to extract part of a data type
Concatenation Adding and printing the characters of two strings.
Repetition multiple copies of the same string
in, not in
(membership
operator)
Using membership operators to check a particular
character is in string or not. Returns true if present.
29. Lists
List is an ordered sequence of items. Values in the list
are called elements / items.
It can be written as a list of comma-separated items
(values) between square brackets[ ].
Items in the lists can be of different data types.
31. Indexing Accessing the item in the particular position
Slicing Slice operator is used to extract part of a string, or some
part of a list Python
Concatenation Adding and printing the items of two lists.
Repetitions multiple copies of the same string
Updating the list Updating the list using index value
Inserting an element Inserting an element in 2nd position
Removing an element Removing an element by giving the element directly
35. Updating the list
Inserting an element
Removing an element
Note:
Update,Insert:Need
to give Position
Remove:give value
alone
36. Tuple
A tuple is same as list, except that the set of elements is enclosed in
parentheses instead of square brackets.
A tuple is an immutable list. i.e. once a tuple has been created, you can't
add elements to a tuple or remove elements from the tuple.
Tuples are faster than lists
39. Dictionaries
Lists are ordered sets of objects, whereas dictionaries are
unordered sets.
Dictionary is created by using curly brackets. i,e. {}
Dictionaries are accessed via keys and not via their
position.
41. Variables
Rules:
A variable allows us to store a value by assigning it to a name,
which can be used later.
Named memory locations to store values.
Programmers generally choose names for their variables that are
meaningful.
It can be of any length. No space is allowed.
We don't need to declare a variable before using it. In Python, we
simply assign a value to a variable and it will exist.
42. Assigning a single value to several variables simultaneously:
Assigning multiple values to multiple variables
a=b=c=10,20,"Ram"
print(c)
(10, 20, 'Ram')
print(a)
(10, 20, 'Ram')
a=b=c=100
print(a)
100
print(c)
100
43. Expressions and Statements
Statements:
Instructions that a Python interpreter can executes are called statements.
A statement is a unit of code like creating a variable or displaying a value.
Expressions:
An expression is a combination of values, variables, and operators.
>>> n = 17
>>> print(n)
a=2
a+3+2
7
str=("Good"+"Morning")
print(str)
GoodMorning
44. Multiple assignments
same value to multiple variables
Assign multiple values to multiple variables
a=b=c=10
print(a)
10
print(b)
10
x, y, z = "Orange", "Banana", "Cherry"
print(x)
Orange
45. Comments
Comments are the kind of statements that are written in the
program for program understanding purpose.
In Python, we use the hash (#) symbol to start writing a comment.
Python Interpreter ignores comment.
If we have comments that extend multiple lines, one way of doing it
is to use hash (#) in the beginning of each line.
# This is comment line
print(I love my country)
percentage = (minute *
100) / 60 # calculating
percentage of an hour
#This is
#another example
#of comment statement
46. OPERATORS
Operators are the constructs which can manipulate the value of operands.
Consider the expression 4 + 5 = 9.
Here, 4 and 5 are called operands and + is called operator
48. Arithmetic operators
They are used to perform mathematical operations like addition,
subtraction, multiplication etc
49. Operator Description
+ Addition Adds values on either side of the operator
- Subtraction Subtracts right hand operand from left hand operand.
* Multiplication Multiplies values on either side of the operator
/ Division Divides left hand operand by right hand operand
% Modulus Divides left hand operand by right hand operand and
returns remainder
** Exponent Performs exponential (power) calculation on operators
// Floor Division - The division of operands where the result is
the quotient in which the digits after the decimal point are
removed
51. Comparison (Relational) Operators
Comparison operators are used to compare values.
It either returns True or False according to the condition. Assume, a=10 and b=5
==,<
>
<=
>=
!=
54. Operator Description Example
= Assigns values from right side operands to
left side operand
c = a + b assigns value of a
+ b into c
+= Add
AND
It adds right operand to the left operand
and assign the result to left operand
c += a
is equivalent to c = c + a
-= Subtract
AND
It subtracts right operand from the left
operand and assign the result to left
operand
c -= a
is equivalent to c = c - a
*= Multiply
AND
It multiplies right operand with the left
operand and assign the result to left
operand
c *= a
is equivalent to c = c * a
**=
Exponent
AND
Performs exponential (power) calculation
on operators and assign value to the left
operand
c **= a
is equivalent to c = c ** a
//= Floor
Division
It performs floor division on operators and
assign value to the left operand
c //= a is equivalent to c = c
// a
56. Logical Operators
Logical operators are the and, or, not operators
And True if both the operands are True
Or True if either of the operands is true
not True if operands is false
58. Bitwise Operators
A bitwise operation operates on one or more bit patterns
at the level of individual bits
Let x = 10 (0000 1010 in binary) and
y = 4 (0000 0100 in binary)
59. x = 10 (0000 1010 in binary) and
y = 4 (0000 0100 in binary)
& Bitwise AND X&Y= (0000 0000)
| Bitwise OR X|y= (0000 1110)
~ Bitwise Not -x=(1111 0101)
^ Bitwise XOR x ^ y =(1111 0001)
>> Bitwise right shift X >>2=(0000 0010)
<< Bitwise left shift X <<2=(0010 1000)
60. Membership Operators
Evaluates to find a value or a variable is in the specified sequence
of string, list, tuple, dictionary or not.
Let, x=[5,3,6,4,1]. To check particular item in list or not, in and not in
operators are used.
61. Identity Operators
They are used to check if two values (or variables) are
located on the same part of the memory.
If the two values are identical: True
62. Precedence of operators
When an expression contains more than one operator, the order of
evaluation depends on the order of operations.
PEMDAS (Parentheses, Exponentiation, Multiplication, Division, Addition,
Subtraction)
64. Input function
Input is data entered by user (end user) in the program.
input () function
x=input("enter the name:")
enter the name:hhh
y=int(input("enter the number"))
enter the number 3
65. Output function
Output can be displayed to the user using Print statement
print (expression/constant/variable)
print("Hello")
Hello
print(2+4)
6
print(6)
6
66. Type Casting(Type Conversion)
Is the process of converting the value of one data type to another
Python Implicit Type Conversion
Python Explicit Type Conversion
67. Implicit Type Conversion
In this, method, Python converts the data type into
another data type automatically. Users dont have to
involve in this process.
a=10
b=12.0
c=a+b
print(c)
22.0
68. Explicit Type Conversion
This involves converting a data type explicitly using predefined
functions like int(), float(), str(), etc., where the programmer
specifically directs the type of conversion required.
a=10
print(type(a))
<class 'int'>
print(float(a))
10.0
b=12.24
print(type(b))
<class 'float'>
print(int(b))
12
c=15.78
print(int(c))
15
69. Convert string to int: (Value Error)
Converting string to int datatype in Python with int() function. If the given
string is not number, then it will throw an error.
a="Hema"
print(int(a))
Traceback (most recent call last):
File "<pyshell#16>", line 1, in <module>
print(int(a))
ValueError: invalid literal for int() with base
10: 'Hema'
a="5"
print(int(a))
5
70. Formatting numbers and strings
price = 49
txt ="The price is {price} dollars"
print(txt)
Output:
The price is {price} dollars
price = 49
txt =f"The price is {price} dollars"
print(txt)
Output:
The price is 49 dollars
71. Celsius to Fahrenheit:
F = [(C*9/5) +32]
convert kilometers to miles
Miles=0.62*km