8000 GitHub - AriFullah3202/basic-python: Explore the essentials of Python programming! This repository covers basic syntax, variables, strings, and data types. Get started with our README.md instructions and enhance your Python skills.
[go: up one dir, main page]

Skip to content

Explore the essentials of Python programming! This repository covers basic syntax, variables, strings, and data types. Get started with our README.md instructions and enhance your Python skills.

Notifications You must be signed in to change notification settings

AriFullah3202/basic-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

variable role

valid role

1st rule

aiquest = 110
_studernt = 'ai based'
# 2nd rule
django2 = "web development"
print(django2)

kivabe variable likhbo

  1. kind of variable you can use

1 . camel case

āϛ⧋āϟ āĻĨ⧇āϕ⧇ āĻŦ⧜

helloWorld = 'hello world'

2 . pascal case

āϤāĻžāϰ āĻĒā§āϰāĻĨāĻŽ āĻ…āĻ•ā§āώāϰ āĻŦ⧜

HelloWorld = 'hello world'
  1. snake case

āĻāĻ–āĻžāύ⧇ āĻāĻ•āϟāĻž āĻļāĻŦā§āĻĻ⧇āϰ āĻĒāϰ⧇ āĻĄā§āϝāĻžāĻļ āĻĨāĻžāϕ⧇ āĨ¤

hello_world = 'hello world'

Multiple Assignment variable and single value

āĻā§āĻ–āĻžāύ⧇ id āĻĻāĻŋā§Ÿā§‡ āϞ⧋āϕ⧇āĻļāύ āĻšā§‡āĻ• āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇ āĨ¤ a, b , c āĻāĻĻ⧇āϰ āϞ⧋āϕ⧇āĻļāύ āϏ⧇āχāĻŽ āĨ¤

varible āϗ⧁āϞ⧋ āĻāĻ• āϜāĻžā§ŸāĻ—āĻžā§Ÿ āϏ⧇āχāĻŽ āĻšāĻšā§āϛ⧇ āĨ¤

a = b = c = 34 # ekhane location same
print(id(a)) # memory location dekte pari
print(id(b)) # id mane location
print(id(c))

Mutiple Assignment variable and multiple value

z, u , m āĻāĻ–āĻžāύ⧇ āĻŽā§‡āĻŽā§‹āϰāĻŋ āϞ⧋āϕ⧇āĻļāύ āĻ­āĻŋāĻ¨ā§āύ āĨ¤

z , u, m  = 10 , 20 , 39 # ekhane location different
print(id(z))
print(id(u))
print(m)

Input and Output

input

āĻāĻ–āĻžāύ⧇ āĻĄāĻŋāĻĢāĻ˛ā§āϟ āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āύāĻŋāĻŦ⧇ āĨ¤

āϏ⧁āϤāĻžāϰāĻžāĻ‚ āϝāĻĻāĻŋ āφāĻŽāϰāĻž āχāύāĻĢ⧁āϟ āĻšāĻŋāϏ⧇āĻŦ⧇ āϏāĻ‚āĻ–ā§āϝāĻž āĻĻāĻŋāχ āϤāĻžāĻšāϞ⧇ āĻ“ āĨ¤

z = input('enter 1st number') # string input value string hbe bydefault string
y = input('enter 2nd number') # string input value string hbe bydefault string
sum = z + y
print(sum)
print(id(z))

āϝāĻĻāĻŋ āφāĻŽāϰāĻž āχāύāĻĢ⧁āϟ āĻšāĻŋāϏ⧇āĻŦ⧇ āχāύāϟāĻŋāϜāĻžāϰ āύāĻŋāϤ⧇ āϚāĻžāχ , āϤāĻžāĻšāϞ⧇

# input for int =================
z = int(input('enter 1st number')) # string input value string hbe bydefault string
print(id(z))
y = int(input('enter 2nd number')) # string input value string hbe bydefault string
sum = z + y
print(sum)

