Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

datatypes in python

Datatypes introduction:
Datatypes represent the type of data that we are using is known as a datatype. It helps to understand what kind of operations can be performed on a value and it also represents the type of data stored inside a variable.
since we know that python is a dynamic programming language that means hare we no need to declare the type explicitly i.e., it is automatically considered based on your provided data by the python virtual machine(PVM).
where in C,C++,java we have to define the type so these type of languages are called as statically typed language.
the fundamental data types are:
  • int
  • float
  • complex
  • bool
  • str
1. int datatype:
this type of datatype represents the data which has numeric value.
that is the numbers without decimal point is known as integers.
if we want to represent integral numbers int datatype is used.
example:
a = 100
here we did not need to declare the type explicitly i.e., it is automatically considered based on your provided data by the python virtual machine(PVM).
type() function is a built-in function to know the type of data.

example:
a = 100
print(type(a))
output:
<class 'int'>

if we want to know where the object is stored i.e., to know the address of the object we have a built-in function id( ).
a = 100
print(type(a))
print(id(a))
output:
<class 'int'>
2440165086672

note:
in other languages like java they have four types to represent integral values such as
byte
short
long
int

but in python we have only one type even how long the size of integer it is int type only.
example:
a = 100
b = 199999999999999999999999999
print(type(a))
print(type(b))
output:
<class 'int'>
<class 'int'>

to represent int values we have 4 possible ways they are..
1. Binary 
2. Decimal
3.Octal
4.Hexaadecimal

1.Binary form:(Base-2)
It allows only 0's and 1's
example:
a = 10101
print(a)
output:
10101
it is not treated as binary number because the default number is always considered as decimal only
but to specify it as a binary number then we have to specify the number prefixed with 0b or 0B.
that is if a number is prefixed with 0b or oB this number is considers as binary number.
example:
a = 0b10101
print(a)
output:
21
now you can get a doubt why the output is 21 even though if we specify it as a binary number means
that is the default number system is decimal 
so it converts binary number a = 0b10101  to decimal and then prints on screen with the help of print().

2.Decimal form:(base-10)
this is  the default number system.
it allows digits upto 0 to 9.
Ex: 123

3.Octal form : (base 8)
 it allows digits upto 0 to 7 only.
Remember the literal value should starts with 0o or 0O (zero capital O or  Small o).
Ex: this a=0o123 octal into decimal will be converted. and then prints on screen with the help of print().
a=0o123
print(a)
output:
83

4.Hexadecimal: (base-16)
It allows digits from 0 to 9 and there after A to f either capital or small A to F.
where,
A = 10
B = 11
C = 12
D = 13
E = 14
F = 15
The literal should be prefixed with 0X or 0x ie, Zero & Small x or Capital x
example:
a=0x10
print(a)
output: 
16
note:
If you observe, even though if we entering input in decimal or binary or octal or hexadecimal but the output was always generates only in decimal by the python virtual machine.
but if you want the output in other ways like binary or octal or hexadecimal then we can achieve it by using base conversions.
i.e., to convert from one base to another base for this python provides three built-in functions
1.bin( )
2.oct(  )
3.hex( )

example:
bin(15)
output:
0b1111

print(oct(177))
output:
0o261

print(hex(12345))
output:
0x3039

2. Float datatype:
It is a real number with floating point representation and it is specified by a decimal point.
that is the number with decimal point is considered as floating point values.
example:
floatvalue = 1.2
print(type(floatvalue))
output:
<class 'float'>

we can also represent floating point numbers in exponential form i.e, by using e or E
floatvalue = 1e3
print(type(floatvalue))
print(floatvalue)
output:
1000.0

note:
Floating points is applicable only in decimal values but not in binary,octal or hexadecimal.
If you try in binary,octal or hexadecimal. it will throws an error.

