blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
260b16156f06b8596c55dedf94d28c65c2d4a23a
alhasib/UVA-online-judge
/ailabfinalass.py
12,965
3.984375
4
import copy matrix_no = 0 main_q = [] print("Enter The Goal Matrix: ") goal_matrics = [] for row in range(3): coloumn =[] for col in range(3): coloumn.append(int(input())) goal_matrics.append(coloumn) print("this is goal {}" .format(goal_matrics)) print("Enter the initial state"...
a7c52abe10e8dce9b752c96bc007cd2a276960a0
cool-RR/python_toolbox
/python_toolbox/combi/perming/comb_space.py
2,356
3.78125
4
# Copyright 2009-2017 Ram Rachum. # This program is distributed under the MIT license. from .perm_space import PermSpace class CombSpace(PermSpace): ''' A space of combinations. This is a subclass of `PermSpace`; see its documentation for more details. Each item in a `CombSpace` is a `Comb`, i.e. a ...
88bad80eba5edaf3cf8aae38852a45a9a58ab689
soheil2017/Machine-Learning
/Linear Regression/03 - Polynomial Regression/Regression Polyminal_two input.py
1,296
4.0625
4
#https://realpython.com/linear-regression-in-python/#beyond-linear-regression #Polynomial Regression With scikit-learn (two column input) #𝑓(𝑥₁, 𝑥₂) = 𝑏₀ + 𝑏₁𝑥₁ + 𝑏₂𝑥₂ + 𝑏₃𝑥₁² + 𝑏₄𝑥₁𝑥₂ + 𝑏₅𝑥₂². polynominal for two inputs import numpy as np import matplotlib.pyplot as plt from sklearn.linear_model ...
26ed6e35ac94c7a51fad8ab4226b135121c1d759
ABenxj/leetcode
/101 isSymmetric.py
964
4.09375
4
#!/usr/bin/env pyhton # -*- coding: utf-8 -*- # # Copyright (c) 2021 , Inc. All Rights Reserved # """ Authors: jufei Date: 2021/5/9 9:36 上午 """ # Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: ...
17f995a4510074854810642f84bae7cb140deee3
jameswmccarty/CryptoToyUtils
/check_lang.py
1,659
3.859375
4
#!/usr/bin/python """ This code will 'score' input against an English ASCII characters frequency distrubution. If run with multiple inputs, the lowest score represents the closest match to English text. """ """ Letter frequencies for the English language values from https://en.wikipedia.org/wiki/Letter_frequency ...
50ca2dfeb622eadb0ba547988d353af0e3996e3f
standrewscollege2018/2020-year-11-python-code-kanyesouthwest
/Gigabyte Program.py
186
3.59375
4
MEGABYTES = 1024 gig = int(input("Enter number of gigabytes:")) gig_megabytes = MEGABYTES*gig amount_of_gigabytes = gig_megabytes print("Total amount of megabytes:", amount_of_gigabytes)
a3323b6c78d5e9866182f702a7c03d937573bbfe
oaftab77/Python-Files-MIT-OCW
/cube_root_bisection_search.py
829
4.15625
4
# -*- coding: utf-8 -*- """ Created on Thu Jul 26 13:39:17 2018 @author: aftab """ ## EXAMPLE: bisection cube root (only positive cubes!) #################### userinput = float(input("Input the number: ")) epsilon = 0.00001 low = 0.0 high = max(1,abs(userinput)) # ================================================...
74f1530bc5efb040cba7f528578bbcc55f82c79f
YuriMukin/MAI-labs
/sem4/CompMath/laba5/Max_Eigenvalue.py
582
3.609375
4
import numpy as np def Max_Eigenvalue(matrix): y0 = np.array([[1],[1],[1]], dtype = float) y1 = np.dot(matrix, y0) y2 = np.dot(np.linalg.matrix_power(matrix, 2), y0) res = 0 count = 2 while abs(res - (1/3)*sum(y2/y1))>=0.001: res = (1/3)*sum(y2/y1) y1 = y2 count+=1 ...
9ab01ac9581af5a14b2c1d551e5607efb8b54d38
YasirHabib/modern_deep_learning_in_python
/Section3/theano_6.py
2,525
3.53125
4
# Section 7, Lecture 25 # A 1-hidden-layer neural network in Theano. # This code is not optimized for speed. # It's just to get something working, using the principles we know. import numpy as np import theano import theano.tensor as T import matplotlib.pyplot as plt from sklearn.utils import shuffle from utility im...
4afaccb469da8cea001ccaf9a6d861b6a327c07d
AlphaBitClub/alphabit-coding-challenge
/alphabit-coding-challenge-02/07_owl_race/solutions/owl_race.py
359
3.65625
4
def owl_race(x1, v1, x2, v2): if (v1 == v2): return "YES" if(x1 == x2) else "NO" else: t = int(abs((x2-x1)/(v1-v2))) eq1 = x1 + v1 * t eq2 = x2 + v2 * t if (eq1 == eq2): return "YES" else: return "NO" x1, v1, x2, v2 = map(int, input().spl...
96aa20215c4c70e99cfd1dc8113c06f69f46fd2b
KameronKales/GetSocialNetwork
/utils.py
6,911
3.5
4
import datetime, math, json, re class WorkTime(object): def __init__(self, iyear, imonth): if not isinstance(iyear, int): raise TypeError('{} is not an integer'.format(iyear) ) if not isinstance(imonth, int): raise TypeError('{} is not an integer'.format(imonth) ) i...
6c19dbf9bb77ebe93514bfb3dc0a5e45a177a8d9
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/leetcode/leetCode/String/StringToInteger.py
3,508
4.1875
4
""" Implement atoi which converts a string to an integer. The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and inte...
5f4324864eeeca6d88089d0959ed0f4a4f524c68
PABannier/nanograd
/build/lib/nanograd/nn/conv_ops.py
3,837
3.703125
4
import numpy as np def get_conv1d_output_size(input_length:int, kernel_size:int, stride:int, padding:int) -> int: """Computes the output size of a 1d convolution. Args: input_length (int): Length of the sequence ...
d10d0d376de92f4d6a0d83ea046a7d42e196d898
DanielJHaar/Python_Practice_Jun2020
/re_detect_floating_point.py
244
3.703125
4
# -*- coding: utf-8 -*- """ Created on Sun Jul 5 09:17:35 2020 @author: danie """ from re import match, compile pattern = compile('^[+-]?[0-9]*\.[0-9]+$') for _ in range(int(input())): print(bool(pattern.match(input())))
194e827bccf08a8452240c43218c4babf19a7034
liu-zongxi/-source_code_2020_embedded_loogson_badmintons_sweeper
/opencv_canny_badminton/make picture.py
824
3.609375
4
#1.plt.subplot(ijn)形式,其中ij是行列数,n是第几个图,比如(221)则是一个有四个图,该图位于第一个 # import numpy as np # import matplotlib.pyplot as plt # x = np.arange(0, 100) # #作图1 # plt.subplot(221) # plt.plot(x, x) # #作图2 # plt.subplot(222) # plt.plot(x, -x) # #作图3 # plt.subplot(223) # plt.plot(x, x ** 2) # plt.grid(color='r', linestyle='--', line...
0cd72197982fd7cfe0c9fe340e6ef2124134786d
lixiang2017/leetcode
/leetcode-cn/0031.0_Next_Permutation.py
1,005
3.6875
4
''' 执行用时:52 ms, 在所有 Python3 提交中击败了10.69% 的用户 内存消耗:14.9 MB, 在所有 Python3 提交中击败了83.68% 的用户 通过测试用例:265 / 265 ''' class Solution: def nextPermutation(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ ''' 21 4 18 23 36 23 1 3 3 7 7 ...
5e9d91984263d0d88591b68f6df8053d4232f099
kiralpoon/machinelearning
/lessons/lessons_decisionTree/studentMain.py
1,465
3.890625
4
#!/usr/bin/python """ lecture and example code for decision tree unit """ import sys from class_vis import prettyPicture, output_image from prep_terrain_data import makeTerrainData import matplotlib.pyplot as plt import numpy as np import pylab as pl from classifyDT import classify def RepresentsInt(s): try: ...
a90cb2d461993a45ab2bd9a98f809ad3f09fa102
dolphin-in-a-coma/python-course
/2-9_Rest_subjects/5_Functions/5.2.19.py
475
3.8125
4
import random def amountdigits(num): '''return amount of digits argumet: *num(int): natural number result: int ''' if num>10: num//=10 return amountdigits(num)+ 1 else: return 1 def sumdigits(num): '''return sum of digits argumet: *num(int): natural number result: int ''' if...
a2abd60f06a5fbff439ec35460cb228f0d2ca4a8
SHANMUGAM161790/Digital-
/append.py
416
4.09375
4
a=input("enter the first array:") b=input("enter the second array:") c=input("enter the third array:") for i in range(len(b)): #loop for appending the elements of first to second array a.append(b[i]) print("combined array of a and b:",a) for j in range(len(c)): #loop for appending the third array elements which a...
75cffd535822b3f7b7f11d0f4c02ae24b456d54f
karthiksuresh181/ML_Ctron
/Python_Assignment_1/5.py
357
3.765625
4
s = 'abcd' t = (10, 20, 30) u = (-1,-2,-3) al = [1,2,3] def shortest_sequence_range(*args): return range(len(sorted(args, key=len)[0])) g = ((s[i], t[i], u[i], al[i]) for i in shortest_sequence_range(s,t,u,al) ) print("Inbuilt Zip(): ",list(zip(s,t,u,al))) print("\nUser Defined Zip():") ...
1d5382b0936b0bd8745780896f7a59a31b2e9894
xKuZz/mastercienciadatosugr
/PROG_DAT/Python/Relación 2/ej2-7.py
871
3.984375
4
# -*- coding: utf-8 -*- """ 7. Escribe una función, contar_letras(palabra), que tome una palabra como argumento y devuelva una lista de pares en la que aparece cada letra junto con el número de veces que aparece esa letra en la palabra. Por ejemplo, contar_letras('patata'), devuelve [('a',3), ('p', 1), ('t', 2)]. ...
e614c8336738a97d349f1a95aafe8168643646b4
marcos-mpc/CursoEmVideo-Mundo-1
/ex010.py
214
3.8125
4
print(18*'=') print('CONVERSÃO DE MOEDA') print(18*'=') n = float(input('digite quanto de dinheiro vc tem em sua carteira: R$')) print('vc pode comprar US${:.2f} com os R$ {:.2f} que vc tem!'.format((n/3.27), n))
28b3f16569b312ff91a2bcf47c2813e5aade433a
JoshuaRomanV/W3school-Python
/Python Strings/Ejercicio 29.py
226
3.78125
4
# Inserte la sintaxis correcta para agregar un marcador de posición para el parámetro de edad. age = 36 txt = "My name is John, and I am {}" print(txt.format(age)) # con {} se le puede insertar valores numericos en cadena.
057c9e9f6ba7ec31d9f71ed315a6886d105432e1
CaiZhongheng1987/algorithm_questions_and_codes
/leetcode023/test_Merge_k_Sorted_Lists.py
1,994
3.75
4
# 合并 k 个排序链表,返回合并后的排序链表。请分析和描述算法的复杂度。 # # 示例: # # 输入: # [ # 1->4->5, # 1->3->4, # 2->6 # ] # 输出: 1->1->2->3->4->4->5->6 class Solution(object): def mergeKLists(self, lists): """ :type lists: List[ListNode] :rtype: ListNode """ if not lists: return [] ...
2eeb058470e16eb1460f16016c489bd494e90778
jjermanis/pc-py
/challenge05.py
589
3.6875
4
#!/usr/bin/env python3 import urllib.request import pickle def main(): # This resource is identified in the page source url = "http://www.pythonchallenge.com/pc/def/banner.p" data = pickle.loads(urllib.request.urlopen(url).read()) for row in data: line = "" for char, count in row: ...
d488f28ed8c95640b1f1470e822280e1dbb5a3e3
Dr-jnm23/Lessons
/Lesson,9.2,Travis.py
818
4.0625
4
# create list of users known_users = ['John', 'Paul', 'George', 'Ringo'] while True: print('Hi my name is Travis') name = input('what is your name? ').strip().capitalize() if name in known_users: print('Hello ' + (name)) remove = input('Would you like to be removed from system? ...
5c02129c45d567b119c47544b42cc35d55521ca0
frankylin1111/1081ML
/python/webbrowser/mapIt.py
457
3.5
4
# 2019/1/28 #! python 3 # matIt.py - Launches a map in the browser using a address from the # command line or clipboard ## 目標: 從google Map 搜尋地址 ## 最後修訂日期:2019/2/1 import webbrowser,sys ,pyperclip if len(sys.argv)>1: #Get address from the command line address = ' '.join(sys.argv[1:]) else: #Get address f...
319fa3a005edc66b2783271fcd67b176d7562dfe
fbreversg/checkio
/Elementary/popular_words.py
743
3.984375
4
def popular_words(text: str, words: list) -> dict: result = {} split_lower_text = text.lower().split() for word in words: result[word] = split_lower_text.count(word) return result if __name__ == '__main__': print("Example:") print(popular_words(''' When I was One I had just begun Wh...
c245a6d41e25187f094e1b49d2907ac6166f4ed1
johnny-581/CCC
/2019/Junior/J5-2.py
1,338
3.578125
4
rules = [] for i in range(3): rules.append(raw_input().split()) seperated_values = raw_input().split() S = int(seperated_values[0]) I = seperated_values[1] F = seperated_values[2] def get_rules(s): possible_rules = [] for i in range(len(s)): for j in range(len(rules)): if s.startswith(...
2bb867a887cce88c4e0c36d4000677ebec4e5f71
udelinure/py_study
/common/count.py
123
3.671875
4
def count(sequence, item): number = 0 for letter in sequence: if letter == item: number += 1 return number
fd4856b73e3693db94acdc105044b249c3dc037f
onuryarartr/trypython
/fonksiyon_problem1.py
1,492
4.09375
4
"""1'den 1000'e kadar olan sayılardan mükemmel sayı olanları ekrana yazdırın. Bunun için bir sayının mükemmel olup olmadığını dönen bir tane fonksiyon yazın. Bir sayının bölenlerinin toplamı kendine eşitse bu sayı mükemmel bir sayıdır. Örnek olarak 6 mükemmel bir sayıdır (1 + 2 + 3 = 6).""" print("""*************...
24c21296a4f3c99eb006c40e641a920667d5e771
PrathameshDhumal/Python-programming
/Arithematic/Arithematic5.py
229
3.84375
4
#sum of 2 nos with better input method #user defined addition no1 = int(input("Enter First number")) #scanf("%d,&no1); no2 = int(input("Enter second number")) ans = no1 + no2 print("Addition is : ",ans)
7a50562e33ca32fa963a7e5ad173acf40f4b3af7
green-fox-academy/admrid
/week-03/day-2/d2_e9_reversed_order.py
403
3.9375
4
# Create a method that decrypts reversed-lines.txt def decrypt(file_name): textfile = open(file_name) textdec = open('file9dec.txt', 'w') textorig = textfile.readlines() # textorig.append('\n') text = '' for i in reversed(range(len(textorig))): text += textorig[i] textdec.write(text...
e3a516602c4d4b171715e919049d5cbf99eba315
Mniharbanu/guvi
/codekata/project.py
97
4.03125
4
a1,a2,a3=input().split() a1=int(a1) a3=int(a3) if(a2=='/'): print(a1//a3) else: print(a1%a3)
1b5e571174713169c1909b99f0918a958c79ee36
zesameri/Beginner-Python-Projects
/Basic Concepts/grades.py
384
4.1875
4
''' Created on Oct 9, 2011 @author: Meredith ''' grade = int(input('Test Score: ')) if grade >= 90: print('HAPPY DANCE!!!, Your Grade is an A!!') elif grade >= 80: print('Almost there, Your Grade is a B') elif grade >= 70: print('You can do better, Your Grade is a C') elif grade >= 60: print(':O, Your ...
e1b53eec01401fcca2ffeceec5f0bfea32988547
gokhantamkoc/learning-python
/src/basics/nativedatatypes/number_types.py
1,333
4.125
4
# Python supports integers, floating point numbers and complex numbers. # They are defined as int, float and complex class in Python. # Integers and floating points are separated by the presence or absence of a decimal point. # 5 is integer whereas 5.0 is a floating point number. # Complex numbers are written in the ...
dffc9614b035d5ff6205f1958a74687f350e2f9b
OctavioMaia/PLC_SPLN
/spln2018/aulas/a8/chatbot.py
629
3.6875
4
#!/usr/bin/python3 import re import random def resp(inp): for (patt,resps) in regras: r = re.findall(patt,inp) if r : res = random.choice(resps) if callable(res) : return res(r[0]) else: return res return "Não entendi" inp = ...
a9fd1283eab4e5e085ebf633ce254b10e61189b5
thiagosousadasilva/Curso-em-Video
/CURSO DE PYTHON 3/Mundo 3 - Estruturas Compostas/2 - Listas em Python/Parte 02/Exerc088 - Palpites para a Mega Sena.py
809
4.09375
4
''' Exercício Python #088 - Palpites para a Mega Sena: Faça um programa que ajude um jogador da MEGA SENA a criar palpites. O programa vai perguntar quantos jogos serão gerados e vai sortear 6 números entre 1 e 60 para cada jogo, cadastrando tudo em uma lista composta. ''' print("== Exercício Python #088 - Palpites p...
f872ed13c04fc4b9970312a461c329abbf471aaa
MrNullPointer/AlgoandDS
/Udacity_NanoDegree/Linked_Lists_2ndAttempt/duplicate_number.py
332
3.796875
4
def duplicate_number(arr): if arr is None: return current_sum = 0 actual_sum = 0 for val in arr: current_sum = current_sum + val for num in range(0,len(arr)-1): actual_sum = num + actual_sum return current_sum - actual_sum arr = duplicate_number([0,1,2,3,8,4,5,6,7,3,9])...
c699dc7baa011d702df6a12b4d745bf5c691157f
m4l1c1ou5/reverse_Shell
/server.py
3,521
3.71875
4
import socket import sys from queue import Queue import threading # create socket def socket_create(): try: global host global port global s host='' port=9999 s=socket.socket() except socket.error as err: print ("Socket Creation error: "+ str(err)) # bin...
cc6225301ad6ed3464018070432acb0d0dfffe60
rmanak/python_misc
/problem_solving_python/hash_table.py
1,799
3.9375
4
class HashTable: """ Very simple implementation of Hash Table using python lists """ def __init__(self): self.size = 11 self.slots = [None]*self.size self.data = [None]*self.size def hashfunction(self, key): return key % len(self.slots) def rehash(self, hashvalu...
9e2adce57478f69136a77a5efefe8f05521b426c
kyeongwoong/Scipy
/plotEx2.py
948
3.59375
4
# Matplotlib의 triangular grid 사용 # 삼각 그리트 지원을 해주는 패키지 임포트 # import matplotlib.tri as mtri # 삼각 그리드 생성 # 삼각 그리드는 Triangulation 클래스를 이용하여 생성한다. # Triangulation(x, y, triangles) # triangles는 생략했을 경우 자동으로 생성된다. import numpy as np import matplotlib.tri as mtri import matplotlib.pylab as plt x = np.array([0...
9effd3c95186231a85df42f5e5830ec8b572c069
Bklyn/adventofcode
/2018/7.py
7,557
4.125
4
#!/usr/bin/env python3 '''--- Day 7: The Sum of Its Parts --- You find yourself standing on a snow-covered coastline; apparently, you landed a little off course. The region is too hilly to see the North Pole from here, but you do spot some Elves that seem to be trying to unpack something that washed ashore. It's quite...
446f6dc6c22b274d40f72e53551da46d7fca4e8e
yeshwindbz9/natural-language-processing_crash_codes
/tokenization.py
1,145
3.875
4
""" Tokenization is the process of breaking up the original text into component pieces called tokens. eg: 'We're moving to L.A.!'->[We, 're, moving, to, L.A., !] They are the basic building blocks of doc elements in tokens: prefix, infix, suffix & exception example of tokens: $, -, km, U.S. ""...
b4b2dcbcbb9e5b53cc5057221410556b77b8819b
unfit-raven/yolo-octo
/CST100 Object Oriented Software Development/Week Four/randomturtle.py
811
3.8125
4
## Random turtles import turtle import random wn = turtle.Screen() t = turtle.Turtle() t.shape("turtle") def isInScreen(w, t): leftBound = -(wn.window_width()/2) rightBound = wn.window_width()/2 topBound = wn.window_height()/2 bottomBound = -(wn.window_height()/2) turtleX = t.xcor() turtleY ...
a92bd291ec677a6cc394a5e2d104778c914be629
jjeeey/practicum_1
/33.py
1,101
4.25
4
""" Имя проекта: practicum_1 Номер версии: 1.0 Имя файла: 33.py Автор: 2020 © Ю.А. Мазкова, Челябинск Лицензия использования: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/deed.ru) Дата создания: 10/12/2020 Дата последней модификации: 10/12/2020 Связанные файлы/пакеты: numpy, random Описание: Решение за...
044635390f137b2937d415795ddb8e4201176e6a
scottzig/interpolation_and_ode_solvers
/na2_hw4_p2d.py
977
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Numerical Analysis II Homework 4 Problem 2d This code approximates the derivative of f(x)=e^x at x_0=0 using a three-point and five-point finite difference operator. """ import numpy as np import matplotlib.pyplot as plt def f(x): return np.exp(x) # three point ...
13608a555757ba21065a915e185eb1dcb3fab807
stem-club-of-america/GECO
/meeting_20190727/ChatTrail.py
13,905
3.96875
4
import time #Welcome user to the game print() print ("* * * Hello! Welcome to Adventure on the Chattooga Trail * * *") print() #add slight delay for gameplay flow time.sleep(1) print ("You will be going on a hike in the woods and have some challenges to overcome!") print() #add slight delay for gameplay flow...
e1b659bb00658cc90fdbde9c3dce4bcef958d694
fatimaig/Python
/ejemplo3_Las Listas.py
1,278
4.4375
4
#LAS LISTAS #En python pueden guardar diferente tipo de valores # Se pueden expandir dinamicamente. milista=["Juan","Maria","Pepe","Marta"] #imprimir toda la lista print( milista[:]) #acceder a un elemento print(milista[2]) #INDICE NEGATIVO, empieza por atras empiezando pos 1... print (milista[-2]) ...
13134e982856cfd4b75334eda83803095bf66252
jerryfeng007/pythonCodes
/python100/006.py
101
3.578125
4
# 递归 i = 5 def gui(i): if i == 1: return 1 return i * gui(i-1) print(gui(i))
cf867b20eb0b94eac326b2f6a5e7f6ca19f3eb99
maxzxc0110/Algorithm
/深度优先搜索/LeetCode_733.py
2,370
3.546875
4
#!/usr/bin/python # -*- coding: UTF-8 -*- # 733. 图像渲染 难度:简单 # 有一幅以二维整数数组表示的图画,每一个整数表示该图画的像素值大小,数值在 0 到 65535 之间。 # 给你一个坐标 (sr, sc) 表示图像渲染开始的像素值(行 ,列)和一个新的颜色值 newColor,让你重新上色这幅图像。 # 为了完成上色工作,从初始坐标开始,记录初始坐标的上下左右四个方向上像素值与初始坐标相同的相连像素点,接着再记录这四个方向上符合条件的像素点与他们对应四个方向上像素值与初始坐标相同的相连像素点,……,重复该过程。将所有有记录的像素点的颜色值改为新的颜色值。 # 最后返回...
790d43a3397211691a503f2efbbf299c3a562f53
Veselin-Stoilov/softuni_projects-python-fundamentals
/Lists_basics_exercise/survival_of_biggest.py
256
3.625
4
nums_str = input() nums_to_remove = int(input()) nums_list = nums_str.split() for i in range(len(nums_list)): nums_list[i] = int(nums_list[i]) for _ in range(nums_to_remove): min_num = min(nums_list) nums_list.remove(min_num) print(nums_list)
ffc4693fd03914b240dec4616d959a58352ca788
Xana8U/Small-Projects-n-Tests
/stack, helps/marko.py
2,084
3.90625
4
# //tehtävä 7 size = int(input("Box size (3-10)")) if size > 10 or size < 3: raise Exception("Select between 3 and 10") for a in range(0, size): print("* " * size) # //tehtävä 8 # älä välitä mistään .format() setistä, ei alkuperäisessä tehtävän annossa. # Tee pankki datalle mihin säilöt päivien tiedot tässä t...
0b40b8f14e926adb756181719d33ebe7aa58d51e
Halleloya/COMS4701-AI
/hw2/randy_ai.py
2,597
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -* """ COMS W4701 Artificial Intelligence - Programming Homework 2 Randy is an "AI" for Othello that randomly chooses a legal move. Play against this AI to get familiar with the game. You can also have your AI compete against your AI to test its performance. @author: Daniel...
6bf5a1ef6f8e823a6a8d9f0574cbca05724d9cff
Aimery1990/gitRepository
/py_learning/noob_master/sets.py
945
3.59375
4
s0 = {"aa", "bb", "cc", "cc"} print(s0) s0 = {(1,1,2,2,3,3)} print(s0) # {(1, 1, 2, 2, 3, 3)} # s0 = {[2,2,2,4,4,6,6,7]} # TypeError: unhashable type: 'list' print(s0) s0 = set((1,1,2,2,3,3)) # {1, 2, 3} print(s0) s0 = set([2,2,2,4,4,6,6,7]) # {2, 4, 6, 7} print(s0) s0.add("aaa") print(s0) s0.remove("aaa") p...
9f59387236b3e7cae18adba3b8d2a7169b3e3733
jingxiufenghua/algorithm_homework
/jianzhi_offer/61.py
873
3.546875
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- ''' @Project :algorithm_homework @File :61.py @IDE :PyCharm @Author :无名 @Date :2021/5/1 15:08 ''' from typing import List class Solution: def isStraight(self, nums: List[int]) -> bool: repeat = set() ma,mi = 0,14 for num in nums: ...
df5c9c8f22b21a24ea78a86f7ca81c0cf2ad5d2d
cscoder99/CS.Martin
/Gambling_project.py
2,067
3.78125
4
import random A = 10 K = 10 Q = 10 J = 10 cards = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'A', 'K', 'Q', 'J'] def comp_choice(x): if x < 21: print 'You Lose' elif x == 21: print 'You Win' else: print 'Nice' return comp_choice(x) start = random.choice(cards) start2...
73e533476efe4f1ba5c7ed45875dc92ab22280ce
shrutisaxena0617/Data_Structures_and_Algorithms
/all/queueArray.py
1,038
3.5625
4
class queueArray: def __init__(self, capacity): self.capacity = capacity self.rear = capacity - 1 self.front = self.size = 0 self.myqueue = [None]*self.capacity def isEmpty(self): return self.size == 0 def isFull(self): return self.size == self.capacity def enqueue(self, elem): if se...
9c38b50dc8169e6ed92c44f737829a27cb747540
hyagods4/POO_Treino
/pessoa.py
2,645
3.9375
4
class Pessoa: def __init__(self, nome, idade, peso, altura): self.nome = nome self.idade = idade self.peso = peso self.altura = altura def envelhecer(self, ano): if self.idade < 21: self.idade += ano self.altura += 0.5 else: se...
3dafe2b1bcd7ba9cb9f3b0079820293057860a22
ViniciusGranado/_studies_Python
/_exercises/exercise089/exercise089.py
2,511
4.03125
4
def validate_float_number(number_str): is_valid = True if number_str == '' or number_str[-1] == '.': is_valid = False else: for i in number_str: if not (i.isnumeric() or i == '.'): is_valid = False return is_valid def get_number(msg_index): message = (...
471b21cb003753f4504118d81455a58b94799c0e
vivaxy/algorithms
/python/problems/custom_sort_string.py
1,553
3.671875
4
""" https://leetcode.com/problems/custom-sort-string/ https://leetcode.com/submissions/detail/142301270/ https://leetcode.com/submissions/detail/142463607/ """ from functools import cmp_to_key class Solution1: def customSortString(self, S, T): """ :type S: str :type T: str :rtyp...
07554c2f15909a6af179a5cc92fec3256c6bcea1
sovan91/Python-Code
/basics/conditionstatement.py
426
4.09375
4
''' Created on Jan 16, 2019 boolean @author: SOVAN ''' x = int(input('Enter the first number:')) y = int(input('Enter the second number:')) if x > y : print('first number is greater than second number') print('greater number is:', x) print('Smallest number is:', y) else : print('second numb...
5f22056213ccc843bcbda175ec977663f258d90b
chatterjeelab2022/VADER
/read_parameters.py
6,211
3.640625
4
# -*- coding: utf-8 -*- """ @author: Rachel Kelemen Finalized: April 2019 This module contains a function to read a .csv file specifying the parameters for Illumina data processing and returns a dictionary of parameters. Base indices are corrected from SeqBuilder (starts at 1) to Python (starts at 0) """ ...
2edfceb92d815fbaf75ec3a9b6cf70d2758849f2
ShivanshThakur/DSA
/anagram.py
732
3.640625
4
def func(anagrams): d = defaultdict(list) j = 0 for i in anagrams: d[''.join(sorted(i))].append(i) print(d) func(['eat', 'tea', 'tan', 'ate', 'nat', 'bat']) '''' class Word(object): def __init__(self, string, index): self.string = string self.index = index def cr...
67edadcefd24dfe06581da66cc936e46c6fd9874
ncoop22/CSCI156Activity-12.1
/Answers 12.1.py
492
3.625
4
__author__ = 'Nickolas' def email(): email = (input("email.address")) gtld=['gov','com','edu','org','mil','net'] while True: try: username, domain = email.split('@') site, domaintype = domain.split('.') if domaintype in gtld: return username,site,d...
d1a885eee86c5cb6268a7470cc05eaea1f47e182
eduardogm81/ud_curso_data_science
/1.intro_a_python/4.estructuras_de_datos_basicas_4_ejercicios.py
673
3.828125
4
# -*- coding: utf-8 -*- """ ****************************************************************************** EJERCICIOS ****************************************************************************** """ #%% """ Crear un diccionario cuyas claves sean los tres primeros dias de la semana y los valores sean la posicion...
8ec87e4a8408ee067b0b2ca103f86378898f890b
ruhigit/Perceptron
/percepclassify.py
1,166
3.734375
4
##Classify each line of input ##Will be invoked as python3 percepclassify.py MODELFILE < data.in > data.out ##The label/class for each input will be the output import pickle import sys ##The feature_vector is the model that will be used to calculate the classes ##Testset is a list of sentnces that have to be tagged w...
018d7e71d247f1cf14104ddaa8dd21e7939a67d6
loveguan/test
/main/zhuangshiqi.py
790
3.53125
4
#!/usr/bin/env python #_*_ coding:utf-8 _*_ #zhuang shi qi #带参数和返回值的装饰器 def outer(fun): def wrapper( arg): print 'xxxxxx' tet=fun(arg) return tet return wrapper @outer def Func1(arg): print 'func1',arg return 'return' test = Func1('nihao') p...
13d1b3ba2a7dff8b87112119a35d06bc93cbb664
OliveiraFabioPereirade/introducao_python
/aula3.py
1,997
4.125
4
# a = int(input('Entre com o primeiro valor: ')) # como o input retorna uma string # b = int(input('Entre com o segundo valor: ')) # tem que converter retorno em int antes das operações # c = int(input('Entre com o terceiro valor: ')) # # if a > b and a > c: # print('O maior número é: {}' .format(a)) #python recon...
f166ad2667204bef98e3a4e5082ad0e1193851d2
davepage-mcr/aoc2018
/day06/day6-1.py
2,798
3.9375
4
#!/usr/bin/python3 import sys import re import pprint import string # Read the input from the file name specified on the command line inputfile = open(sys.argv[1]) def manhattan_distance(coords, target): return abs(coords[0] - target[0]) + abs(coords[1] - target[1]) def closest_target(coords): # Return the ...
ca7ac9d8f793881958a0699cfa68f9ce5b4ab3a1
yennanliu/CS_basics
/leetcode_python/Dynamic_Programming/min-cost-climbing-stairs.py
3,619
4.1875
4
""" On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the top of the floor, and you can either start from the step with index 0, or the step with index 1. Example 1: Input: cost = ...
1df88d1b7761019ad71d01b90f1ca784f114308b
svenkat19/functionali
/tests/test_statements.py
791
3.796875
4
from functionali import if_, or_, and_ def test_if_(): assert if_(True, 1, 2) == 1 assert if_(False, 1, 2) == 2 def test_or_(): assert or_(True, True, False) == True assert or_(True, False, False) == True assert or_("a" == "a", 5 % 5) == True assert or_(False, False, 0) == 0 assert or_(...
c2ce392822e66867f323d790523c1cb20a6f1975
tiagorodriguessimoes/MSc-Thesis-Tools
/removeTermsShorterThan.py
1,840
3.921875
4
# !/usr/bin/python2.7 # -*- coding: utf-8 -*- """Removes terms shorter than N size from CSV file. Usage: removeTermsShorterThan.py [--category=<index> --text=<index>] (-l=<k> | --length=<k>) FILE removeTermsShorterThan.py -h | --help Options: --category=<index> Category index [default: 0]. --...
e95d3fb96b275d810959f07aa0900d68d38cbaa5
adamhartleb/py_musings
/misc/finite_fields.py
956
3.671875
4
class FieldElement(): def __init__(self, num, prime): if num >= prime or num < 0: error = f'Num {num} not in field range 0 to {num}' raise ValueError(error) self.num = num self.prime = prime def __repr__(self): return f'FieldElement_{self.prime}(...
1cdbb2b91a8471f284f2eb168e3a29bfa5e5026c
ktjack2009/ProjectEuler
/common_functions.py
639
3.875
4
def judge_palindrome(num): # 判断回文数 num_str = str(num) if num_str == num_str[::-1]: return True else: return False def factoring(num): # 因式分解 arr = [] i = 2 while num != 1: if num % i == 0: while num % i == 0: arr.append(i) ...
478d033274835936a42a534db21a667668405191
Technologicat/unpythonic
/unpythonic/syntax/tests/test_conts.py
36,630
3.578125
4
# -*- coding: utf-8 -*- """Continuations (call/cc for Python).""" from ...syntax import macros, test, test_raises, error, fail # noqa: F401 from ...test.fixtures import session, testset, returns_normally from ...syntax import macros, continuations, call_cc, multilambda, autoreturn, autocurry, let # noqa: F401, F811...
37a87cf4d347275cd2c00b0f768b4bf24cd23615
turab45/Travel-Python-to-Ml-Bootcamp
/Day 4/task2.py
328
3.6875
4
# Task-02 - Create a Mobile class with ram and rom instance attributes. # Author : Muhammad Turab class Mobile: def __init__(self, brand_name, ram, rom): self.brand_name = brand_name self.ram = ram self.rom = rom i_phone = Mobile("Iphone", 4, 128) print(i_phone.brand_name, i_phone.ram,...
7f6ba38aef3008c7d0b4a9dae57f3db05fb1bea4
nextkara/python
/createrandom.py
259
3.703125
4
#!/usr/bin/python import random count = input("how many>> ") maxnum = input("Max is >> ") minnum = input("Min is >> ") p = open("num.txt",'w') for x in range(0,int(count)): p.write(str(random.randint(int(minnum),int(maxnum)))) p.write('\n') p.close()
8f978e098713e2661bbe5b1d7a497da8990c7623
pauloaaa/curso_python
/aula04/ex004.py
178
3.625
4
pNumero = int(input('Primeiro número ')) sNumero = int(input('SSegundo número ')) soma = pNumero + sNumero print('A soma entre {} e {} vale {}'.format(pNumero, sNumero, soma))
5017e0fd84d761c0ab96e38acba6dce2d075e301
abraichdata/predection_mortalite_MIMICIII
/dtw.py
4,714
3.828125
4
# -*- coding: utf-8 -*- """ Implementation of dynamic time warping. This module implments dynamic time warping (DTW) for calculating the similarity distance between two multivariable time series. """ import numpy as np import pandas as pd def dynamic_time_wraping(a, b, metric): """Returns the minimum cost betwe...
3420f6f217b76fc047faf2e9cf39aee37b2d247c
GuilhermeLaraRusso/python_work
/ch_8_functions/8_22_mixing_positional_and_arbitraty_arguments.py
756
4.46875
4
# If you want a function to accept several different kinds of arguments, the # parameter that accepts an arbitrary number of arguments must be placed # last in the function definition. Python matches positional and keyword # arguments first and then collects any remaining arguments in the final # parameter. # For exam...
a62d194e1e6658ce362c86de4d527dfceae61c64
dbconfession78/interview_prep
/code_wars/0011_ip_validation.py
2,250
3.625
4
""" Write an algorithm that will identify valid IPv4 addresses in dot-decimal format. IPs should be considered valid if they consist of four octets, with values between 0..255 (included). Input to the function is guaranteed to be a single string. Examples // valid inputs: 1.2.3.4 123.45.67.89 // invalid inputs: 1.2...
8bf1b318995c56191adac92be67f05592ffedd7d
Aura-Zlata/Instructiunea-WHILE
/WHILE1.gyp
335
3.828125
4
""" Se introduc succesiv numere nenule până la introducerea numărului 0. Să se afişeze suma tuturor numerelor introduse. Exemplu: Date de intrare 3 5 4 2 0 Date de ieşire 14. """ n=eval(input('Introduceti un numar:')) s=0 while n!=0: s+=n n=eval(input('Introduceti un numar:')) print('Suma numerelor e...
5f84528faf544616f282afe4bacd690667ebb5b0
Vickybilla/PRACTICA-PHYTON
/EjerciciosPython/ejercicio2-2.py
690
4.15625
4
"""Ejercicio 2: Crear una lista con 10 números enteros cualquiera. Indicar cuál es el número mayor y cuál es el número menor. Si al menos hay 3 números mayores a 100, imprimir esos números, si no, imprimir los números menores a 50 que formen parte de la lista.""" lista_num= [2,4,6,7,23,977,6.0,3,66,8965] lista_num....
af8e6e2c1c1abb83dc04b75223bea9578c5d42ef
CaseyJames669/Adv_Python
/example916.py
840
3.953125
4
def read_data(fin): '''Read class data from a file opened for reading Purpose: Tell your 'story' here Preconditions: fin is an input file, open for reading that must adhere to data input specs Postconditions: Returns a tuple including the integer number of quizzes to consider i...
df6c74a61cb10ae3a8c8a684aa2c2137dbd9342f
gabriellaec/desoft-analise-exercicios
/backup/user_088/ch45_2020_10_03_00_48_28_261595.py
211
4.0625
4
numeros=[] n=int(input("Digite um numero: ")) while(n>0): numeros.append(n) n=int(input("Digite um numero: ")) i=0 quant=len(numeros) while(quant>i): print(numeros[quant-1]) quant-=1
5937cd28c9b85a64a298276d6874bca749972b77
PeriCode/PythWinter2018
/PyNoFantasy2k18/l10/oop1.py
879
3.6875
4
# count_wheel = 4 # engine = True # fuel = 'oil' # def ride(): # print('Врум врум') # name = 'чайка' class Car: # описали класс Car count_wheel = 4 # свойство класса engine = True # свойство класса fuel = 'oil'# свойство класса def ride(self, speed): # метод класса print('Врум врум '*speed) seagull = Car()...
3d2e73e5d31b1f3a51613133109696458f086a97
zhuohuwu0603/interview-algothims
/ladder_advanced/6_dynamic_problem_II/29. Interleaving String.py
1,617
3.875
4
'''Description Given three strings: s1, s2, s3, determine whether s3 is formed by the interleaving of s1 and s2. Have you met this question in a real interview? Example For s1 = "aabcc", s2 = "dbbca" When s3 = "aadbbcbcac", return true. When s3 = "aadbbbaccc", return false. Challenge O(n2) time or better ''' class ...
b0dd78793d95a2967eaedf9650d6c9d9d5a5346b
samyak1903/Data-Types-1
/A7.py
356
4.1875
4
#Q.1- Count even and odd numbers in that list. l=[] even,odd=0,0 elements=int(input("Enter the number of elements to be added in list")) for num in range(elements): num=int(input("Enter the value")) l.append(num) for n in l: if n%2==0: even=even+1 else: odd=odd+1 print("Even count=%d\n O...
1f632c387d604d28ba95dc41fbd5d49018c52480
calvinchu8172/Leetcode-problems
/30-Day-LeetCoding-Challenge/middle-of-linked-list/Solution.py
992
4.0625
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def middleNode(self, head): nodes = [] while head: nodes.append(head) head = head.next return nodes[len(nodes) // 2] def cr...
531657226bc07e43cf235332a34c5e88e41c1030
bwblock/Udacity
/relational-databases/quiz-1-4-adding-rows.py
1,354
3.859375
4
# # Insert a newborn baby opossum into the animals table and verify that it's been added. # To do this, fill in the rest of SELECT_QUERY and INSERT_QUERY. # # SELECT_QUERY should find the names and birthdates of all opossums. # # INSERT_QUERY should add a new opossum to the table, whose birthdate is today. # (Or you ...
eab21b8204ca380316b3868becbd1b7fcdc348e9
w940853815/my_leetcode
/easy/283.移动零.py
1,406
3.984375
4
# # @lc app=leetcode.cn id=283 lang=python3 # # [283] 移动零 # # https://leetcode.cn/problems/move-zeroes/description/ # # algorithms # Easy (63.81%) # Likes: 1983 # Dislikes: 0 # Total Accepted: 1M # Total Submissions: 1.6M # Testcase Example: '[0,1,0,3,12]' # # 给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。 # # ...
e8c9563ee60745bc968b01787f390d4a6875395f
faiderfl/algorithms
/recursion/DecimalToBinary.py
188
3.828125
4
def decimal_to_binary(n): assert int(n)==n, 'Fail' if n==0: return 0 else: return (n%2) + 10 * decimal_to_binary(int(n/2)) print(decimal_to_binary(112))
8d996330ec7a446f99cbf5994f624f812e5b855b
p2327/CS61a_Berkeley
/generators.py
1,101
4.3125
4
def letters_generator(): current = 'a' while current <= 'd': yield current current = chr(ord(current)+1) """ for letter in letters_generator(): print(letter) """ letters_a_d = letters_generator() next(letters_a_d) def letters_maker(start, finish): while start <= finish: ...
6d9c106f945dd3e1762498142958157c48a43caa
bgmsora/Katas
/Thinking & Testing A B.py
161
3.515625
4
def test_it(a, b): result=0 for x in (str(a)): print(x) for y in (str(b)): result=result+int(x)*int(y) return result
66723ebb603f7fafdae560f01dd2f89807e8afca
ajitnak/py_pgms-hash_maps
/most_freq.py
650
3.59375
4
#[12,3,4,6,7,9,10,3, 6,4,4], 3 => [3,6] import collections def max_freq_items(arr, n): count_dict = collections.defaultdict(int) for i in arr: count_dict[i] += 1 print count_dict # allocate an arr of size len(dict) freq_list = [None]*(len(arr)+1) for i in range(len(arr)): freq_list[i] = [] for k,v in count...
75ba0b00576d595d4b038ae01154aa91ab449168
UWPCE-PythonCert-ClassRepos/Self_Paced-Online
/students/patchcarrier/Lesson03/mailroom.py
4,655
4.09375
4
#!/usr/bin/env python3 donors = [["Conrad Anker", 550, 1200, 0.02], ["Tommy Caldwell", 600.50, 80], ["Margo Hayes", 200, 550.50], ["Alex Honnold", 0.01], ["Paige Claassen", 750, 800, 150.25]] def thankyou_menu(): """Prompt the user to enter information about a donation a...
2d6e7eb545563d2d4100b534929ece9b82899252
ErkRacicot/Poker-Solitaire
/Andrews-stuff/AndrewPokerSolitaire/POKER SOLITAIRE, text based.py
25,434
3.5
4
#https://codereview.stackexchange.com/questions/172646/simple-deck-of-cards-python-program - is where the deck of cards class is from #https://github.com/notpeter/Vector-Playing-Cards #https://stackoverflow.com/questions/16455777/python-count-elements-in-a-list-of-objects-with-matching-attributes import random import ...
c5ff21689a026cdd398e5912e4c400314fac418a
sdk1926/toycoding
/cafe.py
2,407
3.515625
4
# 카페 주문 프로그래밍 draft_cafe = {'아메리카노': 4100, '카페라떼': 4400, '얼그레이티': 4500, '달고나 라떼': 3800, '망고스무디': 4800 } def order_coffee(): global draft_cafe print('메뉴판','아메리카노: 4100','카페라떼: 4400','얼그레이티: 4500','달고나 라떼: 3800', '망고스무디: 4800', sep='\n') coffee =...
31e12c910333999cf5380448a4077acca99e3060
aminul788/NSL-RAShip-Programm
/python-basic/Problem-Solving/TheMinionGame.py
1,560
3.828125
4
''' Date : 02/11/2020 Day : Monday Author : Md. Aminul Islam Topic : Problem Solving Problem : The Minion Game Problem link : https://www.hackerrank.com/challenges/the-minion-game/problem ''' def minion_game(string): ### using mathemetical equation: n+(n-1)...