output

print āĻĢāĻžāĻ‚āĻļāύ ⧍āϟāĻž āφāĻ°ā§āĻ—āĻŽā§‡āĻ¨ā§āϟ āύāĻŋāĻŦ⧇ āĨ¤

  1. sep // āĻāϟāĻž āφāϞāĻžāĻĻāĻž āĻ•āϰāĻŦ⧇
  2. end // āĻāϟāĻž
  3. values
  4. file
  5. flash
print('hello world')
print("hello" , 'world' , sep="&" ,end="]") # hello&world]

String operation

import  sys;
s = 'welcome to python with django'
# āĻāĻ–āĻžāύ⧇ āϕ⧋āύ āχāύāĻĄā§‡āĻ•ā§āϏ⧇ āĻ•āĻŋ āφāϛ⧇ , āĻāϟāĻž āĻšā§‡āĻ• āĻ•āϰāĻž 
print(s[0:3]) # wel
print(s[0:3333]) 
# upper case
print(s.upper()) # WELCOME TO PYTHON...
# lower case
print(s.lower())  # welcome...
# white space remove
# āϝ⧇āĻŽāύ : s = '    welcome to python with django'
# āĻāĻ–āĻžāύ⧇ capital āϕ⧇ small āĻ•āϰ⧇ āĻĻāĻŋāĻŦ⧇ āĨ¤ 
print(s.capitalize()) #
# white space remove
print(s.strip())
# repalace string
print(s.replace('o' , 'a')) #
# split string
print(s.split()) # 'welcome' , 'to' , 'python'
print(s.split()[0]) # welcome āĻŽāĻžāύ⧇ āĻĒā§āϰāĻĨāĻŽ āĻļāĻŦā§āĻĻāϟāĻž āϰāĻŋāĻ°ā§āϟāĻžāύ āĻ•āϰāĻŦ⧇ āĨ¤
# stirng Concatination
v = '23'
print(s+ "" + v)  # welcome to ... '23'
# counting
print(s.count("o")) # 3 ta o ache
# lenth
print(len(s))
# āĻ“āχ āĻ•āϤ āĻŦāĻžāχāϟ āϏāĻžāχāϜ āĻāϟāĻž āĻĒā§āϰāĻŋāĻ¨ā§āϟ āĻ•āϰāĻŦ⧇ āĻŽāĻžāύ⧇ āĻ“ā§āχ āĻ­ā§āϝāϰāĻŋā§Ÿā§‡āĻŦāϞ āĻ•āϤ āϏāĻžāχāϜ āĻĻāĻ–āϞ āĻ‹āĻŦ⧇ āφāϛ⧇ āĨ¤ 
print(sys.getsizeof(s))
# index , find āĻāχ āĻŽā§‡āĻĨāĻĄ āĻĻ⧁āχāϟāĻž āχāύāĻĄā§‡āĻ•ā§āϏ āύāĻžāĻŽā§āĻŦāĻžāϰ āϰāĻŋāĻ°ā§āϟāĻžāύ āĻ•āϰāĻŦ⧇ āĨ¤ 
# āϝāĻĻāĻŋ āĻ­āĻžāϞ⧁ āύāĻž āĻĨāĻžāϕ⧇ index āĻ āχāϰāϰ find āĻ -1 return āĻ•āϰāĻŦ⧇ āĨ¤ 
print(s.index('w' , 0 , 8))
print(s.find('y' , 4 , 8))
# āĻāϟāĻž āϝ⧇āϗ⧁āϞ⧋ āĻŦ⧜ āĻšāĻžāϤ⧇āϰ āφāϛ⧇ āĻ“āϟāĻž āϛ⧋āϟ āĻšāĻžāϤ⧇āϰ , āϛ⧇āϟ āĻĨāĻžāĻ•āϞ⧇ āĻŦ⧜ āĨ¤ 
print(s.swapcase())
# āĻāϟāĻž āĻĒā§āϰāĻ¤ā§āϝ⧇āĻ•āϟāĻž āĻļāĻŦā§āĻĻ⧇āϰ āĻĒā§āϰāĻĨāĻŽ āĻ…āĻ•ā§āώāϰ āĻŦ⧜ āĻšāĻžāϤ⧇āϰ āĻšāĻŦ⧇ āĨ¤ 
print(s.title())
# āĻāϗ⧁āϞ⧋ āĻŦ⧜ āĻšāĻžāϤ⧇āϰ āĻ•āĻŋāύāĻž
10000
 āĻāĻŦāĻ‚ āϛ⧋āϟ āĻšāĻžāϤ⧇āϰ āĻ•āĻŋāύāĻž āĻšā§‡āĻ• āĻ•āϰāϰ⧇ āĨ¤ 
