Skip to content

Commit

Permalink
new_update
Browse files Browse the repository at this point in the history
  • Loading branch information
ahammadshawki8 committed Feb 18, 2021
1 parent d2a1937 commit 52cf024
Show file tree
Hide file tree
Showing 32 changed files with 448 additions and 73 deletions.
4 changes: 4 additions & 0 deletions .vscode/ReadAge.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Essam,14
Heyam,14
rajib,34
manik,75
1 change: 1 addition & 0 deletions .vscode/UserGuest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
good boy \n i know you \n by the way \n boronmoron zontrona
Binary file added .vscode/boss.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .vscode/boss2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .vscode/boss3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File (Integrated Terminal)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"port": 5678,
"host": "localhost",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}
]
},
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "enter-your-module-name-here",
"console": "integratedTerminal"
},
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"console": "integratedTerminal",
"args": [
"runserver",
"--noreload",
"--nothreading"
],
"django": true
},
{
"name": "Python: Flask",
"type": "python",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "app.py"
},
"args": [
"run",
"--no-debugger",
"--no-reload"
],
"jinja": true
},
{
"name": "Python: Current File (External Terminal)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "externalTerminal"
}
]
}
2 changes: 2 additions & 0 deletions .vscode/practice.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
what i am practicing
moga tasbih
2 changes: 2 additions & 0 deletions .vscode/record.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
shawki,14
sowad,15
Binary file added pic/CV.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions python05 (manipulating code).py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
print(message.rfind("world")) # returns the index starting at the rightmost ccurance of the string, else -1
print(message.rindex("world")) # simmlar to rfind but raise ValueError if not found
# the number which comes to the output means the characters before the word is that number.
# we can also tell python where to start and where to end. they are going to be the 2nd and 3rd arguement.
# we can also tell python where to start and where to end. they are going to be the 2nd and 3rd argument.
print(message.find("l",4,-1))
print(message.count("o")) # count the number of the letter.
print(" dhaka ".strip()) # ignore the blank space.
print(" dhaka ".rstrip()) # ignore the blank space of right side.
print(" dhaka ".lstrip()) # ignore the blank space of left side.
# we can also use specific character to remove by adding another arguement in those above 3 methods.
# we can also use specific character to remove by adding another argument in those above 3 methods.
print("kkkkkkkkkkkkkk foo kkkkkkkkkkkkkk".strip("k"))
print(message.center(100)) # returns the string at the center of 100 spaces.
print(message.ljust(100)) # returns the string before center of 100 spaces.
Expand Down
2 changes: 1 addition & 1 deletion python06 (solving math with python).py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
print(int(0o52))
print(int(0x7f))

# we can also explicitely tell the base by adding a second arguement in the int() method.
# we can also explicitely tell the base by adding a second argument in the int() method.
print(int("ff7",16))

# to express big integres in scientific way 3.45X10^45 we can use this format.
Expand Down
2 changes: 1 addition & 1 deletion python08 (if statement).py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
print(f.read())

# all() and any() function.
# all() and any() function takes an iterable as an arguement.
# all() and any() function takes an iterable as an argument.
# all() returns true if all the values of that iterable is true, otherwise false.
# any() returns true if any of the values of that iterable is true, otherwise false.
if all([True,True,True,False]):
Expand Down
2 changes: 1 addition & 1 deletion python12 (lists).py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
# second method-
# delete the first item in the list
del fun[0] # it is delete command
print(fun[0]) # delete command takes the index as an arguement.
print(fun[0]) # delete command takes the index as an argument.

# third method
# deleting the last item of the list using pop method.
Expand Down
2 changes: 1 addition & 1 deletion python14 (reading from files).py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
print(bubble.readline())
# this prints pretty awkward. it gives extra newline after each line.
# its a default system.
# we can change it through changing the end arguement.
# we can change it through changing the end argument.
print(bubble.readline(),end="")
print(bubble.readline())
print()
Expand Down
10 changes: 5 additions & 5 deletions python20 (functions).py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def function2():
# inside a function, parameters behave like a variable.
# we can use parameters both for integer value or string value.

# differnce between parameter and arguement
# differnce between parameter and argument
# when we define variables for accepting when defining a function is called a perameter.
# when we insert values for parameters when calling a function is called an arguement.
# when we insert values for parameters when calling a function is called an argument.

# integer
def function3(x):
Expand Down Expand Up @@ -317,13 +317,13 @@ def ft(greeting="hi", name="you"):
# if we give an argument, it will ignore default argument.

