Skip to content

Commit

Permalink
added some files'
Browse files Browse the repository at this point in the history
  • Loading branch information
amantiwari8861 committed Aug 28, 2024
1 parent aa368b1 commit 5f8c78b
Show file tree
Hide file tree
Showing 12 changed files with 319 additions and 56 deletions.
22 changes: 11 additions & 11 deletions 05 Collections/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@
# print(fruits)


fruits=["Apple","strawberry",67,True,"mango",45.89,"Apple"]
for f in fruits:
# print(" the fruit is :",f)
if isinstance(f,str):
print(" the fruit is :",f)
if isinstance(f,int):
print("the number is :",f)
if isinstance(f,float):
print("the float is :",f)
if isinstance(f,bool):
print("the boolean is :",f)
# fruits=["Apple","strawberry",67,True,"mango",45.89,"Apple"]
# for f in fruits:
# # print(" the fruit is :",f)
# if isinstance(f,str):
# print(" the fruit is :",f)
# if isinstance(f,int):
# print("the number is :",f)
# if isinstance(f,float):
# print("the float is :",f)
# if isinstance(f,bool):
# print("the boolean is :",f)
Binary file modified 05 Collections/listvsSetvs.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 31 additions & 19 deletions 05 Collections/set.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# A set is an unordered collection and no indexal access.
# Sets are mutable and have no duplicate elements.

# fruits={} #empty set
# fruits={10,}
# fruits=set() #empty set
# fruits={"Apple","Mango","Apple","Banana",10,78,54.55}

Expand All @@ -18,39 +18,51 @@

# # the remove() method will raise an error if the specified item does not exist
# # , and the discard() method will not
# fruits.remove("Banana")
# fruits.discard("Banana")
# fruits.remove("Banana 2")
# fruits.discard("Banana 2")
# print(fruits)

# fruits.update(["custardapple","cherry"])
# fruits.update({"custardapple2","cherry2"})
# print(fruits)

fruits={"Apple","Mango","Apple","Banana",10,78,54.55}
# # # Remove all elements of another set from this set.
# fruits.difference_update(["custardapple","Mango","kashmiri apple"])
# print(fruits)

# favourite_fruits={"Apple","Mango","litchi"}
# print('favourite fruits :',favourite_fruits)

favourite_fruits={"Apple","Mango","litchi"}
# favourite_fruits=["custardapple","Mango","kashmiri apple"]
# # print('favourite fruits :',favourite_fruits)
# print("after difference :",fruits.difference(favourite_fruits)) # A-B
# print("after difference :",favourite_fruits.difference(fruits)) # B-A
# print(fruits)
# print(favourite_fruits)

# print("after intersection :",fruits.intersection(favourite_fruits)) # A intersection B
print("after intersection :",fruits.intersection(favourite_fruits)) # A intersection B
print("after intersection :",favourite_fruits.intersection(fruits)) # A intersection B
# print("union :",fruits.union(favourite_fruits))
# print(" is not Any Common element :",fruits.isdisjoint(favourite_fruits)) #if none of the items are present in both sets
# # vegetables={"potato","spinach"}
# vegetables={"potato","spinach","Apple"}
# print(" is not Any Common element :",fruits.isdisjoint(vegetables))
print(" is not Any Common element :",fruits.isdisjoint(favourite_fruits)) #is none of the items are present in both sets (Return True if two sets have a null intersection.)
# vegetables={"potato","spinach"}
vegetables={"potato","spinach"}
print(" is not Any Common element :",fruits.isdisjoint(vegetables))


# A={1,2,3,4,5}
# B={1,2,3}
# C={1,2,3,8,9}
# print(A.issubset(B)) # is all Element of A is present in B
# print(B.issubset(A))
# print(A.issuperset(B)) # is All elements of B present in A

A={1,2,3,4,5}
B={1,2,3}
C={1,2,3,8,9}
print(A.issubset(B)) # is all Element of A is present in B
print(B.issubset(A))
print(A.issuperset(B)) # is All elements of B present in A
# print(A.symmetric_difference(C)) #

print(A.symmetric_difference(C))
# fruits={"Apple","Mango","Apple","Banana",10,78,54.55}
# favourite_fruits=["custardapple","Mango","kashmiri apple"]

# remaining=fruits.difference_update(favourite_fruits)
# print(remaining)
# print(fruits)
# print("---------------------------------------")
# remaining=fruits.difference(favourite_fruits)
# print(remaining)
# print(fruits)
34 changes: 12 additions & 22 deletions 05 Collections/tuple.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#tuple means row but in python tuple is a type of collection
#in python tuple is a type of collection
#which is immutable and ordered and it can also store the duplicate elements and it is subscriptable

# tup=() #creating empty tuple
# tup=tuple() #creating empty tuple

# row1=("Aman","abhishek","aman",10,56.78,"aman")

# # print(row1)
# # print(row1[2])
# # row1[0]="Aman Tiwari" # tuples are immutable
# print(row1)
# print(row1[2])
# row1[0]="Aman Tiwari" # tuples are immutable

# print(row1.count("aman"))
# # # print(row1)
# # # # print(row1)
# print("found at index ",row1.index("aman"))
# print("next index after 3 :",row1.index("aman",3))

Expand All @@ -30,27 +30,17 @@