print(s.isupper())
print(s.islower())
# āĻāĻ–āĻžāύ⧇ ā§§ā§Ļā§Ļ āϘāϰ āĻĒāϰ⧇ welcome to ... āĻāĻ­āĻžāĻŦ⧇ āφāϏāĻŦ⧇ āĨ¤ 
print(s.center(100))
# āĻ¸ā§āĻŸā§āϰāĻŋāĻ‚ āĻĢāϰāĻŽā§‡āϟ 
# āĻāĻ–āĻžāύ⧇ 1000 {} āĻāϰ āĻŽāĻ§ā§āϝ⧇ āĻŦāϏ⧇ āϝāĻžāĻŦ⧇ āĨ¤
x = 1000
print('this si {} taka'.format(x)) # this is 1000 taka
print(s.encode())
# āĻāĻ–āĻžāύ⧇ byte āφāĻ•āĻžāϰ⧇ āφāϏāĻŦ⧇ āĨ¤
print(type(s.encode()))

Data type

Numaric Data type

  • 3 types of Numaric data typd
    • Integer
    • Float
    • Complex
Integer

āĻāĻ–āĻžāύ⧇

a = 33
b = -88
c = 88888800000000000000000000000088888888888
print(type(a))
print(type(b))
print(type(c))
Float
d = 89.9
e = -88.8
f = 888888888888888888888888888888888888888888888888888888888888888.888
print(type(d))
print(type(e))
print(type(f))
Complex
# complex ekhane kivabe china jay
g = 4+4j
h = 4+8j
print(type(g))
print(type(h))

Convert data type

āχāĻ¨ā§āϟāĻŋāϜāĻžāϰ āĻĨ⧇āϕ⧇ āĻĢā§āϞ⧋āϟ float to interger āĻ•āύāĻ°ā§āĻ­āĻžāϟ āĻšā§Ÿ āĨ¤

string to integer and float āĻ•āύāĻ­āĻžāĻ°ā§āϟ āĻšā§Ÿ āĨ¤

string and interger āĻĨ⧇āϕ⧇ complex āĻ āĻ•āύāĻ­āĻžāĻ°ā§āϟ āĻšā§Ÿ āĨ¤ āĻ•āĻŋāĻ¨ā§āϤ

complex āĻĨ⧇āϕ⧇ interger and float āĻ•āύāĻ­āĻžāĻ°ā§āϟ āĻ•āϰāĻž āϝāĻžā§Ÿ āύāĻž āĨ¤

z = 30
u = 33.44
m = 8j # j chara r hbe na
num_str = "10"
num_int = int(num_str)  # Converts string to integer
print(num_int)  # Output: 10

num_float = 3.14
num_int = int(num_float)  # Converts float to integer
print(num_int)  # Output: 3

num_str = "10"
num_int = complex(num_str)  # Converts string to complex
print(num_int)  # Output: 10+0j

num_float = 3.14
num_int = complex(num_float)  # Converts float to complex
print(num_int)  # Output: (3.14+0j)


