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 random | |
| def binary_search(input_list , target_value): | |
| ''' | |
| Function executing binary search to find if element is in a list. | |
| parameters: | |
| - list | |
| - target | |
| return value: True/False (bool) |
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 list_elements_sum(input_list , sum_check): | |
| #list to store complements | |
| complements = [] | |
| for index,value in enumerate(input_list): | |
| #get complement for current value | |
| check_sum = sum_check-value | |
| #if value is in complements list we found our match | |
| if value in complements: |
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 list_elements_sum(input_list , sum_check): | |
| #loop through the list | |
| for index,value in enumerate(input_list): | |
| #we don't want to work with the last index as it is covered | |
| if index != (len(input_list)-1): | |
| #sum loop element with the rest of the list | |
| for inner in range(index+1, len(input_list)): | |
| add_item = input_list[inner] | |
| sum_current = value + add_item |
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 os | |
| import pathlib | |
| def get_file_exts(directory): | |
| #list all files in directory: | |
| search_path = pathlib.Path(directory).iterdir() | |
| file_list = [file.name for file in search_path if file.is_file()] | |
| #create a new list with tuple pairs of the filename and extension for all files: |
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 maya.cmds as cmds | |
| list_cameras = cmds.listCameras() | |
| cam_list = [cam for cam in list_cameras if not cmds.camera(cam, q=True, startupCamera=True)] | |
| for cam in cam_list: | |
| print(cam) |
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 Food(): | |
| def __init__(self,name,price,ingredients=[],allergens=[]): | |
| self._name = name | |
| self._price = price | |
| self._ingredients = ingredients | |
| self._allergens = allergens | |
| def add_ingredient(self,ingredient): |
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 sys | |
| from zipfile import ZipFile | |
| from datetime import datetime | |
| import os | |
| from pathlib import Path | |
| import shutil | |
| def get_file_path(filename): | |
| ''' | |
| function returning the full path of the file passed |
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 os | |
| def publish(search_path): | |
| print(f'working on: {search_path}') | |
| #list folders in search path | |
| scan_search_path = [folder.name for folder in os.scandir(search_path) if folder.name != '.DS_Store'] | |
| #if there is a work folder available, we can start working | |
| if 'work' in scan_search_path: |
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 kivy | |
| from kivy.app import App | |
| from kivy.uix.boxlayout import BoxLayout | |
| from kivy.uix.anchorlayout import AnchorLayout | |
| from kivy.uix.gridlayout import GridLayout | |
| from kivy.uix.textinput import TextInput | |
| from kivy.uix.button import Button | |
| from kivy.uix.label import Label |