# *args and **kwargs
def student(*args, **kwargs):# args and kwargs are allowing us to accept an orbitory number of positional or keyword arguement.
def student(*args, **kwargs):# args and kwargs are allowing us to accept an orbitory number of positional or keyword argument.
print(args)
print(kwargs)
student("math","comsci",name="shawki",age=14)
# here "math" and "comsci is positional argument, and the name="shawki" and age=14 is keyword arguement.
# here "math" and "comsci is positional argument, and the name="shawki" and age=14 is keyword argument.
# *args give us positional argument in a tuple.
# **kwargs give us keyword arguements in a dictionary.
# **kwargs give us keyword arguments in a dictionary.

# we can do the same thing-
def students(*args, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion python21 (error handling).py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class CustomError(Exception): # this error class will inherit from built-in pyth
# now we can use this error by raise keyword.
def err_name(name=None):
if name is None:
raise CustomError("expected 1 arguement (name) but none was given")
raise CustomError("expected 1 argument (name) but none was given")
else:
return "Beautiful Name :)"
#print(err_name())
Expand Down
8 changes: 4 additions & 4 deletions python24 (lambda expression).py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def built_quadratic_function(a, b,c ):
print(f(1))
print(f(2))

# we can also use lambda as a arguement in other functions.
# we can also use lambda as a argument in other functions.
# sorting tuples using lambda.
list1=[("eggs",1.09),("mango",0.44),("banana",3.89),("milk",8.90)]
list1.sort(key=lambda x:x[0])#here in the expression,x[0] means we want to sort them in the order of keys
Expand All @@ -49,8 +49,8 @@ def built_quadratic_function(a, b,c ):
print(list(map(lambda x:x**2,list_square)))

# conditionals in lambda
# the structure of lambda arguement is-
"""lambda args(arguement):a if boolean_expression else b"""
# the structure of lambda argument is-
"""lambda args(argument):a if boolean_expression else b"""
starts_with_A=lambda x:True if x.startswith("A") else False
print(starts_with_A("Ahammad"))

Expand All @@ -75,7 +75,7 @@ def do_something(func,val):

# what if we want to know if it is a number or not?
# we can use lamdas
isnumber=lambda q:q.replace(".","",1).isdigit()# here the third arguement indicates that the replace command will only executes one time.
isnumber=lambda q:q.replace(".","",1).isdigit()# here the third argument indicates that the replace command will only executes one time.
print(isnumber("233.45"))
#but thats not good enough it returns false if it is a negative number.
print(isnumber("-233.45"))
Expand Down
2 changes: 1 addition & 1 deletion python26 (Counter Class).py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# but sometimes there are lots of keys while we are working with big data.
# so we may not have to acces all the keys. we may need to know only the mos common 10 keys or three keys.
# we can do that most_common method in Conter class.
print(c.most_common(3)) # it takes one arguement which is how many keys we want to display.
print(c.most_common(3)) # it takes one argument which is how many keys we want to display.
# this method gives us a list with paired tuples which first item is the key and second item is the value of the key.

# So it can be said that, its definately the best way and extreamly helpful to do something like this with counter.
14 changes: 7 additions & 7 deletions python28 ( 5 common mistakes in python).py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
# we we can also step on to our toes if we aren't careful.

# mistake 3
# mutable default arguements
# another thing people get tripped up on is mutable default arguements.
# mutable default arguments
# another thing people get tripped up on is mutable default arguments.
def add_employee(emp,emp_list=[]):
emp_list.append(emp)
print(emp_list)
# this function takes two arguement emp and also an employee list.
# this function takes two argument emp and also an employee list.
# and it simply going to add this employee to this employee list and then print out the emp_list.
# but we can see here the employee list has a default value which is a empty list.
# so if we dont pass any emp_list when we call the function then it should make a new empty list for us from scratch.
Expand All @@ -63,7 +63,7 @@ def add_employee(emp,emp_list=[]):
# each time it will get longer and longer and keeps appending to the same list
# even though we should haev the empty list by default.
# so whats going on here?
#=> in python default arguements are evaluated once at a time it creates the function.
#=> in python default arguments are evaluated once at a time it creates the function.
# so its not actually creating a new empty list each time we calling the function.
# we wont notice that with immutable types like strings and things like that.
# but in muttable datatypes like list, it is using the same list that it created when the function was defined.
Expand All @@ -76,22 +76,22 @@ def add_employee2(emp,emp_list=None):
print(emp_list)
add_employee2("Shawki")
add_employee2("Hasnine")
# so basically default arguements are created once when the function was defined,
# so basically default arguments are created once when the function was defined,
# it dont created every time when the function is called.

# there are some more places where we may face this problem.
import time
from datetime import datetime

def display(time=datetime.now()):# it takes time a arguement. it has a default value of current time.
def display(time=datetime.now()):# it takes time a argument. it has a default value of current time.
print(time.strftime("%B, %D, %Y %H:%M:%S"))

display()
time.sleep(1)# here we are sleeping the code after each function call for 1 sec.
display()
time.sleep(1)
display()
# we might expect if we dont give time arguement, we will always have the current time printed.
# we might expect if we dont give time argument, we will always have the current time printed.
# but we can see that each time it ran it didnt update the time like we might expect.
# the reason is as before is it executes only one when the function was defined and not each time the function is run.
# to solve this problem we could do something like this.
Expand Down
20 changes: 10 additions & 10 deletions python29 (10 Quick tips for python coders).py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
print(index,name)
# so enumerate is a function which returns both the indexes and the values from the list that we are looping over.
# and we can use unpacking to grab this values by index,name.
# we can also pass in a start value by adding start arguement, if we dont want to start counting from 0.
# we can also pass in a start value by adding start argument, if we dont want to start counting from 0.

# tip 5
# recognizing all functions correctly.
Expand Down Expand Up @@ -151,9 +151,9 @@ class Person:
# to order to do this we need to use a built_in function called setattr().
# setattr() is able to use a value of a variable.
setattr(person1,"first","Ahammad")
# here the first arguement is the object.
# the second arguement is the attrinute name.
# the third arguement is the value of that attribute.
# here the first argument is the object.
# the second argument is the attrinute name.
# the third argument is the value of that attribute.
print(person1.first)
# that runs well.
# setatter() function allows us to use variable instead of the exact value.
Expand All @@ -165,7 +165,7 @@ class Person:
# Again if we want to get a value, we can use getatter() at a same way.
# if we want to get this last attribute here using that variable instead.
last=getattr(person1,last_key)
# here the first arguement is the object name and the second is what we want to get.
# here the first argument is the object name and the second is what we want to get.
# now if we run that-
print(last)
# but we might not see the usefulness in this but it is good to know because sometime we many need this.
Expand Down Expand Up @@ -215,16 +215,16 @@ class Person:
# if we look at the python documentation then the official explanation is that-
# -m will quote search sys.path for the name to module and execute its content as the main module.
# basically it is saying that it is simply running that specific module that we specified after -m. so in that case the module will be smtpd.
# and everything after that is the arguement for that module.
# and everything after that is the argument for that module.
# but we might be wondering why we dont run those scripts like other python scripts that we write in our code?
# when we use our script in the command prompt we do something like this- python script_name.py
# we can do that because they exists in our current directory.
# other scripts dont exists in our current directory. so we cant run them like this.
# if we wanted to we could run our own script in that style as well.
# python -m script_name. here we dont have to use .py because we just need to write the module name.
# so just like the documentation said when we use -m it will search in our sys.path and impoet that module.
# now we also may wonder which arguements the code after -m takes?
# in this example, the smtpd module takes an arguement of -c and -n
# now we also may wonder which arguments the code after -m takes?
# in this example, the smtpd module takes an argument of -c and -n
# now how would we know that?
# if we run that module with -m, it also means we can import that module becausse we can import anything in our sys.path.
# so if we want to learn more about that module, we can import it and further look at it.
Expand All @@ -235,8 +235,8 @@ class Person:
import smtpd
print(help(smtpd))
# we can see their there is a section called options
# their we can find all the arguements and what they do.
# so anytime we see such arguements in any module that we dont know what to do with that,
# their we can find all the arguments and what they do.
# so anytime we see such arguments in any module that we dont know what to do with that,
# we can just print it with our help function.
# Actually, just knowing how the things work and all the operations that they can do will take us a long way in they coding world.
# actually big programmers whom seen to know all about programming,
Expand Down
8 changes: 4 additions & 4 deletions python32 (array).py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# to make an array we can use the array() method.
a=arr.array("i",[9,3,4,5])
# array() takes 2 arguements.
# array() takes 2 arguments.
# first one in typecode. there are different type codes for different datatypes.
# second one is the values. we have to pass the values in a list.
print(a)
Expand Down Expand Up @@ -84,7 +84,7 @@
print(b)
# we can also use the insert() method to insert values to an array with certain index.
b.insert(0,6)
# here we have to pass two arguements.
# here we have to pass two arguments.
# first one is the index
# second one is the value.
# insert doesnt delete any values it just shift other values.
Expand All @@ -95,11 +95,11 @@
b.remove(7)
print(b)
popped=b.pop(0)
# note that, pop() takes the index of the value as an arguement.
# note that, pop() takes the index of the value as an argument.
print(b)
print(popped)
del b[0]
# note that, del takes the index of the value as an arguement.
# note that, del takes the index of the value as an argument.
print(b)

# indexing
Expand Down
Loading

0 comments on commit 52cf024

Please sign in to comment.