blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
123f44d763fe59334151321a24a1c3a3cf7b284c
Ret-David/Python
/IS 201/Concept Tests/CT05_David_Martinez.py
689
4.21875
4
# David Martinez # Write a pseudo code to design a program that returns the # of occurrences of # unique values but sorted from the list. For example, with the input list # [1, 2, -2, 1, 0, 2, 4, 0], the program should provide the output as follows: # unique value (# of occurrences) # -2(1) # ...
0dbbc02921221a9a82b45cb35a06a3104b728679
Ret-David/Python
/IS 201/Module 8/HOP08_David_Martinez_read_excel.py
472
3.625
4
# David Martinez import openpyxl wb = openpyxl.load_workbook('example.xlsx') print (wb.sheetnames) # wb.active selects the first available sheet (sheet 1) sheet = wb.active print (sheet.title) for i in range(1, sheet.max_row+1): # print all data in column A,B,C # ljust() is used to make it easier to read ...
29cb21e25dc8a989a0360ef7185a6c7dde7fa3a1
Ret-David/Python
/IS 201/Module 5/HOP05_David_Martinez_Files_mode.py
702
3.921875
4
# David Martinez file = open('hello.txt', 'a') # open file hello.txt in append mode file.write('\nThis is new content I just appended.') # append new content file.close() # close file hello.txt new_file = open('world.txt', 'w') # open file world.txt in (over)write mode ne...
f2dab556908346b8cb19bc3f858d181006f8dab9
Ret-David/Python
/IS 201/Module 4/HOP04_David_Martinez_print_numbers.py
212
3.671875
4
# David Martinez def numbers(limit): i = 0 numbers = [] while i < limit: numbers.append(i) i = i + 1 return numbers user_limit = int(input("Give a limit: ")) print(numbers(user_limit))
879206042b294d5da53faf0c85858394a2e7b28e
Ret-David/Python
/IS 201/Module 1/HOP01.py
1,789
4.34375
4
# HOP01- David Martinez # From Kim Nguyen, 4. Python Decision Making Challenge # Fix the program so that the user input can be recognized as an integer. # Original Code guess = input("Please guess a integer between 1 and 6: ") randomNumber = 5 if (guess == randomNumber): print("Congrats, you got it!") else: ...
241f1927f8616969495a6e01ad60214c94e8bebc
Ret-David/Python
/IS 201/Practical Exercises/PE03_David_Martinez_1.py
557
3.859375
4
# David Martinez # Write a Python script to concatenate following dictionaries to create a new one. # Sample Dictionary : # dic1={1:10, 2:20} # dic2={3:30, 4:40} # dic3={5:50,6:60} # Expected Result : {1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60} dic1={1:10, 2:20} dic2={3:30, 4:40} dic3={5:50,6:60} myDict = {} ...
0d022905006e7bb3113a9726c9780b13eb55b544
Ret-David/Python
/IS 201/Practical Exercises/PE05_David_Martinez_4.py
1,725
4.34375
4
# David Martinez # Make two files, cats.txt and dogs.txt. # Store at least three names of cats in the first file and three names of dogs in # the second file. # Write a program that tries to read these files and print the contents of the file # to the screen. # Wrap your code in a try-except block to catch the...
92acf42a33fefc55d10db64cb4a2fd7856bc21de
Ret-David/Python
/IS 201/Concept Tests/CT09_David_Martinez.py
616
4.375
4
# David Martinez # Write a pseudo code to design a program that returns I-th largest value # in a list. For example, with the input list [3, 2, 8, 10, 5, 23] # and I = 4, the program prints the value 5 as it is 4 th largest value. # ========== My Pseudo Code ========== # >> 5 is in index 4 position but is the...
3eace911aeb3aab302f3059d10faf28c58cb2732
Ret-David/Python
/IS 201/Module 7/HOP07_David_Martinez_operator_overloading.py
250
3.890625
4
# David Martinez class Point: def __init__(self, x, y): self.x = x self.y = y # overriding magic method def __add__(self, other): return self.x + other.x, self.y + other.y p1 = Point(1, 2) p2 = Point(3, 4) print(p1+p2)
46aeb7ee8588b79b64ace088e125ff0dc0ab9ed9
samsonharveyy/game-of-life
/game_of_life.py
6,513
3.9375
4
""" Simple Conway's Game of Life simulator """ def displayGrid(grid): """ Displays current contents of the grid """ for lines in grid: print(lines) def initialGrid(grid, file): """ Sets the initial grid state """ x = file.readline() lines_in_file = [single_line.strip('\n') for si...
9e4819940a439c8357f0246be55ab3b82ec371d2
roselandroche/Graphs
/projects/ancestor/ancestor.py
3,199
3.53125
4
class Graph(): def __init__(self): self.vertices = {} def add_vertex(self, new_vertex): if new_vertex not in self.vertices: self.vertices[new_vertex] = set() def add_edge(self, vertex_1, vertex_2): self.vertices[vertex_1].add(vertex_2) def get_neighbors(sel...
d8fa5194932e571800d3dfbb789ab7b96395e27d
unixpickle/Weekly-Programming-Challenge
/week2/stephd_permutation_test.py
554
3.734375
4
a= str(input('Gimme a string!')).lower() b= str(input('Gimme another string (of the same length)!')).lower() i=0 h=0 if(len(a) == len(b)): print('Yay, they\'re the same length.') for i in range(0, len(a)): if(a[i] in b): print ('Found ' +a[i]+ ' in '+b) h+=1 else: ...
9bdf7afce30f5997453dd1c175695d3417d4ca4e
roger254/interview
/Simple_Pig_Latin_Converter.py
2,863
4.09375
4
class Simple_Pig_Latin_Converter(object): def pig_latin_converter(self, word): # create an empty list to store the digits digit_list = [] # keep count of the '?' character counter = 0 # returns if word passed the conditions valid = False # loop through the st...
a98aa35a8e020540f6ee6aa3b6827fea4c8bb7e6
roger254/interview
/passwordValidator.py
1,159
4.03125
4
class Password_Validator(object): def validate_password(self, passwords): """return valid passwords from the string input""" special_characters = ['$', '#', '@'] passwords_list = passwords.split(",") correct_passwords = [] for password in passwords_list: lower_cas...
71d630396eac3835fd30d5d033dc606e96ffd462
kraxik/00Name_generator
/main.py
705
3.8125
4
import sys from modules import generate_name def main(): race = input("Choose race from orc/elf/human/undead/troll: ") if (race.lower() == 'orc'): name = generate_name.get_name('orc') elif (race.lower() == 'elf'): name = generate_name.get_name('elf') elif (race.lower() == 'hu...
6535dab888c3fc21e8134eba92a4bc4b69e7003e
lisachu2727/MIS-304
/A3_ChuTzu-Chuan.py
5,457
4.21875
4
#Name: Tzu-Chuan Chu #Assignment Number: 3 #Date: 9/27/18 #Section: 8:00 - 9:30 #Description: This program is designed for Mrs. Kate of Delectable Cakes to process orders. #Description: This program also allows inventory to update itself as sales occur and calculates the profit made from sales. #Setting prices ...
271f57a8524a59b4389a08857e4f61a77847720e
lisachu2727/MIS-304
/A5_ChuTzu-Chuan.py
5,171
3.84375
4
#Name: Tzu-Chuan Chu #Assignment Number: 5 #Date: 10/26/18 #Section: 8:00-9:30 #Description: This program reads employee ID and wage information in a text file #Description: and then processes the highest monthly salary for each employee as well as #Description: each employee's average monthly salary. This progra...
2f8ceb822df1222331ba9dd1755eae8c4f6d9c12
KnPk11/Cryptocurrency_Mining_AHK_Scripts_Windows
/Protect GPU against overheating.py
732
3.59375
4
# Shuts down computer to prevent overheating over a specified threshold # Needs Open Hardware Monitor to be running # v1.0: Initial version import wmi from decimal import Decimal import os w = wmi.WMI(namespace="root\OpenHardwareMonitor") # Operating system interface, call the OpenHardwareMonitor class t...
1ac54f873ec739f4fb89038ee731d61888b66990
valeriacavalcanti/IP-2020.1-R
/Semana_06/questao_02.py
402
3.578125
4
times = [] votos = [] for i in range(4): times.append(input("Time: ")) votos.append(0) for i in range(6): voto = input('Voto: ') for j in range(4): if (voto == times[j]): votos[j] += 1 break print(times) print(votos) # Times: flamengo(2) - palmeiras(2) - sport(1) - bo...
0d9cdbf760a39f9c5c0b593f22bbceb8461c4436
valeriacavalcanti/IP-2020.1-R
/Semana_03/questao05.py
143
3.734375
4
n1, n2 = input("Informe dois valores: ").split() n1, n2 = int(n1), int(n2) for i in range(n1, n2 + 1): if (i % n1 == 0): print(i)
2c1cd5d2c31d157f0ce5cea4e98507e8e682c056
valeriacavalcanti/IP-2020.1-R
/Semana_05/questao_04.py
219
4.03125
4
numero = int(input("Informe um valor: ")) binario = [] num = numero while (num // 2 != 0): binario.append(num % 2) num = num // 2 binario.append(num) binario.reverse() print(bin(numero)[2:]) print(binario)
c3730089033d1a5581e89a38dee200828d217ae2
valeriacavalcanti/IP-2020.1-R
/Semana_02/questao03.py
220
3.953125
4
mes = input("Mês: ") if (mes == 'jan') or (mes == 'mar') or (mes == 'mai') or (mes == 'jul') or (mes == 'ago') or (mes == 'out') or (mes == 'dez'): print(31) elif (mes == 'fev'): print('28 ou 29') else: print(30)
bd1edaa3933bb5a1ed6caba17453dfed416d9205
valeriacavalcanti/IP-2020.1-R
/Semana_11/questao01.py
167
3.796875
4
def somar(n1, n2): return n1 + n2 # PROGRAMA PRINCIPAL num1 = int(input('Informe um valor: ')) num2 = int(input('Informe um valor: ')) print(somar(num1, num2))
3861e45d9fe4f61a67a76182c63a7d9ba5fb0c08
ChloeDumit/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/2-matrix_divided.py
986
4.03125
4
#!/usr/bin/python3 """Divide all elements of a matrix """ def matrix_divided(matrix, div): """ Function to divide elements of a matrix """ e1 = "Each row of the matrix must have the same size" e2 = "matrix must be a matrix (list of lists) of integers/floats" new_matrix = list(map(list, matrix)) ...
5e7b828d0d74462a10fefbbee34d14c3f29f4c0c
ChloeDumit/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/models/square.py
1,674
4.28125
4
#!/usr/bin/python3 """ Write the class Rectangle that inherits from Base""" from .rectangle import Rectangle """ creating new class """ class Square(Rectangle): """ class Square """ def __init__(self, size, x=0, y=0, id=None): "initializes data" self.size = size super().__init__(sel...
ef17aadecdd2a2177688ba28552dcd6c6dbd6cd5
ChloeDumit/holbertonschool-higher_level_programming
/0x0B-python-input_output/2-append_write.py
205
4.0625
4
#!/usr/bin/python3 """ reads a text file """ def append_write(filename="", text=""): """write a file and returns number of chars """ with open(filename, 'a') as f: return f.write(text)
4ca0ba5def80c4a12b64cdf7193482b250fadaea
somadisingh/WordFrequencyPython
/WordFreq.py
4,153
4.125
4
""" Python Code to find out most frequent words from famous GRE lists WordLists ( Courtesy: www.quizlet.com ) 1. Barrons 1100 Words 2. Magoosh 1000 Words 3. Majortest Essential 1500 Words 4. Princeton 500 Words 5. Kaplan 500 Words 6. Manhattan Basic+Essential 1000 Words Above words are stored in different text files ...
6eb9af73caf69c7a30a6e60e64ca3f7da1f0216d
congthanh97/root
/Python/New folder (2)/tiinhsn2.py
98
3.671875
4
n = int(input("nhap n : ")) sn = 0 for i in range(1,n+1): sn += i*i print("total : ",sn)
6343b6cbb498e41f699c0c7cfb0adc3ab633de02
congthanh97/root
/hinhchunhat.py
300
3.5
4
class Hinhchunhat(object): def __init__(self, l, w): self.dai = l self.rong = w def dt(self): return self.dai*self.rong def cv(self): return (self.dai + self.rong)/2 aHinhchunhat = Hinhchunhat(10,2) print (aHinhchunhat.dt()) print (aHinhchunhat.cv())
6576d9abce26d247e2d0de2550eb37f760d0c219
alisol/book
/ch08/02.py
1,478
4.09375
4
class Contact: def __init__(self, name, phone_number, e_mail, addr): self.name = name self.phone_number = phone_number self.e_mail = e_mail self.addr = addr def print_info(self): print("Name: ", self.name) print("Phone Number: ", self.phone_number) print(...
c843dba7832275c6c69c4b614cec39daab73683a
mefistmef/cuddly-waffle
/format.py
542
3.984375
4
# Процентное форматирование name = 'Vi' age = 24 print('Your name %s, your age %d.' %(name, age)) # Форматирование .format name = 'Vi' age = 24 print('Your name {}, your age {}.' .format(name, age)) # Форматирование f-строка name = 'Vi' age = 24 print(f'Your name {name}, your age {age}.') # точка в данном случае обо...
9f8463600325a460085f797231a419d10ac206a0
mefistmef/cuddly-waffle
/zad5.py
725
3.96875
4
profit = float(input('Введите сумму выручки за год: ')) costs = float(input('Введите сумму издержек за год: ')) if profit > costs: print(f'Поздравляю! Вы не банкрот. Рентабельность выручки составила {(profit / (profit - costs)):.2f}') workers = int(input('Введите количество сотрудников: ')) print(f'Ваша п...
015e8232f2a297ecc7e8d0ebe7a25038125f13eb
dyfloveslife/SolveRealProblemsWithPython
/Practice/student_teacher.py
1,166
4.15625
4
class Person(object): """ return Person object """ def __init__(self, name): self.name = name def get_details(self): """ return string include person's name """ return self.name class Student(Person): """ return Student Object,include name,branch,y...
18a33a6664f29a85ab879e36ca34ebbf189a5f04
dyfloveslife/SolveRealProblemsWithPython
/BasicKnowledge/test_20180706.py
2,954
3.578125
4
# var1 = 10 # var2 = var3 = 10.1 # var4, var5, var6 = 5, 6, 'hello' # print(var1, var2, var3, var4, var5, var6) # a, b, c, d = 1, 3.14, True, 1 + 2j # print(type(a)) # print(type(b)) # print(type(c)) # print(type(d)) # a = 100 # result = isinstance(a, int) # print(result) # print('1 + 2 =', 1 + 2) # print('2 - 1 =', ...
9e46b9f38fe413aaffbb68f488fc301740cc9eb5
dyfloveslife/SolveRealProblemsWithPython
/BasicKnowledge/test_20180703.py
4,423
3.65625
4
# def f(x): # return x * x # # # r = map(f, [1, 2, 3, 4, 5, 6, 7, 8, 9]) # print(list(r)) # from functools import reduce # # # def fn(x, y): # return x * 10 + y # # # def char2num(s): # digits = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} # return digits[s] # # prin...
da10e0e1a678e7adccaa467a418e460130c41075
dyfloveslife/SolveRealProblemsWithPython
/BasicKnowledge/test_20180617-2.py
656
3.9375
4
# name = input('Please enter your name:') # print("Hello", name) # print(1024 * 768) # print(10 / 2) # print(10 // 2) # d = {'Bob': 81, 'Mack': 99} # print(d['Tom']) # d = {} # # print(d['Tom']) # d.get('Tom', -1) # print(d[]) # d = {'Michael': 95, 'Bob': 75, 'Tracy': 85} # # print(d.get('Thomas', -1)) # print(d.p...
ae486e39a097e65de05fda88ac496b90dc136f6c
dyfloveslife/SolveRealProblemsWithPython
/BasicKnowledge/test_20180815-2.py
1,003
3.890625
4
''' # g = lambda x: 2 * x + 1 # print(g(100)) ''' ''' scifi_authors = ['Isaac Asimov', 'Ray Bradbury', 'Robert Heinlein', 'Arthus C. Clarke', 'Frank Herbert'] # help(scifi_authors.sort) scifi_authors.sort(key=lambda name: name.split(' ')[-1].lower()) print(scifi_authors) ''' # import math # from fu...
ecad20955903ed12ab50e9cd187b1a332b9e1529
dyfloveslife/SolveRealProblemsWithPython
/BasicKnowledge/test_20180714.py
451
3.609375
4
x = int(3.3) x = 0 def outer(): x = 1 def inner(): x = 2 print(x) inner() outer() x = int(3.3) x = 0 def outer(): x = 1 def inner(): i = 2 print(x) inner() outer() x = int(3.3) x = 0 def outer(): o = 1 def inner(): i = 2 print(x) ...
982a3dd465f2d544319f95d55ca4c805c106b249
swaps95shah/Graph-1
/maze.py
1,366
3.6875
4
""" Time: O(mn) Space: O(mn) Leet: Accepted Problems: None """ class Solution(object): def hasPath(self, maze, start, destination): """ :type maze: List[List[int]] :type start: List[int] :type destination: List[int] :rtype: bool """ def findNeighbors(node): ...
b8e42d344e48fc43c5bc3b071faa845555f5cdbe
bolongpa/Basic-ML-agl-implementation
/PCA/PCA.py
3,106
3.65625
4
'''Implementation of PCA in python''' #importing modules import numpy as np import matplotlib.pyplot as plt def read_data(): # to read the given data data = [] with open('pca-data.txt', 'r') as f: for line in f: line = line[:-1] # remove '\n' line = line.split('\t') ...
d6cf29b5a328539c2cc53990c52eb77751f41004
natenka/q_and_a
/code/03_filter_json_dict_by_key/solution_1.py
891
3.640625
4
import json from pprint import pprint import click from rich import print def filter_data_by_name(data, search_key): results = [] if type(data) == dict: for key, value in data.items(): if key == search_key: results.append(value) else: results.ex...
b81d05dbcc2bf739add9878e0c1f657efc9fa587
sunjj94/python
/杨辉三角.py
227
3.53125
4
#!/usr/bin/end python3 #-*- coding:utf-8 -*- def triangles(): a = [1] while 1: yield a a.append(0) a=[a[i] + a[i - 1] for i in range(len(a))] t = triangles() n = 0 for x in t: print(x) n = n + 1 if n == 10: break
b1971470ca81337039678ed2149c7596c14970f8
Y-EK/Python_OOP_Basics
/manager.py
877
3.71875
4
from employee import Employee class Manager(Employee): def __init__(self, fname, lname, pay, employees=None): super().__init__(fname, lname, pay) if employees is None: self.employees = [] else: self.employees = employees def add_employee(self, emp): if...
3e5a1166f2db92d254d2f6be5a8d64697742b248
AnsaldiAndrea/release_scraper
/package/normal.py
923
3.703125
4
"""module for variouse string normalization""" from datetime import datetime import re def normalize_release_date(date_str=None, date_tuple=None, date=None): """return normalized release date""" if date_tuple: return datetime(date_tuple[0], date_tuple[1], date_tuple[2]).strftime('%Y-%m-%d') if dat...
cdeac90be8ee6b3ff3bfda6723fd2391495c7947
aastha-vidushi/practice-problems-in-python3
/String_programs/list_problem_1.py
626
3.984375
4
ip ="192.168.225.134" print("Given IP : ", ip) # Spliting the given string into a list in order to swap the position of 2nd & 3rd octet ipList = ip.split(".") # Output : ['192', '168', '225', '134'] print(ipList) # swaping the value at 2nd position with the value at 3rd position ipList[1], ipList[2] = ipList[2], ipLi...
7d32795a21910f37af9de23d0ddbc06f80576a5c
gamesguru/greedymatrix
/resources/reduce.py
899
3.65625
4
#!/usr/bin/env python3 import sys import csv file = sys.argv[1] o_index = 0 d_index = 1 nums = {} print("Read in CSV") with open(file) as in_f: reader = csv.reader(in_f) for row in reader: i = int(row[o_index]) j = int(row[d_index]) # Add e.g. 100 --> 97, map original index to reduce...
9bfb5874b84cd05278e840b4066aca012f434074
kevapostol/holbertonschool-higher_level_programming
/0x03-python-data_structures/8-multiple_returns.py
231
3.96875
4
#!/usr/bin/python3 def multiple_returns(sentence): '''Returns a tuple with the length of a string and its first character.''' if len(sentence) == 0: return len(sentence), None return len(sentence), sentence[0]
d8fc8268dbfc376e124f67101f560b417d72dbd8
kevapostol/holbertonschool-higher_level_programming
/0x02-python-import_modules/3-infinite_add.py
216
3.609375
4
#!/usr/bin/python3 from sys import argv sum = 0 if __name__ == '__main__': if len(argv) == 1: print(0) else: for i in range(1, len(argv)): sum += int(argv[i]) print(sum)
fb9c65abf09e05678af15a7dbe96589257b9ce9f
dryelixir95/Basic-Python
/Tugas1/soal3.py
669
3.84375
4
pilihan = "y" while (pilihan != 'n'): nilai_ujian_teori = float(input("masukkan nilai ujian teori? ")) nilai_ujian_praktek = float(input("masukkan nilai ujian praktek? ")) nilai1, nilai2 = nilai_ujian_teori, nilai_ujian_praktek if nilai1 >= 70 and nilai2 >= 70: print("Selamat, anda lulus...
1f6934e3fba69d6d2b34ad94e8cfdb2845ef1166
Copenbacon/code-katas
/katas/convert_array.py
335
4
4
"""Convert a number (n) in a reverse list of the individual numbers.""" def digitize(n): """Convert a number into a reverse list of each individual number.""" str_list = list(str(n)) str_list.reverse() num_list = [] for idx in range(len(str_list)): num_list.append(int(str_list[idx])) r...
65a6523ec93440b3bd83213c7d0d1dc4d0fa4967
Copenbacon/code-katas
/katas/sum_series.py
267
3.890625
4
"""Sum Series module from Codewars.""" def series_sum(n): """Sum a series of fractions up to the nth value.""" answer = float(0) for series_len in range(1, 1 + n * 3, 3): answer += float(1) / float(series_len) return "{:.2f}".format(answer)
8a4cd80218ad131a0427446cb7ca67e7d775ac8f
Copenbacon/code-katas
/katas/test_cuckoo_clock.py
1,946
3.8125
4
"""Testing cuckoo clock module.""" from cuckoo_clock import fizz_buzz_cuckoo_clock def test_basics(): """Basic times tests.""" assert fizz_buzz_cuckoo_clock("13:34") == "tick" assert fizz_buzz_cuckoo_clock("21:00") == "Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo Cuckoo" assert fizz_buzz_cu...
4168151b95dabbbdb3075ee1e3360f030fb13855
chirumist/Python-Practice
/python-files/guess-number-game.py
712
4.09375
4
""" Guess number count start """ guesses = 8 numbers = [2, 4, 5, 6, 9] guessCount = int(0) print(numbers) while guessCount <= guesses: number = int(input("Guess number: \n")) if number in numbers: numbers.remove(number) print("Remain number guess ", len(numbers)) print("remain guesses...
a77e453db54257941f567075630cf03eb7680d4c
chirumist/Python-Practice
/python-files/snack-water-gun.py
968
3.890625
4
import random swg = {"0": 'Snack', "1": 'Water', "2": 'Gun'} computer = random.choice(tuple(swg)) for index, gameObj in swg.items(): print(f"Press {index} For {gameObj}") player = 1 def gameStart(): global player player = input() def checkWin(pl, bot): if swg[pl] == 'Snack' and swg...
1cf774f7971d6ef9fd23b8033faaf7cb1f445ebe
schubline/west_nile_virus_project
/utilities/lat_lon_ds.py
1,646
3.8125
4
def lat_lon_ds(p_1, p_2): """Argument 'p1' is a list of decimal [lat, lon] coords in degrees. 'p2' is another list. Function returns the distance between them in meters, without correction for curvature of the earth. Distance will be slightly underestimated by a fraction approximately (t - sin(t)), where t ...
c04fd41845d7800bf8dd2c28c6b4a4058fd89ee1
caramelfish/career-planning-app
/skills.py
1,644
3.859375
4
import sqlite3 userID = "" skillTable = "skill_"+userID usersTable = "users" def create_table(): with sqlite3.connect("Users.db") as db: cursor = db.cursor() cursor.execute('CREATE TABLE IF NOT EXISTS '+skillTable+'(' 'skillname VARCHAR(20) ...
9179d4736e8966ca6fc0a029823b4cd7606424a9
DubeyJacob/05b-Exercises-pygame-physics
/exercise1.py
5,385
3.6875
4
#!/usr/bin/env python ''' Choose values for gravity, friction, and air_resistance (lines 25–27). Try to find a combination that seems realistic For every line in the update method (lines 41-66), please add a comment describing what it does. Try to describe each line within the context of the program as a whole, rat...
9d5da4a70185516d705f64b3015839e259a55f90
AntonnyAguilar/PythonTesting
/function.py
671
3.953125
4
''' break continue pass ''' def sum_val(arg1, arg2): ''' Here is the information related to the function ''' # print arg1+arg2 return arg1+arg2 x=sum_val(2,3) def say_hello(): print 'Hello' def greeting(name): print 'Hello '+ name def is_prime(num): ''' Check if a number is prime or not '...
c3f0fc8ae72403a823bdd487c40c689ba92f457c
AntonnyAguilar/PythonTesting
/loop.py
413
3.90625
4
l = [1,2,3,4,5] for element in l: print element for num in l: if num%2==0: print 'even number: %s' %(num) else print 'Odd even number: %s' %(num) list_num=0 for num in l: list_num = list_num + num print list_num tup = (1,2,3,4,5) l = [(2,4), (6,8), (10,12)] for (t1,t2) in l: print t1 d = {'k1'...
837e33d3c68490c802413072261a0b1a44b02aed
robbaralla/sql
/sql-search.py
737
4.09375
4
import sqlite3 with sqlite3.connect("newnum.db") as connection: c=connection.cursor() prompt= """pick an operation: 1: average 2: min 3: max 4: sum 5: exit """ while True: #get user input x = input(prompt) if x...
b037c5eb09154f226b1c6ff6c605c040fc37320a
hahaliu/LeetCode-Python3
/709.to-lower-case.py
336
3.546875
4
# ex2tron's blog: # http://ex2tron.wang class Solution: def toLowerCase(self, str): """ :type str: str :rtype: str """ # 使用内建函数: # return str.lower() # 不适用内建函数: return "".join([chr(ord(ch)+32) if 'A' <= ch <= 'Z' else ch for ch in str])
13ab332e5e59551b16c11b355c79c4a050e60409
hahaliu/LeetCode-Python3
/020.valid-parentheses.py
926
3.5625
4
# ex2tron's blog: # http://ex2tron.wang class Solution(object): def isValid(self, s): """ :type s: str :rtype: bool """ # 别人的代码 temp = [] dicts = {"{": "}", "(": ")", "[": "]"} for c in s: if c in dicts.keys(): temp.append(...
8a2cc39e3dd9799e46aa0bd8f8b922fad8c99d8a
hahaliu/LeetCode-Python3
/654.maximum-binary-tree.py
1,420
4.15625
4
# ex2tron's blog: # http://ex2tron.wang # 我的思路:先求max,然后分成左右,最后左右分别递归 # Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def constructMaximumBinaryTree(self, nums): """ :...
f63cd2634c86429d2ef614b97143aff297020bab
hahaliu/LeetCode-Python3
/198.house-robber.py
978
3.625
4
# ex2tron's blog: # http://ex2tron.wang # 方法一 # 自底至上的动态规划 # 先判断前i个房间能获得的最多金钱 # maxV[i] = max( maxV[i-2]+nums[i], maxV[i-1] ) class Solution: def rob(self, nums): """ :type nums: List[int] :rtype: int """ if not nums: return 0 if len(nums)<=2: ...
e3c33517182c8fa5451eddf56d05ad6404bd4bc9
hahaliu/LeetCode-Python3
/122.best-time-to-buy-and-sell-stock-ii.py
429
3.65625
4
# ex2tron's blog: # http://ex2tron.wang # 这题不会 # 别人的思路: class Solution: def maxProfit(self, prices): """ :type prices: List[int] :rtype: int """ profit = 0 for i in range(len(prices)-1): print(prices[i+1]-prices[i]) profit += max(0, prices[...
57b69469ce2e7047f8b759d8979a49e125b57929
hahaliu/LeetCode-Python3
/890.find-and-replace-pattern.py
1,624
3.53125
4
# ex2tron's blog: # http://ex2tron.wang # 我的写法:太复杂 # class Solution: # def findAndReplacePattern(self, words, pattern): # """ # :type words: List[str] # :type pattern: str # :rtype: List[str] # """ # ret = [] # match = True # for word in words: # ...
e7e32bf65fa62ff5b6fff0da1d47ad04b3894efb
hahaliu/LeetCode-Python3
/830.positions-of-large-groups.py
1,130
3.5
4
# ex2tron's blog: # http://ex2tron.wang # class Solution: # def largeGroupPositions(self, S): # """ # :type S: str # :rtype: List[List[int]] # """ # ret = [] # start, end = 0, 0 # for i in range(len(S)-1): # if S[i] != S[i+1]: # en...
2dc9e9a4e312d85a3b46be4158374567f55d7e19
hahaliu/LeetCode-Python3
/006.zigzag-conversion.py
1,734
3.703125
4
# ex2tron's blog: # http://ex2tron.wang # 我的写法:太复杂,可以实现 # class Solution: # def convert(self, s, numRows): # """ # :type s: str # :type numRows: int # :rtype: str # """ # if numRows == 1: # return s # ret = [] # split = 2*(numRows-1) # ...
301877486970334a725281597e5cd58c343e99da
hahaliu/LeetCode-Python3
/145.binary-tree-postorder-traversal.py
690
3.96875
4
# ex2tron's blog: # http://ex2tron.wang # Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def postorderTraversal(self, root): """ :type root: TreeNode :rtype: List[int] ...
49cba8d48367a7f61e46d8e63d07a274d61cc4f7
hahaliu/LeetCode-Python3
/589.n-ary-tree-preorder-traversal.py
588
3.671875
4
# ex2tron's blog: # http://ex2tron.wang # 我的思路:先添加val,遍历children # Definition for a Node. class Node(object): def __init__(self, val, children): self.val = val self.children = children class Solution(object): def preorder(self, root): """ :type root: Node :rtype: Lis...
e73aee052841dcc678833b5ed63e93ede8c06d49
hahaliu/LeetCode-Python3
/876.middle-of-the-linked-list.py
1,215
4
4
# ex2tron's blog: # http://ex2tron.wang # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None # 我的代码:先求长度,再取半 # class Solution: # def middleNode(self, head): # """ # :type head: ListNode # :rtype: ListNode # "...
8b894406418bb918fd137a0641bfcf7741b2c678
hahaliu/LeetCode-Python3
/747.largest-number-at-least-twice-of-others.py
368
3.5625
4
# ex2tron's blog: # http://ex2tron.wang class Solution: def dominantIndex(self, nums): """ :type nums: List[int] :rtype: int """ if(len(nums) == 1): return 0 lst = sorted(nums, reverse=True) return nums.index(lst[0]) if lst[0] >= 2*lst[1] else -1 ...
0b631f717428967b8f1313203c8e723e78e6cbbe
hahaliu/LeetCode-Python3
/504.base-7.py
835
3.703125
4
# ex2tron's blog: # http://ex2tron.wang # class Solution: # def convertToBase7(self, num): # """ # :type num: int # :rtype: str # """ # ret = "" # negative = True if num < 0 else False # shangshu = abs(num) # while shangshu >= 7: # shangs...
d081aa3d5eed225811e8ffd1ec93fc4db335a013
hahaliu/LeetCode-Python3
/204.count-primes.py
1,361
3.984375
4
# ex2tron's blog: # http://ex2tron.wang import math # 别人的方式: # 厄拉多塞筛法 # (1)先把1删除(现今数学界1既不是质数也不是合数) # (2)读取队列中当前最小的数2,然后把2的倍数删去 # (3)读取队列中当前最小的数3,然后把3的倍数删去 # (4)读取队列中当前最小的数5,然后把5的倍数删去 # (5)读取队列中当前最小的数7,然后把7的倍数删去 # (6)如上所述直到需求的范围内所有的数均删除或读取 class Solution: def countPrimes(self, n): """ :type n: in...
047324370042446e32639c9ca3d2e9dd84cd9cc0
jadeD1995/gamenight
/quiz.py
849
4.0625
4
print('Welcome to the quize about life') answer=input('Are you ready to play the Quiz ? (yes/no) :') score=0 total_questions=3 if answer.lower()=='yes': answer=input('Question 1: What started the world') if answer.lower()=='aliens': score += 1 print('correct') else: pr...
dbf7af66905d57acb0a438c241c952695b281182
devzer01/misc
/django/mysite/test.py
348
3.84375
4
array = ["is", "are", "was", "the", "he", "she", "fox", "jumped"] sentence = "He was walking down the road" words = sentence.split(" "); newarray = []; for word in words: if word.lower() in array: newarray.append(word) for i in range(0, len(word), 1): newarray.append(word[i:i+1]) for word in ...
ed9a96971eb72f1ef888f050b040b44b28632950
RidvanDayanc/python-exercises
/program-2.py
263
3.875
4
print("use , for seperate") myduplicatedarray = (input("Give Me List:")).split(",") print("Array which contains duplicated items is",myduplicatedarray) mycleararray = list(set(myduplicatedarray)) print("Array which not contains Duplicated items is", mycleararray)
d69644b5fb3c8f44f1531294ad8176725bcb29d3
ProjectBlueOfficial/Relentless
/AbandonedRoad.py
4,312
3.640625
4
import time from math import floor import Combat import Answers as a from Enemy import Zombie from MapBuilder import Map from Start import player import Strings as s map = Map(10, 10) def init(): time.sleep(1) player.x = floor(map.rows / 2) player.y = floor(map.cols / 2) print("You wake up on an aba...
1c7ce416e9ec93eaebf9ccbf44dcd2111dc5782e
sozos/Practice
/binaryTree.py
7,247
4.125
4
#!/usr/bin/python import random # Notes while learning about Python classes: # fnA means fnA is public and is what should be called # _fnA means fnA is still publicly accessible but should not be used. i.e. its implementation is not guaranteed to always stay the same # __fnA means fnA is private and can only be used w...
688d033fc5dd61f33fe2c19085ee984615b6f9b5
lz69/CodePractice
/Python/my_collections.py
526
3.609375
4
from collections import namedtuple, deque, defaultdict, OrderedDict, Counter Point = namedtuple('Point', ['x', 'y']) p = Point(1, 2) print(p.x, p.y) q = deque(['a', 'b', 'c']) q.append('x') q.appendleft('y') print(q) dd = defaultdict(lambda:'N/A') dd['key1'] = 'abc' print(dd['key1']) print(dd['key2']) d = dict([('a...
d46877843280e7b93d6c7ad19638d61f2a5cda11
Vikash082/algo-1
/remove_kth_node_from_end.py
591
3.765625
4
class LinkedList: def __init__(self, value): self.value = value self.next = None # T: O(n) def remove_kth_node_from_end(head, k): first = second = head counter = 1 # F S # 0->1->2->3->4->5>6 while counter <= k: second = second.next counter += 1 # ...
e2c2327dc55591847c5aa345f8acba144afe58d3
air5005/python_work
/example/while.py
130
3.734375
4
while True: print('Please input your name.') name = input() if name == 'ych': break print('exit')
202304b6643c46e5baed5d5c4c6bbb1e585e5440
taspa90/Project_2
/MemoryGame.py
466
3.59375
4
import random import time number = input('How many number do you want to guess:') number = int (number) chack = [] for i in range (0,number): chack.append(random.randint(0,101)) print(chack) time.sleep(0.7) for i in range (0,50) : print('') for i in range(0,number): print('enter number at index' +str...
2af7fcda23fc1d24159062cf94bcefe0eec26666
callump5/TextAdventure
/characters.py
1,587
3.71875
4
class gladiator(object): def __init__(self, name): self.name = name self.exp = 1000 self.level = 1 self.inventory = [] self.equipedItems = [] self.base_hp = 180 self.hp = 0 self.base_damage = 24 self.damage = 0 def update_level(self): ...
19b7ca25c810d909ac8c730129a9e602f3f24e84
voralexan/CV-labs
/lab1.py
4,250
3.53125
4
import cv2 import numpy as np if __name__ == "__main__": # Load the cascade for face recognition and read an image face_cascade = cv2.CascadeClassifier('trained_face_recognition.xml') img = cv2.imread("image.png", 1) ########################### # 1. Найти лицо на изображении. #######################...
433b752500da2a4188eb39c474deb753a83ede65
MohamadHosny/Simple-Python-Calculator-with-functions
/HosnyCalculator.py
748
3.875
4
# coding: utf-8 # In[52]: #Mohamad Ashraf Mohamad Hosny . #3/9/2019 #This is a simple Python Calculator Code . #basic operations implemented by 4 funs. : def Sum(q,w): return q+w def Sub(e,r): return e-r def Mul(t,y): return t*y def Div(o,p): return o/p # fun. Calc is what u have to call ...
5df8e77b3c0573d35d990c70b8f2459a6b1c2b53
HONOOUR/Algorithm_Test
/Algorithm_Python/ValidPalindrome.py
803
3.828125
4
from collections import deque class ValidPalindrome: def init(self, s: str) -> list: array = [] for char in s: if char.isalnum(): array.append(char.lower()) return array def isPalindrome(self, s: str) -> bool: array = self.init(s) return a...
19150810afcf88bc5d8b140e24142d698238aaa5
HONOOUR/Algorithm_Test
/Algorithm_Python/TargetNumber.py
546
3.640625
4
from collections import deque class TargetNumber: def getTargetAnswers(self, nums: list, target: int): answer = 0 queue = deque([(0, 0)]) while queue: s, l = queue.popleft() # sum, level queue.append((s+nums[l-1], l+1)) queue.append((s-nums[l-1], l+1)) ...
c4db07fef0a8d291e7fd71c6c5cd4d7981f417ca
FHantke/FitnessTrackerAnalysisTool
/Database/database.py
28,290
3.546875
4
from datetime import datetime from datetime import timedelta import hashlib import sqlite3 import os import math # from typing import Dict, Any """ TABLES Every table is represent as one class with getter and setter methods. """ class Sleep: start = [] end = [] wakeup_day = [] de...
5592f8f04714d6862c6ac90e03e5a83d0c4cd814
Aritiaya50217/CompletePython3Programming
/section13_Gui/lecture98_event.py
765
4.125
4
# Event Driven Programming การเขียนโปรแกรมตามลำดับเหตุการณ์ from tkinter import * def leftClickButton(event): print("Left Click !! ") def rightClickButton(event): print("Right Button !! ") def doubleClickLeft(event): print("DoubleClick Left !!") def doubleClickRight(event): print("DoubleClick Right !...
4b68bfc2067a802ee50c5521209a65067c1b4fd0
Aritiaya50217/CompletePython3Programming
/section13_Gui/lecture94.py
418
4.03125
4
# การจัดการ Layout ของ widget from tkinter import * def sayHello() : print("Hello World!!") mainWindow = Tk() button1 = Button(mainWindow,text="Click me 1",command=sayHello).grid(row=0,column=1) button2 = Button(mainWindow,text="Click me 2",command=sayHello).grid(row=0,column=2) button3 = Button(mainWindow,text="...
b12bbaf3e31c5362fd198c6512d76d858470ac8d
jinayshah86/DSA
/CtCI-6th-Edition/Chapter1/1_6/string_compression_1.py
1,653
4.1875
4
# Q. Implement a method to perform basic string compression using the counts # of repeated characters. For example, the string 'aabcccccaaa' would become # 'a2b1c5a3'. If the "compressed" string would not become smaller than the # original string, your method should return the original string. You can # assume the stri...
37727c4956ad9181b4e2d6bcacae08e6280cf58d
jinayshah86/DSA
/CtCI-6th-Edition/Chapter2/2_5/sum_list_2.py
3,881
4.03125
4
# Q. You have two numbers represented by a linked list, where each node # contains a single digit. The digits are stored in forward order, such that # the 1's digit is at the tail of the list. Write a function that adds the two # numbers and returns the sum as a linked list. # Example: # Input: (6 -> 1 -> 7) + (2 -> 9 ...
1455d5e6de85fde6715e397b613ba45f33107c55
jinayshah86/DSA
/CtCI-6th-Edition/Chapter1/1_7/rotate_matrix_2.py
1,998
3.765625
4
# Q. Given an image represented by an NxN matrix, where each pixel in the # image is 4 bytes, writes a method ot rotate the image by 90 degrees. Can # you do this in place? # Time complexity: O(N^2); N is the size of the NxN matrix. # Space complexity: O(1) import unittest def rotate_90_matrix(matrix): n = len(m...
2588bdaa6c31eded3aca35076c4870c24e2405a0
ocalderinp/agendaPython
/agenda.py
3,633
3.5
4
# -*- coding: utf-8 -*- import os import sqlite3 import re # contactos = [] conexion = sqlite3.connect('agenda.s3db') cursor = conexion.cursor() class Contacto: nombre = "" apellido = "" telefono = "" email = "" def limpiar(): os.system('cls') def addContact(): limpiar() print ...
55bbc84b8eecce932fe2d33dcd5c065d01d40a11
dustin181/javareference
/docs/python algorithms/mine/leetcode50/smallest_subarray_with_given_sum.py
917
4.09375
4
import math def smallest_subarray_with_given_sum(s, arr): window_sum = 0 min_length = math.inf left = 0 for right in range(len(arr)): window_sum += arr[right] # add the next element # shrink the window as small as possible until the 'window_sum' is smaller than 's' while wind...
6f20818231975ec2b2a5e6fec27b9eb8f321e553
dustin181/javareference
/docs/python algorithms/mine/leetcode50/dfs_graph_mirror.py
1,137
3.859375
4
from collections import defaultdict class Graph: def __init__(self, graph): self.graph = graph def addEdge(self, vertex, edge): self.graph[vertex].append(edge) def bfs(self, vertex): visited = [vertex] queue = [vertex] while queue: node = queue.pop(0) ...
be6b3159380fb6df7504d277e80fc90a70832520
dustin181/javareference
/docs/python algorithms/mine/leetcode50/max_subarray_of_size_k.py
957
3.953125
4
def max_sub_array_of_size_k_brute_force(k, arr): max_sum = 0 for i in range(len(arr) - k + 1): window_sum = 0 for j in range(i, i+k): window_sum += arr[j] max_sum = max(max_sum, window_sum) return def max_sub_array_of_size_k(k, arr): max_sum, window_sum = 0, 0 ...
1cd21c7546a0c089a00d388359db55e632210c1f
dustin181/javareference
/docs/python algorithms/mine/leetcode50/ceiling_of_a_number2.py
567
3.796875
4
def search_ceiling_of_a_number(arr, key): n = len(arr) if key > arr[n-1]: return -1 left = 0 right = n - 1 while left <= right: mid = (left + right) // 2 if key < arr[mid]: right = mid - 1 elif key > arr[mid]: left = mid + 1 else: ...
f92b81374c05781fd0821a6203c0839ee62f2c05
dustin181/javareference
/docs/python algorithms/mine/hashing/is_formation_possible.py
866
4.03125
4
from HashTable import HashTable def is_formation_possible(lst, word): if len(word) < 2 or len(lst) < 2: return False hash_table = HashTable() for elem in lst: hash_table.insert(elem, True) for i in range(1, len(word)): # Slice the word into two strings in each iteration ...