In this tutorial we are going to so you how to learn python programming language in short time very easy and quick, so lets get started ............
What is Python?
- Web Development (Server Side),
- Drone Development,
- Mathematics,
- System Scripting.
- Data science
- Artificial intelligence (AI)
- Machine learning (ML)
- Robotics and more.
What can we do with Python?
- Python can be used to create web applications.
- Python can be used in software to create workflows.
- Python can connect to database systems. and It can also modify and read the files.
- Python can be used to process big data and perform complex mathematics.
- Python can be used for rapid prototyping or production-ready software development.
Why Python?
- Python runs on a variety of platforms (Windows, Mac, Linux, Raspberry Pi, etc.).
- Python has a simple syntax similar to English.
- Python has syntax that allows developers to write programs in fewer lines than other programming languages.
- Python runs on an interpreter system. This means that as soon as you write your code, you can run it. This means prototyping can be very fast.
Python Syntax
- Developed for readability, Python has some similarities to English and is influenced by mathematics.
- Python uses newlines to complete commands, unlike other programming languages that often use semicolons and parentheses.
- Python relies on indentation with spaces to define scope. Similar to loop, function, and class scoping. Other programming languages often use curly braces for this purpose.
Output
>>Hello, world!
Python Comments
- You can use comments to describe Python code.
- You can use comments to make your code easier to read.
- Comments can be used to prevent execution when testing code.
- Comments starting with # are ignored by Python:
Example:
Multiline
Comments
- Python has multiline comment syntax, which can be used ''' '''(triple quade).
- To add a multi-line comment, you can insert # on each line.
Variables
- Variable is an one type of container which is it stored the data value in memory location.
- A variable is created the moment you first assign it a value.
Example:
x = 4 # x is of type int
y = "Sally" # x is now of type str
print(y)
Output:
Sally
Casting
If you want to specify the data type of a variable, This can be done with a cast.
Type:
You can get the data type variable with type()
function.
Example:
Note: Variables are case sensitive
Assign Multiple
Values
In Python, you can assign values to multiple variables in one line.
Example
Unpack a Collection
If you have a collection of values in lists, tuples, etc., you can use Python to extract the values into variables. It's called unpacking.
Example
Output Variable
print()
is often used to print variables.Output
Python is great
print()
function prints multiple variables separated by commas:Example
You can also use the + operator to print multiple variables:
Example
Global Variable
Variables created outside a function (as in all the examples above) are called global variables. Global variables are available to everyone, inside or outside the function.
Example
Example
·
int
·
float
·
complex
example:
Integer:
An Int or Integer is a positive or negative integer with no fractional part and unlimited length.
Example
A float can also be a scientific number with an "e" to indicate powers of ten.
Complex
Complex numbers are written with a "j"
as the imaginary part:
Example
Type Conversion
You can convert from one type to another with
the int()
, float()
, and complex()
methods:
Example
random()
function to create random numbers, but Python has a built-in module called random
that can be used to create random numbers.Example:
import random # import random variables
Python Casting
Sometimes you want to specify the type of a variable. This can be done by pouring. Since Python is an object-oriented language, classes are used to define data types, including primitive types.
• float() - constructs a floating point number from an integer literal, floating point literal, or string literal (assuming the string represents a floating point number or an integer).
• str() - many including Constructs strings from data types of strings, integer literals, floating point literals
Example
True
or False
. You can evaluate any expression in Python to get one of two answers: True
or False
.Example
The bool()
function allows you to evaluate any value, and give
you True
or False
in return.
Example
True
if they contain some content.True
except the empty string.0
are True
.True
except empty ones.Example
()
, []
, {}
, ""
, the number 0, and the value None. Of course, False
.isinstance()
function that can be used to determine if an object is of a particular data type.
0 Comments