This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def isPP(n): | |
| """Your task is to check wheter a given integer is a perfect power. If it is a perfect power, return a pair m and | |
| k with mk = n as a proof. Otherwise return Nothing, Nil, null, NULL, None or your language's equivalent. | |
| Read more - https://bit.ly/37mivH7""" | |
| numbers = set() | |
| for i in range(1, 120): # Generating a list of base of power | |
| for j in range(2, 15): # Generating a list of index power | |
| numbers.add(pow(i, j)) # Adding created numbers into a set |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def title_case(title, minor_words=''): | |
| """Write a function that will convert a string into title case, given an optional list of exceptions (minor | |
| words). The list of minor words will be given as a string with each word separated by a space. Your function | |
| should ignore the case of the minor words string -- it should behave in the same way even if the case of the | |
| minor word string is changed. """ | |
| words = [] | |
| minor_words = minor_words.lower().split() | |
| for word in title.lower().split(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| def domain_name(url): | |
| """Write a function that when given a URL as a string, parses out just the domain name and returns it as a | |
| string. """ | |
| # Creating a Regular expression to search a website | |
| regex = re.compile(r"""(http://www.|https://www.|www.|http://|https://)?(.*)\.""") | |
| # Writing down matches into result variable and splitting them into groups | |
| result = regex.match(url).group(2).split(".") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def testit(s): | |
| """How many times do you find the 'word' in a given string? | |
| More info : https://bit.ly/30KCAWx""" | |
| matches = [] | |
| count = 0 | |
| letters = ['w', 'o', 'r', 'd'] | |
| for word in s.lower(): | |
| if word not in matches: | |
| matches.append(word) | |
| try: # Using try/except block to avoid problems with indexes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PokeScan: | |
| """The task: https://bit.ly/3hycrA2""" | |
| characters = {"water": "wet", "fire": "fiery", "grass": "grassy"} | |
| def __init__(self, name, level, pkmntype): | |
| self.name = name | |
| self.level = level | |
| self.pkmntype = pkmntype | |
| if level in range(0, 21) or level < 0: | |
| self.level_character = "weak" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyClass: | |
| pass | |
| def class_name_changer(cls, new_name): | |
| """The task: https://bit.ly/2UWVJAE""" | |
| if new_name.isalnum() and new_name[0].isupper(): | |
| cls.__name__ = new_name | |
| return new_name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Create an @authenticated decorator that only allows the function to run is user1 has 'valid' set to True: | |
| user1 = { | |
| 'name': 'Sorna', | |
| 'valid': True # changing this will either run or not run the message_friends function. | |
| } | |
| def authenticated(fn): | |
| def check(*args, **kwargs): | |
| if dict(*args).get('valid'): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| def up_array(arr): | |
| """Given an array of integers of any length, return an array that has 1 added to the value represented by the | |
| array. More info: https://bit.ly/3elEzV2""" | |
| if len(list(None for number in arr if number < 0 or number not in range(0, 10) or len(arr) < 1)) > 0: | |
| return None | |
| elif len(arr) < 1: | |
| return None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| from bs4 import BeautifulSoup | |
| import pprint | |
| """This Parser returns Title, Link and a price. Additional functions will be included in a future""" | |
| URL = "https://www.olx.ua/elektronika/kompyutery-i-komplektuyuschie/" | |
| HEADERS = { | |
| 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' | |
| 'Chrome/81.0.4044.138 Safari/537.36 OPR/68.0.3618.191', 'accept': '*/*'} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="ru"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Lorem ipsum</title> | |
| <link rel="stylesheet" type="text/css" href="style.css"> | |
| <meta name="description" content="Your lorem ipsum"> | |
| <meta name=keyword" content="Lorem, ipsum"> | |
| </head> | |
| <body> |