Skip to content

Commit 6888a9d

Browse files
committed
new programs
1 parent 8f785e4 commit 6888a9d

File tree

10 files changed

+466
-0
lines changed

10 files changed

+466
-0
lines changed

api.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from bs4 import BeautifulSoup
2+
import requests
3+
url=("https://www.regexsoftware.com/")
4+
data = requests.get(url).text
5+
soup = BeautifulSoup(data,"lxml")
6+
#print(soup.prettify)
7+
for div_tag in soup.find_all("div",{"class":"elementor-element elementor-element-9ba7258 elementor-column elementor-col-25 elementor-top-column"}):
8+
for div_data in div_tag.find_all("div",{"class":"elementor-heading-title elementor-size-default"}):
9+
print(div_data)

newprojectaws/S3.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import boto3
2+
import time
3+
import datetime
4+
import random
5+
6+
while True:
7+
time.sleep(10)
8+
resource=boto3.resource("s3")
9+
10+
11+
12+
ts=time.time()
13+
14+
bucket=resource.Bucket(f"mynewbucket{ts}")
15+
response = bucket.create(
16+
ACL='public-read-write',
17+
CreateBucketConfiguration={
18+
'LocationConstraint': 'ap-south-1'
19+
},)
20+
s=random.randint(0,10)
21+
with open('/newprojectaws', 'w') as data:
22+
resource.Bucket(f'mynewbucket{ts}').upload_file('/newprojectaws', f'newfile{s}')
23+
24+
25+
26+
27+
28+
29+

newprojectaws/newtest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from importlib.resources import Resource
2+
import boto3
3+
4+
resource=boto3.resource('s3')
5+
list_=resource.buckets.all()
6+
for buckets in list_:
7+
print(buckets.name)
8+
for my_bucket_object in resource.objects.all():
9+
print(my_bucket_object)

newprojectaws/test.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# s3 = boto3.resource('s3')
2+
# the_bucket = s3.Bucket('my_bucket')
3+
4+
from asyncio.windows_events import NULL
5+
from http import client
6+
from re import X
7+
import boto3
8+
import time
9+
import datetime
10+
import random
11+
import botocore
12+
s3= boto3.resource('s3')
13+
the_bucket = s3.buckets.all()
14+
for bucket in the_bucket:
15+
# print(bucket.name)
16+
N=bucket.name
17+
my_bucket=s3.Bucket(bucket.name)
18+
# response= resource.list_objects_v2(bucket.name)
19+
20+
# list_=(map(lambda x: (x.bucket_name, x.key), my_bucket.objects.all()))
21+
# listkeys=my_bucket.bucket_name()
22+
23+
# print(listkeys)
24+
for keys in my_bucket.objects.all():
25+
list_= (keys.bucket_name)
26+
27+
for keys in the_bucket :
28+
list_2=(keys.name)
29+
print(list_2)
30+
# for i in list_:
31+
# print(i)
32+
# list_=filter(None,list(list_))
33+
for i in list_2:
34+
if i not in list_:
35+
response=s3.delete(i)
36+
37+
# print(list_)
38+
# else:
39+
# my_bucket.delete_bucket(list_[0])
40+
#
41+
42+
# # list2=list(filter(None,list_))
43+
# for i in list_:
44+
# if len(list_)<1:
45+
# continue
46+
# my_bucket.delete_bucket(list2[0])
47+
# if my_bucket.all()
48+
# else:
49+
# print(list_[0])
50+

newprojectaws/time.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from asyncio.windows_events import NULL
2+
from http import client
3+
from importlib.resources import Resource
4+
from re import X
5+
6+
7+
import boto3
8+
import time
9+
import datetime
10+
import random
11+
import botocore
12+
resource = boto3.resource('s3')
13+
response = resource.buckets.all()
14+
for bucket in response:
15+
# print(bucket.name)
16+
N=bucket.name
17+
my_bucket=resource.Bucket(bucket.name)
18+
# response= resource.list_objects_v2(bucket.name)
19+
20+
# list_=(map(lambda x: (x.bucket_name, x.key), my_bucket.objects.all()))
21+
# listkeys=my_bucket.bucket_name()
22+
23+
# print(listkeys)
24+
for keys in resource.Object.all():
25+
list_= (keys.bucket_name)
26+
27+
for keys in response :
28+
list_2=(keys.name)
29+
print(list_2)
30+
# for i in list_:
31+
# print(i)
32+
# list_=filter(None,list(list_))
33+
for i in list_2:
34+
if i not in list_:
35+
bucket=response.Bucket("nonamebuckt9898")
36+
response = bucket.delete()
37+
38+
# print(list_)
39+
# else:
40+
# my_bucket.delete_bucket(list_[0])
41+
#
42+
43+
# # list2=list(filter(None,list_))
44+
# for i in list_:
45+
# if len(list_)<1:
46+
# continue
47+
# my_bucket.delete_bucket(list2[0])
48+
# if my_bucket.all()
49+
# else:
50+
# print(list_[0])
51+