3. Complex datatype:
This is the special datatype in python because other languages like java,C,C++ it doesn't contains this type of datatype so it is a special datatype.
this type of datatype is useful for developing scientific applications
the syntax for this datatype is a+bj
where a is a real part and b is a imaginary part and j is  j = √-1 and j² = -1
Example:
a = 1+2j
print(type(a))
output:
<class 'complex'>

To know the real and imaginary parts we have 
a = 1+2j
print(type(a))
print(a.real)
print(a.imag)
output:
<class 'complex'>
1.0
2.0

note:
We can take int values or float values in real and imaginary parts 
a = 1+2j
and
a  = 10+23.2j

we can take binary,octal or hexadecimal in real part but in imaginary we should take only decimal values 
Example:
a = 0b111+20j

remember that we can also perform arithmetic operations between two complex numbers

4. Bool datatype:
This type of datatype used to represent logical values such as true and false
this datatype consist of only two values True and Flase.
It should be started with capital i.e, True and Flase otherwise it throws an error
example:
a = true
print(a)
output:
    a = true
NameError: name 'true' is not defined

where is we define in capital then
a = True
print(a)
output:
True

To check the type
a = True
print(a)
print(type(a))
output:
True
<class 'bool'>

a small program to get understand about bool datatype
program:
a = 10
b = 20
c = a>b
print(c)
output:
False

Internally the value of True is 1 and false is 0.
print(True+True)   #2
print(True+False) #1
print(True*True) #1
print(True-True) #0
print(True/True) #1.0
print(False+False) #0
print(False-True) #-1
print(False+True) #1
print(False-False) #0
print(False*False) #0

5. str datatype:
string datatype is the most common datatype in any language.
A string is a collection or sequence of one or more characters enclosed  in single quote, double-quote or triple quote.
where other languages like java single char with single quote is char datatype but not in python i.e, in python there is no char datatype.a char is a string of length one. and it is represented by str.
Example:
s= "zaheer"
print(type(s))
print(s)
output:
<class 'str'>
zaheer

we can use single or double quotes or triple quotes
Example:
s= 'zaheer'
print(type(s))
print(s)
output:
<class 'str'>
zaheer

note:
single and double quotes are useful for single line string 
but to define multiline string we should have to use triple quotes
Example:
name = """zaheer
    this is a multiline
    string example"""
print(name)

output:
zaheer
    this is a multiline
    string example

and triple quotes are very useful to use single quote and double quotes as a normal characters in string.
Example:
name = """ 'python' is "easy" """
print(name)
output:
 'python' is "easy" 

etc..are the fundamental datatypes in python.

note:
i hope you like the content. like and comment your opinion and dont forget to subscribe..

python reserved words


PYTHON RESERVED WORDS OR KEYWORDS
What do you mean reserved?
Means to be kept or set apart for some particular use or purpose.

like the same way in programming languages it contains keywords that have particular meaning and for a particular purpose.
i.e., these words represent meaning or functionality such type of words is called reserved words.

present in python 3.9 has 36 keywords, which will increase over time, with the addition of newer keywords.
They are

['False',  'None',  'True',  '__peg_parser__',  'and',  'as',  'assert',  'async',  'await',  'break',  'class',  'continue',  'def',  'del',  'elif',  'else',  'except',  'finally',  'for', 
'from',  'global',  'if',  'import',  'in',  'is', 'lambda',  'nonlocal',  'not',  'or',  'pass',  'raise',  'return',  'try', 'while',  'with',  'yield']

Note:
All the keywords are denoted with characters only i.e., in lower case letters, and only three words are started with upper capital letters they are True, False, None and instead of this if you use symbols or digits it throws an error. 

example:
a = true
print(a)
output:
Traceback (most recent call last):
  File "D:\practical\one.py", line 318, in <module>
    a = true
NameError: name 'true' is not defined

so true or false or none should be capital only ie.,
example:
a = True
print(a)
output: True
note:
Switch and do while concepts are not applicable in python.

