Skip to content

Instantly share code, notes, and snippets.

View reloadedd's full-sized avatar
💭
Stackin' up

ʀᴇʟᴏᴀᴅᴇᴅᴅ ⌞⌯⌝ reloadedd

💭
Stackin' up
View GitHub Profile
#!/usr/bin/env python3
def dummy_search(elements: list, n: int) -> bool:
"""Search a number (n) in an ordered list of numbers (elements)
Returns the True if the element is in the list, otherwise it returns False.
"""
for i in elements:
if n == i:
return True # We found it
#!/usr/bin/env python3
import requests
from bs4 import BeautifulSoup
from pprint import pprint
if __name__ == '__main__':
r = requests.get('https://www.vanityfair.com/style/society/2014/06/'
'monica-lewinsky-humiliation-culture')
soup = BeautifulSoup(r.text, 'html.parser')
#!/usr/bin/env python3
from random import randint
def get_input() -> int:
n = int(input('Please enter a 4-digit number >>> '))
# if the number has more or than 4 digits
while n > 9999 or n < 1000:
#!/usr/bin/env python3
import requests
from bs4 import BeautifulSoup
responseObj = requests.get('https://www.nytimes.com/')
soup = BeautifulSoup(responseObj.text, 'html.parser')
print('The article titles in NYT are the following: ')
article_titles = soup.find_all('span')
#!/usr/bin/env python3
from string import printable, whitespace
from random import randint
def generate_password(strong: bool = True) -> str:
password = ''
if strong:
#!/usr/bin/env python3
def reverse_string() -> str:
"""This function asks the user for a string and then returns the reversed version of the string.
"""
input_string = input('Enter a string >>> ')
reversed_string = input_string.split()
reversed_string.reverse() # reverse the list withing itself
#!/usr/bin/env python3
import random
def remove_duplicates(the_list: list) -> list:
"""This function takes a list and then returns another list containing the elements of the original list, but without duplicates.
"""
return list(set(the_list))
#!/usr/bin/env python3
def generate_fibonacci_sequence(elements_number: int) -> int:
"""Generate the first *n* elements of the fibonacci sequence
"""
fib1 = 1
fib2 = 1
printed_elements = 2
#!/usr/bin/env python3
def first_and_last_element_list(the_list):
"""This function takes a list and returns a new list that contains only the first and the last element of list given as parameter.
"""
new_list = []
new_list.append(the_list[0])
new_list.append(the_list[-1])
return new_list
#!/usr/bin/env python3
def check_prime_number(x: int) -> bool:
if x == 2:
return True
elif (x < 3) or (x % 2 == 0):
return False
d = 3
while d * d <= x: