1 / 63

Python Tutorial For Beginners | Python Crash Course - Python Programming Language Tutorial | Edureka

** Python Certification Training: https://www.edureka.co/python ** <br>This Edureka tutorial on "Python Tutorial for Beginners" (Python Blog Series: https://goo.gl/nKQJHQ) covers all the basics of Python. It includes python programming examples, so try it yourself and mention in the comments section if you have any doubts. Following are the topics included in this PPT: <br><br>Introduction to Python <br>Reasons to choose Python <br>Installing and running Python <br>Development Environments <br>Basics of Python Programming <br>Starting with code <br>Python Operators <br>Python Lists <br>Python Tuples <br>Python Sets <br>Python Dictionaries <br>Conditional Statements <br>Looping in Python <br>Python Functions <br>Python Arrays <br>Classes and Objects (OOP) <br>Conclusion <br><br>Follow us to never miss an update in the future. <br><br>Instagram: https://www.instagram.com/edureka_learning/ <br>Facebook: https://www.facebook.com/edurekaIN/ <br>Twitter: https://twitter.com/edurekain <br>LinkedIn: https://www.linkedin.com/company/edureka

EdurekaIN
Download Presentation

Python Tutorial For Beginners | Python Crash Course - Python Programming Language Tutorial | Edureka

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Agenda Python Certification Training https://www.edureka.co/python

  2. Agenda 01 Introduction Introduction to Python 02 Getting Started Installing and working with Python 03 Concepts Overview of the concepts in Python 04 Practical Approach Looking at code to understand theory Python Certification Training https://www.edureka.co/python

  3. Introduction to Python Python Certification Training https://www.edureka.co/python

  4. Introduction to Python Python is a powerful high-level, object-oriented programming language created by Guido van Rossum. What is Python? I created Python! No. It wasn't named after a dangerous snake. Rossum was fan of a comedy series from late seventies. Largest community for Learners and Collaborators The name "Python" was adopted from the same series "Monty Python's Flying Circus". Let’s get started then! Open Source Python Certification Training https://www.edureka.co/python

  5. Why is Python so popular? Python Certification Training https://www.edureka.co/python

  6. Popularity Of Python Learning other languages Learning Python Syntax is extremely simpleto read and follow! Pythonis very beginner-friendly! Millions of happy learners! Hello Python! I’m a happy coder! Python Certification Training https://www.edureka.co/python

  7. Unique Features of Python Python Certification Training https://www.edureka.co/python

  8. Features Of Python 02 Free and Open-Source Simple language -Easier to learn 01 Portability Extensible and Embeddable 04 03 Large Standard Libraries High Level –Interpreted Language 05 06 Object Oriented You shall master Python! 07 Python Certification Training https://www.edureka.co/python

  9. Why should you learn Python? Python Certification Training https://www.edureka.co/python

  10. Why Should You Learn Python? Python is a general-purpose language Wide range of applications Graphical User Interface Web Development Mathematical Computations Length of the code is relatively short Fun to work with! Python Certification Training https://www.edureka.co/python

  11. 4 Reasons to Choose Python Python Certification Training https://www.edureka.co/python

  12. Reasons to Choose Python as First Language We can fetch any number of reasons for you! Simple Elegant Syntax a = 2 b = 3 sum = a + b print(sum) Programming in Python is fun! It's easier to understand and write Python code Why? The syntax feels natural. Python Certification Training https://www.edureka.co/python

  13. Reasons to Choose Python as First Language We can fetch any number of reasons for you! Not overly strict No need to define the type of a variable in Python Also, no semicolon at the end of the statement Phew, no more semicolon!!! Python enforces you to follow good practices (like proper indentation) Python Certification Training https://www.edureka.co/python

  14. Reasons to Choose Python as First Language We can fetch any number of reasons for you! Expressiveness of the language Python allows you to write programs having greater functionality with fewer lines of code Woah Python <3 You will be amazed how much you can do with Python once you learn the basics Python Certification Training https://www.edureka.co/python

  15. Reasons to Choose Python as First Language We can fetch any number of reasons for you! Great Community and Support Python has a large supporting community We have an amazing community with lots of videos, blogs and course certifications on Python! Python Certification Training https://www.edureka.co/python

  16. Installing And Running Python Python Certification Training https://www.edureka.co/python

  17. Installing And Running Python 6 very simple steps to install Python! Go tothe official Python downloadpage on the official site and clickDownload Python 3.6.0 When the download is completed, double-click the file and follow the instructions to install it. When Python is installed, a program called IDLE is also installed along with it. It provides graphical user interface to work with Python. To create a file in IDLE, go toFile > New Window(Shortcut:Ctrl+N) Write Python code and save (Shortcut:Ctrl+S) with.pyfile extension Go toRun > Run module(Shortcut:F5) and you can see the output. Python Certification Training https://www.edureka.co/python

  18. Development Environments Python Certification Training https://www.edureka.co/python

  19. Development Environments There are a lot of environments you can use! Komodo IDE Python Certification Training https://www.edureka.co/python

  20. Compiling v/s Interpreting Python Certification Training https://www.edureka.co/python

  21. Compiling v/s Interpreting Python is directly interpreted into machine instructions! execute compile output source code Hello.java byte code Hello.class interpret output source code Hello.py I’m learning Python! Python Certification Training https://www.edureka.co/python

  22. Basics of Python Python Certification Training https://www.edureka.co/python

  23. Expressions Diving into the heart of Python! Expression: A data value or set of operations to compute a value. Examples: 1 + 4 * 3 42 Arithmetic operators we will use: + -* / addition, subtraction/negation, multiplication, division • % modulus, a.k.a. remainder • ** exponentiation • Precedence: Order in which operations are computed. * / % ** have a higher precedence than + - 1 + 3 * 4 is 13 • I’m learning Python! Parentheses can be used to force a certain order of evaluation. (1 + 3) * 4 is 16 • Python Certification Training https://www.edureka.co/python

  24. Math Commands Python has useful commands for performing calculations! Command name abs(value) Description absolute value ceil(value) cos(value) floor(value) log(value) rounds up cosine, in radians rounds down Constant Description logarithm, base e 2.7182818... e log10(value) max(value1, value2) min(value1, value2) logarithm, base 10 3.1415926... pi larger of two values smaller of two values round(value) sin(value) nearest whole number sine, in radians sqrt(value) square root I’m learning Python! Python Certification Training https://www.edureka.co/python

  25. Variables Variable is a named piece of memory that can store a value! Usage: • Compute an expression's result, store that result into a variable, and use that variable later in the program. – – – Assignment statement: Stores a value into a variable. • Syntax: name= value • Examples: x = 5 gpa= 3.14 A variable that has been given a value can be used in expressions. x + 4 is 9 • I’m learning Python! Python Certification Training https://www.edureka.co/python

  26. Basic Datatypes Many datatypes to choose from in Python! Integers (default for numbers) z = 5 / 2 # Answer 2, integer division Floats x = 3.456 Strings Can use “” or ‘’ to specify with “abc” == ‘abc’ Unmatched can occur within the string: “matt’s” Use triple double-quotes for multi-line strings or strings than contain both ‘ and “ inside of them: “““a‘b“c””” I’m learning Python! Python Certification Training https://www.edureka.co/python

  27. Whitespaces Whitespace is meaningful in Python: Especially indentation and placement of newlines Use a newline to end a line of code Use \when must go to next line prematurely No braces {}to mark blocks of code, use consistentindentation instead •First line with lessindentation is outside of the block •First line with moreindentation starts a nested block Colons start of a new block in many constructs, e.g. function definitions, then clauses. I’m learning Python! Python Certification Training https://www.edureka.co/python

  28. Comments Comments help us understand the code better! Start comments with #, rest of line is ignored Can include a “documentation string” as the first line of a new function or class you define Development environments, debugger, and other tools use it: it’s good style to include one. #ImAComment I’m learning Python! Python Certification Training https://www.edureka.co/python

  29. Assignment So how do you put some value in a variable? Binding a variablein Python means setting a nameto hold a referenceto some object Assignment creates references, not copies! Names in Python do not have an intrinsic type, objects have types Python determines the type of the reference automatically based on what data is assigned to it You create a name the first time it appears on the left side of an assignment expression: x = 3 A reference is deleted via garbage collection after any names bound to it have passed out of scope. Python uses reference semantics(more later) I’m learning Python! Python Certification Training https://www.edureka.co/python

  30. A Quick Break! Python and it’s big players around the world! Python Certification Training https://www.edureka.co/python

  31. Naming Rules Watch out for reserved words! Names are case sensitive and cannot start with a number. They can contain letters, numbers, and underscores. bob Bob _bob _2_bob_ bob_2 BoB There are some reserved words: and, assert, break, class, continue, def, del, elif, else, except, exec, finally, for, from, global, if, import, in, is, lambda, not, or, pass, print, raise, return, try, while I’m learning Python! Python Certification Training https://www.edureka.co/python

  32. Naming Conventions We have 3 recommended conventions The Python community has these recommended naming conventions • joined_lowerfor functions, methods and, attributes! • joined_loweror ALL_CAPS for constants! • StudlyCapsfor classes! Attributes: interface, _internal, __private I’m learning Python! Python Certification Training https://www.edureka.co/python

  33. Assignment – An Easier Way? Less of typing means more of coding! You can assign to multiple names at the same time >>> x, y = 2, 3 >>> x 2 >>> y 3 This makes it easy to swap values >>> x, y = y, x Assignments can be chained >>> a = b = x = 2 I’m learning Python! Python Certification Training https://www.edureka.co/python

  34. Accessing Non-Existent Names Let’s see how we can raise an error! Accessing a name before it’s been properly created (by placing it on the left side of an assignment), raises an error >>> y Traceback (most recent call last): File "<pyshell#16>", line 1, in -toplevel- y NameError: name ‘y' is not defined >>> y = 3 >>> y 3 I’m learning Python! Python Certification Training https://www.edureka.co/python

  35. Casting We can explicitly convert based on requirement Casting in python is therefore done using constructor functions: •int()-constructs an integer number from an integer literal, a float literal (by rounding down to the previous whole number), or a string literal (providing the string represents a whole number) •float()-constructs a float number from an integer literal, a float literal or a string literal (providing the string represents a float or an integer) •str()-constructs a string from a wide variety of data types, including strings, integer literals and float literals I’m learning Python! Python Certification Training https://www.edureka.co/python

  36. Casting We can explicitly convert based on requirement x = int(1) y = int(2.8) # y will be 2 z = int("3") # z will be 3 # x will be 1 Told you Python is real easy! x = float(1) y = float(2.8) z = float("3") w = float("4.2") # w will be 4.2 # x will be 1.0 # y will be 2.8 # z will be 3.0 x = str("s1") # x will be 's1' y = str(2) # y will be '2' z = str(3.0) # z will be '3.0' I’m learning Python! Python Certification Training https://www.edureka.co/python

  37. Let’s Code Python Certification Training https://www.edureka.co/python

  38. Python Operators Python Certification Training https://www.edureka.co/python

  39. Arithmetic Operators We can perform common math operations easily! Operator + - * / * ** // Name Addition Subtraction Multiplication Division Modulus Exponentiation Floor Division Example x + y x – y x * y x / y x % y x ** y x // y I’m learning Python! Python Certification Training https://www.edureka.co/python

  40. Assignment Operators We can assign values to variables easily! Operator = += -= *= &= >>= <<= Example x = 5 x += 3 x -= 3 x *= 3 x &= 3 x >>= 3 x <<= 3 Same As x = 5 x = x + 3 x = x – 3 x= x * 3 x = x & 3 x = x >> 3 x = x <<3 I’m learning Python! Python Certification Training https://www.edureka.co/python

  41. Comparison Operators We can compare two values easily! Operator == != > < >= <= Example x == y x != y x > y x < y x >= y x <= y Name Equal Not Equal Greater Than Less Than Greater than or equal to Less than or equal to I’m learning Python! Python Certification Training https://www.edureka.co/python

  42. Logical Operators Can we combine conditional statements? Yes, we can! Operator Description Returns True if both statements are true Returns True if one of the statements is true Reverse the result, returns False if the result is True Example And x < 5 and x < 10 Or x < 5 or x < 4 Not not(x , 5 and x < 10) I’m learning Python! Python Certification Training https://www.edureka.co/python

  43. Identity Operators Compare objects, not to check if they are equal but to check if they are the same object Operator Description Example Returns True if both variables are same object Returns True if both variables are not same object is x is y is not x is not y I’m learning Python! Python Certification Training https://www.edureka.co/python

  44. Bitwise Operators Let’s compare binary numbers and operate on them! Operator & | ^ ~ Name AND Description Sets each bit to 1 if both bits are 1 Sets each bit to 1 if one of two bits are 1 Sets each bit to 1 if only one of two bits in 1 Inverts all the bits Shift left by pushing zeros in from the right and let the leftmost bits fall off Shift right by pushing copies of leftmost bit in from the left and let the rightmost bits fall off OR XOR NOT << Zero fill left shift >> Signed right shift I’m learning Python! Python Certification Training https://www.edureka.co/python

  45. Python Lists – Back to Code! Python Certification Training https://www.edureka.co/python

  46. List Methods Python has a set of built-in methods that you can use! Method append() clear() copy() count() extend() index() insert() pop() remove() reverse() sort() Description Adds an element at the end of the list Removes all the elements from the list Returns a copy of the list Returns the number of elements with the specified value Add the elements of a list to the end of the current list Returns the index of the first element with the specified value Adds an element at the specified position Removes the element at the specified position Removes the item with the specified value Reverses the order of the list Sorts the list I’m learning Python! Python Certification Training https://www.edureka.co/python

  47. Python Tuples – Back to Code! Python Certification Training https://www.edureka.co/python

  48. Tuple Methods Python has two built-in methods you can use on tuples! Method Description Returns the number of times a specified value occurs in a tuple Searches the tuple for a specified value and returns the position of where it was found count() index() I’m learning Python! Python Certification Training https://www.edureka.co/python

  49. Python Sets – Back to Code! Python Certification Training https://www.edureka.co/python

  50. Set Methods Python has two built-in methods you can use on tuples! Method add() clear() copy() Description Adds an element to the set Removes all the elements from the set Returns a copy of the set Returns a set containing the difference between two or more sets Removes the items in this set that are also included in another specified set Remove the specified item difference() difference_update() discard() intersection() issubset() pop() Returns the intersection of two other set Returns whether another set contains this set or not Removes an element from the set I’m learning Python! Python Certification Training https://www.edureka.co/python

More Related