To check the keywords
import keyword
a = keyword.kwlist
print(a)
output:
['False', 'None', 'True', '__peg_parser__',
'and','as', 'assert', 'async',
'await', 'break', 'class', 'continue',
'def', 'del', 'elif', 'else', 'except',
'finally', 'for', 'from', 'global','
'if', 'import', 'in', 'is',
'lambda', 'nonlocal', 'not', 'or',
'pass', 'raise', 'return', 'try', 'while',
'with', 'yield']

Remember that we cant use the keywords as an identifier, if you use it then it will get an error.
example:
def = "pyhton"
print(def)
Output:
    def = "pyhton"
        ^
SyntaxError: invalid syntax


note:
if you like it then comment and share it and dont forget to subscribe

Python Important Topics

The topics or questions you must know before you attend the interview
  • What is python & who is the father of python?
  • Why suddenly python became so popular?
  • Comparison of python with other languages? and example.
  • Why the name python? for python programing language.
  • Is python is a functional or OOP or scripting language?
  • Where we can use python?
  • Features of python?
  • Limitations of python?
  • Flavors of python?
  • python versions?
  • Difference between python 2x and 3x?
  • What is the identifier in python?
  • Rules to create identifiers?
  • Reserved words in python? or keywords in python?
  • What are the data types in python?
  • What is typecasting?
  • .......








note:
I will continue to add the remaining questions stay tuned...

python identifiers

Python identifiers are nothing but a name in the python program
for example to identify a thing or a person we have names same as in python it is called as identifiers.

An identifier can be a variable name or a method name or a class name.
Example:
a = 5
here 'a' which can be used to represent
where a is a name of the variable to represent the 5

Where there are some rules to define or to create identifiers they are as follows as
Rule 1:
It allows only characters (ALPHABETS) i.e., capital letters from A to Z
and small letters a to z
and digits from  0 to 9
and only one special symbol is allowed i.e.,  " _ " (underscore)
Except this if you try to enter any other symbols it will show a syntax error.
where a syntax error is the most common and basic error that occurs when the python parser is unable to understand the line of code.

Rule 2:
The identifiers should start with characters only.
and it should not start with digits 
that is we can write or start identifiers name by characters and along with that we can also use the only symbol that is (underscore _) 
Example:
NAME ="zaheer"   ✔
Name = "zaheer"    ✔
_name = "zaheer"    ✔
_NAME = "zaheer"  ✔
NAme123 = "zaheer"  ✔

But we cannot start with any symbols or digits, If we use it again it will show a syntax error.
123name = "zaheer" ❌
$name = "zaheer" ❌

note:
NAME 
Name
_name
_NAME
NAme123

all are different because python is a case-sensitive language.
that means A and a both are different.

last but not least
Rule 3:
There is no fixed length to define an identifier name  
that is example variable name can be written with any length but should be using some specific standards which can be used to understand by any other programmers and
readability of the code depends on this rule.

Hope you find useful
give a like and if you think if it is useful and also don't forget to share with your friends
If you have any doubts comment below or contact me.




python syllabus

Download python syllabus, materials, and important questions

syllabus

UNIT - I 

Python Basics, Objects- Python Objects, Standard Types, Other Built-in Types, Internal Types, Standard Type Operators, Standard Type Built-in Functions, Categorizing the Standard Types, Unsupported Types Numbers - Introduction to Numbers, Integers, Floating-Point Real Numbers, Complex Numbers, Operators, Built-in Functions, Related Modules Sequences - Strings, Lists, and Tuples, Mapping and Set Types 

UNIT - II 

FILES: File Objects, File Built-in Function [ open() ], File Built-in Methods, File Built-in Attributes, Standard Files, Command-line Arguments, File System, File Execution, Persistent Storage Modules, Related Modules Exceptions: Exceptions in Python, Detecting and Handling Exceptions, Context Management, *Exceptions as Strings, Raising Exceptions, Assertions, Standard Exceptions, *Creating Exceptions, Why Exceptions (Now)? Why Exceptions at All?, Exceptions and the sys Module, Related Modules Modules: Modules and Files, Namespaces, Importing Modules, Importing Module Attributes, Module Built-in Functions, Packages, Other Features of Modules

