Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#Python Basic
print('I am not bad')
I am not bad
print("I am not bad")
I am not bad
4 * 5
20
2 - 1
1
2 * 4
8
6 / 2
3.0
int(6 / 2)
3
# Variable
'''
# Python reserved keyword. These below list you can not assign varible name.
False None True
and exec not
as finally or
assert for pass
break from print
class global raise
continue if return
def import try
del in while
elif is with
else lambda yield
except
'''
'\n# Python reserved keyword. These below list you can not assign varible name.\nFalse\tNone\tTrue\nand\texec\tnot\nas\tfinally\tor\nassert\tfor\tpass\nbreak\tfrom\tprint\nclass\tglobal\traise\ncontinue\tif\treturn\ndef\timport\ttry\ndel\tin\twhile\nelif\tis\twith\nelse\tlambda\tyield\nexcept\n'
a = 2
b = 3
a + b
5
c = a + b
print (c)
5
#Data type
type(a)
int
d = 3.14
type(d)
float
e = 'power'
type(e)
str
f = "BH"
type(f)
str
g = True
type(g)
bool
#Other data type
'''
long, complex, unicode, list, tuple, set, dict
'''
'\n long, complex, unicode, list, tuple, set, dict \n'
long = 1
long
1
#Data Input
a = input()
15
b = input()
10
a + b
'1510'
#Type casting
'''
int() Integer cast
float() float cast
str() String cast
tuple() Tuple cast
list() List cast
set() Set cast
dict() Dictonary cast
'''
'\nint()\tInteger cast\nfloat()\tfloat cast\nstr()\tString cast\ntuple()\tTuple cast\nlist()\tList cast\nset()\t Set cast\ndict()\t Dictonary cast\n'
a = 5
type(a)
int
a = str(a)
type(a)
str
#Input
a = input()
a = int(a)
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-68-8941b20ea7e0> in <module> ----> 1 a = int(a) ValueError: invalid literal for int() with base 10: ''
b = 10
b = int(b)
a + b
25
a = int(input())
15
b = int(input())
10
a,b = input().split()
15 10
a
'15'
b
'10'
type(b)
str
a,b = map(int, input().split())
15 10
a + b
25
# Arithmetic opertaor 7 type
'''
+ add op
- subtraction op
* multi op
/ divison op
% modulas op
** exponent op
// floor divison op
'''
'\n+ add op\n- subtraction op\n* multi op\n/ divison op\n% modulas op\n** exponent op\n// floor divison op\n'
2 + 2
4
3 - 1
2
2 * 2
4
4 / 2
2.0
4 // 2
2
10 / 3
3.3333333333333335
10 % 3
1
3 ** 2
9
math.pow(3, 2)
9.0
import math
math.pow(3,2)
9.0
# Comparison Operator 6 type
'''
== equal equal
!= not equal
> Greater than
< less than
>= Greater than or equal operator
<=less than or equal operator
'''
'\n==\tequal equal \n!=\tnot equal\n>\tGreater than\n<\tless than\n>=\tGreater than or equal operator\n<=less than or equal operator\n'
2 == 2
True
2 != 2
False
5 < 3
False
5 > 3
True
5 <= 5
True
5 >= 3
True
5 > 5
False
# Assignment Operator 5 type
'''
=
+=
-=
*=
/=
'''
'\n=\n+=\n-=\n*=\n/=\n'
a = 5
a = a + 2
a
7
a += 2
a
9
# Logical Operator 3 type
'''
and -----> &&
or -------> ||
not ------> !
'''
'\nand -----> && \nor -------> ||\nnot ------> !\n'
2 == 2 && 3==3
File "<ipython-input-141-744ec8abfd5d>", line 1 2 == 2 && 3==3 ^ SyntaxError: invalid syntax
2 == 2 and 3 == 3
True
2 == 2 or 3 == 4
True
3 == 4 or 2 == 2
True
'''
True and True = True
True and False = False
False and True = False
False and False = False
---------------------------
True or True = True
True and False = True
False and true = True
False and False = False
'''
'\nTrue and True = True\nTrue and False = False\nFalse and True = False \nFalse and False = False\n---------------------------\nTrue or True = True\nTrue and False = True \nFalse and true = True \nFalse and False = False\n'
2 == 5
False
not 2 == 5
True
'''
not (False) = True
not (True) = Flase
'''
'\nnot (False) = True \nnot (True) = Flase\n'
# Membership Operrator 2 type
'''
in
not in
'''
'\nin\nnot in\n'
a = 'Bangladesh'
b = 'desh'
a in b
False
b in a
True
b = 'desh'
c = 'desh'
b in c
True
c in b
True
# Identity Oprator 2 type
'''
is
is not
'''
'\nis \nis not\n'
a = 'Bangladesh'
b = 12
a is b
False
a is not b
True
a = 1
b = 1
a is b
True
a is not b
False
a = 257
b = 257
b is a
False
a is b
False
a = 256
b = 256
a is b
True
b is a
True
# Python resever 256 intger in cache memory data range between [-5, 256]. is operator range working [-5,256]
# Comment in Python
'''
# ##########
'''
'\n# ##########\n'
a = 15 # a is a dividend. This comment name is inline commment
# a is an int variable
... # This is another comment.
...
# a is an int variable
... # This is another comment.
#This comment name is 'Block comment'
...
# a is an int variable
... # This is another comment.
This comment name is 'Block comment'
...
File "<ipython-input-186-6ec8084bbcf3>", line 3 This comment name is 'Block comment' ^ SyntaxError: invalid syntax
"""
This comment name is doc string comment.Also this one is String.
"""
'\nThis comment name is doc string comment.Also this one is String.\n'
'''
another way doc comment
'''
'\nanother way doc comment \n'