n2=("sumit 2.0","jatin 2.0")
l1=["hemant","raghav"]
# tup4=n2+l1 # error can only concatenate tuple (not "list") to tuple
# tup4=(n2,l1)
# tup4=(n2,tuple(l1))
# # tup4=n2+l1 # error can only concatenate tuple (not "list") to tuple
# # tup4=(n2,l1)
# # tup4=(n2,tuple(l1))
tup4=(n2+tuple(l1))

# print(tup4)
print(tup4)


# for e in tup4:
# print(e,end=" | ")
for e in tup4:
print(e,end=" | ")

# print()
for i in range(len(tup4)):
print(" at tup[",i,"] =",tup4[i])


for i in range(1,10):
pass

def num():
pass

class abc:
pass
print(" at tup[",i,"]= ",tup4[i],sep="")
5 changes: 5 additions & 0 deletions 09.OOPs/11.polymorphism/OpOver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# print("Hello"+" Aman sir")
# print("$"*5)

# "".

class Point:
def __init__(self, x=0, y=0):
Expand Down Expand Up @@ -54,3 +55,7 @@ def __lt__(self, other):
# Not equal to p1 != p2 p1.__ne__(p2)
# Greater than p1 > p2 p1.__gt__(p2)
# Greater than or equal to p1 >= p2 p1.__ge__(p2)
# 2+3
a=2
b=5
a.__add__(b)
48 changes: 48 additions & 0 deletions DataScience/Threading.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import subprocess
import threading
import time

# Example: Open Notepad
# subprocess.run(["notepad.exe"])
subprocess.run(["explorer.exe"])

# Example: Open a specific file with its default application
# subprocess.run(["C:\\Program Files\\Google\\Chrome Dev\\Application\\chrome.exe"])
# subprocess.run(["C:\\Windows\\System32\\calc.exe"])



def eat():
# time.sleep(2)
print("eating break fast by ",threading.enumerate())
# subprocess.Popen(("open","C:\\Windows\\System32\\calc.exe"))

def watchMovie():
# time.sleep(2)
print("watching Movieby ",threading.enumerate())

def talking():
# time.sleep(2)
print("talking with familyby ",threading.enumerate())

# sequential execution
# eat()
# watchMovie()
# talking()

# print(threading.active_count())
# print(threading.enumerate())

t1=threading.Thread(target=eat)
t1.start()
t2=threading.Thread(target=watchMovie)
t2.start()
t3=threading.Thread(target=talking)
t3.start()

t1.join()
t2.join()
t3.join()

print(threading.active_count(),threading.enumerate())
print(time.perf_counter())
49 changes: 46 additions & 3 deletions Strings/Stringfxn.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
# str1="the quick.BRown fox JUMPS over the lazy frog"

str1="the quick.BRown fox JUMPS over the lazy frog Fox fox"
# length=len(str1)
# print("the sentence length is ",length)
# print(len(str1))
# print(str1[4])
# print(str1[4:9])
# print(str1[4:9]) # here 9th index is not included
# print(str1[0:9])
# print(str1[:9])
# print(str1[-1])
# print(str1[-2:-1])
# print(str1[-6:0]) # won't work
# print(str1[-6:])
# df[start:stop:step]
# print(str1[-4:1:-1]) # to reverse a string
# print(str1[::3])
# print(str1[::2])
# print(str1[::-2])
# print(str1[-2])
# print(str1[-8:-2])
# print(str1[::2])
Expand All @@ -26,3 +34,38 @@
# print("-".join(strarr))
# print(" ".join(strarr))
# print("_".join(strarr))


# print("".join(["aman","ram","shyam"]))
# print("_".join(["aman"]))
# print("_".join("Aman"))

# result="_".join(["aman","ram","shyam"])
# print(result)
# result="aman_ram_shyam"
# listOfNames=result.split("_")
# print(listOfNames)

# print(len(" Aman ".strip()))
# print(len(" Am an ".rstrip()))
# print(len(" Am an ".strip()))


newStr=""
for i in " Am an ":
if ord(i) != 32:
newStr+=i

print(newStr)



# newStr="Aman@123"
# newTwo=""
# for i in newStr:
# if ord(i)>=97 and ord(i)<=122:
# newTwo+= chr(ord(i)-32)
# else:
# newTwo+=i
# print(newTwo)

Empty file added Threads/OOps.py
Empty file.
73 changes: 73 additions & 0 deletions Threads/Threads.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# import threading

# def print_numbers():
# for i in range(5):
# print(i)

# # Create a thread
# thread = threading.Thread(target=print_numbers)

# # Start the thread
# thread.start()

# # Wait for the thread to complete
# thread.join()
# print("Thread finished.")


# import threading

# def print_numbers(prefix):
# for i in range(5):
# print(f"{prefix} {i}")

# # Create a thread with arguments
# thread = threading.Thread(target=print_numbers, args=("Thread 1",))

# # Start the thread
# thread.start()

# # Wait for the thread to complete
# thread.join()


# import threading

# lock = threading.Lock()

# def thread_safe_function():
# with lock:
# # Critical section of code
# print("This section is thread-safe.")

# thread = threading.Thread(target=thread_safe_function)
# thread.start()
# thread.join()



import threading
import requests

def download_url(url):
response = requests.get(url)
print(f"Downloaded {url} with status code {response.status_code}")

urls = [
"https://www.example.com",
"https://www.python.org",
"https://www.github.com"
]

threads = []

for url in urls:
thread = threading.Thread(target=download_url, args=(url,))
threads.append(thread)
thread.start()

# Wait for all threads to complete
for thread in threads:
thread.join()

print("All downloads finished.")
Loading

0 comments on commit 5f8c78b

Please sign in to comment.