UNIT - III 

Regular Expressions: Introduction, Special Symbols and Characters, Res and Python Multithreaded Programming: Introduction, Threads and Processes, Python, Threads, and the Global Interpreter Lock, Thread Module, Threading Module, Related Modules 

UNIT - IV 

GUI Programming: Introduction, Tkinter and Python Programming, Brief Tour of Other GUIs, Related Modules, and Other GUIs WEB Programming: Introduction, Wed Surfing with Python, Creating Simple Web Clients, Advanced Web Clients, CGI-Helping Servers Process Client Data, Building CGI Application Advanced CGI, Web (HTTP) Servers 

UNIT – V 

Database Programming: Introduction, Python Database Application Programmer’s Interface (DB-API), Object Relational Managers (ORMs), Related Modules 

Download syllabus and important questions and previous papers CLICK HERE

About the python programming language

A Python is a general-purpose, high-level, interpreted language with easy syntax and dynamic semantics.
- it was created by Guido van Rossum in 1989.
- Python is an object-oriented programming language, it is called interpreted language because python doesn't convert code into machine code, it simply converts the program code to bytecode.
- within python compilation happens but it's not into a machine language.
- within the environment of python the code is executing in the form of byte code.
- byte code being created and which is not further understood by the CPU.
-  CPU doesn't know what is bytecode, so we actually need an interpreter.
- interpreter is a python virtual machine (PVM) is the one which executes the bytecode. 


To download the materials of all units click the below links...
Material Credits - sia publications

Unit 1 material Download

Unit 2 material Download

Unit 3 material Download
 
Unit 4 material Download

Unit 5 material Download

note: 
if you have any issues or any queries, please feel free to contact us.

python first unit material download

A Python is a general-purpose, high-level, interpreted language with easy syntax and dynamic semantics.
- it was created by Guido van Rossum in 1989.
- Python is an object-oriented programming language, it is called interpreted language because python doesn't convert code into machine code, it simply converts the program code to bytecode.
- within python compilation happens but it's not into a machine language.
- within the environment of python the code is executing in the form of byte code.
- byte code being created and which is not further understood by the CPU.
-  CPU doesn't know what is bytecode, so we actually need an interpreter.
- interpreter is a python virtual machine (PVM) is the one which executes the bytecode.

Syllabus:

UNIT - I

Python Basics, Objects- Python Objects, Standard Types, Other Built-in Types, Internal Types, Standard Type Operators, Standard Type Built-in Functions, Categorizing the Standard Types, Unsupported Types Numbers - Introduction to Numbers, Integers, Floating-Point Real Numbers, Complex Numbers, Operators, Built-in Functions, Related Modules Sequences - Strings, Lists, and Tuples, Mapping and Set Types

Click here to download the material Download

python second unit material download

A Python is a general-purpose, high-level, interpreted language with easy syntax and dynamic semantics.
- it was created by Guido van Rossum in 1989.
- Python is an object-oriented programming language, it is called interpreted language because python doesn't convert code into machine code, it simply converts the program code to bytecode.
- within python compilation happens but it's not into a machine language.
- within the environment of python the code is executing in the form of byte code.
- byte code being created and which is not further understood by the CPU.
-  CPU doesn't know what is bytecode, so we actually need an interpreter.
- interpreter is a python virtual machine (PVM) is the one which executes the bytecode.

Syllabus:

UNIT - II

