Skip to content

Instantly share code, notes, and snippets.

View martinandersson82's full-sized avatar

martinandersson82

View GitHub Profile
@martinandersson82
martinandersson82 / main.py
Created October 12, 2023 22:29
This gist belongs to an article that goes through how to add an icon on top of a profile image.s
import shutil
import csv
import sys
import os
from PIL import Image
def acquire_user_data_csv(file_path):
'''
function that opens a csv file and returns the content
return type: list
'''
2022-04-07
Python script that converts a sentence to
sarcasm stupid Spongebob style
example:
Hello There
hElLo ThErE
'''
import random
class Die():
def __init__(self, faces):
self._faces = faces
def get_faces(self):
return self._faces
def roll_die(self):
from die import Die
def generate_dice(amount, faces):
dice_list = [Die(faces) for die in range(amount)]
return dice_list
def roll(dice):
values = [die.roll_die() for die in dice]
for die in values:
print(die, end=' ')
'''
PHOTOS:
Photo by Josh Sorenson from Pexels
Photo by Darrel Und from Pexels
Photo by cottonbro from Pexels
'''
import pathlib
import sys,os,shutil
from PIL import Image
'''
python script that generates a password based on user input.
supports words,numbers, and special characters.
Author: Martin Aaberge
Date: 2021 10 19
'''
import random
from random import randint
def user_interface(options):
'''
function presenting options and asking for player feedback
returns integer.
'''
for index,option in enumerate(options):
print(f'{index} = {option}')
from random import randint
def computer_number(min_num,max_num):
'''
function that generates a random number based on the range passed as args.
returns random int
'''
return randint(min_num,max_num)
def player_guess(min_num,max_num):
from random import randint
def roll_die(eyes,amount):
'''
function that rolls die based on die data.
returns die_roll list
'''
die_roll = [randint(1,eyes) for die in range(0,amount)]
return die_roll
def binary_performance():
run_setup = '''
from __main__ import binary_search
'''
run_code = '''
bin_list = list(range(6,501))
binary_search(bin_list,15)
'''
performance = timeit.repeat(setup = run_setup,