Skip to content

Instantly share code, notes, and snippets.

View Abuton's full-sized avatar
💭
A better me everyday

Abubakar Alaro Abuton

💭
A better me everyday
  • Kitopi, AFarms
  • Ilorin, Kwara State
  • X @Abuton1
View GitHub Profile
import re
with open("company (2).txt") as file:
com = file.read()
com_split = com.split("-------")
com_list = com_split[3].replace('--', '').split("\n")[1:-3]
a = [x.split('(') for x in com_list]
dict_prod = {}
for i in a:
dict_prod[i[0]] = i[1].replace(')', '')
CREATE TABLE IF NOT EXISTS `Cages`
(
cageId INT NOT NULL AUTO_INCREMENT,
noOfBirds INT DEFAULT 0,
PRIMARY KEY (`cageId`)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `Customer`
(
EntityName = {attribute1 datatype, attribute2 datatype, …..}
Cages = {cageId INT, noOfBirds INT}
Employees = {employeeId INT, firstName TEXT, lastName TEXT, dateJoined DATE, salary DOUBLE, position VARCHAR(25)}
Sales = {id INT, date DATE, customerId INT, employeeId INT, price DOUBLE, noOfEggSold INT}
import pandas as pd
import os
import shutil
def extract(path: str = "s3://my_bucket_name/file0.parquet") -> pd.DataFrame:
df = pd.read_parquet(path)
return df
def replace_word(roots: list, sentence: str) -> str:
output = []
sentence_list = sentence.split()
for word in sentence_list:
output.append(word)
for r in roots:
if word.startswith(r):
output[-1] = r
return " ".join(output)
def find_bigrams(S: str) -> list:
# 1. create a list of words from the string
new_s = S.lower().split()
# 2. create an empty list to append tuples to
bigrams = []
# 3. loop through this list k-1 times say k is the length of list
for i in range(len(new_s)-1):
# 4. append the current word and the next to the empty list
bigrams.append((new_s[i], new_s[i+1]))
# 5. return the list
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
import collections
def solution(S):
# write your code in Python 3.6
# create an empty dictionary to store the values of S
f_dict = collections.defaultdict(int)
# loop S
for i in S:
# increase number of times each character exists in S
-- write your code in PostgreSQL 9.4
SELECT r.task_id, t.name as task_name,
case when avg(r.score) <= 20 then 'Hard'
when avg(r.score) > 20 and avg(score) <= 60 then 'Medium'
when avg(r.score) > 60 then 'Easy' End As difficulty
from reports r left join tasks t on r.task_id = t.id
group by r.task_id, task_name order by r.task_id
def solution(U, L, C):
# write your code in Python 3.6
if U + L != sum(C):
return "IMPOSSIBLE"
res = [[0 for j in range(len(C))] for i in range(2)]
for i, s in enumerate(C):
if s == 2:
if U == 0 or L == 0:
return "IMPOSSIBLE"
With amounts as (
select t1.id, t1.position, t1.salary, sum(t2.salary) as running_salary
from candidates t1 join candidates t2 on t1.id >= t2.id
and t1.position = t2.position
where t1.salary <= 50000
group by t1.id, t1.position, t1.salary
order by t1.id
),
snrs as (
select id, position, salary, running_salary from amounts