Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Basic-Scripts/Password/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<h1>Hard to guess easy to remember</h1>
<p>Python script to generate a <b>password</b> which is almost <b>impossible to guess</b> by a attacker, by <b>using the easily remembered words</b> of a user day to day life.</p>

Here I use built-in python <b>module</b> name <b>random</b> use to make random choice.
71 changes: 71 additions & 0 deletions Basic-Scripts/Password/password.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#Importing Library
import random

#GENERATE TWO RANDOM STRINGS FROM THE GIVEN LIST
def RandomString(List):
string1=random.choice(List) #First random string
List.remove(string1) #To avoid repetition of strings removing the first word from the list
string2=random.choice(List) #second random string

return string1,string2

#GENERATE TWO RANDOM NUMBERS BETWEEN RANGE (0 - 9)
def RandomNumber():
List=[0,1,2,3,4,5,6,7,8,9]
number1=random.choice(List) #First random number
List.remove(number1) #To avoid repetition of numbers removing the first word from the list
number2=random.choice(List) #Second random number

return number1,number2

#GENERATE TWO RANDOM CHARACTERS
def RandomSpecialChar():
List=['~','`','!','@','#','$','%','^','&','*','?','+','-','_',';',':','>','<']
char1=random.choice(List) #First random character
List.remove(char1) #To avoid repetition of characters removing the first word from the list
char2=random.choice(List) #Second random character

return char1,char2

#GENERATE A RANDOM INDEX FROM PASSWORD STRING
def RandomIndex(List):
index=random.choice(List)
List.remove(index)

return index

#Driver program
if __name__=='__main__':

#Take input from user
names=list(input('Input the list of easily remembered words').split())

#Creating password using two strings
string=RandomString(names)
password=string[0]+string[1]

#Uppercasing random characters in password
IndexList=list(range(0,len(password)))
index=RandomIndex(IndexList)
password=password[:index]+password[index].upper()+password[index+1:]
index=RandomIndex(IndexList)
password=password[:index]+password[index].upper()+password[index+1:]

#Adding random numbers in password
number=RandomNumber()
index=RandomIndex(IndexList)
password=password[:index]+str(number[0])+password[index:]
index=RandomIndex(IndexList)
password=password[:index]+str(number[1])+password[index:]

#Adding random special symbols in password
char=RandomSpecialChar()
index=RandomIndex(IndexList)
password=password[:index]+char[0]+password[index:]
index=RandomIndex(IndexList)
password=password[:index]+char[1]+password[index:]

#Printing the generated password
print('Generated password : ',password)


6 changes: 6 additions & 0 deletions Web-Scraping/Covid-19 Statics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<h1>Scraping Covid-19 Statics</h1>

Scraping the corona virus cases of 213 countries and territories.
Using <b>Beautiful soup</b> python package to extract the <b>HTML</b> content of the website(https://www.worldometers.info/coronavirus/countries-where-coronavirus-has-spread/).

Representing the extracted data in <b>table format</b> form using <b>texttable</b> python library.
52 changes: 52 additions & 0 deletions Web-Scraping/Covid-19 Statics/code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Importing Libraries
import requests
from bs4 import BeautifulSoup
import texttable as tt

# URL for scrapping data
url = 'https://www.worldometers.info/coronavirus/countries-where-coronavirus-has-spread/'

# Get URL html
page = requests.get(url)
soup = BeautifulSoup(page.text, 'html.parser')

data = []

# soup.find_all('td') will scrape every element in the url's table
data_iterator = iter(soup.find_all('td'))
# data_iterator is the iterator of the table

# This loop will keep repeating till there is data available in the iterator
while True:
try:
country = next(data_iterator).text
confirmed = next(data_iterator).text
deaths = next(data_iterator).text
continent = next(data_iterator).text
deaths=deaths.replace(',','') #Removing "," from deaths string
confirmed=confirmed.replace(',','') #Removing "," from confirmed string

# For 'confirmed' and 'deaths', make sure to remove the commas and convert to int
data.append((
country,
int(confirmed), #Converting string to int
int(deaths), #Converting string to int
continent
))

# StopIteration error is raised when there are no more elements left to iterate through
except StopIteration:
break

# Sort the data by the number of confirmed cases
data.sort(key = lambda row: row[1], reverse = True)

# Creating Table
table = tt.Texttable()
table.add_rows([(None, None, None, None)] + data) # Add an empty row at the beginning for the headers
table.set_cols_align(('c', 'c', 'c', 'c')) # 'l' denotes left, 'c' denotes center, and 'r' denotes right
table.header((' Country ', ' Number of cases ', ' Deaths ', ' Continent '))

# Printing the created table
print(table.draw())