FILES: File Objects, File Built-in Function [ open() ], File Built-in Methods, File Built-in Attributes, Standard Files, Command-line Arguments, File System, File Execution, Persistent Storage Modules, Related Modules Exceptions: Exceptions in Python, Detecting and Handling Exceptions, Context Management, *Exceptions as Strings, Raising Exceptions, Assertions, Standard Exceptions, *Creating Exceptions, Why Exceptions (Now)? Why Exceptions at All?, Exceptions and the sys Module, Related Modules Modules: Modules and Files, Namespaces, Importing Modules, Importing Module Attributes, Module Built-in Functions, Packages, Other Features of Modules 

Click here to download the material Download

python third unit material download

A Python is a general-purpose, high-level, interpreted language with easy syntax and dynamic semantics.
- it was created by Guido van Rossum in 1989.
- Python is an object-oriented programming language, it is called interpreted language because python doesn't convert code into machine code, it simply converts the program code to bytecode.
- within python compilation happens but it's not into a machine language.
- within the environment of python the code is executing in the form of byte code.
- byte code being created and which is not further understood by the CPU.
-  CPU doesn't know what is bytecode, so we actually need an interpreter.
- interpreter is a python virtual machine (PVM) is the one which executes the bytecode.

Syllabus:

UNIT - III 

Regular Expressions: Introduction, Special Symbols and Characters, Res and Python Multithreaded Programming: Introduction, Threads and Processes, Python, Threads, and the Global Interpreter Lock, Thread Module, Threading Module, Related Modules

Click here to download the material Download

python fourth unit material download

A Python is a general-purpose, high-level, interpreted language with easy syntax and dynamic semantics.
- it was created by Guido van Rossum in 1989.
- Python is an object-oriented programming language, it is called interpreted language because python doesn't convert code into machine code, it simply converts the program code to bytecode.
- within python compilation happens but it's not into a machine language.
- within the environment of python the code is executing in the form of byte code.
- byte code being created and which is not further understood by the CPU.
-  CPU doesn't know what is bytecode, so we actually need an interpreter.
- interpreter is a python virtual machine (PVM) is the one which executes the bytecode.

Syllabus:

UNIT-IV

GUI Programming: Introduction, Tkinter and Python Programming, Brief Tour of Other GUIs, Related Modules, and Other GUIs WEB Programming: Introduction, Wed Surfing with Python, Creating Simple Web Clients, Advanced Web Clients, CGI-Helping Servers Process Client Data, Building CGI Application Advanced CGI, Web (HTTP) Servers.

 Click here to download the material Download

python fifth unit material download

A Python is a general-purpose, high-level, interpreted language with easy syntax and dynamic semantics.
- it was created by Guido van Rossum in 1989.
- Python is an object-oriented programming language, it is called interpreted language because python doesn't convert code into machine code, it simply converts the program code to bytecode.
- within python compilation happens but it's not into a machine language.
- within the environment of python the code is executing in the form of byte code.
- byte code being created and which is not further understood by the CPU.
-  CPU doesn't know what is bytecode, so we actually need an interpreter.
- interpreter is a python virtual machine (PVM) is the one which executes the bytecode.

Syllabus:

UNIT – V 
Database Programming: Introduction, Python Database Application Programmer’s Interface (DB-API), Object Relational Managers (ORMs), Related Modules.

Click here to download the material Download


what is programming language

 

Introduction to Programming Languages:

A programming language is nothing but a set of instructions, which is given to a computer to get the required output.

A programming language is a way to talk with a computer.

For Example: if we need to communicate with others we need a language to speak at the same way to talk with computers we need a language called a programming language.
these programming languages are divided into 2 types:
they are high-level and low-level languages.

High-level programming Language: In High-level it consists of 
-procedure programming 
-object-oriented Language
-Functional programming

 Low-level programming Language: it consists of

-assembly language
-machine language

High-level:

→ procedure programming:

it is also known as Routine subroutines or functions. 
it  Simply consists of series of computational steps to be carried out.
During a program execution in procedural programming Language, any given procedural might be called at any point including by other procedures or itself.
Ex: C, COBOL, Fortran.

→ object-oriented Language:

the most common and most frequently wed programming Language in the current era is object-oriented Language. any object that is created in object-oriented programming is also called a Component of a programming language. which will have the modules and data structures. the modules are here are also called the methods and are used to access the data from the object. it's like Creating an object and filling the methods and data structures into it.
So, the modern technique is to design a program that is the object-oriented approach.
it is very easy to approach in which a program designed by using objects. So, once an object for any program is designed it can be reused by any other programs.
Ex: C++, java.

→ Functional programming language :

it is a way of thinking about the software by constructing or by creating functions. 
Ex. Haskell, Scala.
note: These are all high-level languages which is not directly understood by the computer.

Low-level:

→ Assembly language :

It is a programming language, the program instructions written in this language are close to machine language. where machine Languages are like 0's and 1's So, Assembly language also known as the second generation of programming Language. . like Ex: for the addition we use add. multiplication we use mul.Subtraction we use Sub. is called low-level symbolic language.

→ Machine Language:

Instructions are in binary form are o's & 1's. which can be directly understood by the computer, without translating them. it is also called machine language or machine code.
Machine Languages are also called as the first generation of programming languages. Machine Language is the fundamental Language of Computer & the programming instructions are in binary form o's & 1's.

complete python syllabus

complete python syllabus from zero to hero...

Introduction:

Getting Started

Python syntax

Keywords and Identifiers

Statements & Comments,escape sequences.

Python Variables

Python Datatypes

Python Type Conversion (python casting)

Python Numbers

Python List

Python Tuple

Python String (String methods)

Python Set

Python Dictionary

Python Operators

Python I/O and import

Python Namespace

python literals

python files i/o and usage, modes

Python File Operation (writing, appending)

using seek(),tell(), on files

Python Directory

Python Exception

Python Try...Except

Python User Input

Python String Formatting

Python Exception Handling

Python User-defined Exception

Python Flow Control:

Python if else

Python for Loop

Python while Loop

Python break and continue

Python Pass

Python Arrays

Python Functions and docstrings

Function Argument

Python Recursion

Anonymous Function

Global, Local and Nonlocal

Python Global Keyword

Python Object & Class

Python OOP

Python Class

Python Inheritance

single,Multiple, multilevel Inheritance

Operator Overloading

Python Modules

Python Package

Python Scope

Python Modules

Python Dates

Python Math

Python JSON

Python RegEx

Python PIP

Python Advanced Topics

Python Iterators

Python Generator

Python Closure

Python Decorators

Python Property

Python RegEx

Python Date & Time

Python DateTime Module

Python DateTime.strftime()

Python DateTime.strptime()

Current date & time

Get current time

Timestamp to DateTime

Python time Module

Python time.sleep()






to convert text into qrcode

 import qrcode

inputtext = "this is a text"

qrimg = qrcode.make(inputtext)

qrimg.save("filename.png")

to remove space from string

 a = "this is a text with space"

b = a.replace(" ","")
print(b)

ans: thisisatextwithspace

python tip1

Do u know?


 2**3**2

=2**9

=2*2*2*2*2*2*2*2*2
ans =512


do you know the answer?

x=1_2_5
y=2
res =x*y
print(res)

ans: 250




























































































































































































what is python and features of python

what is python?

a python is a simple interactive and interpreted object-oriented programming language,
when compared to other programming languages it is a simple robust, and powerful language.
a work on python began in late 1989 by Guido Van Rossum at CWI (Centrum Voor Wiskunde en Informatica, the national research institute of mathematics and computer science)in the Netherlands and it was released in 1991.

Features of python?

High-level:
It is a programming language same as English sentences which is easy to understand.
it can be understood by everyone because of the easy syntax with English sentences.

Object-oriented:
Python is an object-oriented programming language, as it separates data from logic. the object is created to access the data. the Modern technique is to design a program is the object-oriented approach. it is the easy approach, so once the object is created for any program is designed it can be reused by any other program.

Scalable:
It refers to the capability of the programming language. to accept and Handle the additional performance required.