practicebro1.py

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# print("I love to play football")
2+
# print("I can play it anytime") 1
3+
# first_name = "bro"
4+
# second_name = "code"
5+
# full_name = first_name + " " + second_name
6+
# print("hello "+full_name) #2
7+
# print(type(name))
8+
# age = 21
9+
# age += 1
10+
# print("your age is : "+str(age))
11+
# print(age)
12+
# print(type(age))
13+
# height = 150.5
14+
# print("your height is : "+str(height))
15+
# print(type(height))
16+
# human = True
17+
# print(type(human))
18+
# print("are you a human : "+str(human)) #time:17:01
19+
20+
# MULTIPLE ASSIGNMENT BY BRO CODE (18:04)
21+
# name , age , attractive = "rudraksh" , 20 , True
22+
# print(name)
23+
# print(age)
24+
# print(attractive) # if all elements have similar value then below:
25+
# gopu = muniya = raghav = chotu = 20
26+
# print(gopu)
27+
# print(raghav)
28+
# print(muniya)
29+
# print(chotu)
30+
# name = "rudraksh bohra" #len function also counts spaces so instead of 13 it's going to print 14
31+
# print(len(name))
32+
# print(name.find("r")) # find function only gives the index of first element to be found for eg i there are 3 r then it will give the index of first r to be found
33+
# print(name.capitalize()) # it will not capitalize the word after space
34+
# print(name.upper()) # will convert into upper case similarly we can use .lower
35+
# print(name.isdigit()) #return true if our string is numeric value else false
36+
# print(name.isalpha()) # if there is alphabets in string then true but if there is space between two alphabets then it will return false
37+
# print(name.count("r")) #prints the count of characters within our string
38+
# print(name.replace("r","m")) # if we want to replace certain character with other character
39+
# print(name*3) #if we want to print name multiple times
40+
41+
#TYPECASTING IN PYTHON 25:22
42+
# x = 1 #int
43+
# y = 2.0 #float
44+
# z = "3" #str
45+
# y = int(y) #this is permanent tye cast in which if we print y we will get it value 2
46+
# print(x)
47+
# print(int(y)) # this is not permanent typecast
48+
# print(z)
49+
# print("x is "+z)
50+
# print("x is "+x) #it will print error so we have to typecast int and float value in string value in this situation
51+
52+
#HOW WE CAN ACCEPT SOME USER INPUT IN PYTHON(31:00)
53+
# name = input("what is your name?: ")
54+
# age = int(input("how old are you?: "))
55+
# height = float(input("how tall are you?: "))
56+
# age = age + 1
57+
# print("Hello "+name)
58+
# print("you are "+str(age)+" year old")
59+
# print("you are "+str(height)+"cm tall")
60+
61+
#USEFUL FUNCTIONS RELATED TO NUMBERS IN PYTHON(37:09)
62+
# import math
63+
# pi = 3.14 # "import math" to access these functions
64+
# print(round(pi))
65+
# print(math.ceil(pi)) # use to rounded up for the particular value
66+
# print(math.floor(pi)) #rounded down for the particular value
67+
# print(abs(pi)) #give the absolute value i.e. how much the value is far from zero
68+
# print(pow(pi, 2)) #print the power of any certain value
69+
# print(math.sqrt(pi)) # to find the square root of any value
70+
# x = 1
71+
# y = 2
72+
# z = 3
73+
# print(max(x,y,z)) # print the maximum of these values
74+
# print(min(x,y,z)) # min for lowest
75+
76+
#STRING SLICING IN PYTHON(41:05) slicing creates a substring by extracting elements from another string
77+
# two ways by indexing[] or by slice() function [start:stop:step]
78+
# name = "rudraksh bohra"
79+
# first_name = name[0:8] #can also be done by name[:8] , empty space will take default start value
80+
# print(first_name)
81+
# second_name = name[9:14] # can also be done by name[9:] , default stop value
82+
# print(second_name)
83+
# funky_name = name[13:-15:-1] # we can also do it by name[::-1] or name[13::-1]
84+
# print(funky_name)
85+
# print(name[::2])
86+
#STRING SLICING USING SLICE FUNCTION
87+
# website1 = "http://google.com"
88+
# website2 = "http://linkedIn.com"
89+
90+
# slice = slice(7,-4)
91+
92+
# print(website1[slice])
93+
# print(website2[slice])
94+
95+
96+
97+

q1.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
3+
import math
4+
5+
6+
def digSum( n):
7+
sum = 0
8+
9+
while(n > 0 or sum > 9):
10+
11+
if(n == 0):
12+
n = sum
13+
sum = 0
14+
15+
sum += n % 10
16+
n /= 10
17+
18+
return sum
19+
20+
# Driver method
21+
n = input("enter number: ")
22+
x=n.split(" ")
23+
q=x[0]
24+
w=x[1]
25+
if ((int(digSum(int(q))))== (int(digSum(int(w))))):
26+
print(True)
27+
else:
28+
print(False)
29+

q2.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from collections import Counter
2+
x=input()
3+
l1=[]
4+
for i in range(int(x)):
5+
6+
l1.add[i]
7+
d = Counter(l1)
8+
print(d)
9+
10+
new_list = list([item for item in d if d[item]>1])
11+
print(new_list)

0 commit comments

Comments
 (0)