#int to float
l = float(z)
print("int to float" , type(l))
# int to complex
o = complex(z)
print("int to float" , type(o))
# float to complex
r = complex(u)
print('float to complex', type(r))
#float to int
q = int(u)
print('float to int', q)
#Boolean
print(type(True)) #<class 'bool'>
print(type(False))
y = 90<20
print(type(y)) #<class 'bool'>

Dictionary

#dictionary
# {} set , dictionary āĻšāϞ second bracket āĻļ⧁āϰ⧁āϤ⧇ āĻāĻŦāĻ‚ āĻļ⧇āώ⧇ āĻšā§Ÿ āĨ¤
# āϤāĻŦ⧇ python āĻ dictionary āĻ•āĻŋ āĻāĻŦāĻ‚ āĻ­āĻžāϞ⧁ java āϤ⧇ map āĻāϰ āĻŽāϤ⧋ āĨ¤
firstdict = {
    "name" : 'Arif',
    "id" : 222,
    "year" : 2333
}
print(firstdict) # {'name': 'Arif', 'id': 222, 'year': 2333}
print(type(firstdict)) # <class 'dict'>

List

# āϞāĻŋāĻ¸ā§āĻŸā§‡ āĻ…āύ⧇āĻ• āϰāĻ•āĻŽā§‡āϰ āĻĄāĻžāϟāĻž āϟāĻžāχāĻĒ āĻĨāĻžāϕ⧇ āĨ¤
# āĻāĻŦāĻ‚ āĻļ⧁āϰ⧁āϤ⧇ , āĻļ⧇āώ⧇ third bracket āĻĨāĻžāĻ•āĻŦ⧇ āĨ¤

firtlist = ['lenebo' , 33 , '83']
print(firtlist) # ['lenebo' , 33 , 83]
print(type(firtlist)) # <class 'list'>

List access

remove and pop āĻāϰ āĻŽāĻ§ā§āϝ⧇ āĻĒāĻžāĻĨā§āϝāĻ°ā§āĻ• āĻšāĻšā§āϛ⧇ remove parameter āύāĻŋāĻŦ⧇ āĻāĻ•āϟāĻž item . āϝāĻĻāĻŋ āϐ itex āύāĻž āĻĨāĻžāϕ⧇ exception āĻĻāĻŋāĻŦ⧇ āĨ¤
pop āĻšāĻšā§āϛ⧇ index āĻšāĻŋāϏ⧇āĻŦ⧇ āύāĻŋāĻŦ⧇ āϝāĻĻāĻŋ āϐ āχāύāĻĄā§‡āĻ•ā§āϏ āύāĻž āĻĨāĻžāϕ⧇ -ā§§ āϰāĻŋāϟāĻžāύ āĻ•āϰāĻŦ⧇
delete method āχāύāĻĄā§‡āĻ•ā§āϏ āφāĻ•āĻžāϰ⧇ āĻĄāĻŋāϞāĻŋāϟ āĻšā§Ÿ āĨ¤ āϝāĻĻāĻŋ āχāύāĻĄā§‡āĻ•ā§āϏ āύāĻž āĻĨāĻžāϕ⧇ āϤāĻžāĻšāϞ⧇ exception āĻĻāĻŋāĻŦ⧇ āĨ¤ āφāĻŦāĻžāϰ āϏāĻŽā§āĻĒ⧁āĻŖ āĻĄāĻŋāϞāĻŋāϟ āĻšā§Ÿ āĨ¤
course = ['Math', 'Science', 'History', 'English', 'Geography']
print(len(course))

#access item
print('list item is ' , course[4]) # output Geography āĻāϟāĻž āϜāĻŋāϰ⧋ āĻĨ⧇āϕ⧇ āĻļ⧁āϰ⧁ āĻšā§Ÿ āĨ¤
print('list item' , course[-4]) # output Science āĻāϟāĻž āωāĻ˛ā§āĻŸā§‹ āĻĻāĻŋāĻ• āĻĨ⧇āϕ⧇ query āĻ•āϰ⧇ 

