blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
d6e4907b6ff49095da36fcc3cafe9deff8825358
FerdinandL/Courses
/Tutorials/Astuces Programmation/Questions_Interview_Cake.py
761
3.96875
4
## Learning Python #%% Class definition class BinaryTreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def __repr__(self, level=0): ret = "\t"*level+repr(self.value)+"\n" if (self.left): ret +=...
db2755c167683fe5714972adfb5bd16f924e9ff3
DeveloperTinoco/SDEV-220
/Chapter 11 - Exercise 11.9.py
5,044
4.21875
4
# Keeps track of the board's spots gameBoard = {'1': ' ', '2': ' ', '3': ' ', '4': ' ', '5': ' ', '6': ' ', '7': ' ', '8': ' ', '9': ' '} keys = [] for key in gameBoard: keys.append(key) # Function that draws board def drawBoard(board): print(bo...
6c907810a703e1d7bca0b69500f5de31f9e29c97
joey71/LintCodeInPython
/moving_average_from_data_stream.py
672
3.75
4
class MovingAverage: """ @param: size: An integer """ def __init__(self, size): # do intialization if necessary self.size = size self.queue = [] self.start = 0 self.total = 0 """ @param: val: An integer @return: """ def next(self, val): ...
a4b0082a7daa9ef78daed0b5ccd01ae865690345
maxigarrett/cursoPYTHON
/3.clase 3 uso de interfaz/7-messageBox.py
875
3.953125
4
from tkinter import * from tkinter import messagebox as MessageBox ventana=Tk() ventana.title("ingreso de datos") ventana.resizable(0,0)#evitamos la redimencion de la ventana por el usuario ventana.geometry("600x400")#le damos unas dimenciones """Mensajes. Para mostrarle mensajes emergentes al usuario, vamos a uti...
825e969a7c064fb5092da5ba94a4db1925fc8871
MariaJoseOrtiz/MasterPython
/10-set-diccionarios/sets.py
238
3.796875
4
""" set es un tipo de datos , para tener una coleccion de valores, pero no tiene incide ni valores """ persona ={ "victor", "Maria", "Cesar" } persona.add("Paco") persona.remove("Maria") print(type(persona)) print(persona)
1880f799eb27830a3bc492be70a5c12c277a3e34
operation-lakshya/BackToPython
/MyOldCode-2008/JavaBat(now codingbat)/Strings1/lastChars.py
313
3.71875
4
a=raw_input("\nEnter a string\t") b=raw_input("\nEnter a string\t") if (len(a)==0 and len(b)==0): print "\nOut put is: @@" elif (len(a)==0): print "\nOutput is: @"+b[len(b)-1] elif (len(b)==0): print "\nOutput is: "+a[0]+"@" else: print "\nOutput is: "+a[0]+b[len(b)-1] raw_input("\nPress enter to finish")
9923a2b284c772706f0495312129dc8bee9a5051
CrunchyJohnHaven/algosPython
/reverseInteger.py
521
4.09375
4
# Given a 32-bit signed integer, reverse digits of an integer. # Example 1: # Input: 123 # Output: 321 # Example 2: # Input: -123 # Output: -321 # Example 3: # Input: 120 # Output: 21 class Algos(): def reverse(self, x): s = str(x) if x>=0: res = int(s[::-1]) return res...
805821f53824412ae09652e317c2085f771edf31
dnsbob/read-morse-code-from-hand-entry
/threebuttonmorsecode.py
4,983
3.5625
4
# CircuitPython on Trinket M0 using Mu editor ''' # threebuttonmorsecode Read Morse code from hand entry with three buttons: dot, dash, space Which will be much easier than a single button and variable timing Planning to use capacitive touch input Want to be able to input a password, without a display Only an LED for ...
69d44f32e011a4977e6418c7cc863d62c48a504e
5arthak/Efficiency-of-Determinant
/Efficiency of Determinant Project.py
5,945
3.5
4
import numpy as np import time import sys import os from tkinter import simpledialog from tkinter import messagebox from tkinter import * from numpy import * loop = True diagonalSum = 0 def chosenGaussianElimination(): getMatrixDeterminantGaussianElimination(matrix1) def chosenRecursion(): start = time.tim...
7dc991229af987982fbc701341f87c72785e82e4
H4wking/lab10
/animal_1.py
955
3.859375
4
import random class Animal: """ Class for animal representation. """ def __init__(self, position): self.position = position self.old_position = position def move(self): """ Move animal randomly to the left, to the right or keep it at old position. """ ...
bcd57859e088ac2d63adcb85c27d0279f617eb07
glennj/exercism.io
/python/phone-number/phone_number.py
1,595
3.90625
4
import string class PhoneNumber(object): def __init__(self, phone_number): parts = self.parse(phone_number) self.number = "".join(parts) self.area_code = parts[0] self.formatted = f"({parts[0]})-{parts[1]}-{parts[2]}" def pretty(self): return self.formatted def pa...
c6ca2e98ac9da881b5b33a12eb9de0b5913a98bf
pavithra181/p3
/print odd digits in a number.py
64
3.578125
4
n=input() for i in n: a=int(i) if(a%2==1): print(a,end=" ")
ba36e5ade03c1c59a0eea9c38c9e9a8d09179e4d
simtb/coding-puzzles
/daily_coding_challenges/challenges/word_search.py
2,235
4.34375
4
""" Good morning! Here's your coding interview problem for today. This problem was asked by Microsoft. Given a 2D matrix of characters and a target word, write a function that returns whether the word can be found in the matrix by going left-to-right, or up-to-down. For example, given the following matrix: [['F', '...
a72b84ed3ce67b368b4a1d5a48d2df38360b561d
Aasthaengg/IBMdataset
/Python_codes/p03712/s493259149.py
330
3.703125
4
s = input().split() h = int(s[0]) w = int(s[1]) strings = [] for i in range(h): p = input() strings.append(p) for i in range(w + 2): print('#', end='') print('') for i in range(h): print('#', end='') print(strings[i], end='') print('#') for i in range(w + 2): print('#', end='') ...
3feab6e62584e97c818818249caaef68ee7100d8
chowdhuryRakibul/algorithms
/StableMariages.py
3,960
3.84375
4
''' Write a Python function stableMatching(n, menPreferences, womenPreferences) that gets the number n of women and men, preferences of all women and men, and outputs a stable matching. The function should return a list of length n, where ith element is the number of woman chosen for the man number i. ''' def stableMa...
df694c34645af79c3a1a63a8c3f835093eac9757
SamJ2018/LeetCode
/python/python语法/pyexercise/Exercise05_41.py
581
4.1875
4
import sys # Prompt the user to enter the first number number = eval(input("Enter a number (0: for end of input): ")) if number == 0: print("No numbers are entered except 0") sys.exit() max = number count = 1 # Prompt the user to enter the remaining numbers while number != 0: number = eval(input...
8534ec0a1614f0e19755ad7f778bdc4a6ae091f2
Seraphineyoung/module2
/LPTHW/exercise_15.py
378
3.84375
4
#from sys import argv # #script, filename = argv # #txt = open(filename) # # #print(f'Here\'s your file {filename}: ') #print(txt.read()) #print (txt.close()) # # #print('Type the filename again:') #file_again = input('> ') # #txt_again = open(file_again) # #print(txt_again.read()) # #print (txt_again.close()) mylist...
023fd593ae2670443294224f726266652a396c54
renjieliu/leetcode
/1500_1999/1961.py
309
3.65625
4
class Solution: def isPrefixString(self, s: str, words: 'List[str]') -> bool: left = 0 for w in words: if w == s[left:left+len(w)]: left += len(w) if s[left:] == "": return True else: return False
bc25395a5eb18ae64707e41664360be2116eadba
MattMoony/project-euler
/0010/main.py
692
3.96875
4
def next_prime(n, primes): for p in primes: if n%p == 0: return next_prime(n+1, primes) return n def prime_sum(n): if n < 2: return 0 primes = [2] while primes[-1] < n: primes.append(next_prime(primes[-1], primes)) # print(primes[-1]) primes.pop() ...
7c205ff7f2cd992ba2b28fce77a1b34f30771542
da-ferreira/uri-online-judge
/uri/2862.py
171
3.53125
4
casos = int(input()) for i in range(casos): energia = int(input()) if energia > 8000: print('Mais de 8000!') else: print('Inseto!')
d365e03943d1e38bb772a323e586f355631851f4
Jadams29/Coding_Problems
/Exception_Handling/String_Manipulation.py
776
4.375
4
# -*- coding: utf-8 -*- """ Created on Sun Jun 24 15:35:22 2018 @author: joshu """ # Enter a string to hide in uppercase : HIDE # Secret Message : 35647890 # Original Message : HIDE message =input("Enter a string to hide: ") secret_message = '' for i in range(len(message)): secret_message += str(ord(message[...
0e0abde69df3c12a6a9c3b47386edb5a7fa8432e
Oneuri/DAA
/merge2final.py
897
3.875
4
def mergesort(arr): if len(arr)>1: mid=len(arr)//2 lefthalf=arr[:mid] righthalf=arr[mid:] print(arr) mergesort(lefthalf) mergesort(righthalf) print(str(lefthalf)+" "+str(righthalf)) i=0 j=0 k=0 while(i<len(leftha...
af8f742c468a9418cd455e44d9a5ddfeeab521f2
jamezaguiar/cursoemvideo-python
/Mundo 2/040.py
697
4.03125
4
# Crie um programa que leia duas notas de um aluno e calcule sua média, mostrando uma mensagem no final, de acordo com a média atingida: # - Média abaixo de 5.0: REPROVADO # - Média entre 5.0 e 6.9: RECUPERAÇÃO # - Média 7.0 ou superior: APROVADO nota1 = float(input("Primeira nota: ")) nota2 = float(input("Segunda nota...
13a18bc4b9b2d75e513b026a6716825b760c464e
cuongdv1/Practice-Python
/Python3/rice_univ/diff_files.py
1,750
3.890625
4
""" Functions to check first occurennce of difference in every line """ # Define value for identical lines IDENTICAL = -1 def line_diff(line1, line2): """ Checks and returns the first occurence of the differences """ len1 = len(line1) len2 = len(line2) if len1 < len2: short...
baf98b6b31f52edf424c8bc2223cbdd46d09d79f
YuSunjo/algo_study
/python_grammer/python_grammer/stack_queueEx.py
314
3.796875
4
# queue from collections import deque queue = deque() queue.append(5) queue.append(6) queue.append(3) queue.append(9) queue.popleft() print(queue) queue.reverse() print(queue) queueList = list(queue) print(queueList) # stack stack = [] stack.append(3) stack.append(6) stack.append(9) stack.pop() print(stack)
a9843c29ad635ba629f0f4519ea2b2137322021f
erikperillo/mc658
/src/lab_3/csv_to_latex_table.py
772
3.59375
4
#!/usr/bin/env python3 import sys def csv_to_latex_table(filepath): fst_line = True print("\\begin{table}[H]") print("\\centering") with open(filepath, "r") as f: for line in f: line = line.strip().replace("_", "\_").split(",") if fst_line: print("\\begi...
7fe1f31302f04aa747492e36b0939b64182d491b
janousek77/Encrypt_Decrypt
/lab2.py
6,755
3.671875
4
import os, sys, fileinput, base64, hashlib from Crypto.Cipher import AES from tkinter import * # Hash Function def encrypt_string(hash_string): sha_signature = \ hashlib.sha256(hash_string.encode()).hexdigest() return sha_signature # Encryption Function def encrypt(plaintext): global ciphe...
84761b7602f914b01589e5034a4dbd6cf6c65ebf
JaredVahle/individual-project
/explore.py
3,305
3.5
4
import pandas as pd import numpy as np import seaborn as sns import matplotlib.pyplot as plt from sklearn.preprocessing import MinMaxScaler from sklearn.cluster import KMeans import sklearn.feature_selection def salary_heatmap(df,target = 'total_earnings'): ''' returns a heatmap and correlation for our target...
d6b71761a58e7fe92f138a21242b8dd00d254355
J10pro/Encuesta-basica-en-Python
/cuestionario.py
700
3.8125
4
#Por favor no robe este codigo (solo editelo y mande los respectivos creditos a J10) #Trato de ser lo mas limpio y natural en este tipo de codigo de programacion tan impresionante #https://www.youtube.com/channel/UCTxqBfQyNCj0o8g7icj1JBA a = "(Pregunta 1)" b = "(Pregunta 2)" c = "(Pregunta 3)" while True: pr...
eac271a01e69c015ce4006875ef3d82a76c3690d
vertocode/python-course-challenges
/Mundo 1/desafio03.py
205
3.875
4
print('Calculador de soma') primeironumero = int(input('Primeiro número: ')) segundonumero = int(input('Segundo número: ')) resultado = int(primeironumero + segundonumero) print('A soma é ', resultado)
6222ab86ba6675b71cf636202c94eeff61de9b55
Naveen-Krishnamurthy/PythonProgramming
/PythonPrograms/PrimeNumber.py
700
4.0625
4
class testPrime : def function_Range(self) : for n in range(2,10) : for x in range(2,n) : if n % x==0 : print(n,"is not a prime number") break else : print(n,"is a prime number") def function_EvenNumber(self) : for n in range (1,10,2) : if n % 2 == 0 : print(n, "is a even nu...
415e3b3edd704076294a28215694c398738227dc
bethcreate/pythonprojectC1
/controlflow.py
273
4.125
4
num = int(input("Enter a number: ")) print("multiplication table of:") for i in range(1,11): print(num,'x',i,'=',num*i) number = int(input("Enter a number: ")) print("division table of: ") for a in range(1,11): print(number,'/',a,'=',number/a)
b4c0154f1cf83ebca1d1769f20aca383dfd36e3b
Kawser-nerd/CLCDSA
/Source Codes/AtCoder/agc010/A/4896280.py
139
3.515625
4
n=int(input()) a=[int(i) for i in input().split()] odd=0 for i in a: if i%2==1: odd+=1 print("YES" if odd%2==0 else "NO")
6ec56bf7a0f92000960e870c7b6c50d35892fb33
hyunwoojeong123/Algorithm
/BOJ/1014_컨닝.py
2,150
3.609375
4
def DFS(before_line,now): # print(before_line,now) if now == N: return 0 if D[before_line][now] != -1: return D[before_line][now] for cur_line in range(1 << M): # print(bin(before_line),bin(cur_line)) cnt_1 = 0 pos = True # print('검증 간다') # 검증 앉기가 ...
448a36528aa40d1a6f39b1bc9da1ea7e0c397207
wuyb518/python-learn
/基础教程/005字符串.py
1,510
3.625
4
#!/usr/bin/python # _*_ coding:UTF-8 _*_ var1='Hello world' var2='Python Runoob' # 访问字符串中的值 print 'var1[0]',var1[0] print 'var2[1:5]',var2[1:5] # 字符串更新 var1='Hello World' print '更新字符串:-',var1[:6]+'Runoob!' # 字符串运算符 # + 字符串连接 print 'hello '+'world' # * 字符串复制 print 'hello '*2 # [] 按索引获取字符 print 'hello'[1] # [:] 截取字符...
de4352cd7d651055e3204be3f1c06dfb4ba75d83
DarlanNoetzold/P-versus-NP
/P versus NP.py
2,233
4.15625
4
# Simulação de tempo que o computador que está executando o programa # levaria para calcular algumas rotas para o caixeiro viajante sem # utilizar Otimização Combinatória import time # Calcula o tempo que o processador da máquina leva para fazer 10 milhões # de adições, cada edição é o calculo de um caminho (li...
50419f5c6d6ea763626dcd02eb5e023fd65dd1a5
daveydog24/python_fundamentals
/find_characters.py
695
4.15625
4
def find(word_list, char): #function takes in a list and then the character for the test new_list = [] #creates an empty list everytime we are testing within the function for count in range(0, len(word_list)): #goes through each index of the list if word_list[count].find(char) != -1: #test each word in ...
0e9e1258516442601347698e607555c7527ba65b
Nagalaxmi390/Python_Basic
/python_Hacker/nested_list.py
383
4
4
#LIST LIST OPARATION n=int(input('length of main list')) n1=int(input('enter length of first sublist')) n2=int(input('enter length of second sublist')) a=[] b=[] print('element of first sublist') for i in range(n1): a.append(int(input())) print(a) print('elements of second sublist') for i in range(n2): ...
0ccd2ba85d026c2a8b4401e7289f1d6c24dc0520
ZU3AIR/DCU
/Year1/prog1_python2/w4l1/sum-five-0.py
119
3.734375
4
#!/usr/bin/env python n = input() total = n while n != 0: n = input() total = total + n print total
97061024ae4da17acf256ce416722b0a73ea8f6f
DRCART03/CodeCombat
/Forest/WildHorses/WildHorses.py
792
3.8125
4
while True: # Как Вы можете найти ближайшее союзное существо? # horse = ? horse = hero.findNearest(hero.findFriends()) if horse: x1 = horse.pos.x - 7 x2 = horse.pos.x + 7 y = horse.pos.y if x1 >= 1: hero.moveXY(x1, y) elif x2 <= 79: hero.moveX...
070b3b093355893acd699e9808b9399a45e5aab6
daniel-reich/turbo-robot
/v2eHXTn2qobw2WYJP_18.py
1,382
4.25
4
""" Create a function that takes a list representation of a Minesweeper board, and returns another board where the value of each cell is the amount of its neighbouring mines. ### Examples The input may look like this: [ [0, 1, 0, 0], [0, 0, 1, 0], [0, 1, 0, 1], [1, 1, 0, 0] ] The ...
b460cce1fdda5cc19c70035e21cda5f27b2ecbc8
AlanBuechner/MinecraftMazeGenerator
/maze.py
8,860
3.609375
4
from mcpi.minecraft import Minecraft import random import time # verbose printing def verbos_print(msg, msgverbosity, verbosity): # print messege if the verbosity is high enough if(msgverbosity <= verbosity): print(msg) # vector class class Vector(): def __init__(self, x, y, z): # x, y and...
6db1a42747298779f48188eb1b37d793dbb1d0c4
rmmariano/final_project_scientific-program
/exerc_01_a.py
237
3.625
4
# Exerc. 01) a) import matplotlib.pyplot as plt import numpy as np # create 100 values between 0 and 1 x = np.random.rand(100) # do the values between -0.5 and 0.5 x = x - 0.5 print("values of x: ") print(x) plt.hist(x) plt.show()
cd3e0275f8ab48ee1913828f132176c3306fa988
csepdo/Practice
/iterables_iterators_generators.py
4,683
4.46875
4
#Exercise 4 #Create a tuple of month names and a tuple of the number of days in each month (assume that February has 28 days). Using a single for loop, construct a dictionary which has the month names as keys and the corresponding day numbers as values. #Now do the same thing without using a for loop. """months = ("J...
c6f1196bff376683cd063df5be373f760236ff63
AndyPeee/COD_the_fish
/COD.py
14,762
4.15625
4
""" This first block of code just imports pygame and random and sys, and sets up some variables to be used later """ import pygame, sys import random clock = pygame.time.Clock() timer = 3 intitaltext = '10'.rjust(3) # sets the clocks first value score = 0 # sets the initial score to be added to later RED = (255, 0,...
44f5af54689cc21f6608d1c187cf3ebc437cd4ac
viswan29/Leetcode
/Bitmasking/convert_to_base_-2.py
1,546
4.0625
4
''' https://leetcode.com/problems/convert-to-base-2/ Given a number N, return a string consisting of "0"s and "1"s that represents its value in base -2 (negative two). The returned string must have no leading zeroes, unless the string is "0". Example 1: Input: 2 Output: "110" Explantion: (-2) ^ 2 + (-2) ^ 1 = 2 Examp...
5e75ea2e7756cd46d140217c9251a4f3f69556c1
Kastagnus/rest_api_unilab
/MyProject/populate.py
1,128
3.609375
4
# import sqlite3 # from MyProject.resources import hotel_rooms # from MyProject.security import users # connection = sqlite3.connect("alldata.db") # cursor = connection.cursor() # cursor.execute("CREATE TABLE IF NOT EXISTS hotel_rooms(id INTEGER PRIMARY KEY, room_type text, price int , quantity int)") # query_string =...
d3b1719a35bf5afbb61dbcfc3b265dacb9ad4b3e
batrakaushal/Py4e
/904.py
485
3.65625
4
fname = input("Enter file name: ") if len(fname) < 1 : fname = "mbox-short.txt" fh = open(fname) a=[] for line in fh: if line.startswith("From:"): list=line.split() a.append(list[1]) #print(a) count=dict() for mail in a: count[mail]=count.get(mail,0)+1 #print(count) email = None ...
b208f10a89deed6b2f7ccf5ca5a9f5c767f48bdb
gautsi/git_wrkshp
/git_wrkshp/git_wrkshp.py
390
4.125
4
# -*- coding: utf-8 -*- import numpy as np def add(a, b): ''' This function adds two numbers. :param int a: the first number :param int b: the second number :returns: the sum of *a* and *b* :rtype: int For example, >>> add(2, 3) 6 ''' return func(a, b) def func(a, b)...
51d08129003c8346439851e80d1bbee72a43a82e
zzeden/Learn-Python
/selfpy/5.4.0.py
342
4.3125
4
BOTTLE_SIZE = 1.5 def num_of_water_bottles(): """ this function calculates the number of water bottles. required for the trip, given a liters value. :param num_of_liters: total number of liters :type num_of_liters: float :return: number of water :rtype: int """ return int(num_of_...
71202b4f41b2de7c6d14bd2d43b58e221a21086a
Mumujane/PythonAdvance
/Decorator/_@propertyStudy.py
1,540
3.765625
4
class Student(object): def get_score(self): return self._score def set_score(self, value): if not isinstance(value, int): raise ValueError("score must be an integer!") if value < 0 or value >100: raise ValueError("score must between 0 ~ 100!") self._sco...
1753bc160ae1f40833457e2e23974a4a5461739e
SK-642/problem-set
/factorial.py
260
3.96875
4
def factorial(n): ''' n!=1x2x3x4....n ''' if n==0: x=1 return x if n>=1: y=n*factorial(n-1) return y #for x in range(2,n+1): #y=y*x #print(y) n=int(input()) print(factorial(n))
8cc1d5af6cad135ecb6b99200ee5b533c6d665a3
JayZisch/CompilerProject
/server_tests/C8H10N4O2_test_075.py
361
3.859375
4
l1 = [1, 2, 3] l2 = [9, 8, 7] l3 = [3] (l1 if input() else l2)[input()] = input() print l1 print l2 print l3 list = [] l = list print list is list print l is list print list is l print [1] is [1] + [] print [1] != [1] + [] print not [] print not [1] print not [] + [] list = [9, 8, 7] list[True]=True list[False]=False l...
8e11a69b9c46c6d309de7ba42ca4e40dbab159a7
pod1019/python_learning
/第5章 函数用法和底层分析/lambda表达式.py
116
3.625
4
#lambda表达式 f = lambda a,b,c,:a+b+c print(f) print(f(2,3,4)) g = [lambda a:a*2,lambda b:b*3] print(g[1](5))
06852a2826f17d0208a5c2ed0c0fad3a6a9399ed
p3plos/learn_python
/second_week/Максимум последовательности.py
738
4.3125
4
''' Последовательность состоит из целых чисел и завершается числом 0. Определите значение наибольшего элемента последовательности. Формат ввода Вводится последовательность целых чисел, оканчивающаяся числом 0 (само число 0 в последовательность не входит, а служит как признак ее окончания). Формат вывода Выведите отве...
774d295895d7cd041e9f07c1ff65d569b1ad5a8a
EsenbekM/Esenbek-s-Home-Works
/hw_1_1.py
933
4.15625
4
# Переменные для вычесления a=int(input("Введите температуру Чуйской области ")) b=int(input("Введите температуру Ошской области ")) c=int(input("Введите температуру Нарынской области ")) d=int(input("Введите температуру Талаской области ")) e=int(input("Введите температуру Джалал-Абадской области ")) f=int(input("Введ...
aff99c63eaab8e11b54f3c8967549e04558a13f6
bodgergely/algos
/src/python/ic/eight.py
3,653
3.921875
4
""" decide if a binary tree is super-balanced (difference of depth of any two leaf nodes is no greater than 1) """ class BinaryTreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def insert_left(self, value): self.left = BinaryTreeNode(va...
1c11347cd1c4567ce487a459a8d49650e45f1e01
MrzvUz/100-days-python
/day-3/day-3-3-exercise.py
943
4.53125
5
# Checking the year whether it is a leap your or not: https://repl.it/@appbrewery/day-3-3-exercise#README.md # 🚨 Don't change the code below 👇 year = int(input("Which year do you want to check? ")) # 🚨 Don't change the code above 👆 # Write your code below this line 👇 if year % 4 == 0: print(f"The y...
f914c64f92b96938840ebf5dea9d81eed064af50
MachunMC/python_learning
/python_learning/16_while循环.py
922
4.125
4
# -*- coding: utf-8 -*- # @Project : python_learning # @File : 016_while循环.py # @Author : Machun Michael # @Time : 2020/6/16 15:42 # @Software: PyCharm # 如何检查用户输入是否合法? print("Please input a number, and then I will guess the number, enter 999 to end the game.") num = int(input("Now let's begin, please...
e4276ba7bb6e739fd1acbe601f82233fe2b015f2
weekstudy/fucking_the_algorithm
/test58_02_LeftRotateString.py
647
4.1875
4
# 对于一个给定的字符序列S,请你把其循环左移K位后的序列输出。 # 例如,字符序列S=”abcXYZdef”,要求输出循环左移3位后的结果,即“XYZdefabc”。 # -*- coding:utf-8 -*- def left_rotate_String(s, n): # write code here return s[n:]+s[:n] def left_rotate_String1(s,n): str1=[] str2=[] for i in range(len(s)): if i<n: str1.append(s[i]) ...
83c1b20c9896cdd456499b6891c55053aa815dd4
MAKman1/Bilkent-CS-Curriculum
/CS426/Project4/data/read_gen.py
573
3.5
4
from random import choice,randint import sys def dna_string(length): DNA="" for count in range(length): DNA+=choice("CGTA") return DNA def gen_read_file(num_reads, output_filename): f = open(output_filename, "w") read_length = randint(30,199) # Fixed length for i in range(nu...
ca085e065405c10bd6262c741886ab1447daeff6
IsauraRs/PythonInter
/Basico/Martes/tiposDeObjetos/claseDiccionarios.py
3,620
4.09375
4
###############################################DICCIONARIOS################################### #Un diccionario es una estructura de datos y un tipo de objeto en Python con características #especiales que nos permite almacenar cualquier tipo de valor como enteros, cadenas, listas, #etcétera. Además, los diccionarios...
3bef884a9f6333700646d66803cd20f9d31df0f6
qiuxiaoshuang/pythonbook_code
/python_book_code/9/car.py
1,525
3.859375
4
class Car(): def __init__(self,make,model,year): self.make = make self.model = model self.year = year self.odomater_reading=0 self.tank=0 def get_descriptive_name(self): long_time=str(self.year)+' '+self.make+' '+self.model return long_time.title() d...
5d3735e2669f28d52392209c67aebecc70f2a532
pietiep/Qt-with-Python
/tree/printTree.py
430
3.625
4
def printTree(t,l,r,level): if(l<=r): print("{}{}{}".format(level*"-",t[l],l)) #gibt es Sons? if(t[l][1]>0): for j in range(t[l][1]): l+=printTree(t,l+j+1,r,level+1) print(l, t[l][1], level) return j+1 return 0 if __name__ == "__ma...
b572d31915de1cedbbb545d5eed363e0a650ce46
chintanvadgama/Algorithms
/mergeSortedLists.py
1,183
3.59375
4
class Solution(object): def merge(self, nums1, nums2): """ Space O(m+n) :type nums1: List[int] :type m: int :type nums2: List[int] :type n: int :rtype: void Do not return anything, modify nums1 in-place instead. """ n1 = len(nums1) n2 ...
b57914fa9b67dbd459bad93b60978c0c113f87e4
mariadelmarr/Python
/dia3/compararValores.py
637
4.125
4
# number = int(input('Type the score. ')) # if number >= 90 and number <= 100: # print ('Your score is A. ') # elif number >= 80 and number <= 89: # print ('Your score is B. ') # elif number >= 70 and number <= 79: # print ('Your score is C. ') # elif number >= 60 and number <= 69: # print ('Your sc...
c24bd35a3a9241287bff9e8ccac4d0d240f40377
bowrainradio/Python_Adventure
/Day_12(Guess-the-number-game).py
1,512
4
4
import random HARD_LVL = 5 EASY_LVL = 10 def guess_number(): """Guessing one number from 1 to 100""" return random.randint(1, 101) def level_choice(): """Choosing difficulty level: hard = 5 attempts, easy = """ answer = input("Choose a difficulty. Type 'easy' or 'hard': ") if answer == "hard": ...
d317f25d3b9ff06c2f3870bed6f77479197b3834
MohammedGhafri/data-structures-and-algorithms-python
/data_structures_and_algorithms/challenges/repeated_word/repeated_word.py
2,155
3.875
4
from collections import Counter def lengthy_string(str): txt=str arr=splitFun(txt) a = arr=[x.strip(',') for x in arr] b = wordsCount(arr) c = countWords(arr) d = mostOccurrence(arr) repeated = firstRepeatedWord(arr) return a ,b ,c ,d ,repeated def mostOccurrence(arr): ...
e1cac23962d654ade60dcbc4e638c8290caefbe3
ariannasg/python3-training
/essentials/hello-string.py
4,670
4.28125
4
#! usr/bin/env python3 # Str is a fundamental built-in type (all types are classes). Everything is an object in Python 3. # Strings are immutable in python z = 'seven' print(z) print('z is {}'.format(type(z))) print('strings are objects so we can use their functions') print(z.upper()) print('can have multi-line stri...
49d212470d406e9be176848e031b3ec6dbc7d62d
matheusguerreiro/python
/Python/10 - 029 - radar eletrônico.py
427
4.0625
4
# Aula 10 (Condições em Python (if..else)) velocidade = int(input('Digite a Velocidade atual: ')) if velocidade <= 80: print('\nVocê está viajando a {}km/h, tenha uma boa viagem.'.format(velocidade)) else: multa = (velocidade - 80) * 7 print('\nVocê está viajando a {}km/h e ultrapassou a velocidade permit...
88be0a3c209303cd4a28b822efa0effef84398cb
oo89/CS100_PythonHW
/HW02.py
808
4.21875
4
# Exercise 1 print("Exercise 1") print("Type students grades in capital letters separate with a comma") grades=input() #I did this because I was learning how to input in this language. The code without the input is there too. #grades = ['A', 'A', 'A', 'A', 'A', 'B', 'A', 'C', 'A', 'B'] frequency = [grades.count...
802579db60a5ac703cff193cd6004f00916474e4
GBoshnakov/SoftUni-OOP
/Iterators and Generators/vowels.py
490
3.6875
4
class vowels: def __init__(self, text): self.text = text self.text_vowels = [el for el in self.text if el in "AEIOUYaeiouy"] self.index = 0 def __iter__(self): return self def __next__(self): if self.index == len(self.text_vowels): raise StopIteration() ...
b3e864bd7b1136b575f655958352e8093e5c5c6d
yoncharli/Python-Exercises
/ejemplo_if_else_4.py
164
3.90625
4
x = "c" y = 3 if "x" in "computer science": y = y + 5 else: y = y + 10 if x in "computer science": y = y + 20 else: y = y + 40 print (y)
58dc6f6b20c4dbef8c51f7547d3cbda6c654c42b
usako1124/teach-yourself-python
/chap11/data_field.py
283
3.609375
4
import dataclasses @dataclasses.dataclass() class Person: firstname: str lastname: str age: int = dataclasses.field(default=0, compare=False) if __name__ == '__main__': p1 = Person('太郎', '山田', 58) p2 = Person('太郎', '山田', 11) print(p1 == p2)
ffcb43756cfb49643ecb3116ee9195d3289e984a
yakubpeerzade/repo1
/List_Program/matrix_prac.py
137
3.546875
4
m=[[10,20,30],[40,50,60],[70,80,90]] for i in range (len(m)): for j in range(len(m[i])): print(m[i][j],end=' ') print()
819b8b901748db5a5311070d5a733c065c5d094d
sandhyakopparla/pythonprograms
/palindromestring.py
150
4.28125
4
string=input(("enter the string:")) if(string==string[::-1]): print("the string is palindrome") else: print("string is not a palindrome")
f1467fcdf0db194035b05ae6a657b18870c871d4
GuilhermeHenrique01/Eureka
/ex009.py
497
4.0625
4
print('{} DESAFIO 009 {}'.format('='*10, '='*15)) print('Crie uma programa que leia um numero inteiro qualquer e mostre na tela a sua tabuada') n = int(input('-Digite um numero para saber sua tabuada: ')) print(' '*20, '='*20) print(f'{n} x {1:2} = {n*1:2} \n{n} x {2:2} = {n*2:2} \n{n} x {3:2} = {n*3:2} \n{n} x {4:2}...
3976a7dc7985f56df102be87db0bb59e418f1ff8
cocagolau/NEXT_13-00_Preschool
/practice/130228/problem.py
857
3.6875
4
com_num = input("How many computers you have : ") prog = raw_input("How much each runtime of programs : ") prog_run = prog.split(',') prog_num = len(prog_run) program = [] program_sum = 0 for i in range(prog_num) : program.append(int(prog_run[i])) program.sort() ''' for com in range(com_num): if com == 0: print "...
b7cc96cfef59481bc4973bcec30370355f3bcdf9
kulvirs/concurrency-problems
/barbershop/bs.py
3,214
3.578125
4
# This implementation uses a synchronized queue to simulate the waiting room. import threading import time import random import queue MAX_CUSTOMERS = 4 # Maximum number of customers that can be in the barbershop at the same time. TOTAL_CUSTOMERS = 100 # Total number of customers that will arrive throughout t...
8e339d166fa636fbfb677dc9caeaecfb64d572eb
Silvio622/pands-problems-2020
/Lab 07 Files/labs07.04-json.py
1,327
4.34375
4
# Silvio Dunst ''' Using json module to save a data structure (Dict or List) If we want to store a more complicated data structure to a file, we should use either: a. JSON: Which will store the data structure in a human readable way. JSON is a standard way of storing objects, you will see more on this later in t...
166144807c46402c6e9e8011dfcee340d30d959a
kubicodes/100-plus-python-coding-problems
/4 - Conversions/2_celsius_to_fahrenheit.py
775
4.0625
4
""" Category 4 - Conversions Problem 2: Celsius to Fahrenheit The Problem: Take the temperature in degrees Celsius and convert it to Fahrenheit. """ """ Takes in a number as temperature in celsius. Converts and returns fahrenheit value. """ def celsiusToFahrenheit(temperature_in_celsius): assert type(temper...
6113b8fb1103cd316fa8ff11f10d104e53dd6a70
andre-williamson/tip-calculator-start
/main.py
547
4.1875
4
#If the bill was $150.00, split between 5 people, with 12% tip. #Each person should pay (150.00 / 5) * 1.12 = 33.6 print(" TIP CALCULATOR ") bill = float(input("how much was the total bill: $ :" )) tip = int(input("how much do you want to tip, 12 15 20 :")) guest = int(input("How many guest: ")) tip_as_per...
122102a1069a81715c0c5150fabbd3f28c8c9346
phriscage/coding_algorithms
/tic_tac_toe/main.py
3,845
3.921875
4
#!/usr/bin/env python3 """ TicTacToe game logic example """ import sys import uuid import datetime class TicTacToe(object): """ main class """ def __init__(self, player1, player2): """ instantiate the class """ self.game_board = self.create_game() self.player1 = player1 sel...
dbd6cc833c45463eb66bfe750caba226ba4b661c
mohanish12/useCasePythonScripts
/printDiagSqMat.py
253
3.703125
4
def print_diag(mat): n = len(mat) for i in range(n): for j in reversed(range(n)): if (i == j): print (mat[i][j]) mat1 = [[1,2,3,4], [5,6,7,8], [9,10,11,12], [13,14,15,16]] print_diag(mat1)
45068086747dcb04bedccd7fa6142c7e18153703
tanuja816/jalatechItems
/javaAssignments/List.py
773
3.875
4
#!/usr/bin/env python # coding: utf-8 # In[4]: num = [25,12,36,95,14] num # In[5]: num[0] #it will print the number corressponding to the index number # In[6]: num[6] ##coz the list containing only 4 elemets its out of range # In[ ]: # In[7]: num[2:] # it ill start from 3 element as in list index ...
03af626b44b50fd021e5e82311f41599bf45eb6b
cshintov/python
/think-python/ch15.Classes/ex1_distance.py
825
4.0625
4
''' exercise 15.1 finds the distance between two points ''' from math import sqrt class point(object): '''a point''' def distance(pointa,pointb): print pointa.x,pointb.x print pointa.y,pointb.y dist = sqrt((pointa.x-pointb.x)**2+(pointa.y-pointb.y)**2) return dist def create(): pnt = point() pnt.x =...
0b1b53c164bc0bda5001cf2b15f59d7c8acfd29c
atharvakulkarni21/python-day5
/assignment1.py
137
3.578125
4
# Assignment1 list = [0,1,2,10,4,1,0,56,2,0,1,3,0,56,0,4] list.sort() print(list) k=list.count(0) print(k) print(list[k:]+list[:k])
115f2afba7daf77ca8b404473b109aaab473e2cd
RobinDhull/The-Carpenter-s-Challenge
/Carpenter_Challange_BA.py
3,360
3.828125
4
''' author: Robin ''' # n denotes number of wooden pieces # x, y and z are the dimensions of wooden pieces # Assume all dimensions to be in metres. n = int(input("Enter the total number of wooden pieces: ")) wood = [] x, y, z = [], [], [] for i in range(n): x.append(int(input("Enter the length of piece: ")...
00842c6d1b0ac3203e0f1ae92de6291306284131
soaibsafi/project-euler-python
/019.py
2,185
4.03125
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 9 20:04:00 2020 @author: Soaib """ """" Solution 1: Using python 'datetime' package. It is the most trivial solution. We can loop through the all years and count if the weekday() is sunday(0) """ from datetime import date sundays = 0 for i in range(1901, 2001, 1): ...
307f0176ec3bfa98dd6008e1dc9226707e419e72
elitan/euler
/009/main.py
544
4.375
4
""" A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a^2 + b^2 = c^2 For example, 3^2 + 4^2 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. """ import sys import math as m def isPythagoreanTriplet(a, b, c): return m.po...
30fca3ff6d97c8748f385defa71e0f2d2f5dd018
CatWithNineLives/RoadColoringProject
/ag2.py
8,307
3.6875
4
#Determining all cycles count=[0]*8 for i in range(1,2): print("For i=%d" %i) stack=[] #python equivalent here #determine the first straight path currNode=r #receive root from main path=currNode.cnode index=currNode while(len(set(path)==len(path)) #there is no repetition in the ...
8030033789730a4ac0c4d70f881308c2a7a19bc6
DvDevelop/test
/threading.py
901
3.6875
4
import threading import time class MyThread(threading.Thread): def __init__(self, thread_id, name): threading.Thread.__init__(self) self.thread_id = thread_id self.name = name def run(self): print("Starting {0} at {1} \n".format(self.name, time.ctime(time.time()))) ...
572326d000b041836057d590138b8bc6c9e7dbc7
marleyjaffe/ChromeSyncParser
/ChromeParser.py
31,474
3.609375
4
__author__ = 'marleyjaffe' import sqlite3 as lite import argparse import os import time import glob import platform # Sets Global variables for verbosity and outFile verbosity = 3 outFile = False def ParseCommandLine(): """ Name: ParseCommandLine Description: Process and Validate the comma...
8c28f551d9fdafb0119712759e65cb0d80f9da40
Pillow3000/Pillow-Blocks
/DiceRoller.py
384
3.84375
4
def rolldie(dice, mod=None): import random dice_lst = list(range(1, int(dice) + 1)) if dice == None: print('No valid die was chosen... Defaulting to d6') dice = 6 dice_lst = list(range(1, dice + 1)) print(f'You rolled a {random.choice(dice_lst)}!') el...
ec1fb663974037b431e57ab245ea58a8d42520c4
ggirlk/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/0-add_integer.py
622
4.1875
4
#!/usr/bin/python3 """ This is the "0-add_integer" module. The 0-add_integer module supplies one function, add_integer() For example; >>> add_integer(1, 2) 3 """ def add_integer(a, b=98): """ adding 2 integers a: integer b: integer and if not specified it took 98 """ t = 0 if isinstance(a,...
0746ad2555042f24fb7ad9a76aad0f85bfe47fed
0siris7/LP3THW
/pg7.py
389
3.59375
4
tabby_cat = "\tI'm tabbed in." persian_cat = "I'm split\non a line." #escape character excercise \n backslash_cat = "I'm \\ a \\ cat." #insert backslash #prints a tabbed list fat_cat=""" I'll do a list: \t* Cat food \t* Fishies \t* Catnip\n\t* Grass """ #""" and ''' works the same way #basic printing print...
e92ba29970127bcb2a45fd5170c5f42587bf409c
Tenebrar/codebase
/projecteuler/util/conversions.py
290
3.796875
4
from typing import List def to_factoradic(num: int) -> List[int]: # https://en.wikipedia.org/wiki/Factorial_number_system result = [] div = 1 while num > 0: num, remainder = divmod(num, div) result.insert(0, remainder) div += 1 return result
1cb643de99bdb4f5e29189b65824a19cb608747d
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/hamming/bf50011723bf4bfd91f83c4c30ad9ca1.py
239
3.640625
4
def distance(left, right): if len(left) != len(right): raise ValueError("nucleotides must be of equal length") distance = 0; for i in range(len(left)): if left[i] != right[i]: distance += 1 return distance
2ff48b1d67a1c5117414edb477fb1449db9b5440
JavierVarela2000/python
/Proyecto final/regresionlineal.py
859
3.6875
4
#Regresion lineal(y=mx+b) import funciones as fun#se incluyen las funciones para el calculo def reg_lineal(X,Y):#funcion que recibe 2 matrices para calcular la regresion lineal n=len(X)#se asigna el valor de la longitud de la lista a la variable numerador = fun.sumatoria(fun.multi(X,Y))-((fun.sumatoria(X)*f...
fc2e4640c44ec4be815ebae069d71529fdbbf11c
KelvinChi/Algorithm
/sort/nodefun.py
3,613
3.84375
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- # Created by CK 2019-04-11 04:43:20 class Node: def __init__(self, value=None, left=None, right=None, father=None, level=None): self.value = value self.left = left self.right = right self.father = father self.le...