Extensible:
python allows the programmers to code Some parts of the algorithm in different languages like c,c++, java, etc through Python code.

Portable:
Since it was written in c, it was it can work on different platforms you can use python in any system either Windows, Linux, or mac.

Easy to learn:
Very few keywords & Simple Structure & well-defined Structure Made it easy to learn.

Easy to Read:
Unlike other programming languages it doesn't make use of symbols like ($) semicolon(;) rather it defines a simple and clear code that is easier to read. Python does not give as much flexibility to write obfuscated code compared to other languages, making it easier for others to understand your code faster and vice versa. Readability usually helps make a language easy to learn, Python code is easy to understand even to a reader who has never seen a single line of Python before.

Large standard library:
 It consists of a large number of libraries and it Consist of a Huge Community i.e, there are More than 50,000 libraries available in the Python package and it is an open source.

Force & opensource:
It available for free & it is an opensource anyone can use it.
etc...

Operators in python

 Operators in python

Operators: operators are something which is used to perform the operations
such as addition, subtraction, multiplication, etc.

◆   Operators which are going to operate something or perform something

◆   In python, we have seven operators
1.arithmetic operators
2. assignment operators
3.comparison operators
4.bitwise operators
5. logical operators
6. membership operators
7.identify operators

Arithmetic operators :which is used to perform the operations like
+ (addition)
- (subtraction)
* (multiplication)
/ (division)
% (modulus)
** (exponent multiplication)
// (exponent division)