# Range
# āĻāϟāĻž āĻļ⧁āϰ⧁ āĻāĻŦāĻ‚ āĻļ⧇āώ āĻĨ⧇āϕ⧇ āϏāĻžāĻ°ā§āϚ āĻ•āϰāĻŦ⧇ āĨ¤
print("Range:", course[2:5])   # Output: ['History', 'English', 'Geography']
# āĻāϟāĻž āĻļ⧇āώ āĻĨ⧇āϕ⧇ search āĻ•āϰāĻŦ⧇ 
print("Range:", course[:5])    # Output: ['Math', 'Science', 'History', 'English', 'Geography']
# āĻāĻ–āĻžāύ⧇ āφāϛ⧇ āĻĒāĻžāϚāϟāĻž item āĨ¤ āϏ⧁āϤāĻžāϰāĻžāĻ‚ āĻāĻ–āĻžāύ⧇ āĻļ⧁āϰ⧁āϤ⧇ āĻĒāĻžāϚāϟāĻž āĻāϰ āĻĒāϰ āϏāĻžāϚ āĻ•āϰāϞ⧇ āĻĢāĻžāĻ•āĻž array āφāϏāĻŦ⧇ āĨ¤ 
print("Range:", course[5:])    # Output: []

# Negative range
# āĻāϟāĻž āϟāĻŋāĻ• āωāĻ˛ā§āĻŸā§‹ āĻšāĻŦ⧇ āĨ¤
print("Range:", course[-2:])   # Output: ['English', 'Geography']
print("Range:", course[:-2])   # Output: ['Math', 'Science', 'History']

# Item value change
course[1] = 40
# āĻāĻ–āĻžāύ⧇ āĻšā§‡āĻ¨ā§āϜ āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇ āĨ¤
print('New list:', course)   # Output: ['Math', 40, 'History', 'English', 'Geography']
# Insert method
# āĻāĻ–āĻžāύ⧇ āϕ⧋āύ index āĻ insert āĻ•āϰāϤ⧇ āϚāĻžāύ āĨ¤ 
course.insert(0, "aiQuest")
print('New inserted list:', course)   # Output: ['aiQuest', 'Math', 40, 'History', 'English', 'Geography']
# Append method
# append āĻšāĻšā§āϛ⧇ āĻāĻ•āĻĻāĻŽ āĻļ⧇āώ⧇ append korbe
course.append("study marts")
print('Append:', course)   # Output: ['aiQuest', 'Math', 40, 'History', 'English', 'Geography', 'study marts']
# Remove method
course.remove('Math')
print('Remove:', course)   # Output: ['aiQuest', 40, 'History', 'English', 'Geography', 'study marts']
# Pop method
course.pop(2)
print('Pop:', course)   # Output: ['aiQuest', 40, 'English', 'Geography', 'study marts']
# Del keyword
del course[2]
print('Del:', course)   # Output: ['aiQuest', 40, 'Geography', 'study marts']
# Sort method
alphabetic = ['python', 'django', 'ML']
alphabetic.sort()
print('Sorted:', alphabetic)   # Output: ['ML', 'django', 'python']

Set

# āϞāĻŋāĻ¸ā§āĻŸā§‡ āĻ…āύ⧇āĻ• āϰāĻ•āĻŽā§‡āϰ āĻĄāĻžāϟāĻž āϟāĻžāχāĻĒ āĻĨāĻžāϕ⧇ āĨ¤
# āĻāĻŦāĻ‚ āĻļ⧁āϰ⧁āϤ⧇ , āĻļ⧇āώ⧇ second bracket āĻĨāĻžāĻ•āĻŦ⧇ āĨ¤

firstset = {
    'aiquest' , 383, 38.8 , 88, True
}
print(firstset) # {True, 38.8, 88, 'aiquest', 383}
print(type(firstset)) # set output --- <class 'dict'>

Tuple

