Skip to main content

Posts

LIST OF TOPICS YOU WILL BE LEARN THIS WHOLE SERIES

Python  Introduction    Python  Getting Started Python  Variables Python  Comments Python Try Except Python Data Types Python Casting Python Strings Python Operators Python Lists Python Tuples Python Sets Python Dictionaries Python Arrays Python PIP Python Booleans Python If  Else Python Loops Python Functions Python Lambda Function Python Modules Python Random Module Python cmath Module Python Math Module Python Classes and Objects Python Inheritance PYTHON FILE I/O                Video Contain 1. Telusko 2. CodeWithHarry For Certification Course 01. Udemy1 02. Udemy2                                                                                                                                          NEXT>
Recent posts

Python Introduction

  Python  Introduction What is Python? Python is a popular programming language. It was created by Guido van Rossum, and released in 1991. It is used for: web development (server-side), software development, mathematics, system scripting. What can Python do? Python can be used on a server to create web applications. Python can be used alongside software to create workflows. Python can connect to database systems. It can also read and modify files. Python can be used to handle big data and perform complex mathematics. Python can be used for rapid prototyping, or for production-ready software development. Why Python? Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc). Python has a simple syntax similar to the English language. Python has syntax that allows developers to write programs with fewer lines than some other programming languages. Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that prototypin

Python Getting Started

  Python  Getting Started Python Install Many PCs and Macs will have python already installed. To check if you have python installed on a Windows PC, search in the start bar for Python or run the following on the Command Line (cmd.exe): C:\Users\ Your Name >python --version To check if you have python installed on a Linux or Mac, then on linux open the command line or on Mac open the Terminal and type: python --version If you find that you do not have python installed on your computer, then you can download it for free from the following website:  https://www.python.org/ Python Quickstart Python is an interpreted programming language, this means that as a developer you write Python (.py) files in a text editor and then put those files into the python interpreter to be executed. The way to run a python file is like this on the command line: C:\Users\ Your Name >python helloworld.py Where "helloworld.py" is the name of your python file. Let's write our first Python fi

Python Variables

  Python  Variables Variables Variables are containers for storing data values. Creating Variables Python has no command for declaring a variable. A variable is created the moment you first assign a value to it. Example x =  5 y =  "John" print (x) print (y) Variables do not need to be declared with any particular  type , and can even change type after they have been set. Example x =  4         # x is of type int x =  "Sally"   # x is now of type str print (x) Casting If you want to specify the data type of a variable, this can be done with casting. Example x =  str ( 3 )     # x will be '3' y =  int ( 3 )     # y will be 3 z =  float ( 3 )   # z will be 3.0 Get the Type You can get the data type of a variable with the  type()  function. Example x =  5 y =  "John" print ( type (x)) print ( type (y)) Single or Double Quotes? String variables can be declared either by using single or double quotes: Example x =  "John" # is the same as x = 

Python Comments

  Python  Comments Comments can be used to explain Python code. Comments can be used to make the code more readable. Comments can be used to prevent execution when testing code. Creating a Comment Comments starts with a  # , and Python will ignore them: Example #This is a comment print ( "Hello, World!" ) Comments can be placed at the end of a line, and Python will ignore the rest of the line: Example print ( "Hello, World!" )  #This is a comment A comment does not have to be text that explains the code, it can also be used to prevent Python from executing code: Example #print("Hello, World!") print ( "Cheers, Mate!" )

Python Try Except

  Python  Try Except The  try  block lets you test a block of code for errors. The  except  block lets you handle the error. The  finally  block lets you execute code, regardless of the result of the try- and except blocks. Exception Handling When an error occurs, or exception as we call it, Python will normally stop and generate an error message. These exceptions can be handled using the  try  statement: Example The  try  block will generate an exception, because  x  is not defined: try :    print (x) except :    print ( "An exception occurred" ) Since the try block raises an error, the except block will be executed. Without the try block, the program will crash and raise an error: Example This statement will raise an error, because  x  is not defined: print (x) Many Exceptions You can define as many exception blocks as you want, e.g. if you want to execute a special block of code for a special kind of error: Example Print one message if the try block raises a  NameError  an