blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
386df80c796de4736103f490d20e61d9edc1c0f0
league-python-student/level0-module2-samus114
/_02_random/_4_validation/validation.py
914
3.765625
4
import random from tkinter import messagebox, Tk if __name__ == '__main__': window = Tk() window.withdraw() random_number = random.randint(1, 5) print(random_number) for i in range(10): if (random_number == 1): messagebox.showinfo('', "you can do it") elif (random_nu...
c6f7e68566feca6ef581940275ea6ca5a5a08110
kodak0803/turtle
/homework_2.1.py
263
3.796875
4
from turtle import * width(0) color_list = ['red', 'blue', 'brown', 'yellow', 'grey'] x= 0 y = 3 for c in color_list: x = x + 180 color(c) for i in range(y): forward(100) left(180 - (x / y)) y = y + 1 mainloop()
d176f868fbc033e81bd5b2fe2cdd94f786c551e4
BZAghalarov/Hackerrank-tasks
/The HackerRank Interview Preparation Kit/String Manipulation/Alternating Characters.py
752
3.90625
4
''' https://www.hackerrank.com/challenges/alternating-characters/problem?h_l=playlist&slugs%5B%5D%5B%5D=interview&slugs%5B%5D%5B%5D=interview-preparation-kit&slugs%5B%5D%5B%5D=strings ''' ''' t = input() for _ in range(t): s = raw_input() count = 0 for i in range(1,len(s)): if s[i] == s[i-1]: ...
53b078d41de0a5661bd8c5803a8a3ca6bd19792f
AndradeLaryssa/Python_Funcoes
/Mercado_funcoes.py
1,722
3.84375
4
def cadastrarCompras(clientes, mulheres, listaHomens, listaQuantidades, listaProdutos): while (True): codigo = input('Digite aqui o código do cliente: ') nome = input('Digite aqui o nome do cliente: ') sexo = input('Digite aqui o sexo do cliente[M/F]: ') clientes += 1 if sexo...
d72e5d472218ff8b359b351445ac9604db9dba82
giorgoschionas/IEEEXtreme15.0
/gamimenadentrakia.py
7,371
3.671875
4
# a simple parser for python. use get_number() and get_word() to read def parser(): while 1: data = list(input().split(' ')) for number in data: if len(number) > 0: yield(number) input_parser = parser() def get_word(): global input_parser return next(input_parse...
9f078271584e7b6ab1ccea4db8b73cc4c3ad4def
josephsurin/cp-practice
/leetcode/169.py
331
3.828125
4
""" majority element find the element that appears more than n//2 times in an array of size n """ from typing import * from collections import Counter class Solution: def majorityElement(self, nums: List[int]) -> int: d = Counter(nums) for c in d: if d[c] > len(nums)//2: ...
4887ff3b8017392411f639b799c0b3a2f08a0fd6
abrahamchang/trabajo-de-grado-2019
/Diccionarios/languages.py
766
3.515625
4
# -*- coding: utf-8 -*- """ Created on Mon Sep 23 15:45:51 2019 @author: lucia """ import pandas as pd inputCSV = pd.read_csv("./IdiomasCSV.csv") outputCSV = pd.DataFrame() def obtainFirst(string): return string.split(",")[0] outputCSV["lemma"] = inputCSV["Nombre de idioma"].apply(obtainFirst) outputCSV["po...
ee3e8e4a267b3fa4434d83fad477bfcba5b22090
vibhor-kukreja/project_flask
/app/custom/flask_redis/__init__.py
802
3.515625
4
import redis from flask import Flask class Redis: """ This class acts as a wrapper over redis library Initializing methods which are used in flask nomenclature To keep the code for initialization similar to other modules """ def __init__(self) -> None: """ This method initializ...
d950e28c6d6296e0ed159809277b9dd71c7f09e8
TareqMonwer/python_algoritms
/searching/LinearSearch/linearSearch_v1.py
217
3.75
4
arr = [1,3,4,5,6,7] item = 8 s = 0 e = len(arr) - 1 while s < e: if item == arr[s]: print('found in index {}'.format(s)) s += 1 if item != arr[s] - 1: print('Not Found!')
3931df5db17076c1e6b7eb49c56b2458494c91e2
mihaitacristian/curspython
/Lessons/liste.py
1,231
3.703125
4
################# liste ############# # a=23 # b=1 # lista=["fruct",-1,a,5,"a","b",8,9] ####lista[start:stop] # lista1=[] ####lista[start:stop:pas] # lista1.append(a) # lista1.append(a+b) # lista1.append(b) # lista1.append(lista) # # # print (lista1) # # print(lista1[::-1]) # # # print(lista1...
059a53338b5b7f6987799f80b0d248dd51436289
LukovVI/pithon-home
/12.py
1,411
3.78125
4
check = [] def numerics(n):# перевод числа в список return list(map(int, str(n))) def kaprekar_step(L):# преобразование списска в разность чисел составленных из него L = "".join(sorted(map(str, L))) return abs(int(L) - int(L[::-1])) def kaprekar_check(n):# проверка на возможность проведения операц...
07e624d53f9638cb2af2936b2e08024d504fe545
Toyqi/Project-Euler
/007.py
857
4
4
## Euler Problem 7 ''' By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? ''' #! -*- encoding: utf-8 -*- import math def isPrime(n): # an even number cant be a prime (divisible by 2) # 1 and 0 are no primes # ...
5f036c275de00fcb08fc48ef4233222d4e2514ca
jackdonnellan161/PracticePy
/projEuler/p3.py
494
3.734375
4
#! /usr/bin/env python3 #Statement: #The prime factors of 13195 are 5, 7, 13 and 29. #What is the largest prime factor of the number 600851475143 ? num = 600851475143 high = 0 def primeFactor(limit): tot = limit for ii in range(2,tot): if tot%ii == 0: tot = tot//ii print([ii,tot]) return [ii,tot] r...
0a31ed77933d9ec778df7dbc5f5c53b3776e69ad
Cimmanuel/advanced-calculator
/Calculator.py
2,417
4.09375
4
# Advanced Calculator # Author - Immanuel Kolapo """This is a quite advanced calculator as it doesn't just calculate numbers, but also supports variables""" import ply.lex as lex import ply.yacc as yacc # A list of valid tokens. lex has to know which tokens are valid and those that aren't valid tokens = ['I...
f317a42cce2b434aafbc9e7ded74e08051751447
KevinWangTHU/LeetCode
/227.py
1,034
3.578125
4
import re class Solution(object): def calculate(self, s): """ :type s: str :rtype: int """ oplist = ["+", "-", "*", "/"] s = s.replace(" ", "") for op in oplist: s = s.replace(op, " " + op + " ") s = s.split() nums = [] ops ...
cb048717516dfcaca9a453082b1b8aba533571d9
rajat27jha/Machine-Learning-Algorithms-in-Python
/Algo_K-Nearest_Neigh.py
3,306
4.03125
4
# for Euclidean dist. formula or how to calculate it see video 15 # this is the algorithm of K nearest neighbors. from math import sqrt import numpy as np # numpy has actually a built in func that calculates euclidean dist and its much faster there import matplotlib.pyplot as plt from matplotlib import style from col...
e7876a862feca94c0799ecba97a94f10a42220af
Edwardbafford/General
/python/oop/multi_level_inheritance.py
401
3.734375
4
class Animal: def __init__(self, size, weight): self.size = size self.weight = weight class Cat(Animal): def __init__(self, size, weight): super().__init__(size, weight) @staticmethod def meow(): print('Meow!') class Lion(Cat): def __init__(self): super()...
33094241cca0a591fe6c45638f0bf6a9f11ca402
RAmruthaVignesh/PythonHacks
/MiscPrograms/coinflip_result.py
866
4
4
def coinflip(n): '''This function takes the input of number of coins tossed and gives the output of all the possible results of the toss ''' flip = ['h' , 't'] #output of 1 coss toss if n>0: #checks if the input is valid print "Total number of coins is" , n print "Total possible outp...
3a71c82debdbc4ce3add40eeb273c7ad34e810bf
jiriVFX/data_structures_and_algorithms
/interview_problems/palindrome_linked_list.py
1,734
4.09375
4
# https://leetcode.com/problems/palindrome-linked-list/ # Given the head of a singly linked list, return true if it is a palindrome. # Solution 1 # O(2n) time complexity, O(n) space complexity class Solution(object): def is_palindrome(self, head): """ :type head: ListNode :rtype: bool ...
97143a9b3c5a29a5124f1a66e6ccb263648737e5
Soyoung-Yoon/for_Python
/sequence_ex01.py
633
3.515625
4
# 최대값 구하기 # 다음 조건에 따라 값을 구하는 프로그램을 작성하여 보자 # - 9개의 서로 다른 자연수가 한 줄에 공백으로 구분되어 주어진다 # - 9개의 값 중 최대값을 찾고 # 그 값이 몇 번째 수인지 구하여 출력한다 # - 첫째 줄에 최대값을 출력하고, # 둘째 줄에 최대값이 몇 번째 수인지 출력한다 # 예) # 3 29 38 12 57 74 40 85 61 # 85 # 8 a = list(map(int, input().split())) print(a) maxValue = max(a) maxIndex = a.index(max...
a66f0a5439a28c7472a57fe8bc1f01d68fd1e83b
mukeshrock7897/List-Programs
/List Programs/15__Swap First To Last in List.py
206
4.03125
4
a=[] element=int(input("Enter the Number of Element::")) for x in range(element): b=int(input("Enter The Element::")) a.append(b) temp=a[0] a[0]=a[element-1] a[element-1]=temp print("New List::",a)
d56f3777436d29eefc1f92ffeaa903f184a695e9
southbambird/sandbox
/book/effective_python/chap4/item30.py
938
3.515625
4
def index_words(text): result = [] if text: result.append(0) for index, letter in enumerate(text): if letter == ' ': result.append(index + 1) return result address = 'Four score and seven years ago...' result = index_words(address) print(result[:10]) def index_words_iter(te...
eb5ecfeaa8dea9b3156d4b0094780ecc2cdbb33e
trojanosall/Python_Practice
/Basic_Part_1/Solved/Exercise_60.py
211
4.34375
4
# Write a Python program to calculate the hypotenuse of a right angled triangle. import math def hypotenuse_calculator(a, b): c = math.sqrt(a * a + b * b) return c print(hypotenuse_calculator(3, 4))
fbbaba375d312cee42b58e2656629a5b2fef79a5
simgroenewald/ExternalDataSourcesOutput
/RegForm.py
754
4.25
4
# Compulsory Task 2 # This allows the user to enter the number of students registering numStudents = input ("How many students will be registering: ") numStudents = int(numStudents) # Casts the value to in integer RegForm = open("RegForm.txt","w") # Creates the file that it will be stored in allId = "" # Declare...
656ba50a2384ceb2762a58a71528c211983cd9ae
Ritesh-krr/hacktoberfest2020
/selection_sort.py
401
3.921875
4
def selection_sort(lst): for index in range(len(lst)): min_index = index for j in range( index +1, len(lst)): if lst[min_index] > lst[j]: min_index = j lst[index], lst[min_index] = lst[min_index], lst[index] l = [119,12,321,645,130,121,421,127] ...
54a6cf3769b43fa37664e7c5926ce95d1adbecad
ShiJingChao/Python-
/PythonStart/0722Python/用户登录.py
467
3.5625
4
user = "admin" pwd = "000000" auth_code = "2346" is_user = input("请输入用户名:") if is_user != user: print("用户名错误!") else: is_pwd = input("请输入密码:") if is_pwd != pwd: print("密码错误") else: print("验证码为:2346") is_auth = input("请输入验证码:") if is_auth != auth_code: print("...
5163bd9904329a0d1108eaaee7b80bb74e082114
TheJoeCollier/cpsc128
/code/python3/playlist_shuffle.py
253
3.875
4
# playlist_shuffle.py import random nsongs = eval(input("How many songs are in the playlist?")) playlist=[] while len(playlist) < nsongs: song = random.randint(1,nsongs) if song not in playlist: playlist.append(song) print(playlist)
ca7f0ce2c14001b27036a56f0c79c11fdb9018bf
vasu-kukkapalli/python_git
/Udemy/prog_Range_Sum.py
201
4.09375
4
x= range(1,26,1) print(list(x)) my_sum=0 my_product=1 for i in range(1,26): my_sum=my_sum+i my_product=my_product*i print(f'Sum of list is :{my_sum}') print(f'Sum of list is :{my_product}')
481496cc87afa4fed4d9621535d0e3efb1679488
EduardoAlbert/python-exercises
/Mundo 1 - Fundamentos/028-035 Condições/ex030.py
155
3.625
4
num = int(input('\033[7;30mDigite um Nº inteiro:')) if num % 2 == 0: print('\033[33mSeu Nº é PAR!') else: print('\033[36mSeu Nº é ÍMPAR!')
9858017ed80aa63561be68f63dc08837d2e98622
Hovden/tomviz
/tomviz/python/Shift_Stack_Uniformly.py
784
3.515625
4
#Shift all data uniformly (it is a rolling shift) # #developed as part of the tomviz project (www.tomviz.com) def transform_scalars(dataset): from tomviz import utils import numpy as np #----USER SPECIFIED VARIABLES-----# #SHIFT = [0,0,0] #Specify the shifts (x,y,z) applied to data ###SHIFT### ...
1ac4c63dcd4c41bb4a01b2f1bad9435f9043fd46
Amberttt/Python3-Test
/PythonNumber.py
17,942
4.1875
4
# Python3 数字(Number) # Python 数字数据类型用于存储数值。 # 数据类型是不允许改变的,这就意味着如果改变数字数据类型的值,将重新分配内存空间。 # 以下实例在变量赋值时 Number 对象将被创建: # var1 = 1 # var2 = 10 # 您也可以使用del语句删除一些数字对象的引用。 # del语句的语法是: # del var1[,var2[,var3[....,varN]]]] # 您可以通过使用del语句删除单个或多个对象的引用,例如: # del var # del var_a, var_b # Python 支持三种不同的数值类型: # 整型(Int) - 通常被称为...
141893167d67253701c5f42b9dc9cc2edeb1cf96
JaiJun/Codewar
/7 kyu/Sum of Cubes.py
488
4.28125
4
""" Write a function that takes a positive integer n, sums all the cubed values from 1 to n, and returns that sum. Assume that the input n will always be a positive integer. I think best solution: def sum_cubes(n): return sum(i**3 for i in range(0,n+1)) """ def sum_cubes(n): sum ...
348c1beecb36f440b2acef9b84a26558c1408868
thewinterKnight/Python
/dsa/miscellaneous/sum_triplets.py
1,071
3.65625
4
def fetch_sum_triplets(arr, req_sum): n = len(arr) s = {} # for i in range(0, n): # if arr[i] in s.keys(): # s[arr[i]] += 1 # else: # s[arr[i]] = 1 triplets_count = 0 triplets = set() for i in range(0, n-1): tertiary = arr[i] for j in range(i+1, n): residual = req_sum - (tertiary + arr[j]) ...
0ae37ec1a64ba3ab3258df55e3cc41738d7bda73
reedhop24/python-labs
/linked_list_reverse/index.py
929
4.09375
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def append(self, data): new_node = Node(data) if self.head == None: self.head = new_node else: pointer = se...
ecbbe819c04e1c58515373d9f3b7521989c6c7eb
jedpalmer/PythonStuff
/python_stuff/ex18.py
343
3.515625
4
def print_two(*args): arg1, arg2 = args print "arg1: %r, arg2: %r" %(arg1, arg2) def print_two_again(arg1, arg2): print "arg1: %r, arg2: %r" %(arg1, arg2) def print_one(arg2): print "arg2: %r" % arg2 def print_none(): print "I got nothin'." print_two('Jed','Palmer') print_two_again("Jed","Palmer") print_one...
a1fb12f592717961642de5b11d1b380aed842fe4
SudPY/Profit-or-Loss
/Profit or Loss.py
631
3.875
4
def Profit(costPrice, sellingPrice) : profit = (sellingPrice - costPrice) return profit def Loss(costPrice, sellingPrice) : loss = (costPrice - sellingPrice) return loss if __name__ == "__main__": costPrice = int(input("Please enter the cost price : ")) sellingPrice = int(i...
a676f839258dc2aef880661d9d0be03826151102
superMC5657/leetcode-py
/help_others/zy/1.py
1,001
3.84375
4
# -*- coding: utf-8 -*- # !@time: 2021/4/8 2:51 下午 # !@author: superMC @email: 18758266469@163.com # !@fileName: 1.py # 给定一棵二叉搜索树,请找出其中第k大的节点。 # # 示例 1: # # 输入: root = [3,1,4,null,2], k = 1 # 3 # / \ # 1 4 # \ #   2 # 输出: 4 # 示例 2: # # 输入: root = [5,3,6,2,4,null,null,1], k = 3 # 5 # / \ # ...
04634a5ec1b5f4f0848d9f71d56be1fccfe9ec1f
KenjaminButton/dataStructuresAndAlgorithms
/Chapter1/P-1.31.py
2,898
4.4375
4
# -*- coding: utf-8 -*- # Write a Python program that can “make change.” # Your program should take two numbers as input, one that is a monetary # amount charged and the other that is a monetary amount given. It should # then return the number of each kind of bill and coin to give back as # change for the difference b...
6005cbe12b5118fe4d8c886ae2bd79efb922a030
romainpascual/pentomino
/constraint_programming.py
6,685
4.03125
4
#!/usr/bin/env python3 # 2018 - Ecole Centrale Supélec # Les élèves du cours d'optimisation et leur enseignant Christoph Dürr import sys class constraint_program: """Implements a basic constraint programming solver with binary constraints. Variables names can be integers, strings, any hashable object. ...
19e87b1066db708deaf89800569a7c46de91868a
keshprad/Algorithms
/QuickSort/run_test.py
1,555
3.5625
4
import time as t from QuickSort import Comparisons def runComparisons(fileIn): print(fileIn + ":") fileIn = "testCases/" + fileIn compare = Comparisons.comparisonCounter() compare.readFile(fileIn) # Leftmost pivot compare.reset() print("using leftmost pivot:") print("\tinput = " + str...
db78df9662910c144aa836758cd0322395eb426a
rravicha/PyRep
/mohan_pgm/Python-Sample/Python-Class_MultipleInheritance.py
355
3.625
4
class cname: def __init__(self,name): self.name = name def fun(self): print("FirstParent", self.name) class cname1: def __init__(self,age): self.age = age def fun(self): print("SecondParent",self.age) class cname2(cname1,cname): pass ## def fun(self): ## print("my final c...
950873b411b00eb123f32774a03b8fa0dc66c9ce
MightyPhoenix/python-assgn
/Python Assingments/assgn4/ass4.2.py
767
3.75
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 12 13:59:26 2019 @author: agnib """ TOP = -1 stack = [] while(True): print("----STACK OPERATIONS-----\n1.Display\n2.Peek\n3.Pop\n4.Push") choice=int(input("Enter Choice : ")) if(choice!=00): if(choice==1): print(stack) elif(choic...
c7c2dae8b6d974ffe5a7a84b2a62b99bed09e09a
kindleflow/movie-trailer-website
/project/media.py
1,879
3.5625
4
""" author: H. Kin Fung dates: 20140406,0504 """ import urllib import json from string import replace from re import sub class Movie(): """ construct a movie instance to contain info. of the movie including its title, brief storyline, poster image url, and url of trailer on youtube ""...
85995ae3543db5637d938c087720caa656d3b51d
IvannikovG/Python-cheatsheet
/python/strings.py
413
3.71875
4
# message = 'A: Valar Morgulis! B: Valar Dahaeris..' # print(message) # print(len(message)) # print(message[0:].lower()) # print(message.count('A')) # #string.find -> shows from where the searched str starts # x = message.replace('A:', 'S:') # print(x) greeting = 'Cyka' name = 'Michael' beleidigung = 'Gandon, eb tv...
74b7e0dbe649c8e1d7562722e1c6b25e96c158e9
nishantchaudhary12/w3resource_solutions_python
/Tuple/reverseTuple.py
374
4.34375
4
#Write a Python program to reverse a tuple. def reverse_tuple(tup): tup = tuple(reversed(tup)) print(tup) def reverse_tup(tup): sorted_list = list() for each in range(len(tup)-1, -1, -1): sorted_list.append(tup[each]) print(tuple(sorted_list)) def main(): tup = (1, 2, 3, 4, 5, 6, 7...
5f96a796fb9280fd974f3fb5315ffc4262c09942
MADHAV180699/MAP-REDUCE-PYTHON
/part4.py
1,771
4.03125
4
from mrjob.job import MRJob from mrjob.step import MRStep import csv """takes as input a CSV file containing comma separated words and outputs for each word the lines that the word appears in.""" def csv_readline(line): """Given a sting CSV line, return a list of strings.""" for row in csv.reader([line]): ...
ddb982dec6b4cb17786b6320a5ccef2c0b6e76aa
jroper1130/Final-Python-Drill-File-transfer-
/FInalPythonDrillv2.py
3,410
3.625
4
import sqlite3 from tkinter import * from tkinter import filedialog import tkinter as tk import datetime from datetime import datetime, timedelta import os import shutil databaseName = 'last_check.sqlite' #make table def datetime_tbl(): conn = sqlite3.connect(databaseName) c = conn.cursor() c...
7916d2271e8945d51c8a6c2ada41c027e2e9a4eb
5l1v3r1/Python-Advanced
/Multithreading/custom_thread.py
780
4.0625
4
import threading import time class AsyncWrite(threading.Thread): def __init__(self,text,out): threading.Thread.__init__(self) self.text=text self.out=out def run(self): f = open(self.out,"a") f.write(self.text+'\n') f.close() time.sleep(2) pr...
cb2f75be29d24fb441430535a72df1f65e2ad5fe
tgtn007/DSAinPython
/Projects/project1_UnscrambleCSProblems/Task2.py
1,258
4.15625
4
""" Read file into texts and calls. It's ok if you don't understand how to read files """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) # Creating a dictionary to calculate how ...
5d08e324dfa82bf0fd12662ec1268ef6118ba2ad
cobergmann/project_x
/project_x/lib.py
152
3.59375
4
def try_me(): name = input('What is your name? ') output = f"""Your name starts with {name[0]} and ends with {name[-1]}.""" return output
7d13b49b53f8d8db90e590feb2a43b893cc2b360
davidzemancz/GraphIt
/GraphIt/BinaryTree.py
3,528
3.9375
4
class TreeNode: def __init__(self, key = 0, data = None): self.key = key self.data = data self.left = None self.right = None def get_left(self): return self.left if self.left is not None else TreeNode() def get_right(self): return self.right if self.right ...
19a336b4eea25f5270deb70687eb1fc65e7421a0
raziyeaydin/Python
/kesir_islem.py
1,480
3.703125
4
# -*- coding: cp1254 -*- class Kesiryap(): def __init__(self): self.pay1=0 self.payda1=0 self.pay2=0 self.payda2=0 def yap(self): self.pay1=input("pay giriniz: ") self.payda1=input("payday girin: ") print "yazdnz ilk kesir...." print self...
c6d1ab3b01d5dfd3b4869d655d0eaf31c659f096
jinammaheta/python
/practicals/19.py
106
4.125
4
s=input("Enter The String\n") l=s.split(" ") print("Number of words in the string is:{}".format(len(l)))
ef66f451d7c3ac2eaee9de429ff0e0e2a014a6f7
atulanandnitt/questionsBank
/stream/find_median_in_a_stream.py
351
3.703125
4
# -*- coding: utf-8 -*- """ Created on Tue Jul 10 21:26:43 2018 @author: atanand """ #code def find_median_in_a_stream(mean,i,x): newMean = ( (mean * i) + x) /(i+1) return int(newMean) t= int(input()) mean =0 for i in range(t): x=int(input()) mean=find_median_in_a_stream(m...
b1992d3b155ffc969efb0e4464958a5785d74af9
jmnels/Astar-with-graphics
/pygameAstarCombined.py
8,537
3.59375
4
import math import sys import random import time import pygame import tkinter as tk obstacles = [] short_path = [] explored = [] class Node(): """Start Pathfinding""" def __init__(self, parent=None, position=None): self.parent = parent self.position = position self.g ...
744293b21464cfeae374b0891a162dc868c61a0d
irevilak7/POO
/WinForms.py
828
3.8125
4
import tkinter class Forms: def createWindow(self): self.window = tkinter.Tk() self.window.title("Demo Window") self.window.geometry("500x500+100+200") self.lbl01 = tkinter.Label(self.window, text="Hola Mundo!") self.lbl01.grid(column=0, row=0) ...
090a87e5466d9b96d88ccd7eeb82d87b4f60ef77
shaibaz166/assingment
/SAE assingments/checking holiday using tuple.py
264
4.03125
4
#WAP to take an ip from a user &tell whether its present or not in holiday n=int(input('enter a date-')) h=(5,16,27) for each in h: if n not in h: print('NO HOLIDAY SORRY') break else: print('holiday') break
3cf734af1b0d15d0359ef6fbefa13f39e77c7093
msurrago/ISU-CS
/cs303/gcd.py
437
3.984375
4
#!/usr/bin/env python3 import sys def gcd(a,b): if b==0: print("Error: b cannot be zero") r=a%b if r==0: return b a=b b=r return gcd(a,b) if __name__ == "__main__": args = sys.argv if len(args)<3 or not args[1].isdigit() or not args[2].isdigit(): print("Usage: ...
fa8991b71926a61fd19994df65955ec7e6f6e2dc
kxF1205/some-tools-for-computer-vision
/rename.py
557
3.78125
4
#you can rename the file after scaping some images from website import os try: fname=input("Please insert the name for the directory:") #this name is for the directory where you use to save the images oldpath = os.path.join(os.getcwd(),fname) files = os.listdir(oldpath) except: print("Please chec...
cdc05de3ecfcc35f59a31d7f824a9e5a49f0ad8d
Marek-Be/LCA
/LCA.py
1,840
3.59375
4
#Node object for our binary tree. graph = {} #Checks if data is in given tree def getAllParents(graphList, node): parents = [] for i in range(len(graphList)): if (node in graphList[i][1]): parents.append(graphList[i][0]) return parents def checkTwoLists(list1,list2): fo...
80eed917263bd5f9fdc227cf7784ae66f21e423e
953250587/leetcode-python
/ReverseOnlyLetters_917.py
1,546
4.03125
4
""" Given a string S, return the "reversed" string where all characters that are not a letter stay in the same place, and all letters reverse their positions. Example 1: Input: "ab-cd" Output: "dc-ba" Example 2: Input: "a-bC-dEf-ghIj" Output: "j-Ih-gfE-dCba" Example 3: Input: "Test1ng-Leet=code-Q!" Output: "Qedo1...
389f323067e6058235ed23a30e18149b205b7c1d
Melj16/Jeopardy-Game
/scoreboard.py
217
3.59375
4
#!/usr/bin/python # scoreboard.py '''class definition for score keeper''' __author__ = "Melissa Jiang" __version__ = "1.0" class Score(object): score = 0 def change_score(self): Score.score += int(self)
d8f69572008f46fd2c9fee496eb7e3770113ddf5
qmnguyenw/python_py4e
/geeksforgeeks/python/python_all/11_5.py
4,490
4.34375
4
Python program to print number of bits to store an integer and also the number in Binary format Given an integer, the task is to write a Python program to print the number of bits to store that integer and also print the same number in Binary format. **Example:** > **Input:** n = 10 > > **Output:** ...
3b473b276485f302a826621a6c61ac6b20e66aa9
WhiteLie1/PycharmProjects
/alex_python/day4/生成器并行.py
1,347
3.5
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019/2/25 19:13 # @Author : chenxin # @Site : # @File : 生成器并行.py # @Software: PyCharm ''' import time def consumer(name): print('%s 准备吃包子了!'%name) while True: baozi = yield print('包子[%s]来了,被[%s]吃了'%(baozi,name)) c=consumer('chenxin') c.__...
bceb4060029f4c84663e16d4d488c95b57698123
bes-1/lessons_python
/dz_2_4_berezin.py
435
3.546875
4
enter_str = input('Введите строку из нескольких слов через пробел: ') list_str = enter_str.split() enter = '\n' for i in range(len(list_str)): if len(list_str[i]) > 10: print(f"Значение {i + 1} слова больше 10 символов, первые 10 символов = {list_str[i][:10]}") else: print(f"Значение {i + 1} сло...
2ac90c818f32e524914ca38e80007afebd7b247b
brianchiang-tw/leetcode
/No_1367_Linked List in Binary Tree/linked_list_in_binary_tree_by_dfs_and_string.py
4,623
4.15625
4
''' Description: Given a binary tree root and a linked list with head as the first node. Return True if all the elements in the linked list starting from the head correspond to some downward path connected in the binary tree otherwise return False. In this context downward path means a path that starts at some nod...
956564a660a4836604c96b700da45057a953012b
cao280856020/python_sort
/sort/ShellSort.py
369
3.609375
4
array = [6,3,4,1,2,0,5,8,9] def shellSort(): h=1; while h<=len(array): h=3*h+1 while h>0: for out in range(h,len(array)): temp=array[out] i=out while i>h-1 and array[i-h]>temp: array[i]=array[i-h] i-=h array[i]...
d6a89e3b58a5f68f8ea751e2e3cb31f00551a316
wenbu/bloodborne-bg
/actor/actor.py
617
3.609375
4
from board import MapSpace class Actor: """Represents an entity that can move around on the board and has HP, etc.""" def __init__(self, position: MapSpace, max_hp: int): self.position = position self._max_hp = max_hp self._current_hp = max_hp def move(self, new_position...
b9332153f2232a3c62a074c14e470d0250755451
davidthaler/SimpleTree
/simple_tree/simple_tree.py
8,613
3.59375
4
''' SimpleTree implements a base class for decision tree models. ClassificationTree is a single-output binary classifier for 0-1 labels that minimizes Gini impurity. RegressionTree if a single-output regression model that minimizes mean squared error or, equivalently, residual sum of squares. author: David Thaler date...
aa81230c6bf2b9c7f1835c950b2fb08e1583f0b2
JeanBilheux/python_101
/exercises/Modern python tips and tricks/classes.py
9,291
3.921875
4
"""Class exercises""" from calendar import monthrange from datetime import date from functools import total_ordering from math import sqrt class Point(object): """Three-dimensional point.""" def __init__(self, x, y, z): self.x = x self.y = y self.z = z @property def magnitud...
862e306a871552f9ff7aa67be3704a993099276e
YuliyaGerner/myproject
/test4.py
371
3.734375
4
class Flower(object): def factory (type): if type == "Poppy": return Poppy() if type == "Rose": return Rose() factory = staticmethod(factory) class Poppy(Flower): def die(self): print("Poppy dying.") class Rose(Flower): def die(self): print("Rose d...
3ec0513e8562bf2c92c50de1f1d0b45b2f7174b9
x89846394/280201032
/lab4/example3.py
97
3.53125
4
nums = [8, 60, 43, 55, 25, 134, 1] total = 0 for number in nums: total += number print(total)
318e22c5beff30073c88c8697b124d5db0a1e029
LuisManuelMendez/LuisMendez
/Ruffini Grado 5,4,3.py
2,508
3.6875
4
# -*- coding: utf-8 -*- """ Created on Wed Jul 14 06:14:52 2021 @author: Luis Manuel Méndez """ """ # RUFFINI de Grado 5, 4 ó 3. # aX^5 + bX^4 + cX^3 + dX^2 + eX + f = 0 """ print("") print("") print("Autor: Luis Manuel Méndez") print("") print(" INGRESA LAS VARIABLES DE TU ECUACIÓN") print("") print("...
f73ce250c7bcedd080721fac2fdd42c9acb27ee0
vishalcc/euler
/euler 20.py
153
3.546875
4
a=1 for i in range(2,100): a*=i def getsum(a,sum=0): if(a==0): print(sum) else: sum+=a%10 getsum(a//10,sum) getsum(a)
bb06ba0dfc9620dcf9c7a9633da380cc0d3a61b1
Philex5/codingPractice
/DrasticPlan/maxProfit.py
1,517
3.75
4
""" 买卖股票的最佳时机 给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。 如果你最多只允许完成一笔交易(即买入和卖出一支股票),设计一个算法来计算你所能获取的最大利润。 注意你不能在买入股票前卖出股票。 示例 1: 输入: [7,1,5,3,6,4] 输出: 5 解释: 在第 2 天(股票价格 = 1)的时候买入,在第 5 天(股票价格 = 6)的时候卖出,最大利润 = 6-1 = 5 。 注意利润不能是 7-1 = 6, 因为卖出价格需要大于买入价格。 示例 2: 输入: [7,6,4,3,1] 输出: 0 解释: 在这种情况下, 没有交易完成, 所以最大利润为 0。 """ import...
6eafaef7d3926b73fd8d739d237b3c3fa3cbdfe8
Zetinator/cracking_the_coding_interview
/python/zero_matrix.py
692
3.78125
4
"""1.8 Zero Matrix: Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column are set to O """ def zero_matrix(matrix: list)-> list: # deep copy of matrix def zero_row(index): for j in range(len(matrix)): tmp[index][j] = 0 def zero_column(index): ...
41be6634145090b65d36145e71893f9210417e9a
rpryzant/code-doodles
/purely_random/tictactoe.py
1,938
4.03125
4
from random import choice from sys import argv # helper function to quickly generate a game's worth of coordinates def initAvailable(): return [(x, y) for x in range(3) for y in range(3)] # make a move for a player, given the available board spots def makeMove(player, board, available): # if there aren't any ...
afea2c1859eb54e7eacfc1a9fe674ef92069a25a
ws3109/Leetcode
/Python/73. Set Matrix Zeroes/set_zeros.py
898
3.546875
4
class Solution: def setZeroes(self, matrix): """ :type matrix: List[List[int]] :rtype: void Do not return anything, modify matrix in-place instead. """ if not matrix or not matrix[0]: return row_0_zero = 0 in matrix[0] col_0_zero = 0 in [row[0] for...
5fec4da0a51a47648f9e025e47300528db4045cf
111110100/my-leetcode-codewars-hackerrank-submissions
/hackerrank/minMaxSum.py
141
3.640625
4
def minMaxSum(arr): res = [sum(arr) - arr[i] for i in range(len(arr))] print(f'{min(res)} {max(res)}') print(minMaxSum([1,2,3,4,5]))
ac7a71ee5e15b05917e17413db448500ee7779e0
boonwj/adventofcode2019
/day02/intcode.py
2,242
4.03125
4
""" This creates program that executes `intcode` programs used in Santa's space shuttle. Intcode program overview: - A list of comma seperated integers - Using the following opcodes to indicate operations - 1: Sum values of next 2 index's values, total stored in position indiciated by 3rd integer. - 2: Multiply ...
986b4bfc658beebe4a232dbc2988711a04cb8630
futureUnsure/AI-CS561
/Mancala/Testcases/HW2 test cases+grading scripts/hw2GradingScript_log.py
1,336
3.546875
4
#Siddharth Jain #Grading script to compare traverse log import sys f = open(sys.argv[1]) g = open(sys.argv[2]) desiredLines = [] actualLines = [] for line in f: desiredLines.append(line.strip()) f.close() for line in g: actualLines.append(line.strip()) g.close() incorrect = 0 total = l...
81c86097e66c2eaef8bd78af254da636f202ffed
Hugo-Leyva/Python_Projects
/python/EV47_lista_append.py
125
3.828125
4
lista=[] for x in range (5): valor=int(input("Ingresa un valor entero: ")) lista.append(valor) print(lista)
171a7fe6533ec9e41cc840d8369b42640fb0f69a
shweta1122/Data-Structures
/StringManipulation.py
190
3.84375
4
list1=['A', 'app','a', 'd', 'ke', 'th', 'doc', 'awa'] list2=list(reversed(['y','tor','e','eps','ay',' ','le','n'])) print(" ".join(list(map(lambda x : ''.join(x) ,list(zip(list1,list2))))))
160b1b4f7e9641c05b352b48114dd63b1624d535
few2net/ai_camp_python
/example_9_Break_loop.py
188
3.890625
4
x = 0 while(x < 10): if(x % 2 != 0): x = x + 1 break print(x) x = x +1 print("***********") x = 0 while(x < 10): if(x % 2 != 0): x = x + 1 continue print(x) x = x +1
b6934c1a29a3bdd13b2344a848886834918a70b4
DmitrTRC/Training-1
/Lesson_2/qest.py
508
4.15625
4
name = str(input("Enter Your Name: ")) print(f"{name} you are stuck at work") while True: print(" You are still working and suddenly you you saw a ghost, Now you have two options") print("1.Run. 2.Jump from the window") answer = input("Choose 1 or 2: ") if answer == '1': print("You did it") ...
dac216d1a0da7868060382b6fb80352bf2bff673
Leshy4/CS-1-Principles
/PYTHON HW/Src in Visual Studios PYTHON/PythonHW3/PYTHON_HW3/PYTHON_HW3.py
1,656
3.8125
4
'''----------------#Problem 5---------------------''' colors = ['Red', 'Black', 'White'] cars = ['Chevrolet', 'Ford', 'Cadillac', 'GMC'] for x in colors: for y in cars: print(x, y) '''----------------#Problem 4---------------------''' FruitInventory = {'Apples' : 7, 'Bananas' : 10, 'Pears' ...
db35ce87ef55f140b6f01ea1abb8912be266812e
Nancy027/ds
/Lesson7b.py
395
3.875
4
# functions with/without parameters # functions that return. def addition(): # without params x = 7 y = 8 answer = x + y print('You total is ', answer) addition() addition() #=================================== # with params def addition2(x, y): answer = x + y print('Your 2nd total is ', ans...
5244272433e6a46d91a0c245cf9678e5949715a7
alexmanul/python-first-touch
/loftblog/introduction/lesson06/IsPrime.py
293
3.984375
4
def isPrime(a): divider = 2 while a % divider != 0: divider += 1 if divider == a: print(a, ' - простое число') else: print(a, '- составное число') isPrime(3) isPrime(5) isPrime(7) isPrime(10) isPrime(18) isPrime(25)
13653a744017303d472e5612b1fd4d1b423001e3
gydmercy/CodingInterviews
/12_RectCover.py
474
3.90625
4
# -*- coding:utf-8 -*- """ 我们可以用2*1的小矩形横着或者竖着去覆盖更大的矩形。 请问用n个2*1的小矩形无重叠地覆盖一个2*n的大矩形,总共有多少种方法? """ class Solution: def rectCover(self, number): if number < 3: return number ele1, ele2 = 1, 2 for i in range(3, number + 1): elei = ele1 + ele2 ele1 = ele2...
2380f33ffbb896013f99e0a3470712c6f9ed8772
learn21cn/StudyInUdacity
/DeepLearning/NeuralNetworks/gradient-descent/backpropnew.py
7,578
3.765625
4
# 反向传播 #%% import numpy as np import pandas as pd import os # 注意这里是notebook的工作目录 np.random.seed(21) cwd = os.getcwd() print(cwd) # 如果读不出来,添加路径 # admissions = pd.read_csv(cwd+'\\gradient-descent\\test.csv') admissions = pd.read_csv('./gradient-descent/test.csv') print(admissions) #%% # 数据预处理 # Make dummy variables fo...
87773df870c0fdeef63c277062b18a27da466521
jjoyson/Operating-Systems-CS450
/xv6OS-master/python/src/2_dance_mixer.py
6,730
3.5625
4
#HOW TO RUN: change variables if wanted - lines 12-13 - and run without arguments from threading import Thread, Semaphore from time import sleep import sys from collections import deque # Thread safe print printf = lambda x: sys.stdout.write("%s\n" % x) ## Main setup n_leaders = 2 n_followers = 5 ## ## Advanced set...
902c58e8131dcd6cea3adebd6c095ddb64cb8c1a
lonesloane/Python-Snippets
/objects/Factory.py
1,847
3.828125
4
class Card(object): """A standard playing card for Blackjack.""" def __init__(self, r, s): self.rank, self.suit = r, s self.pval = r def __str__(self): return "%2d%s" % (self.rank, self.suit) def get_hard_value(self): return self.pval def get_soft_value(self): ...
851a09badef5b3808285c6dd5cd4eb31a88d9f3d
MadSkittles/leetcode
/324.py
304
3.734375
4
class Solution: def wiggleSort(self, nums): nums.sort() half = len(nums[::2]) nums[::2], nums[1::2] = nums[:half][::-1], nums[half:][::-1] if __name__ == '__main__': solution = Solution() l = [1, 1, 2, 1, 2, 2, 1] solution.wiggleSort(l) print(l)
780eba26e3ed76f1aee751675f3f09cdd7badefa
biam05/FPRO_MIEIC
/exercicios/RE04 Conditionals and Iteration/concatenate.py
928
3.765625
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 17 22:00:19 2018 @author: biam05 """ # # DESCRIPTION of exercise 5: # # Write a program that, given two numbers n1 and n2 provided by the user # (each one in a different input() statement) produces a new number result # from the concatenation of both of them, in...
c6fae47eb488a881ad33b8112670af7ad1227702
Jaysparkexel/DP-1
/problem1.py
1,615
3.625
4
// Time Complexity : O(nlogn) // Space Complexity : O(n) // Did this code successfully run on Leetcode : No // Any problem you faced while coding this : # Brute force solution is missing some test cases. Wasn't able to find dynamic algorithm. // Your code here along with comments explaining your approach class So...
5d5b709443271b6bf19b1d6caf09ad9c6fbeb757
woshiZS/Snake-Python-tutorial-
/Chapter7/makeAlbum.py
490
3.828125
4
def make_album(artist,title,song_nums = None): info={'artist':artist,'title':title} if song_nums: info['number_of_songs']=song_nums return info print(make_album('Jay Chou','QiLixiang')) print(make_album('Justin Biber','Baby',10)) while True: art = input("Please Enter an artist's name.Or q to q...
330e1c1d0767a8045cbd1c3020bc3023f7d847ad
longLiveData/Practice
/python/20190913-SnakeGame/snake/game.py
6,666
3.609375
4
'''A simple game development API for educational purposes. the game module was developed for educational purposes to provide a a simple game development API to students with no prior knowledge of TkInter or TK/TCL. It includes wrapper for tkinter.Tk and tkinter.Canvas to ease their use for the purposes of game develop...
6fb5b5f5e10673c061144cdc1679310fb9ac4b7a
nikolata/LeetCodeTasks
/reverse_integer.py
545
3.703125
4
class Solution(object): def reverse(self, x): """ :type x: int :rtype: int """ x = str(x) is_negative = False if x.count('-') == 1: is_negative = True x = x.replace('-', '') x = x[::-1] if len(x) != 1: while ...
beb824ba207658edf4465f1822e93e1c35f1900d
EngelsZ10/ProblemasParaPracticar
/Cracking interview/1/main.py
1,031
3.625
4
def cuanto_sale(char, string): # funcion que cuenta cuantas veces un caracter char aparece en un string y lo borra count = 0 i = 0 while i < len(string): if char == string[i]: count += 1 # borra char de string cuando lo encuentra string = string[0:i] + string[...
65f52680e24d78a5904ba2ff3e7926e87c203c44
nsky80/competitive_programming
/Hackerrank/Archive 2019/Classes Dealing with Complex Numbers.py
4,201
3.890625
4
# import math # # # # class Complex(object): # # def __init__(self, real, imaginary): # # self.real = real # # self.imaginary = imaginary # # # # def __add__(self, no): # # a, b = str(no).split('+') # # b = b[:-1] # # a, b = float(a), float(b) # # res = (a+self.real, b+self.imaginary) # # re...