# āĻāĻ–āĻžāύ⧇ āφāύ⧇āĻ•āϗ⧁āϞ⧌ āĻĄāĻžāϟāĻž āϟāĻžāχāĻĒ āĻĨāĻžāϕ⧇
# āĻāĻŦāĻ‚ āĻļ⧁āϰ⧁āϤ⧇ āĻāĻŦāĻ‚ āĻļ⧇āώ⧇ first bracket āĻĨāĻžāϕ⧇ āĨ¤
firsttuple = ('ai' , 33, "idid" , 8 , True )
print(firsttuple) # ('ai', 33, 'idid', 8, True)
print(type(firsttuple)) # <class 'tuple'>

Binary Type

āĻāϟāĻž āĻŦāĻžāχāύāĻžāϰāĻŋ āύāĻŋā§Ÿā§‡ āĻ•āĻžāϜ āĻ•āϰāĻžā§‡ āĨ¤ āĻĒāϰ⧇ āφāϞ⧋āϚāύāĻž āĻ•āϰāĻž āĻšāĻŦ⧇ āĨ¤

Data frame

āĻāϟāĻž āĻŸā§‡āĻŦāĻŋāϞ āφāĻ•āĻžāϰ⧇ āφāϊāϟāĻĒ⧁āϟ āφāϏ⧇ āĨ¤ āĻāϟāĻž āύāĻŋā§Ÿā§‡ āĻĒāϰ⧇ āφāϞ⧋āϚāύāĻž āĻ•āϰāĻž āĻšāĻŦ⧇ āĨ¤

Operator

Arithmatic operator

modulus āĻšāϞ āĻ­āĻžāĻ— āĻ•āϰ⧇ āϝ⧇āϟāĻž āĻ…āĻŦāĻļāĻŋāĻˇā§āϟ āĻĨāĻžāϕ⧇ āĨ¤

division and floor division āĻŽāĻ§ā§āϝ⧇ āĻĒāĻžāĻĨāĻ•ā§āϝ āφāϛ⧇ āĨ¤

division āĻŽāĻ§ā§āϝ⧇ āϝāĻĻāĻŋ āĻ­āĻžāĻ—āĻļ⧇āώ āύāĻž āĻĨāĻžāĻ•āϞ⧇ āĻĒā§‚āĻ°ā§āĻŖ āϏāĻ‚āĻ–ā§āϝāĻž āφāϰ āĻĨāĻžāĻ•āϞ⧇ āϤāĻžāĻšāϞ⧇ āĻĒā§Ÿā§‡āĻ¨ā§āϟ āφāĻ•āĻžāϰ⧇ āĻĻāĻŋāĻŦ⧇ āĨ¤ floor āĻšāĻšā§āϛ⧇ āĻ­āĻžāĻ—āĻļ⧇āώ āĻĨāĻžāϕ⧁āĻ• āĻŦāĻž āύāĻž āĻĨāĻžāϕ⧁āĻ• āĻĒā§‚āĻ°ā§āĻŖ āϏāĻ‚āĻ–ā§āϝāĻž āĻĻāĻŋāĻŦ⧇ āĨ¤

āϕ⧋āύ āϏāĻ‚āĻ–ā§āϝāĻžāϝāĻŧ āϝāĻĻāĻŋ āϕ⧋āύ āĻĻāĻļāĻŽāĻŋāĻ• āĻŦāĻž āĻ­āĻ—ā§āύāĻžāĻ‚āĻļ āύāĻž āĻĨāĻžāϕ⧇ āϤāĻžāĻšāϞ⧇ āϏ⧇āϟāĻŋ āĻĒā§‚āĻ°ā§āĻŖ āϏāĻ‚āĻ–ā§āϝāĻžāĨ¤

exponentiation āĻšāĻšā§āϛ⧇ āĻĒāĻžāĻ“ā§ŸāĻžāϰ āĨ¤

x = 12, y = 4 āĻŽāĻžāύ⧇

