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
b0f2cf6edfe8ef9970a3bd5cc3fb5c449bdc7796
johannpistorius/satisfactory_calculator
/src/load_json.py
794
3.53125
4
""" @author johannpistorius """ import json import os class JSON: def __init__(self): parent = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) filename = os.path.join(parent, 'res', 'data', 'data.json') try: with open(filename, 'r') as json_file: ...
b245d7ab86a57c3722721b5b288f3eb59db780b4
AcmenLu/PythonDataSample
/Code/Introduction/Session16.py
227
3.546875
4
# 切片 lst = ["zhangsan", "李四", "王五", "赵六", 3.4, 5.6, 7, 8.9, 4, 6] print(lst) tmp1 = lst[0:4] #[0, 4) print(tmp1) tmp2 = lst[:4] print(tmp2) tmp3 = lst[4:] print(tmp3) tmp4 = lst[1:-2] print(tmp4) # tuple
94807716df21cdb8c4794e94b2607e3b58ab3889
xxao/miniml
/miniml/costs.py
2,306
3.515625
4
# Created byMartin.cz import numpy as np def mean_squared_error(Y, Y_hat): """ Calculates cost and its gradient using Mean Squared Error. (1/2m)*sum(Y - Y_hat)^.2 Args: Y: Data labels. Y_hat: Predictions/activations from the output layer. ...
7e0cf42f4eeb3c3bb2abfca1c2d3755271e08ebc
rikachka/UniLIFT2016
/WeightSensor.py
584
3.578125
4
import random class WeightSensor(object): def __init__(self, weight_limit): self.weight = 0 self.weight_limit = weight_limit def get_weight(self): # print('weight sensor: current weight', self.weight) return self.weight def is_limit_exceeded(self): return self.ge...
bc1c10ebde3b4f3d38705934d84cd4f2ff3b3e14
ashish-2412/Employee-Management-and-Salary-Prediction
/gender_wise_calc.py
846
3.546875
4
import pandas as pd pd.set_option('display.max_rows', 500) pd.set_option('display.max_columns', 500) pd.set_option('display.width', 1000) empsal_df = pd.read_csv('empsal.csv', index_col='empno', parse_dates=['dob']) print(empsal_df.info()) empsal_df.dropna(axis=0, how='any', inplace=True) print(empsal_df.in...
3cb7742e39cbd5ccf369e50a70ad90c8d5605959
ixiaoxinxin/testFlask
/pythontest/taijiewenti.py
234
3.546875
4
fib = lambda n: n if n <= 2 else fib(n - 1) + fib(n - 2) def memo(func): cache = {} def wrap(*args): if args not in cache: cache[args] = func(*args) return cache[args] return wrap print wrap
48c2794bfc8a290a004ddae9f1982227340e561f
ixiaoxinxin/testFlask
/pythontest/newstrip.py
565
3.5625
4
def rightStrip(temStr,splitStr): endindex = temStr.rfind(splitStr) while endindex != -1 and endindex ==len(temStr) - 1: temStr = temStr[:endindex] endindex = temStr.rfind(splitStr) return temStr def leftStrip(temStr,splitStr): startindex = temStr.find(splitStr) while startindex == 0:...
50179bf5aeb7ac00e658f9a2912abfdaff8d0ad0
HYUNJAE-JEON/Coding-Test
/DFS_BFS/factorial.py
572
3.9375
4
# 반복적으로 구현한 n! def factorial_iterative(n): result = 1 # 1부터 n까지의 수를 차례대로 곱하기 for i in range(1, n+1): result *= i return result # 재귀적으로 구현한 n! def factorial_iterative_(n): if n <= 1: #n이 1 이하인 경우 1을 반환 return 1 # n! = n * (n-1) !를 그대로 코드로 작성하기 return n * factorial_iterative(n-1) # 각각의 방식으로 구현한 n!...
74c8301374ed51eeacab675592db9f2e025a70ef
wesleyegberto/rosalind
/ReverseComplement.py
538
4.0625
4
#Reverse Complement Problem (http://rosalind.info/problems/1b/) or #Complementing a Strand of DNA (http://rosalind.info/problems/revc/) #input: #AAAACCCGGT #output: #ACCGGGTTTT #To exec use: python ReverseComplement.py < rosalind_1b.txt text = str(raw_input()); reverse = ""; for n in text: #n = text[i:i + 1] ...
1721135b50b49c0cfb109712ce9355a7695bb438
Jaykb123/jay
/jay1.py
831
4.5
4
print("To check the greater number from the given number!".center(70,'-')) # To take a numbers as an input from the user. first_num = int(input("Enter the first number: ")) second_num = int(input("Enter the second number: ")) third_num = int(input("Enter the third number: ")) # To check among the num...
e5d8b66f41ebecbb7f4576a3375ac2e6d94d0c3a
OwenPendrighElliott/countdown_solver
/letters_and_numbers.py
1,464
3.703125
4
import sys import argparse # letters and numbers classes import letters import numbers parser = argparse.ArgumentParser() parser.add_argument('-g', choices=['letters', 'numbers'], help='The type of game being played', type=str) parser.add_argument('-ls', ...
19e5fafd774900f4b987a6180670d454d7bb2d6b
balajimaniv/python_basics
/args.py
355
3.578125
4
def display(length, breadth, height=20, color='black') : #required arguments should be first from left print " the length is ", length print " the dimension in lXbXh ", length,"X",breadth,"X", height print "color",color display(52,96) # atleast have to give the requied arguments if we call display() it wi...
d0ecd71d89620e2f33d7c6e033a3aef587990694
panushri25/basepairmodels
/basepairmodels/cli/bpnetutils.py
1,263
3.8125
4
import random import string import pytz from datetime import datetime, timezone def getAlphaNumericTag(length): """ generate a random alpha numeric tag Args: length (int): the desired length of the tag Returns: str: alphanumeric string of length `length` ...
290fac3bfc3671924e084d6629b83f9fb91ff533
madcato/speechbutlerphoneme
/text.py
4,465
3.53125
4
# this file is an adaptation from the work at mozilla deepspeech github.com/mozilla/DeepSpeech import kenlm import re from heapq import heapify def wer(original, result): r""" The WER is defined as the editing/Levenshtein distance on word level divided by the amount of words in the original text. In ...
5196057b59256c5470e7c33c73a3944e385e8a32
jduell12/cs-module-project-hash-tables
/d3_application.py
4,924
4.15625
4
#fibonacci numbers - get n fibonacci number # 0 1 1 2 3 5 8 13 21 34... #could use recursion - could end up taking a long time # fib(0): 0 # fib(1): 1 # fib(n): fib(n-1) + fib(n-2) # time complexity: O(2^n) # def fib(n): # if n <= 1: return n # return fib(n-1) + fib(n-2) # for i in range(100): # print(f"...
ed74470444139777ab7692500912766b84508820
abhi7000/e-commerce
/blog/prime.py
329
3.796875
4
from math import sqrt,floor def dynamic(n): dynarr=[1 for i in range(n+1)] uplmt=floor(sqrt(n)) temp=2 while(temp<n+1): if(dynarr[temp]==1): for i in range(temp*2,n+1,temp): dynarr[i]=0 temp+=1 for i in range(n+1): if(dynarr[i]==1): print(i) number=int(input("enter positive number=")) dynamic(...
735096a9258c560979644fdc8c612e6c5045e493
AlbertQueiroz/Atomic-Formulas-and-Logic-Operators-Algorithm
/subformulas.py
580
3.515625
4
atomics = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','x','y','z'] #Se o trem chegou tarde e não tinha taxi na estação, então José chegou atrasado. #(t^(~x))>a F = [['t','^',['~','x']],'>','a'] def subformulas(F,atomics): if (F in atomics): return F if (F[1] no...
4691a2b7364bb142d04d2dfc37d9fb4932d41f68
mosasaki/hw5
/python27-flask/train_service.py
4,225
4.15625
4
def create_graph(network): """Create a graph of train lines Args: network(list): A list of dictionaries of lines and stations in the line Returns: graph(dictionary): A graph of train stations """ graph = {} line = 0 i = 0 while line < len(network): while i <len...
d36cc1f2d6b30c2383a9fd624fdd57a84e9f6818
Lamarcgasolridge/python-challenge
/PyBank/main_pybank.py
1,804
3.671875
4
#import modules import os import csv import statistics #Create Buckets tot = [] months = [] monthly_change = [] #Define avg calculation def average (numbers): total = 0 for number in numbers: total += number find_average = total/len(numbers) return find_average #Read CSV csvpath = os.path.joi...
02cba1197604dfa12f6dcfb55c17337aebbafadd
chadchiukc/machineLearning
/logistics_regression.py
1,355
3.703125
4
import numpy as np import matplotlib.pyplot as plt from sklearn import datasets def get_data(): iris = datasets.load_iris() X = iris.data[:, :2] y = (iris.target != 0) * 1 plt.figure(figsize=(10, 6)) plt.scatter(X[y == 0][:, 0], X[y == 0][:, 1], color='b', label='0') plt.scatter(X[y == 1][:,...
c5b02f24477c2b240ef549776b5a30361e05f109
chadchiukc/machineLearning
/knn.py
3,465
3.546875
4
import pandas as pd import random import math import operator K = 20 PARAM_NUM = 4 PERCENTAGE_OF_TRAINING = 0.8 def get_accuracy(): epoch = 0 overall_accuracy = 0 while epoch < 10: ##Load the txt data file and append to a list iris_data = pd.read_csv("iris.data.txt", header...
8f711d9c3fd1c55bad77a4a1980c5d6a4bea22c6
tusharpl/python_tutorial
/max_value_function.py
502
4.125
4
# Get the list of values ..here it is student scores student_scores = input("Enter the list of student scores").split() # change str to integer so that calculations can be done for n in range(0, len(student_scores)): student_scores[n] = int(student_scores[n]) print(student_scores) # find max value through iterat...
b8bcdcbb683740c51ed3d907bc9d6daeb6feb328
PeterWolf-tw/ESOE-CS101-2015
/Team05_HW06.py
347
4
4
def bubblesort(mylist): for next_num in range(len(mylist)-1,0,-1): for i in range(next_num): if mylist[i] > mylist[i+1]: mylist[i], mylist[i+1] = mylist[i+1], mylist[i] if __name__ == "__main__": mylist = [37,81,92,17,99,34,26,13,20,27] bubblesor...
6f735110edffbb732a6c75cf5bffde421173a61a
PeterWolf-tw/ESOE-CS101-2015
/Team03_Answer.py
969
4
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- from itertools import chain class Friends: def __init__(self, connections): self.connections = list(connections) def names(self): return set(chain(*self.connections)) def connected(self, name): neighbors = [] [neighbors.exte...
65a498863830efd8f137fa007a313927be73858a
PeterWolf-tw/ESOE-CS101-2015
/b01611026_hw02.py
980
3.625
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- def bin2int(N): #本函式將bin轉換成int十進制 #Python 的縮排以「空四個空格」為主。請避免使用 TAB 做為縮排用。 tmpList=[N] leng=len(N) tmpList.reverse(N) ans=0 while leng>0 #while, for, if...等需要縮排的語法,要在後面加 : 冒號。 x=tempList.pop() ans=ans+x*2**leng leng=leng-1 print binum"的二進位表示為" prin...
365560c5b9c7e3262d6b88385a6e734fdd3e58e4
PeterWolf-tw/ESOE-CS101-2015
/B04505035_HW03.py
547
3.671875
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- def jeremy(x): bitchLIST = [] yeeSTR = x curry=len(x) floatcurry=float(curry) for i in yeeSTR: bitchLIST.append((i,float(yeeSTR.count(i))/floatcurry))#計算機率 fuckingset=set(bitchLIST)#用set把重複的刪掉 bitchLIST=list(fuckingset)#調回list才能用sorted來排列...
66804c20bbb58e3c509dca410e53c813fc651250
PeterWolf-tw/ESOE-CS101-2015
/B01611037_HW02.py
761
3.828125
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- #Python 程式的前兩行是固定的,請牢記。 def bin2int(N): a=1 ans=0 while (N > 0): remainder = N % 10 if (remainder>0): ans+=a a*=2 N = (N - remainder) / 10 return ans if __name__ == '__main__': binNumber = 1010 bin2in...
020275c77ea38af2992f5b36e0b21db6cea0e7b4
PeterWolf-tw/ESOE-CS101-2015
/B04505034_HW02.py
1,391
3.734375
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- #作業 1. # 請參考上例,自己寫一個將二進位表示數轉為十進位制的函式: # def bin2int(N): # ''' # 本函式將 bin 二進位制表示數轉為 int 整數 # ''' a = 1 decimal = 0 binary = int(input("Enter Binary Number:")) if(binary > 0): N = binary while(N > 0): remainder = (N...
a1294e460a833ea4f7571d5a385cb9903399b02a
PeterWolf-tw/ESOE-CS101-2015
/Team11_Answer.py
3,858
3.71875
4
#!/usr/bin/env python3 #-*- coding:utf-8 -*- import random def team11(): while True: people=["2","3","4","5"] level=[] A=["+1","+2","+3","return","pass"] B=["+1","+2","+3"] counter = 0 clockwide =True value = 0 while True: n=input("共有多少人參與...
1e31c2021fa15d167eafc833d3e9fc5bb069c457
PeterWolf-tw/ESOE-CS101-2015
/B02505050_HW02.py
906
4.03125
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- #Python 程式的前兩行是固定的,請牢記。 #1. def bin2int(N): m=1 ans=0 while (N > 0): remainder = N % 10 if (remainder>0): ans+=m m*=2 N = (N - remainder) / 10 return ans if __name__ == '__main__': binNumber = 1010 bin...
8db76115343eaba2b9bdeb8ef35599ce21e24194
PeterWolf-tw/ESOE-CS101-2015
/B04505012_HW03.py
420
3.765625
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- def charFreqLister(inputSTR): x = str(inputSTR) L = len(x) resultLIST = [] for i in inputSTR: R = round( x.count(i) / L,8 ) resultLIST.append((R,i)) a = list(set(resultLIST)) S = sorted(a) return S if __name__ ...
9387f9da545fcd3d3d94be2248c8b80516141f42
PeterWolf-tw/ESOE-CS101-2015
/B04505019_HW02.py
1,000
3.703125
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- def bin2int(N): x = 0 a = 0 b = -1 while N>= 1: r = N%10 x = r*(pow(2,a)) + x a += 1 N = N//10 return x #你在第 12 行就做了 return。一個 function() 一旦走到 return 這一步,以下的就不會做囉! #也就是說,你從 15 行開始到 20 行之間的程式都白寫了呢。 while 1>N>=0: ...
80a8f22f72137fec28d2996dbf37486cbe88b77c
PeterWolf-tw/ESOE-CS101-2015
/Team02_CodeWar.py
8,616
3.953125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Assignment_Team01 print ('PLEASE ENTER AN INTEGER') def Com_Div(n): for i in range(1,n): if (n%i==0): print(i) i+=1 return n if __name__ == '__main__': n=int(input()) print(Com_Div(n)) #!/usr/bin/env python # -...
f72b6cb68815d93f96f73d2be8aa4ab64ee6a04b
PeterWolf-tw/ESOE-CS101-2015
/b04505019_HW03.py
1,194
3.609375
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- def charFreqLister(inputSTR): a = str(inputSTR) b = len(a) resultLIST = [] for i in inputSTR: r = round(a.count(i)/b,8) resultLIST.append((r,i)) f = list(set(resultLIST)) c = sorted(f) return c d = input("pl...
7835b04dfa6e29653121b945396710aa4cf9b224
PeterWolf-tw/ESOE-CS101-2015
/B02505042_HW03.py
517
3.84375
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- def charfreqlister(str): len_str = len(str) result = [] for c in str: is_inside = False for element in result: if element[1] == c: element[0] += 1 is_inside = True break if...
b76d6bce21290e696234b06eb3d88f159c4ae6d2
PeterWolf-tw/ESOE-CS101-2015
/B02705046_HW02.py
817
3.796875
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- #Python 程式的前兩行是固定的,請牢記。 def bin2int(N): n = str(N) an = 0 p = 0 while p < len(n): if n[p] == '1': an += 2 ** (len(n) - 1 - p) p += 1 return an if __name__ == '__main__': #下次加個程式的進入點吧! binNumber = 1010 print(bi...
616e74ea3a67d49abf480c18a51d8384fda0da1d
PeterWolf-tw/ESOE-CS101-2015
/B04505037_HW03.py
440
3.953125
4
# !/usr/bin/env python3 # -*- coding:utf-8 -*- def charFreqLister(inputLIST): n = len(inputLIST) result = [] for i in inputLIST: j = float('%.3f'%(inputLIST.count(i)/n)) result.append((i,j)) resultLIST = list(set(result)) resultLIST.sort(key=lambda tup: tup[1], reverse=True)...
28fc2992109b2841196488039417a055c67050cc
PeterWolf-tw/ESOE-CS101-2015
/Team09_HW06.py
762
4.09375
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- #請參考 http://interactivepython.org/runestone/static/pythonds/SortSearch/sorting.html #中提供的 bubble sorting 演算法,將整數列表 [5, 16, 20, 3, 8, 12, 9, 17, 20, 7] 由大排到小。 def bubble(): x = [] x = input("give me some numbers:").split(",") x[:] = [int(a) for a in x] l = ...
8083b5c05108d3f7f3b17f759cf308dc5bd3cb64
PeterWolf-tw/ESOE-CS101-2015
/B04505019_HW04.py
3,068
3.703125
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- #condition00 not condition01 def condNOT(inputSTR_X): outputSTR = "" for i in inputSTR_X: if i == "0": outputSTR = outputSTR + "1" else: outputSTR = outputSTR + "0" return outputSTR inputSTR_X = input("number:") #這兩行 (13,...
310bbebdbcb93aa6fd431a23d132053a440668dc
raxbits/valid_paranthesis
/sol1.py
250
3.5625
4
def sol1(arr:str) -> bool: ''' handles single paranthesis character type. t -> o(n) s -> o(1) ''' cnt = 0 for i in arr: if i == ')': cnt -=1 elif i == '(': cnt+=1 elif cnt < 0: return False if cnt > 0: return False return True
2f544cde3f8fb464360c69b6c0a431805240f24d
QasimK/Project-Euler-Python
/src/problems/p_1_49/p24.py
1,397
4.09375
4
''' A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The lexicographic permutations of 0, 1 and 2 are: 012 021 102 120 201 210 Wh...
ff508760139b4197b86726ac82a698f82ae8caec
QasimK/Project-Euler-Python
/src/problems/p_1_49/p19.py
2,544
4.28125
4
''' You are given the following information, but you may prefer to do some research for yourself. * 1 Jan 1900 was a Monday. * Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on le...
b108c2c7de3669c11c6e765d6e213619aa3d91fe
QasimK/Project-Euler-Python
/src/problems/p_1_49/p23.py
2,656
4.125
4
''' A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number. A number n is called deficient if the sum of its proper divisors is less than n and it i...
ab207785337b6d7bf8bd9f76ff96d83558e1d22f
QasimK/Project-Euler-Python
/src/problems/p_1_49/p35.py
1,616
3.90625
4
""" The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime. There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97. How many circular primes are there below one million? """ """ If the number contains a "0" then o...
fa0ebfd7365c84b9bf24e42d27b5d5461d9c6dde
QasimK/Project-Euler-Python
/src/problems/p_1_49/p31.py
2,076
3.515625
4
""" Problem: In England the currency is made up of pound, £, and pence, p, and there are eight coins in general circulation: 1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p). It is possible to make £2 in the following way: 1x£1 + 1x50p + 2x20p + 1x5p + 1x2p + 3x1p How many different ways can £2 be made using any nu...
fc8c6b9b41109495941d98723c59d8943b2edbb0
MaxAls/LPTHW
/EX36/ex36.py
11,883
3.75
4
from sys import exit import wave global secret_door secret_door = False global found_sword found_sword = False global found_shield found_shield = False #Fanfare = wave.open(/Users/Maximilian/Repositories/LPTHW/EX36/Fanfare.wav/) def start(): print """ You are standing in front of an old mansion. In front ...
82be3dc2c665a3dba5f84c189d8620f864ce9ec0
MaxAls/LPTHW
/EX45/Game/Rooms.py
11,761
4.03125
4
from Characters import * class Rooms(object): def enter(self): pass class Outside(Rooms): def enter(self): print """ You are standing in front of an old mansion. In front of you is a large, heavy looking door. What do you wish to do? """ choice = raw_...
2d7577c282b371b891231c8bf64f0a9bdbaa6a08
idin/txt
/txt/align.py
184
3.578125
4
def align(text, width, side='left'): if side.lower()[0] == 'c': return text.center(width) elif side.lower()[0] == 'r': return text.rjust(width) else: return text.ljust(width)
dbbd8be2f50198be11b08ad05962c5ba057c2e74
lemon24/boomtime
/boomtime/db.py
2,541
3.75
4
import sqlite3 from contextlib import contextmanager @contextmanager def ddl_transaction(db): """Automatically commit/rollback transactions containing DDL statements. Usage: with ddl_transaction(db): db.execute(...) db.execute(...) Note: This does not work with executesc...
ed0baab15b160004bc09324389f4b13c2a927266
sap218/python
/csm0120/02/lect_02b_hw.py
663
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Oct 12 11:03:24 2017 @author: sap21 """ ''' An interactive game to exercise what you know about variables, if statements, loops and input/output. Game: Guess the secret number! ● Initialise a variable to hold a secret number of your choice. ● Prompt th...
1c45bfffbcb2c746d564f3c7e3e33fc146fa1014
sap218/python
/csm0120/01/prac_01.py
1,580
3.59375
4
# -*- coding: utf-8 -*- """ Created on Sat Oct 7 16:44:13 2017 @author: sap21 """ myDNA = "ATTATTATTGC" if myDNA.endswith("GC"): print("ends with GC", myDNA.count('T'), len(myDNA)) today = "Friday" if today != "Saturday" and today != "Sunday": print("not the weekend") else: print("weekend") length ...
9cb54e621850dff5a5e74a9d45e130d1ffddcde2
sap218/python
/csm0120/02/lecture_02b.py
3,036
3.875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Oct 12 10:08:23 2017 @author: sap21 """ ''' location = { "Aber": (52.4, -4.1), "Cardiff": (51.4, -3.1), "Edinburgh": (55.9, -3.2) } for town in location: # .keys() is default print(town) for (lat, lon) in location.va...
6055e591302801c0327ac6505593ea7dfa163c96
sap218/python
/001/script.py
2,558
3.671875
4
# -*- coding: utf-8 -*- """ Created on Wed Aug 9 17:10:04 2017 | @author: sap21 > Recreation of my script """ #USING EXAM SCORE FOR EXAMPLE num_array = list() num = input("enter number of exams:") print ('enter score in set: ') for i in range(int(num)): n = input("score :") num_array.append(float(n)) print (...
7f54846773ea9426e16e2f663334b9e4ef88bf17
sap218/python
/csm0120/08/owl.py
1,241
3.578125
4
class Owl: def __init__(self,common_name="owl",sound="hoot",location=None,ring_number=None,wing_span=None): self.common_name = common_name self.sound = sound self.location = location self.ring_number = ring_number self.wing_span = wing_span def get_info(self): i...
3e7daa67c4dd8cde1d704620b4c30f7008854d87
charishmakc/python-programs
/Lambdafunctions/using map function in lambda.py
384
3.953125
4
l1 = [1,2,3,4,5] l2 = [4,5,6,7,8] print(list(map((lambda x,y:x*y),l1,l2))) print("-----------------") l1 = [1,2,3,4,5] l2 = [4,5,6,7,8] l3 = [3,7,8,3] print(list(map((lambda x,y,z:x*y*z),l1,l2,l3))) print("------------------") l1 = [1,2,3,4,5] l2 = [4,5,6,7,8] l3 = [5,8,4,6] print(list(map((lambda x,...
f2f961f4e5f4ebc4a9a244faa96bf6ce55f8ddb5
charishmakc/python-programs
/Exceptionhandling/TryandExceptexampleprgrm.py
261
3.703125
4
no1=int(input("enter number1:")) no2=int(input("enter number2:")) print("sum =",no1+no2) print("sub =",no1-no2) try: print("div=",no1/no2) except ZeroDivisionError as zde: print(zde)#division by zero -arithmatic exception print("mul=",no1*no2)
f7115ec803f7fa5935712ad690bc385142dcbbeb
Phantsure/algo-rythm-urf-algorithm
/Searching/python/fibonacciSearch.py
1,185
4.15625
4
#List should be in Sorted ascending order from bisect import bisect_left def fibonacciSearch(arr, x, n): # Initialize fibonacci numbers m2 = 0 # (m-2)'th Fibonacci No. m1 = 1 # (m-1)'th Fibonacci No. m = m2 + m1 # m'th Fibonacci # m is going to store the smallest ...
255846a688264433ba0cf7791b6a8b42d2523523
andrei-z30/Classes
/Python/math_ball/ball.py
3,407
3.546875
4
import random class Ball(object): def __init__(self): self.radius = 20 self.position = self.StartPosition() self.velocity = self.StartVelocity() self.bcolor = color(33, 53, 237, 50) self.number = random.randrange(0, 21) self.dead = False self.start = Tru...
7d27d50cd0d55e817df609191eb5b825efdc2b26
FaSidd/DroneTeam
/pathing/path.py
1,580
4
4
""" Fahad Siddiqi --------------------------------------------------------------------------------------------- - A program to convert decimal GPS coordinates and back for generating a path for UH Drone Team - Output exports to generate a text file of a list of GPS coordinates -----------------------------------------...
7330b4a21e8651d542f1c5e8fc24fb171b4c6ffb
jinhaochan/bioinfo
/bioinfo1/week2/4ApproximatePatternCount.py
605
3.625
4
def ApproximatePatternCount(Text, Pattern, d): positions = [] # initializing list of positions for x in range(len(Text)-len(Pattern)+1): curPattern = Text[x:x+len(Pattern)] if HammingDistance(Pattern, curPattern) <= d: positions.append(x) # your code here return len(positions...
d79fb362845c0ee899eee44d9dae4b817d40e647
jinhaochan/bioinfo
/bioinfo2/week1/5DeBruijnGen.py
472
3.578125
4
import sys # put your python code here def DeBruijn(strings): presufDict = {} for string in strings: presufDict[Prefix(string)] = [] for string in strings: presufDict[Prefix(string)].append(Suffix(string)) return presufDict def Prefix(string): return string[:-1] def Suffix(strin...
f39e41fcb76fec75c7de104dbc65a13b83055c32
Chris8765/Python_programs
/shops_counter_covid.py
4,978
3.6875
4
# Gra: "jaka to liczb" # Podajesz, przedział oraz ilosc prob a komputer losuje i sprawdza # czy trafiłes, gdy trafisz komputer poda ile potrzebowałes szans, # lub przegrasz gdy wykorzystasz szanse i nie znajdziesz szukanej liczby.. from tkinter import * import random amount_of_people = 0 class Application_second...
e011852b2108f9183386ba15af87e0ada33b3b41
Chris8765/Python_programs
/play-voyager.py
6,209
3.984375
4
#Gra przygodowa wykorzystująca obiekty, gdzie gracz może podróżować, #pomiędzy różnymi wzajemnie połączonymi miejscami class Voyager(object): def __init__(self, name, response, location_name = "Dom"): self.name = name self.location_name = location_name self.response = response ...
de4f118f61f403ee787d3a90a1c03ef9705a02f5
Yeyin94/ProyectoOpenCv
/Proyecto OpenCv Modificado/ProyectoOpenCv.py
580
3.53125
4
import cv2 from Imagestorage.ImageStorage import ImageStorage import re class Converter: @staticmethod def img_to_gray_scale(img): """Recibe un objeto imagen y devuleve la imagen en blanco y negro""" gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) return gray_img if __name__ == '__main_...
16b42e19b98c16c350c9cc01537494b124921483
rahulnathha/Python-and-Machine-Learning
/numpy_arrays.py
824
3.8125
4
import numpy as np """ Single dimensional """ arr=np.array([4,6,7,8]) print(type(arr)) #<class 'numpy.ndarray'> print(arr.shape) #(4,) print(arr[2]) #7 """ Multi Dimensional array """ two_d=np.array(([1,4,9],[1,2,7])) print(two_d.shape) #(2, 3) """ Zero array """ zeros=np.zeros((2,3)) print(zeros) """ ones a...
d621e77c7c7b62b5d96851cc93c8fd5997f53cfd
samruddhitamboli/Linux-Figlet-command-in-Python3
/abcd.py
4,681
3.671875
4
x=input("Enter string").upper() s=list(x) for j in range(1,8): for t in s: print(' ',end='' ) if t=='A': if(j==1): print(' * ',end='') elif(j==2): print(' * * ',end='') elif(j==3): print(' * * ',end='') elif(j==4 or j==6 or j==7): print('* *',end='') elif(j==5): prin...
0d08cbed308259a362cb713b35c6c5b8dc20662e
vantage-org/vantage
/vantage/builtin/env.py
2,910
3.625
4
"""The __env builtin provides commands that help read and write your env files.""" from typing import List import sys import argparse from pathlib import Path from vantage import utils from vantage.exceptions import VantageException parser = argparse.ArgumentParser( prog="vantage __env", description="Manage e...
5f06717dbc7cdae0b28f34c571f3b04d78653674
nghiavoinit/Alien
/bullet.py
512
3.53125
4
import pygame from pygame.sprite import Sprite class Bullet(Sprite): def __init__(self,sett,screen,ship): super(Bullet,self).__init__() self.screen=screen self.rectb=pygame.Rect(0,0,sett.bullet_width,sett.bullet_height) self.rectb.centerx=ship.rect.centerx self.rectb.bottom=ship.rect.top #self.stop=...
69d87b62ae17e53c79cf494155c5388a3832b8be
DipeshBuffon/assignment-III
/bubblesort.py
256
3.90625
4
#Bubble sort def bsort(list): for i in range(len(list)): for j in range(len(list) - 1): if list[j] > list[j+1]: list[j], list[j+1] = list[j+1], list[j] list=[33,94,21,6,11,7,0,8] bsort(list) print(list)
75fd3b4672cc4aa3b824e6e5c3d01f5945ba2746
whitneygriffith/Introduction-to-Com-Sci-Labs
/convert_military_time.py
894
4.0625
4
hour1 = int(input('Enter the hour (ranging from 0 to 23): ')) min1 = int(input('Enter the minute (ranging from 0 to 59): ')) hour2 = int(hour1 - 12) if (hour1 > 0 and hour1 <= 11) and (min1 >= 10 and min1 <= 59): print(hour1, ':', min1, 'am') elif (hour1 > 0 and hour1 <= 11) and (min1 >= 0 and min1 <= 9): ...
574b0c56813e13f6c5dc184d2b780714f275d7d2
whitneygriffith/Introduction-to-Com-Sci-Labs
/airbnb.py
301
3.765625
4
def max_of_nights(): sum_nights= sum(reservations) for i in reservation: while nights <= sum_nights: nights = i + 2 return nights #variables used reservations = [5, 7, 10, 3] nights = 0 max_of_nights([5, 7, 10, 3]) reservations = [5, 7, 10, 3]
a0316657e1da4f14426f33353fe7e60d757a603e
whitneygriffith/Introduction-to-Com-Sci-Labs
/is_even.py
135
3.78125
4
def isEven(num): if num % 2 == 0: print('True') elif num % 2 != 0: print('False') isEven(5) isEven(8)
76c93fffce2fd2bafe74a7e4644d567285cbdad7
whitneygriffith/Introduction-to-Com-Sci-Labs
/count_vowels.py
311
3.84375
4
def CountVowels(string): count = 0 for i in string: if i == 'a' or i == 'e' or i == 'i' or i == 'o' or i == 'u' : count += 1 print(count) CountVowels('pizza') CountVowels('i like ike') CountVowels('today was a good day') CountVowels('grrrrrrrrrr') CountVowels('')
60326e3fc03ae571c6ec381c8028b27542042d82
whitneygriffith/Introduction-to-Com-Sci-Labs
/multiplication_table.py
550
4.03125
4
def PrintMultiplicationTable(num_1, num_2): #count for num_1 count_1 = 1 #count for num_2 count_2 = num_2 + 1 #while loop for table, iterating through count_1 while count_1 <= num_1: #for loop to iterate through num_2 for i in range(1, count_2): #...
7feeddf50d4da2f672a2e2ded98b87fdba2bd25b
mellosilvajp/projetos_unipampa
/teste github/exercicios_vetores_11.py
487
3.71875
4
lista_numeros = [] lista_pares = [] lista_impares = [] numero = 0 print('Digite 20 números') for i in range(20): lista_numeros.append(float(input('Digite um número: \n'))) numero = lista_numeros[i] if numero %2 == 0: lista_pares.append(numero) else: lista_impares.append(numero) print('=...
3978a26c7eae2acc34309229aba939942f55edf8
mellosilvajp/projetos_unipampa
/teste github/exercicios_vetores_14.py
1,728
4.15625
4
# https://www.passeidireto.com/arquivo/56813560/listas-em-python-exercicios-iniciais # # Os alunos de uma turma foram muito mal em uma prova. # O professor resolveu, então considerar a maior nota como o 10.0 e transformar as demais notas em relação # a esta nota da seguinte maneira: nota do aluno * 10/ maior nota. # F...
5023d632510441d3fbe3f945d1723680b75c88e8
mellosilvajp/projetos_unipampa
/teste github/arvore_recursiva_ap.py
1,080
3.90625
4
#https://panda.ime.usp.br/pythonds/static/pythonds_pt/04-Recursao/16-exercicios.html #Faça um programa recursivo para desenhar árvores usando Turtle #Modifique a espessura dos ramos para que, quando o tamanho_do_galho ficar menor, a linha fica mais fina. #Modifique a cor dos ramos para que, quando o tamanho_do_galho fi...
66545f46da8e13b3ab35d5e43bce00eee90365b8
mellosilvajp/projetos_unipampa
/teste github/encontra_menor_recursivo.py
1,296
3.75
4
#http://www.facom.ufu.br/~backes/gbt017/ListaPython07.pdf #Crie um programa que contenha uma função recursiva para encontrar o menor valor em um vetor import random #Método tradicional (não funcional) def encontra_menor_valor_tradicional(vetor, menor_valor, primeira_vez = True): if len(vetor) <= 1: retu...
1af01a5fa4e430b70905361ca2cb70bccbee6951
carmel21-meet/meetyl1
/class Parrot.py
528
3.703125
4
class Person: def __init__ (self,name,age,city,gender): self.name = name self.age = age self.city = city self.gender = gender def eat(self): print(self.name + " is eating his favorite food = trash") def sport(self): print(self.name + " is playing his sport = sleeping") person1 = Person("shoba doba", 72, ...
bac88e814d5dd6428b1ccd7b4d8b998f20bff59c
jackalsin/Python
/15112/TextBook/1D_List.py
587
3.796875
4
import string def collapseWhitespace(s): result='' if len(s)==1: if s in string.whitespace: return ' ' else: return s for i in range(len(s)-1): if s[i] not in string.whitespace: result+=s[i] if s[i] in string.whitespace and s[i+1] not in s...
bbaed04eb0096ff23828f24cb25c9ec1467cc37e
jackalsin/Python
/Python2/ValidBinarySearchTree.py
1,213
3.859375
4
class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None def toString(self): return "val = " + self.val + "\tleft = " + self.left + "\tright = " + self.right class Solution(object): def isValidBST(self, root): """ :t...
bbb34f21bb15657d10221e58e412bfc3b8910331
jackalsin/Python
/90812-Intro to Python/week2Lab2/Xin_LabWk2_zxin.py
454
4.09375
4
#!uer/bin/python3 # @author Zhiwei Xin, andrew ID zxin # Created on Sep 7, 2016 # Modified on Sep 7, 2016 # @version 0.0.0 # # This is a file to finish Lab on Week 2 def main(): while(True): inputVal = input("Please enter the flag\n").strip() if (inputVal == "1"): print ("Good Morning!"...
a8673165a736e059e75c3e3fb4df94d2c36243a5
jackalsin/Python
/15112/TextBook/2dList.py
1,834
3.6875
4
def wordSearch(board,word): (rows,cols)=(len(board),len(board[0])) result=None for row in range (rows): for col in range (cols): result=wordSearchInCell(board,word,row,col) if result!=None: return result return result def wordSearchInCell(board,word,start...
92db6d4dda410a818ea09f4b0d3be7a47eda3a0d
jackalsin/Python
/12746-XuesongPython/Assignment 3/tryPrivate.py
285
3.859375
4
class MyClass(object): def __init__(self): self.name = "myName" self._privateName = "my secret name" def __eq__(self, other): return self.name == other.name def __repr__(self): return self.name myObj = MyClass() print myObj._privateName
0d5b851281532d0c64cddcf77f0451ff11c654a5
jackalsin/Python
/15112/Homework/HW4V5_RunByLocal2.py
14,309
3.546875
4
# hw4.py # Zhiwei Xin + zxin + AA ################Q1 # count the first item of list a and remove this item for 'count' times import copy def lookAndSay(a): aa=copy.copy(a) result=[] while(len(aa)>0): count=aa.count(aa[0]) result.append((count,aa[0])) for j in range(count): ...
4f1a013815d70778bea4f4d446cabdd554f8d714
jackalsin/Python
/15112/Final Review/sorting.py
1,406
4.0625
4
def mergeSort(L): n = len(L) step = 1 start1 = 0 while (step < n): for start1 in range(0, n, 2*step): start2 = min(start1 + step, n) end = min(start1 + 2 * step, n) print(start1, start2, end) merge(L,start1,start2,end) step *= 2 return...
aed6e42687cef1d47a5938c0f318282c2775f916
jackalsin/Python
/15112/Quiz/H2P6_Truncatable prime.py
1,228
4.0625
4
import math def isPrime(n): if n<2: return False elif n==2: return True elif n%2==0: return False else: limit=round(math.sqrt(n))+1 for i in range (3,limit,2): if n%i==0: return False return True def digitsNum(n): n=abs(n) i...
f4213c107d9c3af2ef513956e280def0f9441504
jackalsin/Python
/15112/Quiz/Q1_7_triangleArea.py
649
3.5
4
def distance(x1, y1, x2, y2): return ((x2-x1)**2 + (y2-y1)**2)**0.5 def triangleArea(x1, y1, x2, y2, x3, y3): a=distance(x1, y1, x2, y2) b=distance(x1, y1, x3, y3) c=distance(x3, y3, x2, y2) s=0.5*(a+b+c) return (s*(s-a)*(s-b)*(s-c))**0.5 def almostEqual(d1, d2): epsilon = 0.00001 ...
d3c7376325b647035ed85d2434100de156683539
jackalsin/Python
/15112/Homework/hw9_Turtle.py
3,567
4.25
4
import turtle from tkinter import * #################################### # customize these functions #################################### def init(data): data.n = 0 def mousePressed(event, data): # use event.x and event.y pass def keyPressed(event, data): print(event.keysym) if (event.keysym ...
fa34eb07bfad7ab8d670213711fddf9bc8ba5692
jackalsin/Python
/12746-XuesongPython/Assignment 4/BookClass.py
225
3.5625
4
class Book(object): def __init__(self, number, title, author, price, pages): self.number = number self.title = title self.author = author self.price = price self.pages = pages
a21ab27aab04ad7c3f03239fed77151c1d7c7f3a
jackalsin/Python
/15112/Quiz/Q1P_3_circlesIntersect.py
511
3.71875
4
#circlesIntersect def distance(x1,y1,x2,y2): return ((x1-x2)**2+(y1-y2)**2)**0.5 def circlesIntersect(x1, y1, r1, x2, y2, r2): return distance(x1,y1,x2,y2)<=(r1+r2) def testCirclesIntersect(): print("Testing circlesIntersect()...", end="") assert(circlesIntersect(0, 0, 2, 3, 0, 2) == True) assert(c...
758f6e6f094983c75e47478821c95bdfedd31802
jackalsin/Python
/15112/Quiz/Q5PP.py
785
3.828125
4
def lockerRoom(lockers): lockers=[False] *(lockers+1) students=lockers openLockers=[] for student in range(1,students): for locker in range(1,lockers,student): lockers[lockers]=not lockers[locker] for locker in range(1,lockers): if lockers[locker] == True: op...
f25686a1bf1de1c370c8e863d5a283226c76d322
shivamdattapurkayastha99/tcs-nqt-codes
/tcsnqt.py
875
3.6875
4
import math def getFare(source,destination): route=[ [ "TH", "GA", "IC", "HA", "TE", "LU", "NI", "CA"], [800,600,750,900,1400,1200,1100,1500] ] fare = 0.0 if not (source in route[0] and destination in route[0]): print("Invalid Input") exit() if route[0].index(source) < route[...
62fdd947f52074e87540c6d931329454b3203236
akash22gupta/Data_Structures_HackerRank
/Stacks/balanced_brackets/balanced_brackets.py
888
3.6875
4
#!/bin/python3 import math import os import random import re import sys # Complete the isBalanced function below. def isBalanced(s): stack = [] for _ in s: stack.append(_) i = -1 while(stack): if abs(i)>=len(stack): break t = stack[i] if (t == '}' and stack[...
bb39ac2a16c6e81fbc41d8f3f72dc91d8d8273da
andrewvern/hierarchical-clustering
/binary_tree.py
3,097
3.75
4
class BinaryTree: def __init__(self, root_data=None, left_child=None, right_child=None): self.root_data = root_data self.left_child = left_child self.right_child = right_child def get_right_child(self): return self.right_child def get_left_child(self)...
f51b9168b729d6f527ddb10eabfc315d2c8d8baf
Shakeel-O/122COM
/122COM_sql-master/lec_dynamic.py
255
3.796875
4
import sqlite3 as sql con = sql.connect('firefly.sqlite') cur = con.cursor() question = input('Who is the...') cur.execute('''SELECT forename, surname FROM staff WHERE job = ?;''', (question,)) for row in cur: print('%s %s' % row)
65d76c1473f6de2f01c3d62e5195033f5219f493
SandyHuang0305/test
/bmi-test.py
620
3.984375
4
hight=input('請輸入您的身高:') weight=input('請輸入您的體重:') hight=int(hight) weight=int(weight) hight=hight/100 bmi=weight/hight/hight if bmi < 18.5: print('您的bmi值為:', bmi, '屬於過輕') elif bmi >= 18.5 and bmi < 24: print('您的bmi值為:', bmi, '屬於正常') elif bmi>=24 and bmi < 27: print('您的bmi值為:', bmi, '屬於過重') elif bmi>=27 and ...
306acc3d4318cbcbf8b35bc3c4bcd0a650b67547
misomarcell/codecool
/fib.py
440
3.609375
4
num = input("Number count: "); i = 0 prn = 0 spc = 0 lis = [0,1] print("Calculating " + str(num) + " Fibonacci numbers:") if num < 101: while i < num: last = lis[len(lis) - 1] blast = lis[len(lis) - 2] prn = int(last) + int(blast) lis.append(prn) spc = len(str(prn)) + len(...
cae4d9a36f9b8031bb7d1db5b32feab485b6679d
MeGaLoDoN227/python_programs
/Calculator.py
336
3.90625
4
a = input('enter the first number:') b = input('enter the second number:') c = input('enter action:') r = int(a) t = int(b) if c == '+': print(r + t) elif c == '-': print(r - t) if c == '*': print(r * t) if c == '/': print(r / t) y = input('Your result above') ...
eb4a17197f807f4042257fe42819bb1cd112f44a
tomosukhumvit/DK-Cording-Corse
/team_allocator2.py
943
4.0625
4
import random players = ["Martin","Craig","Sue", "Claire","Dave","Alice", "Sonakshi","Harry","Jack", "Rose","Lexi","Maria", "Thomas","James","William", "Ada","Grace","Jean", "Marissa","Alan"] print("Welcome to Team Allocator!") while True: random.s...