Assignment operators: which is used to assign the values they are
(=, +=, -=, *=, /=, **=, //=, %=)


Comparison operators: which is used to compare, it consists of
( == , != ,< , > , <=, >= )

Bitwise operators: it works on the gates such as

| , & , ^

|- or gate

& - and gate

^ -  xor gate


Logical operators: it is used when more than two conditions consist of
orandnot


Membership operators: it checks is it member or not such as      
 in & not in

Identify operators: it  is used to identify it consist of  
  isis not

Variables in python

Variables in python:

Variable:  it is a thing which going to store something.
- we can say that variable is a container that stores something.
ex: name = “Zaheer”
age = 24
here, name and age are variables. and “ = “ is an assignment operator to assign values to the variable.

- you can choose any name for a variable but, while we are working in a company or with a team then we should follow some rules and guidelines

◆   While we are working In a company we always have to follow some rules
◆   That means you have to write the code in such a manner (that is not only for u to understand)but it should be everyone in a team or in a company.
◆   Python is case-sensitive,   means   ex: [ name, NAME, Name, _name, _NAME ]

◆   The name of the variable always starts with a small or by capital letter it can’t start with any numbers or any special characters.

◆   In python, only one special character can be allowed to use as first the character of the variable that is “underscore  _ “.
◆   here,name1=“Zaheer”  can be a variable but,  1name=“Zaheer”   can’t be a variable

◆    if you are going to a store  such as for ex: your first name

First_name  (--it is correct)

First  name  (--- it is wrong)

◆   In the same way, we have

First-name
First_Name

Last-name
We can store in this way
Last_name

◆   Assigning a single variable
name=“Zaheer”

◆   Assigning multiple variables
name, age = “john”, 10

◆   And same values for multiple variables
fname = lastname =middlename  = “zaheer”

◆Comments :

“ # “we can make a single line comment

for multiple comments: 
#for multiple comments
"""
-------
-------

"""

note:

-  whenever you are going to store a string that will always be in a quoted. you can use a single as well as double quotes
- single-quote for when you are going to assign  a word


ex:‘a’ -word

“I am learning python“ -sentence.

"""for to store a paragraph or
 to make it as a comment"""

 

Datatypes in python:

 Datatypes in python:

Data type: datatype is something that represents the type of data.

ex: name=“Zaheer”

Here name is a variable and Zaheer is a string.

There are different types of data types are there, they are :

numbers
String
List
Tuples
Dictionary
Boolean
sets

-Numbers: it consists of - integers ( ex. 1,2,3,4 )

- floats(ex. Decimal numbers 1.2, 2.000)

- complex numbers (a combination of real and Imaginary( ex. 2+4i )

-Strings: is a collection of characters(mystr1=“Zaheer”)

-List: is a group of values inside  square brackets [ ]
ex: [ ‘a’, 10,  7.12, ”data”]

-tuples:  a group of values within brackets ( )
my group = (  ‘a’, ’b’, ’c’, )

-Dictionary: a group of values within curly braces { }
ex: mydictionary = {1: ‘john’ , 2: ‘bob’ }
1:’john’ was 1 is a key and john is a value here two elements are required to define the elements in a dictionary key and value

-Sets: an unordered collection of items within { } and we don’t need to define key values in it. It is basically an unordered collection of items
ex:  myset = {1,2,3}

-Boolean: it consists of true and false where In c and c++  0 and 1 is used for Boolean
- 0 represents “false”
- 1 represents “true”

A small comparison 

in c language :

in c language to add numbers we have


int a ; /* declaration */

a=5;  /* initialization*/

int a, b, c ; 
a = 5
c = a + b


wherein python :

were in python  a =5 
b = 6
c = a+b
here is no declaration part inpython

It automatically includes initialization and declaration So there is no specific data type to declare a variable. here  ‘a’ is a variable to store numeric data ‘5’. ‘b’ is a variable to store numeric data ‘6’. 




advantages, disadvantages and features of python

advantages, disadvantages, and features of python

About python

◆   A python is a general-purpose high-level interpreted language.

◆   With easy syntax.

◆   It was created by Guido van Rossum in 1989.

◆   It is a popular language because it is easy to start. Its features make it one of the best languages for anybody to get started with programming.

◆   Free -- means it is an open-source language I.e., free for everybody to use.

◆   Python is used to make almost anything like GUI applications, mobile applications, web applications, etc., and is also used in AI and ML algorithms.

◆  library and support: there is a huge community of people who come together will make the libraries and modules that can be used to obtain a solution.

◆   The main thing is code is much lesser than compare to other programming languages

Comparison of code with other languages.

c language:

#include<stdio.h>
Main()

{

Printf(“hello world\n”);

}

In java programming :


Class myfirstjavaprog

{

Public static void main(string args[])

{

System.out.println(“hello world”);

}

}

in python:

 Print(“hello world”)


Features of python

1. SIMPLICITY
2. OPENSOURCE
3. PORTABILITY
4. OBJECT-ORIENTED LANGUAGE
5. HIGH-LEVEL LANGUAGE
6. EXTENSIBLE FEATURES
7. INTEGRATED

Features:

◆Simplicity: python has made programming fun because of its simplicity it makes you think more about the solution rather than syntax.

◆Opensource: python is an open-source language, which means it is free for anybody to use.

◆Portability: python supports portability which means you can write code and can share it with anybody that you want this makes the project much easier.

◆    Object-oriented-language: one of the key features of python is object-oriented-
programming. It supports classes, objects, and encapsulations, etc.

◆High-level language: means, we write programs we do not need to remember the system architecture, nor do we need to manage the memory.

◆Extensible features: we can write python code  (c)and (c ++) language and we can compile the code.

◆Integrated: Because we can easily integrated python  with other languages like c, c ++, etc

Advantages of python

◆   Easy to read, learn, and write because it has English-like syntax.

◆   Interpreted language: directly executes the code line by line, if in case of any errors it stops further execution and reports the errors which have occurred.

◆   Free and open-source: we don’t need to pay.

◆   Portability means you can share and it also supports c and c ++

Disadvantages of python

◆Slow speed: because it is an interpreted language that means the line-by-line execution of code often leads to slow execution.

◆A large amount of memory: python programming language uses a large amount of memory this can be a disadvantage while building applications when we prefer memory
optimization.