Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
21 views
Python Unit 1
mm
Uploaded by
d37332058
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Python Unit 1 For Later
Download
Save
Save Python Unit 1 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
21 views
Python Unit 1
mm
Uploaded by
d37332058
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Python Unit 1 For Later
Carousel Previous
Carousel Next
Save
Save Python Unit 1 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 17
Search
Fullscreen
SIMPLE AND EASY EXPLANATION + NOTES PDF TOPIC Introduction to Python: Python variables, Python basic Operators, Understanding python blocks. Python Data Types, Declaring and using Numeric data types: int, float etc. Engineering Express PYTHON PROGRAMMING Introduction to Python: Python variables, Python basic Operators, Understanding python blocks. Python Data Types, Declaring and using Numeric data types: int, float etc. Python Program Flow Control Conditional blocks: if, else and else if, Simple for loops in python, For loop using ranges, string, list and dictionaries. Use of while loops in python, Loop manipulation using pass, continue, break and else. Programming using Python | conditional and loop blocks. AwA\X) Python Complex data types: Using string data type and string operations, Defining list and list slicing, Use of Tuple data type. String, List and Dictionary, Manipulations Building blocks of python programs, string manipulation methods, List manipulation. Dictionary manipulation, Programming using string, list and dictionary in-built functions. Python Functions, Organizing python codes using functions. Python File Operations: Reading files, Writing files in python, Understanding read functions, read(), readline(), readlines(). Understanding write functions, write() and writelines() Manipulating file pointer using seek Programming, using file operations. Python packages: Simple programs using the built-in functions of packages matplotlib, numpy, pandas etc. GU! Programming: Tkinter introduction, Tkinter and PythonProgramming, Tk Widgets, Tkinter examples. Python programming with IDE.Engineering Express @ | What_is Python? programming language. It was created by ‘Guido Vam Rossum’ In 1991. | Python syntax allows program to express their concepts in fewer lines | of code and let’s as work guickly and intrigued system more efficiently, Python in high level language: According to the basic principle of coding the fact that_make a |being an_ interpreted language which is not subject to_process, make: |python a high-level language. Python is interactive: is exe is Foll |key the result will be_printed on the screen _immediately. Python is object oriented | oriented programming) approach and often following advantages; _| Provides a clean program structure, Python is an object oriented because it is Designed with oops Cobject- || _Engineering Express @ | Facilitates Easy maintenance and modification of executing code. __||__ It supports automatic Garbage collections | It_can be easily integrated with C, C’*, Java etc. Python syntax comparison to other programming language: _« || Python has some similarities with English language with influence | from mathematics, Python uses new lines to complete and command. Other language Step 1 Step 1 — Run the Application Run the Application Bt Step2 Step 2 b Test the Application Test the Application Step 3 Step 3 Edit source code Again Edit source code Again step 4 Step 4 Recompile | Repeat (if needed) step 5 | RelinkEngineering Express @ | Python IDE: PyCharm- | Jupyter Notebook | Wing IDE | Sublime text Atom PyCharm: Interactive python console __© || Support for web framework Fast refracting time |Lesser development | Jupyter Notebook: ANN cof wid : In-built refracting capacity _|| Sublime text: Cross platform Multitasking | Better customizationEngineering Express @ Atom: | Better customization Better uses interfc : 5 To run a python program e vari described below: Run on IDLE (integrated Development Environment for Python):- To run python program_on IDLE, follow the given steps: Write the python code and save it. |To run the program, go to Rum>Run Module or simply click FS. _| |Run_on Command line: 7 | it fil nie \\\, . fl 5 Ai it fi ‘ he ”, -h f File wi | python script, bx: / f rh ” Ty . ; ne [Python hellopy) |Run on Text Editor: | Steps are as follows: = z Ai let “hello.py” 5 the file. To run the code, Right click > select Run code, Else press ‘ctrl talt +N’ to run the code Input/Output Function in python; © Output function: This function help to print or display the output after the executing line of code.Engineering Express @ We can give one or more arguments and prints them to the __| tandard output. | Syntax: print”) Ex: printCHello World”) | Output: Hello World output: hello world rintChello worl I hello world Input function: seer LA ov enter some Text and returns that text_as_a_string. a BY lecnbt CordnO Comments: | Single-line comments: Created with t. Used for short explanations on the same line. Syntax: BSS esi line. Chlock) : Used for longer explanations spanning multiple lines. |__ Syntax: Mult-line comment Python program >> Best practices (Advantage of comments): Provide clarity and context.Engineering Express @ program. For example: in = For example: number =10.S Syntax: variable=expression zocall ; ; AY oll asia toaol NE cei ) ; enn ; and else in return as except is True assert finally lambda try break false nonlocal with class for None while continue from not yield def global or del if pass “|| ent import raise Identifier:Engineering Express @ | Must start with letter Ca-z, A-2) or an underscore (_) Data types: Data types are the classification or categorization of data items, It represents the kindof value that tells what operations can be performed on a particular data Data Types in Python = 3 =o So be & | Integer Cint): Represents whole numbers without decimal points Example: y=S Complex(complex):Engineering Express @ | Represents complex numbers with a_re i Example: 2= 3+4) Float Coat): _|| Represents numbers with decimal_points over in exponential form. | Example: y=3.14 Dicti (dict): Represents a collection of key-val irs Example: person= fname’: ‘Alice’, ‘age’ 2S? Boolean(bool): Represents either true or false. TupleCtuple): Similar to_a_list but immutable (cannot be changed after creation) Example: coordination= (4,5) “"NoneTypeCNone);Engineering Express @ | Represents the absence of a value ora null value. | Type conversion: Type conversion in_python_is changing the datatype of a variable, a ion: Automatic conversion n_ based on the o, ion Being performed. Explicit_conversionCcasting): |IntQ_ for integer conversion. |Float©)_for float conversion. StrO_ for string conversion Loperation will be performed first. There the various type of expressions are as follows: Content expression Arithmetic expression Integer expression || Flight expression mS bw fe > Relational expressionEngineering Express @ | Logical expression _|| operations on operands. | Assignment operators Comparison operators Logical operators Identity operators __= ||Membership operators Bitwise_ operators + Ad 442 6 — : Subtraction 4-2 2 ~~ T —- * Muitiplication 4*2 8 —_ ——_r- 1 Division 412 2 — Modulus operator to get % remainder in integer division 5%2 1 [ ++ Increment A=10; i Att — — -—= Decrement A= 10; 9! A-- Applying addition between two numbers, a=l2 | b=10 c=a tbEngineering Express @ | printCc) | Output: 22 | Assignment operation Assignment operations are used to_assign the value to variable. Operator Equals To + E oe = a IF aes a=a>>10 <
2 True <= Less than or equal to 5<=2 False >= Greater than or equal to True = Equal to False l= Not equal to 5=! True It compared two value and retum true or false, Example: A=! B=2 print(a==b, a>b, b>a) output: false false true Logical operators: Perform logical operations on Boolean values. and Logical and (5<2) and (5>3) False or Logical or (5<2) or (5>3) True not Logical not not (5<2) True Identity operators: It compare the memory location of two objects.Engineering Express Operator Name Example is TRUE, if both the variable xisy points to the same object, with same memory locations. is not TRUE, if both the variable xisnoty points to different objects. | Example: |a=S |b=a |print(a is b, a is not b) |output: true false p | Membership operators: | Check_if the value is a_member_of a_sequence. Operator Name Example in TRUE, if variable is in the list, | xin y string, dictionary, etc. not in TRU, if variable isnot inthe | xnotiny list, string, dictionary, etc. Example: a=[),2,3,5] b=4 print(b in a, b not in a) output: false true Bitwise_operators:Engineering Express Perform operations on individual bits of binary numbers. Operator Meaning & Bitwise AND I Bitwise OR “ Bitwise exclusive OR / Bitwise XOR_ ~ Bitwise inversion (one’s complement) << Shifts the bits to left / Bitwise Left Shift >> Shifts the bits to right /Bitwise Right Shift Lxarnple: 4 TN a a=3 LZ La \ Se ah. b=? |print(a & b, ~a) Sa. = a loutput: 3 4 ___Python Operator Precedence ay Precedence ign | Operator Name Highest Exponentiation ‘Unary positive, unary negative, bitwise negation Multiplication, division, fo dlivision, modulus ie Addition, subtraction -shift,right-shift & Bitwise AND: x ‘Bitwise XOR 1 Bitwise OR = a is,isnot not Boolean NOT Comparlson, identity ay ‘a, i eee!Engineering Express @ Determine the order of execution for operators with the same | precedence. There are two type oi ociativity: L ight: first the move towards_right. |__2. Right to Left: Operators of the same precedence are executed from the right | Example |a=3+2-] | printCa) output: 4 Operators of the same precedence are executed from the left side ||Engineering Express: Simplifying Engineering Education ‘Are you drowning in complex engineering concepts? Struggling to decipher cryptic notes? Fear not! Welcome to Engineering Express, where we decode the mysteries of engineering subjects for you. §P What We Offer: Clear Explanotions: Our notes break down intricate topics into bite-sized, easy-to-understand language, No jargon, no headaches! Real-Life Connections: Ever wondered how those abstract formulas apply in the real world? We've got you covered with relatable examples. Maximize Your Marks: Our mission? Boost your exam scores. With our straightforward notes, you'll be well- prepared to conquer any engineering challenge. Follow us on social media YouTube - https://www youtube.com/@Engineering Express. ?sub_contirmation=I WhatsApp - https://chat.whatsapp.com/H]6tpUl2SmQ3o6vleD2Dlu Instagram - https://www.instagram.com/engineeringexpress2 312/ Telegram - https://t.me/engineeringexpressofficial Join the Engineering Express community today ond unlock the power of simplified learning! <7 @
You might also like
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Mark Manson
4/5 (6134)
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
4/5 (627)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brene Brown
4/5 (1148)
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
Chris Voss
4.5/5 (935)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
4/5 (8215)
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Angela Duckworth
4/5 (631)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
4/5 (1253)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
4/5 (8365)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
4.5/5 (860)
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Carmen Maria Machado
4/5 (877)
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Ben Horowitz
4.5/5 (361)
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Margot Lee Shetterly
4/5 (954)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
4/5 (2923)
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
Ashlee Vance
4.5/5 (484)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
4.5/5 (277)
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Fredrik Backman
4.5/5 (4973)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
4.5/5 (444)
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
Colm Toibin
3.5/5 (2061)
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
Garth Stein
4/5 (4281)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
4/5 (100)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Meik Wiking
3.5/5 (447)
Yes Please
From Everand
Yes Please
Amy Poehler
4/5 (1988)
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Gilbert King
4.5/5 (278)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
3.5/5 (2283)
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Roxane Gay
4/5 (1068)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
4/5 (1993)
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
Ruth Ware
3.5/5 (2641)
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
Betty Smith
4.5/5 (1936)
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
Viet Thanh Nguyen
4.5/5 (125)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
3.5/5 (692)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
4.5/5 (1912)
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
Hilary Mantel
4/5 (4074)
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Naomi Klein
4/5 (75)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
3.5/5 (830)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
3.5/5 (901)
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
3.5/5 (143)
John Adams
From Everand
John Adams
David McCullough
4.5/5 (2544)
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
M L Stedman
4.5/5 (790)
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
4/5 (45)
Little Women
From Everand
Little Women
Louisa May Alcott
4/5 (105)
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel
John le Carré
3.5/5 (109)