12 * 12 * 12 * 12 āĻāĻ–āĻžāύ⧇ 12 4 āĻŦāĻžāϰ āĨ¤

x = 5
y = 2
#Addition
print("Add ", x + y); # 7
# Subtraction
print('sub', x -y) # output : 3
# mutiple
print('multiply' , x * y) # output : 10
# division
print('div' , x / y) # output : 2.5
# modulus
print("modulus" , x % y) # output : 1
# exponentiation
print("exponentiation", x**y) # output : 25
# floor division
print('floor division' , x//y) # output : 2

Assignment Operator

āĻāĻ–āĻžāύ⧇ āĻāĻ•āϟāĻž āĻ­ā§āϝāϞ⧂ āφāϰ⧇āĻ•āϟāĻž āĻ­ā§āϝāĻžāϞ⧁ āĻāϰ āĻŽāĻ§ā§āϝ⧇ āĻāϏāĻžāχāύ āĻ•āϰāĻž āĨ¤

x = 5
y = 3
x =y
print('assign' , x ) # output 3
x += y
print('add and Assgainment' , x) # age 3 chilo , ekhon 3 + 3 = 6
x -= y
print("sub and assign" , x)
x *= y
print("multiply and assign" , x)
x %= y
print("moduls and assign" , x)

Bitwise Operator

āĻāϟāĻž āĻŽāϜāĻžāϰ āϜāĻŋāύāĻŋāϏ

āĻāϟāĻž āĻŦāĻžāχāύāĻžāϰāĻŋ āύāĻŋā§Ÿā§‡ āĻ•āĻžāϜ āĻ•āϰ⧇

  1. & : bitwise and
  2. | : bitwise Or
  3. ^ : bitwise Xor
  4. ~ : bitwise complement operator
  5. << : left shift operator
  6. : >> : right shift operator
x = 12
y = 13
print('complement operator', ~x) #~ reverse kore ~1=0 , ~0=1 , output = -13
print('bitwise and ' , x&y) # output 12
print("bitwise or", x|y) # output 13
print("bitwise xor" , x^y) # output 1
a = 12
b = 2
print('left shift ', a<<b) #output 48
print('right shift ', a>>b) # output 3

Comparison operator

< : less than

.> : Greter than

<= : less than or equal to

.>= : Greater than or equal to

== : Equal to

!= : Not Equal to

x = 5
y = 2
print("less than ", x<y) # output False
print("Grater than" , x>y) # output True
print('Less than or eqal to' , x<=y) # output False
print('Greater than or eqal to ', x>=y) # output True
print("Equal to", x==y) # output False
print("Not equal to ", x!=y) # output True

identity operator

x = 12
y = 12
print(x is y) # True
print(x is not y) # false

Different between Equal to , Not equal to and identity operator

== āĻāϟāĻž value āĻšā§‡āĻ• āĻ•āϰ⧇ āĨ¤

is āĻāϟāĻž memory location āĻšā§‡āĻ• āĻ•āϰ⧇ āĨ¤

x = 5
y = 2
print(x is y) # True
print(x is not y) # false
print("Equal to", x==y) # output False
print("Not equal to ", x!=y) # output True

Logical operator

x = 14
y = 3
print(x>y and x<y) # false , āĻāĻ–āĻžāύ⧇ āĻĻ⧁āϟāĻž āϏāĻ¤ā§āϝ āĻšāϤ⧇ āĻšāĻŦ⧇ 
print(x>y or x<y) # true , āĻāĻ–āĻžāύ⧇ āĻāĻ•āϟāĻž āϏāĻ¤ā§āϝ āĻāĻŦāĻ‚ āĻŽāĻŋāĻĨā§āϝāĻž āĻšāϤ⧇ āĻšāĻŦ⧇ 
print(not(x<y and x>y)) # true , āĻāϟāĻž āĻ āĻŋāĻ• āωāĻ˛ā§āĻŸā§‹ 

Membership Operator

āĻāϟāĻž āϞāĻŋāĻˇā§āĻŸā§‡ āφāĻžāϛ⧇ āĻ•āĻŋāύāĻž āĻšā§‡āĻ• āĻ•āϰāĻŦ⧇ āĨ¤

x = ['python', 'django']
print("python" in x) # true
print("pythons" not in x) # true

if-elif-else , if , else

javaScript , java āϤ⧇ second bracket āφāϛ⧇ āĨ¤ āĻ•āĻŋāĻ¨ā§āϤ python āĻ āĻļ⧁āϧ⧁ āϕ⧋āϞāύ āφāϛ⧇ āĨ¤

āĻāĻ–āĻžāύ⧇ indentation āĻšā§‡āĻ• āĻ•āϰāϤ⧇ āĻšāĻŦ⧇ āĨ¤

elif āĻŽāĻžāύ⧇ āĻāĻ•āĻĻāĻŽ else if

motu = 100
patlu = 40
jhatka = 32
if(motu>patlu and motu<jhatka) :
    print('this is if')# ekhane identaion check korte hbe
elif(patlu>motu or patlu>jhatka):
    print("this is else")
else:
    print("this is else")

For loop

for loop āϏāĻ‚āĻ–ā§āϝāĻž āĻ­āĻŋāĻ¤ā§āϤāĻŋāϤ⧇ āĻāĻŦāĻ‚ āϞāĻŋāĻˇā§āĻŸā§‡ āϞ⧁āĻĒ āĻ•āϰāĻž āĻšā§Ÿā§‡ āĨ¤

javaScript , java āϤ⧇ second bracket āφāϛ⧇ āĨ¤ āĻ•āĻŋāĻ¨ā§āϤ python āĻ āĻļ⧁āϧ⧁ āϕ⧋āϞāύ āφāϛ⧇ āĨ¤

# āĻāϟāĻž list
fruits = ['banana', 'apple', 'orange']
for fruit in fruits:
    if fruit == 'apple':
        continue # āĻāϟāĻž apple āĻāϰ āϏāĻžāĻĨ⧇ āĻŽāĻŋāϞāϞ⧇ āĻ¸ā§āĻ•āĻŋāĻĒ āĻ•āϰāĻŦ⧇ āĨ¤
    print("Fruits name" ,fruit)
    print('fruit len' , len(fruit))
# āĻāϟāĻž range 
# range(stop)=============================
for i in range(10):
    print("this is my range") # 0 theke 9 print korbe
# range(start , end)
for i in range(50, 60): # 50 theke 59 porjonto print korbe because ekhane 60 border hisabe kaj kore
    print("this is my range" , i)
# range(start , end ,
# range(start, stop, step)
for i in range(2 , 100 , 3):
    print("this is ")

while

āĻ…āύāĻŦāϰāϤ āϘ⧁āϰāϤ⧇ āĻĨāĻžāĻ•āĻŦ⧇ āĨ¤

condition āĻĻāĻŋāϤ⧇ āĻšāĻŦ⧇ āĨ¤

javaScript , java āϤ⧇ second bracket āφāϛ⧇ āĨ¤ āĻ•āĻŋāĻ¨ā§āϤ python āĻ āĻļ⧁āϧ⧁ āϕ⧋āϞāύ āφāϛ⧇ āĨ¤

value increase āĻ•āϰāĻžāϰ āĻĒāĻĨ āĻŦāϞ⧇ āĻĻāĻŋāϤ⧇ āĻšāĻŦ⧇ āĨ¤

i = 4
while i<10:
    print(i)
    i+=1 # eta dite hbe
while i<1 :
    i+=1
    if i == 5 : # ekhane
        continue
    print(i)
else:
    print(i)

About

Explore the essentials of Python programming! This repository covers basic syntax, variables, strings, and data types. Get started with our README.md instructions and enhance your Python skills.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0