Learn Python


Go Full Page [ Cheatsheet ]


#ABOUT 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.
#NOTE: CLICK ON THE IMAGE TO VIEW IT IN HD


#ROAD-MAP OF LEARNING PYTHON
#Before starting roadmap we need to learn two basic stuffs
  • PYTHON SYNTAX
  • PYTHON INDENTATION
#PYTHON SYNTAX
U can simply assume syntax as output
Python syntax can be executed by writing directly in the Command Line:
Or by creating a python file on the server, using the .py file extension, and running it in the Command Line:

#Execute Python Syntax

  • Command Line
  • Creating a python file on the server
remember the file extension for python is  '.py'
#PYTHON INDENTATION

  • Indentation refers to the spaces at the beginning of a code line.
  • Where in other programming languages the indentation in code is for readability only, the indentation in Python is very important.
  • Python uses indentation to indicate a block of code.

NOW WE ARE STARTING OUR ROADMAP
#1.PYTHON STRINGS
  • #Strings_basics
  • #Slicing Strings
  • #Modify Strings
  • #String Concatenation
  • #Format - Strings
  • #Escape Characters
  • #String Methods
#Strings_basics

GO through the image for better understanding!
#2.FUNCTION
FUNCTIONS:
TAKE AN EXAMPLE: YOU ORDERED A BOOK FROM AMAZON, AMAZON will

1.take a box and specify ur name in the box
2.put the book inside the box
3.close the box, then Delivered to you

SIMILARLY!

1.Open a box by defining any  name u want
2.Put ur code inside that box
3.close the function

BASIC EXAMPLE:
EXAMPLE-1
EXAMPLE-2
#WHY WE USE FUNCTION?
CUZ each function u define has its unique output

#lemon juice example!


GO through the image for better understanding!

#3.PYTHON VARIABLES
  1. Variables_basics
  2. Variables names
  3. Assign multiple variables
  4. Output variable
  5. Global variable
1.VARIABLES
  • Variables are containers for storing data values.
  • Python has no command for declaring a variable.
  • A variable is created the moment you first assign a value to it.
#VARIABLES - NAMES
A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume).
#Rules for Python variables:
  • A variable name must start with a letter or the underscore character
  • A variable name cannot start with a number
  • A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
  • Variable names are case-sensitive (age, Age and AGE are three different variables)
3.ASSIGN MULTIPLE VALUES
Python allows you to assign values to multiple variables in one line:

Note: Make sure the number of variables matches the number of values, or else you will get an error.

#OUTPUT - VARIABLES
  • The Python print statement is often used to output variables
  • To combine both text and a variable, Python uses the + character:
#GLOBAL - VARIABLES
  • Variables that are created outside of a function (as in all of the examples above) are known as global variables.
  • Global variables can be used by everyone, both inside of functions and outside.

#4.DATA-TYPES
Built-in Data Types
In programming, data type is an important concept.

Variables can store data of different types, and different types can do different things.

Python has the following data types built-in by default, in these categories:
  • Text Type: str
  • Numeric Types: int, float, complex
  • Sequence Types: list, tuple, range
  • Mapping Type: dict
  • Set Types: set, frozenset
  • Boolean Type: bool
  • Binary Types: bytes, bytearray, memoryview
#Getting the Data Type
You can get the data type of any object by using the type() function:

#PYTHON CASTING
You can CONVERT the DATA-TYPE in any DATA-TYPE

#OPERATORS
#Python divides the operators into the following groups:
  • Arithmetic operators
  • Assignment operators
  • Comparison operators
  • Logical operators
  • Identity operators
  • Membership operators
  • Bitwise operators


1 Comments

If you have any doubts, please let me know

Previous Post Next Post