blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
07e215d9b5600c3d700f224fc2b61524dbd591c2
ZacJoffe/crackme-scripts
/save_scooby.py
446
3.625
4
#!/usr/bin/env python3 import os cwd = os.getcwd() # cwd = cwd.replace("/", "$") newStr = "" for char in cwd: if char == "/": char = "$" else: if ord(char) < ord('a') or ord('z') < ord(char): if ord('@') < ord(char) and ord(char) < ord('['): char = chr(ord(char) +...
987c7587fafe205422aea44fb11a6a26b7d46880
Bal-Mukund/openCV
/cartoon.py
1,029
3.609375
4
import cv2 def nothing(x): #quite does nothing pass img = cv2.imread("C:\\Users\\balmu\\OneDrive\\Pictures\\cartoon.jpg") #path of the image img = cv2.resize(img,None,fx=0.1,fy=0.1) # creating a trackbar cv2.namedWindow("cartoon") cv2.createTrackbar("trackbar","cartoon",1,255,nothing) while True: ...
c80352f2d78eb2afa5b55f913e9c35c999bf73bf
Arup276/365Days_Challenge
/#Day_4/codebat.py
1,315
3.625
4
def front_back(str): len_str = len(str) if len_str <= 1: return str else: return str[len_str-1]+str[1:len_str-1]+str[0] def front3(str): #ln = len(str) #if ln < 3: # return str #else: return 3*str[:3] ######################################################################...
da95084765ac532143fcde5ecf6805b3d7736300
huhuzwxy/leetcode
/Dynamic Programming/53_maximum_subarray.py
619
4.0625
4
# 给定一个数组,返回其最大子数组的和 # Input: [-2,1,-3,4,-1,2,1,-5,4] # Output: 6 # 思路: # 加完之后小于当前值,则从该值重新开始加,前面的放弃 # 维护一个max_sum记录当前最大值 class Solution: def maxSubarray1(self, nums): sum = max_sum = nums[0] for i in range(1, len(nums)): sum = sum + nums[i] sum = max(sum, nums[i]) ...
14d7f30c07f8136345c20cd181742ce904b3fd1c
kdrag0n/aoc2020
/python/day23.py
1,285
3.5
4
#!/usr/bin/env python3 import sys def ints(itr): return [int(i) for i in itr] with open(sys.argv[1], "r") as f: cups = ints(f.read().replace("\n", "")) ilist = [] imap = {} total = 0 result = 0 other = 0 def idx(l, v): try: return l.index(v) except ValueError: return -1 while True...
740c41b1f12bc87e8885a5e511f059f3694ac20c
pamekasancode/Code-Forces-Algorithm
/Python/Helpfull Math.py
238
3.828125
4
def solve(): chars = str(input()) signs = ["+", "-", "/", "*"] sign = [sign for sign in signs if sign in chars] if not sign: return chars return sign[0].join(sorted(chars.split(sign[0]))) print(solve())
2f6ce759502d77f8121c09a014daceebcfd3915a
joestalker1/leetcode
/src/main/scala/common_lounge/Variation.py
457
3.921875
4
def find_pairs(arr, diff): pairs = 0 i = 0 j = 0 while i < len(arr) and j < len(arr): while j < len(arr) and abs(arr[j] - arr[i]) < diff: j += 1 if j < len(arr): pairs += (len(arr) - j) i += 1 return pairs s = input() arr = s.split() n = int(arr[0]) ...
56482b6d1b784b6135ca00e3fc90e78b34dc3766
SujanMaga/Python-prac-for-ref.
/test/Conditional_Expression/01_conditional.py
255
4.25
4
a = 45 if(a>4): print("The value of a is greater than 4") elif(a>7): print("The value of a is greater than 7") else: print("The value of a is not greater nor lesser than 3 or 7") # demo syntax # to check all the statement if if if can be used
00220f8264c6609477cb8617797664111f9362bd
skyyyylark/hw4_Magomedov_G
/main.py
641
3.734375
4
import random import calculator rand_list = [] for i in range(20): number1 = random.randint(0, 100) rand_list.append(number1) num1 = random.choice(rand_list) num2 = random.choice(rand_list) num_of_user = int(input()) sum_list = [] for i in range(num_of_user): num = random.choice(rand_li...
ad8014a1865f256f92244b772a1f833ad84a580d
lorryzhai/test7
/oh-my-python-master/oh-my-python-master/target_offer/009-用两个栈实现队列(两个队列实现栈)/QueueWithTwoStacks.py
919
3.625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2017/12/29 16:06 # @Author : WIX # @File : QueueWithTwoStacks.py """ 用两个栈实现一个队列。队列的声明如下,请实现它的两个函数appendTail 和deleteHead,分别完成在队列尾部插入结点和在队列头部删除结点的功能。 """ class Solution: def __init__(self): self.stack1 = [] self.stack2 = [] def pus...
dde0844ace3e4dd133ee23ab580fc969d6458e85
dborski/code_challenges
/camel_case/camel_case_solution.py
572
3.953125
4
def to_camel_case(text): dash = text.find('-') underscore = text.find('_') if dash == -1 and underscore == -1: return text elif dash > -1: new_text = text.replace('-' + text[dash + 1], f'{text[dash + 1]}'.upper(), 1) return to_camel_case(new_text) elif underscore > -1: new_text = text.replace...
6c9f0fe9769a0dfd3f7056e975907d1a6f5c305a
RCTom168/Intro-to-Python-1
/Intro-Python-I-master/src/07_slices.py
1,128
4.53125
5
""" Python exposes a terse and intuitive syntax for performing slicing on lists and strings. This makes it easy to reference only a portion of a list or string. This Stack Overflow answer provides a brief but thorough overview: https://stackoverflow.com/a/509295 Use Python's slice syntax to achieve the following: "...
3724cae8f98320b9e3b16752eb552c06e6987d1e
p4zzz/gitTest
/helloWorld.py
131
3.703125
4
s = "Hello World" arr = [] for letter in s: arr.append(letter) arr = arr[::-1] r = '' for item in arr: r += item print(r)
d2c86733ad4cbb7bc53263c8173eee74c09c4ab7
SimonGideon/Touch
/Classes.py
1,067
4.15625
4
class Polygon: def __init__(self, sides, name): self.sides = sides self.name = name square = Polygon(4, "Square") print(square.sides) class People: def __init__(self, name, age): self.name = name self.age = age def myfunc(self): print("Heloo my name is " + self.n...
31d46ac0b438c1435e1a7518bef00cbec740d607
CafeYuzuHuang/coding
/SameTree.py
2,248
3.78125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def isSameTree(self, p: TreeNode, q: TreeNode) -> bool: # 2021.03.16 # 1st solution: naive, ...
83da99625db591e0573c34a75a3b17030b1d9c39
Thalisson01/Python
/Exercício Python #079 - Valores únicos em uma Lista.py
585
3.84375
4
n = list() cont = 0 while True: nv = int(input('Digite um valor: ')) if cont == 0: n.append(nv) else: while nv in n: print('Este valor já existe na lista, tente novamente!') nv = int(input('Digite um valor: ')) n.append(nv) escolha = str(input('Deseja...
671ac59582797037b7c19d0bee325d56d2e781c6
ssbbkk/Python-scripts
/words.py
449
4.0625
4
import scrabble letters = "abcdefghijklmnopqrstquwxyz" def has_a_double(letter): for word in scrabble.wordlist: if letter + letter in word: return True return False for letter in letters: if not has_a_double(letter): print(letter + " never appeard doubbled") # Print all words...
ff06dd9d854d0c636d79599ded1e62c2be153700
pedestrianlove/10901_Python_THU
/HW/HW3/3.2/30.py
551
3.671875
4
# for formatting purpose class underline: start = '\033[04m' end = '\033[0m' # input hourly_wage = eval ( input ("Enter hourly wage: " + underline.start)) print (underline.end, end='') working_hours = eval ( input ("Enter number of hours worked: " + underline.start)) print (underline.end, end='') # output p...
b0cde6b41bb5500669ebce30cfd2a977ca19c3c1
joschi127/tugger
/lib/tugger-container-init/json-merge.py
833
3.515625
4
#!/usr/bin/python2.7 # merge two json files, given as command line arguments, and output merged json data import sys from pprint import pprint import json def merge_recursively(a, b, path=None): "merges b into a" if path is None: path = [] for key in b: if key in a: if isinstance(a[key...
723fc61188d10a22d09fceb9c5b4fbdbacad720a
jsourabh1/Striver-s_sheet_Solution
/Day-16_String2/question1_z_function.py
547
3.5
4
def solve(string): # print(string) z=[0]*len(string) n=len(string) first=end=0 for i in range(1,len(string)): flag=False if i<=end: z[i]=min(end-i+1,z[i-first]) while i+z[i]<n and string[z[i]]==string[z[i]+i]: flag=True z[i]+=1 if i+z[i]-1>end and flag: first=i end=i+z[i]-1 # print(z...
d98722c8416a1ca2880eda4ebb4418767066e22d
OWAISIDRISI53/Password-Cracker-by-Owais-Idrisi
/PasswordCracker.py
1,234
3.796875
4
# PASSWORD CRACKER from random import * import time time.sleep(1) print(""" ░█████╗░░██╗░░░░░░░██╗░█████╗░██╗░██████╗ ██╔══██╗░██║░░██╗░░██║██╔══██╗██║██╔════╝ ██║░░██║░╚██╗████╗██╔╝███████║██║╚█████╗░ ██║░░██║░░████╔═████║░██╔══██║██║░╚═══██╗ ╚█████╔╝░░╚██╔╝░╚██╔╝░██║░░██║██║██████╔╝ ░╚════╝░░░░╚═╝░░░╚═╝░░╚═╝░░╚═╝╚...
e39d00a8d6e7bdc06478e8b4bf31c1a1d9c02b29
TheRenegadeCoder/sample-programs
/archive/p/python/duplicate_character_counter.py
424
3.703125
4
import sys if len(sys.argv) != 2 or not sys.argv[1]: print("Usage: please provide a string") sys.exit() counter = dict() dupes = False for char in sys.argv[1]: counter.setdefault(char, 0) counter[char] += 1 if counter[char] > 1: dupes = True if dupes: for key, value in counter.items()...
db0d979c785c24607f9674740544b9c77586174f
Blossomyyh/leetcode
/Permutation.py
3,231
4.125
4
""" 46 permutations first of all there is no efficient way to do it it has to be brute force we're just going to generate every single combination let's take look at this one [1,2,3] you have 3 spots and the first element/ scenario you can have up to 3 different numbers second - 2, last position - only one number th...
d330c1d5f73c1b612342234bc90c3f2be4b45e81
ShahShailavi/Back-End-MicroService-Using-Load-Balancer
/comment_database.py
614
3.609375
4
import sqlite3 connection = sqlite3.connect('comment_database.db') c=connection.cursor() c.execute("""create table if not exists comments_table (comment_id INTEGER PRIMARY KEY AUTOINCREMENT, comment text, username TEXT, ...
34746a351b278858661170b6fda6eb4568f709ee
busterguy26/devpy
/base_type/Example.py
885
4.09375
4
def simple_sort(data: object) -> object: """ Sort list of ints without using built-in methods. Examples: simple_sort([2, 9, 6, 7, 3, 2, 1]) >>> [1, 2, 2, 3, 6, 7, 9] Returns: """ sorted_list = [] if isinstance(data, list): for i in data: if not isinstance...
58418906ff38095da3f8fe3bcaa84dfc3cdaef98
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/226/users/4153/codes/1674_1100.py
632
3.734375
4
# Teste seu código aos poucos. # Não teste tudo no final, pois fica mais difícil de identificar erros. # Ao testar sua solução, não se limite ao caso de exemplo. vdc = int(input("Insira o valor da cedula: ")) print("Entrada:", vdc) if((vdc != 2) and (vdc != 5) and (vdc != 10) and (vdc != 20) and (vdc != 50) and (vdc !...
b787d5796db4ef7cfaf71d448bf81c2e6fe55582
akerem16/basic-calculator-git-en-tr
/main.py
1,543
4.3125
4
# Basic calculator in python 3.6 # Made in Turkey # By akerem16 # [EN] First we will get number of operations. We will run the code block according to what action will be taken. # [TR] ilk önce işlem numarasını almamız gerekiyor. Hangi işlem yapılacaksa ona göre kod bloğu çalıştıracağız. operationnumber = str(input(""...
2859d064b6a5630856dfe99220f4428063876fb3
Danielcormar/programaci-n-python
/laboratorio3/ejercicio4.py
89
3.8125
4
x=input("dame un numero ") if x%2==0: print "es par" else: print "es impar"
48af33aac0268086658157aecf14351010172ef7
worthurlove/python_work
/SA18225511-zhengjie-2.1.py
611
4.0625
4
# Function:accept a quiz score as an input and prints out the corresponding grade #Author:worthurlove #Date:2018.10.8 score_grade = {5: 'A', 4: 'B', 3: 'C', 2: 'D', 1: 'E', 0: 'F'} ''' 定义数据字典,将测试分数与成绩一一对应 ''' def get_grade(score_grade): score = int(input('请输入0到5之间的测试分数:')) if (score < 0 | score > 5): ...
8150a81a72c29fad6b8101b2129acdee547d29ab
wenxinjie/leetcode
/String/python/leetcode14_Longest_Common_Prefix.py
870
3.921875
4
# Write a function to find the longest common prefix string amongst an array of strings. # If there is no common prefix, return an empty string "". # Example 1: # Input: ["flower","flow","flight"] # Output: "fl" # Example 2: # Input: ["dog","racecar","car"] # Output: "" # Explanation: There is no common prefix amon...
185eb00177e3cc58c2d62ef33ba8589688ea8993
uvenil/PythonKurs201806
/___Python/Carsten/p07_file_io/m01_count_files.py
431
3.578125
4
from pathlib import Path # Zähle die Anzahl Ordner in einerm Ordner (inkl. aller Unterordner) def count_dirs(path): subdirs = [subdir for subdir in path.iterdir() if subdir.is_dir()] # Bestimme die direkten Unterordner des Ordners path print(subdirs) count = 0 for subdir in subdirs: c...
730d258c6f4821206d8abff023f5ad58e0736502
BerilBBJ/scraperwiki-scraper-vault
/Users/P/pathipati/ukcartaxband.py
2,740
3.578125
4
import scraperwiki from BeautifulSoup import BeautifulSoup def scrape_table(soup): #to define coloumns name used in table scraperwiki.sqlite.save('data_columns', ['Authority', 'Avg sync speed (Mbit/s)',\ ' % not rece - iving 2Mbit/s ',\ 'Super fast broad - band availa - bility ...
01943ae3760b723e61111f4add3ee3da3c2e5315
forget726/PythonBase
/画图实例.py
266
3.796875
4
import turtle p = turtle.Pen() turtle.bgcolor("black") sides = 7 colors = ["red","orange","yellow","green","cyan","blue","purple"] for x in range(360): p.pencolor(colors[x%sides]) p.forward(x*3/sides+x) p.left(360/sides+1) p.width(x*sides/200) done()
7818a58b12e6d72299d277f6871b8982f0a23ae7
samsepiolc64/codewars
/uniqueinorder/uniqueinorder.py
612
3.59375
4
def unique_in_order(iterable): #print(sorted(set(list(li)))) iterable = list(iterable) dl = len(iterable) new = [] i = 0 j = 1 while j <= dl: tmp = iterable[i] if j < dl: if (tmp != iterable[j]) : new.append(tmp) i = j ...
1ccc9715499668c4b22b62e294f6998c34df9e39
hkristof03/GoogleFooBar
/lvl2/Task2.2/solution.py
1,255
3.578125
4
from collections import Counter def numberToBase(n, b): """""" if n == 0: return [0] digits = [] while n: digits.append(str(int(n % b))) n //= b return digits[::-1] def assign_tasks(n, b): """""" k = len(n) x = sorted(n, reverse=True, key=int) x = ''.join...
8776b5691db0f6e6796cf9505ee769eff8acb44c
Neal5580/python_exercises
/capitalize/index.py
849
3.796875
4
# Solution 1 # def capitalize(str): # words = [] # for item in str.split(): # firstChar = item[0].upper() # # if len(item) > 1: # # words.append(firstChar + item[1::]) # # else: # # words.append(firstChar) # words.append(firstChar + item[1::] if ...
a725aa2dbe87f4bfb8480c519a6db75f3fb155f8
adamh17/ca318-Advanced-Algorithms-and-AI-Search
/Week 3 - Improving Brute Force/heuristic.py
519
3.90625
4
def h(start, goal): assert "".join(sorted(start)) == " 12345678" and "".join(sorted(goal)) == " 12345678" # Work out the manhattah distance of each tile from its eventual goal sboard = [int(num) if num != " " else 0 for num in start] gboard = [int(num) if num != " " else 0 for num in goal] man...
fc6d1a25f50df37ab3ca2520effb126a1654ffa9
mindful-ai/oracle
/amstar-03/day_02/code/loop_else_block_demo.py
1,055
4.125
4
# PROJECT A # Detecting if a number is prime or not ''' for <var> in <iter>: <statements> else: <statements> while <condition>: <statements> else: <statements> Loop exits because of two scenarios: 1. elements in the <iter> is exhausted, or <condition> becomes false (NATURAL EXIT)...
8ad654321cceeeb0b61178d7580a23d26281ef41
Larissa-D-Gomes/CursoPython
/introducao/exercicio040.py
989
4.0625
4
""" EXERCÍCIO 040: Aquele Clássico da Média 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 """ def main(): try: ...
eb9270b2b5d6acd78bd896cf367accc9d57989a0
allisonlynnbasore14/SlotGame
/slotmachine.py
2,377
3.859375
4
import random def main(): #pygame.init() slot_machine = SlotMachine() slot_machine.startGame() class SlotMachine: def __init__(self): # Make the starting information like possible bets icons jackpot etc. self.icons = [] self.createIcons() def startGame(self): self.setStartingValues() gameisGoing ...
6c514831626be7f8efba510eb7d0f1a5a5e4dcfa
JoshuaPMallory/DS-Unit-3-Sprint-2-SQL-and-Databases
/module5-sprint2-sql-and-databases/northwind.py
2,323
3.78125
4
import sqlite3 import SQL parttwo = SQL.SQL('northwind_small.sqlite3') questions = ['What are the ten most expensive items (per unit price) in the database?' ,'What is the average age of an employee at the time of their hiring?' ,'What are the ten most expensive items (per unit price) in th...
1ffb4bc2c39bddeaab891cad34c01fb3c9ee7324
aliceKatkout/ExoCode
/niveau1.py
216
3.828125
4
mot = input("Ecris un mot :") def solution(mot): lettres = list(mot) lettres.reverse() mirror ="".join(lettres) return mirror resultat =solution(mot) print("le mot à l'envers est "+resultat+" !")
41d0d1116ee62f9152ef29a392f07e4f1b0ee12b
Sivaramkrishna1/Python_basic_programms
/valid_email.py
266
3.59375
4
import re regex = '^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$' n=int(input('enter num:')) print(n) guess_count=0 while guess_count < n: valid_email=input('') guess_count+=1 if (re.search(regex,valid_email)): print(valid_email)
987d231d0cc82ea9167342a7a1cff6cd65abe304
jaehyun02px2021/PythonGrammar
/Class/hotandcold.py
1,042
3.875
4
#working code 1 : problem is that we don't check if the value is in the range once we put a right input. # answer = 63 # inputNumber = int(input()) # # if inputNumber > 0 and inputNumber < 100: # if inputNumber == answer: # print ("Correct Answer") # while inputNumber - answer: # if answer - in...
82209e19ec217ef054ceec745a085fc78f880889
gjw199513/mkw-pythonsz
/chapter3/4.demo.py
913
3.921875
4
# -*- coding:utf-8 -*- __author__ = 'gjw' __time__ = '2018/1/18 0018 下午 4:32' # 3-4 如何进行反向迭代以及如何实现反向迭代 l = [1, 2, 3, 4, 5] """ 使用reverse方法实现改变原来的列表 使用反向切片浪费空间 使用revered内置函数较为合适 """ for x in reversed(l): print(x) print() print() class FloatRange: def __init__(self, start, end, step=0.1): ...
181b324a8d592953290bd28ec9a56369053597c0
tymancjo/Game-Of-Life
/GOL.py
5,537
4.03125
4
# This is my quick project idea # A Game Of Life implementation # Done just for fun andPython training # the general idea comes form classic: # https://pl.wikipedia.org/wiki/Gra_w_%C5%BCycie # plan to work it out as pythonic as possible :) # one: play around with numpy arrays to understood it deeply # pygame: used fo...
2d089d9d2eb46d07f1f16097417b5286e70cf1b9
nuydev/my_python
/Basic_Data_Type_Variable.py
364
3.859375
4
#DataType & Variable #ชื่อตัวแปร = ค่าที่เก็บในตัวแปร x = 10 print(x) print('ผลลัพธ์ =', x) print(type(x)) print('ผลลัพธ์ ='+ str(x)) #แปลง String y=3.645 z=True print(y) print(type(y)) print(z) print(type(z)) a = 'Teerawat' print(a) print(a,a) print(a+a) print(type(a))
eb489b2f313f4517c9593eb06b9a36e34de5c4f9
frankad/python
/python/Dra.py
10,735
3.953125
4
# Name: Fentahun Reta # Date: 10/15/15 # Dicription: This program demonstrates drawing shapes on a canvas using # some Gui tools. It is not interactive. It draws the same picture # every time it is executed. To run this program, you must save the # file Gui3.py in the same folder as ...
964496a57617e462e640640faccd9173f1b9124d
xiaohai0520/Algorithm
/algorithms/1373. Maximum Sum BST in Binary Tree.py
712
3.53125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def maxSumBST(self, root: TreeNode) -> int: self.res = 0 def dfs(node): if not node: ...
eea4b73ba5ae1137ca469e4f8c7d47e96640ccb8
TimBossuyt/5WWIPython
/06-Condities/Trolleyprobleem.py
530
3.75
4
antwoord_1 = input('Trek aan de hendel van de wissel? ') antwoord_2 = input('Man van de brug duwen? ') if antwoord_1 == 'ja' and antwoord_2 == 'ja': doden = 2 elif antwoord_1 == 'ja' and antwoord_2 == 'nee': doden = 1 elif antwoord_1 == 'nee' and antwoord_2 == 'ja': doden = 1 elif antwoord_1...
0ffeb640c4c731ccebe44b3c2ba5cb07f518fc0f
AP-MI-2021/lab-4-VargaIonut23
/main.py
3,424
3.765625
4
def citire_lista(): l = [] listasstring = input("Dati lista ") numberasstring = listasstring.split(",") for x in numberasstring: l.append(str(x)) return l def print_menu(): print (" 1. Citire lista ") def se_gaseste_in_lista(l , l2): ''' :param l: un sir de caractere ...
488048012d9bffaf0fd795aaba7059c4d4688a59
jzijin/leetcode
/606.根据二叉树创建字符串.py
2,640
3.640625
4
# # @lc app=leetcode.cn id=606 lang=python # # [606] 根据二叉树创建字符串 # # https://leetcode-cn.com/problems/construct-string-from-binary-tree/description/ # # algorithms # Easy (47.83%) # Total Accepted: 2.4K # Total Submissions: 5.1K # Testcase Example: '[1,2,3,4]' # # 你需要采用前序遍历的方式,将一个二叉树转换成一个由括号和整数组成的字符串。 ...
9dc39abe32ef7bda1c6f08a0f3c3ec23b5e67c4c
anilectjose/S1-A-Anilect-Jose
/Python Lab/03-02-2021/1.factorial.py
459
4.28125
4
num = int(input("Enter a number: ")) factorial = 1 if num < 0: print("Sorry, factorial does not exist for negative numbers") elif num == 0: print("The factorial of 0 is 1") else: for i in range(1, num + 1): factorial = factorial * i print("The factorial of", num, "is", factorial) ...
57a9956fd68636043a5de5b35dd707c4d6b2251f
aslamdien/Random_Number
/age_determine.py
1,586
3.921875
4
from tkinter import * from tkinter import messagebox from datetime import date root = Tk() root.title("How Old Are You") root.geometry("500x500") year = StringVar() month = StringVar() day = StringVar() lab1 = Label(root, text = "Year Your Were Born:") lab1.place(x=50, y=10) ent1 = Entry(root, textvariable = year) e...
6c3d121109f9f919ec6a2aee1aa50849a59cebff
bigMARAC/cco
/INE5402-01208B/prova-02/2473.py
602
3.671875
4
values = list(map(int, input().split(' '))) winning = list(map(int, input().split(' '))) count = 0 # Esse problema é bastante simples, basta fazer um loop # nos números apostados e dentro desse, fazer um loop nos # números certos, depois é só comporar o número X com os N # números certos, e incrementar o 'count' toda ...
8e23cda823c275dc1b30be7b6dc3a57d9fdd17a0
maikelwever/simplecryptodome
/simplecrypto/hashes.py
1,277
3.828125
4
""" Module for standard hash algorithms, always returning the hash in hexadecimal string format. """ import hashlib from Crypto.Hash import HMAC, SHA256 from .formats import to_bytes def md5(message): """ Returns the hexadecimal representation of the MD5 hash digest. """ return hashlib.md5(...
55ddc8e4f14956fa560f7305ca7ccfba9258eab1
Alhzz/Python3
/Align.py
431
3.890625
4
""" Align """ def main(): """ Print text """ size = int(input()) locate = input() word = input() if locate == "left": pass elif locate == "right": print(" "*(size - len(word)), end="") else: if (size - len(word)) % 2 == 0: print(" "*((size - len(word))//...
886c2c29f6ba3a4eeba5c818f56b4f8dfdcda1a1
wonheejeong/Algorithm_No_1
/2주차/python/1번_정원희.py
213
3.6875
4
def solution(n): answer =[] while n >0: if n %2 ==1: answer.insert(0,"수") else: answer.insert(0,"박") n-=1 return ''.join(answer) print(solution(3))
577df6cc31f95c40a0bc3ad82b6271781e528fed
GunalanD95/Technical-Interview-Guide
/HackerRank/StrangeCounter.py
381
3.75
4
# https://www.hackerrank.com/challenges/strange-code/problem # Easy def strangeCounter(t): rem = 3 # The time upward while(rem < t): t = t - rem # Subtract from the original rem *= 2 # Follow the condition and increment return(rem - t + 1) # The difference between time upward and original ...
9767b5307a7d416b6806bc07cb9b848789a82507
samuelklam/rabin-miller-primality-test
/rabin-miller.py
1,184
3.609375
4
from random import randrange import math def mod_e(base, expo, n): val1 = 1 while expo > 0: # the case that expo is odd, make sure to multiply by 1 base if expo % 2 == 1: val1 = (val1 * base) % n # repeated squaring base = (base * base) % n expo = math.floor...
d9f4ee2336aad65df24a3d6942641c8cd83a5d40
tanya9779/lab20
/6.py
4,568
3.65625
4
# coding: utf-8 # Отобразить кратчайший путь между двумя вершинами (восстановление пути) import matplotlib.pyplot as plt import networkx as nx def LoadGraph(f_name): # из файла прочитаем ребра и их вес with open (f_name, 'r') as f : line = f.readline() while line: u,v,w = line.split() ...
9be91dff0d65d1e8fc4764b2e6c80d17c80778fe
jholgado/text-adventure
/src/my_pkg/game.py
1,783
3.671875
4
from my_pkg.player import Player, userinput from my_pkg import level, items # main game driving code including text intro and short explanation def play(): print("Welcome to the Tower of Trials") print("Do you wish to enter and test your might? (yes/no)") select = userinput("", ["yes", "no"]) if selec...
6ec7fe721587c1e0de55bb41db492dcd8838b62b
vaios84/Python-Tutorial
/remove-duplicates-in-list.py
162
4
4
numbers = [1,5,7,5,8,1,9,6,4,7,13,9,7,1,36,3,5] uniques = [] for number in numbers: if number not in uniques: uniques.append(number) print(uniques)
87edd16fb4a10e704a51177ef41e8db3f5d94397
cbare/data-science-from-scratch
/chapter_07/population_mean_vs_sample_mean.py
1,027
3.546875
4
""" Compare population mean with sample mean """ import random import numpy as np import matplotlib.pyplot as plt import seaborn as sns from stats import * from normal import normal_pdf # a population of 1 million pop = [random.random() for _ in range(1000000)] population_mean = sum(pop)/len(pop) print('population m...
240dc8f3be157f31acb374dc440bb413b1e3d3c6
greenday8426/big_data_web
/5일차 20180201/계산기 프로그램.py
685
3.71875
4
##변수 선언 부분 a,b,ch=0,0,"" ##메인(main) 코드 부분 a=int(input("첫 번째 수를 입력하세요:")) ch=input("계산할 연산자를 입력하세요:") b=int(input("두 번째 수를 입력하세요:")) if ch=="+": print("%d+%d=%d 입니다. "%(a,b,a+b)) elif ch=="-": print("%d-%d=%d 입니다. "%(a,b,a-b)) elif ch=="*": print("%d*%d=%d 입니다. "%(a,b,a*b)) elif ch=="-": print("%d/%d=%...
f66ed1dcc518d14bb5d3f9d977eba79e26e2108c
rafaelperazzo/programacao-web
/moodledata/vpl_data/12/usersdata/71/5304/submittedfiles/impedimento.py
181
3.71875
4
# -*- coding: utf-8 -*- from __future__ import division import math L = input("L: ") R = input("R: ") D = input("D: ") if L>50 and L<R and R>D: print("S") else: print("N")
927368235a08540c72c289154a1915abf3eb4964
nitendragautam/python_apps
/python_core/pythontutorials/files.py
552
3.96875
4
#Open a file #Open the file in write mode fo = open('test.txt', 'w') #Info of File print('Name: ',fo.name) print('Is Closed: ', fo.closed) print('File Opening mode: ',fo.mode) fo.write('This is a test') fo.write('\n I repeat') fo.close() #Open and Append File fo = open('test.txt', 'a') #Open file i...
932b539e320bc00c94ccb3686a6ba0f0f0869ff7
kitfair/kitspython
/swaplist.py
276
3.953125
4
def swap(val): """ :param val: a list of object :return: new order list """ m = len(val)//2 return val[m:]+val[:m] def main(): val = [9,13,21,4,11,7,1,3] print(val) val = swap(val) print(val) if __name__ == '__main__': main()
12e1ed64a52807a910d07af82beece0aa81fc643
Antonio2401/t08_ballena.custodio
/ramos_flores/busqueda.py
19,089
3.65625
4
# Busquedas de cadenas # Ejercicio (PARSER) # Ingresar el codigo numerico # 1 -> hola # 2 -> como estas # 3 -> te quiero # Ingresar un comando de 4 codigos numerico comando="12333" cmd1=comando[0] cmd2=comando[1] cmd3=comando[2] cmd4=comando[3] code="" # 1 2 # 01234567890123456...
426b08fe06904d662aaa13f140bae9d6726d3316
M-Elteibi/udemyCourse-CompletePythonDeveloper
/guessNumber.py
920
4
4
import numpy as np studentList = [] def create_student(): name = input("Please enter the name of the new student: ") studentData = { 'name': name, 'marks': [] } return studentData def add_marks(student, mark): student['marks'].append(mark) def calculate_average...
b240d5a7ed2e4250f31ab9aee92eeb4a1586fc31
swayamsaikar/Data-Sampling-In-Python
/main.py
2,681
4.0625
4
import pandas import statistics import plotly.figure_factory as ff import plotly.graph_objects as go import random # !! IN THIS PROGRAM WE HAVE TAKEN 30 RANDOM SAMPLES FROM THE CLAPDATA AND FIND THEIR MEAN AND RETURN IT # !! WE ALSO HAVE WRITTEN STANDARD_DEVIATION FUNCTION REPEAT THE ABOVE LINE 100 TIMES SO TYHAT IT ...
00a2e8ef58de2da0de62f9fb58aecf79aa9666dc
bonicim/technical_interviews_exposed
/src/algorithms/misc/daily_temperatures.py
1,284
4.5
4
def get_days_to_warmer_temp(temperatures): """ Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put 0 instead. For example, given the lis...
e8acdf823445de2c1c2a7ec9205a8ee0e9a709be
tangx/python36project
/randpass/使用string模块的randpass.py
1,192
3.875
4
#!/usr/bin/env python # encoding: utf-8 """ @author: tangxin@haowan123.com @python_version: python2.7 @python_version: python3.6 @file: 使用string模块的randpass.py @time: 2017/8/16 11:43 """ import os import sys import string import random # print(string.ascii_letters) # 所有字母 # print(string.ascii_lowercase) # 小写字母 # pr...
e8457fc37ef41a062547d89cbda1d03eaffe2eb6
ckronber/PythonExamples
/Intermediate/mapFunction.py
248
4.03125
4
#Map Function li = {1,2,3,4,5,6,7,8,9,10} def func(x): return x**x #map function printed print(list(map(func,li))) #list comprehension print([func(x) for x in li]) #list comprehension for even numbers print([func(x) for x in li if x%2==0])
7a8a86d333562ba5dc0c84b1c93be57b68aa0f66
chunweiliu/leetcode
/problems/valid-palindrome/valid_palindrome.py
657
3.625
4
class Solution(object): def isPalindrome(self, s): """ :type s: str :rtype: bool """ # s = ''.join([c.lower() for c in s if c.isalnum()]) # return s == s[::-1] i, j = 0, len(s) - 1 while i <= j: if s[i].lower() == s[j].lower(): ...
e33e3163cbab057c86941590a7de2f89dfbd0cc8
BasavaG/python_sandbox
/numericpy.py
981
4.5
4
#Creating arrays with numpy import numpy as np arr1 = np.array([1,2,3,4,5]) print(f"{arr1} and type is {type(arr1)}" ) #2- D array arr2 = np.array([[1,2,3],[4,5,6]]) print(arr2) # 3 D array arr3 = np.array([[[1,2,3], [4,5,6]],[[7,8,9],[10,11,12]]]) print(arr3) # To check the dimensions of the array use "ndim" attrib...
406095543cfb04ce273b07c2d05cb692088d6367
achristopher4/Recipe-Scaler
/CMPSC HW4.py
2,436
4.15625
4
""" Alex Christopher abc5885@psu.edu HW4 """ import math ##Introduction/Instructions print("This is a recipe scaler for serving large crowds!") print("Enter one ingredient per line, with a numeric value first.") print("Indicate the end of input with an empty line.") ##dictionary and saved values savedValues = {} cou...
700ff77bc10c700b79885ac017ee2d10326aba73
kathytbui/mythical_creatures_python
/src/mythical_creatures/direwolf.py
806
3.5
4
class Direwolf: def __init__(self, name, home = 'Beyond the Wall', size = 'Massive'): self.name = name self.home = home self.size = size self.starks_to_protect = [] self.hunts_white_walkers = True def protects(self, stark): if stark.location == self.home: ...
c8812ed95984048b2964fdcc399f7093c8cd5859
markomamic22/PSU_LV
/LV1/Drugi.py
368
3.90625
4
ocjena = -1.0 while ((ocjena < 0.0) or (ocjena > 1.0)): ocjena = float(input("Unesite broj između 0 i 1: ")) def cases(ocjena): if(ocjena >= 0.9): print('A') elif(ocjena >= 0.8): print('B') elif(ocjena >= 0.7): print('C') elif(ocjena >= 0.6): print('D') elif(ocj...
fccd7f7a94edae00503b01293b1cefed64396a40
gogeekness/Pygames_Tiles
/Py_tiles/Gtiles_Class.py
1,572
3.53125
4
# Tile class # This will setup the graphical displaying of the tiles # # It will pull the color and status from teh board class # # -------------------------------------------------------- import os, pygame, random, math import Tile_Config as config # import Board_Class as board def load_image(subfile, tcolor): ...
2cd96408c1cf249f4595dea257ff936bc252b8e4
bhuvanjs25/Python-Basics
/for4.py
420
4.0625
4
#print("searching for a value 3") #or i in[9,41,12,3,74,15]: # if i==3: # print("true",i) # elif i!=3: # print(i)1x print("find the smallest value") small= None for i in[9,41,12,3,74,15]: #if small is none replace it with i if small is None: small=i #if i is smaller than ...
5409cb2ddb690e2bdc967850ca25651155358714
rafajob/Python-beginner
/contanumero.py
173
3.875
4
numero = int(input("Digite o valor de n: ")) soma = 0 while (numero != 0) : resto = numero % 10 soma = soma + resto numero = numero // 10 print(soma)
6411b286f9d19b077dbcc3c03988ddb8bc5360f7
JavaRod/SP_Python220B_2019
/students/shodges/lesson01/calculator/test.py
1,079
3.734375
4
from unittest import TestCase from adder import Adder from subtracter import Subtracter from multiplier import Multiplier from divider import Divider from calculator import Calculator class AdderTests(TestCase): def test_adding(self): adder = Adder() for i in range(-10, 10): for j in ...
3497bd42bcce0d8560d58ddf8597489c0afcb330
blackwings001/algorithm
/leetcode/1-50/_29_divide.py
1,304
3.578125
4
class Solution(object): def divide(self, dividend, divisor): """ :type dividend: int :type divisor: int :rtype: int """ if dividend == 0: return 0 # 先判断dividend和divisor是否同号,结果1先按两个正数来做,如果两者异号,结果为(-结果1 - 1)(LEETCODE的结果不一样,他认为结果为-结果1) negati...
e7632595390b3f3ec81d1d16696dcc18c351a286
mernaadell/ProblemSolving
/Easy/Mars Exploration.py
407
3.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Nov 5 22:09:15 2019 @author: merna """ if __name__ == '__main__': count=0 s = input() x=len(s)/3 s2="SOS" j=0 for i in range(len(s)): if j==3: j=0 if s[i]!=s2[j] : count+=1 ...
e684e5498ad1624b683960f7cb87f12979ab26ad
BZAghalarov/Hackerrank-tasks
/Cracking coding interview/19 DP Coin Change.py
1,396
3.640625
4
''' https://www.hackerrank.com/challenges/ctci-coin-change/problem ''' ''' #!/bin/python3 # Complete the ways function below. def ways(n, coins): # Complete this function n_perms = [1]+[0]*n for coin in coins: for i in range(coin, n+1): n_perms[i] += n_perms[i-coin] return n_pe...
a910a948044945645ee74b58856324b9474a8d7e
Ternt/Algorithms
/Algorithms/Binary Search.py
766
4.09375
4
arrayData = [1,10,21,35,36,50,69,70,74,98] searchItem = int(input("Input search item: ")) def binarySearch(searchItem): Found = False searchFailed = False First = 0 Last = len(arrayData) - 1 while Found == False and searchFailed == False: middle = (First + Last...
57d72d573f5b41cd8153feb6afec1b7334f5e3e9
diderot-edu/diderot-cafe
/python/asymptotics.py
1,298
3.703125
4
from sympy import * from sympy.parsing.sympy_parser import parse_expr def grade_bigoh(ans, sol, x): ''' Check that ans and sol of the variable x have the same order of magnitude. Examples: grade_bigoh('n', 'n', 'n') grade_bigoh('log(n)', 'n', 'n') grade_bigoh('logn(log(n))', 'log...
5205b37f8c2b3adbdd438b90ccc331c0097aa4e1
nehamjain10/EE2703_Assignments
/Week 4/EE2703_ASSIGN4_EE19B084.py
8,477
3.859375
4
##********************************************************************************************************************************************************************** # EE2703 Applied Programming Lab 2021 # ...
cd896d21abc66cfff2e380b6d6506987a3640394
sakinaiz/dsp
/python/q8_parsing.py
892
4.28125
4
# The football.csv file contains the results from the English Premier League. # The columns labeled ‘Goals’ and ‘Goals Allowed’ contain the total number of # goals scored for and against each team in that season (so Arsenal scored 79 goals # against opponents, and had 36 goals scored against them). Write a program t...
b01534bb410456508ac34a2e4215a0d4aa351650
Akshay-Chandelkar/PythonTraining2019
/Ex69_LongestShortestLine.py
742
4.3125
4
def LongestShortestLine(file_name): fd = open(file_name) if fd != None: line = fd.readline() max_line = line min_line = line while line != '': line = fd.readline() if line == '': break if len(line) > len(max_line): ...
a660da234b02f6bc0c546ca68781ccab5c84891b
p-s-vishnu/udacity
/machine-learning-project/svm/svm_author_id.py
1,675
3.765625
4
#!/usr/bin/python """ This is the code to accompany the Lesson 2 (SVM) mini-project. Use a SVM to identify emails from the Enron corpus by their authors: Sara has label 0 Chris has label 1 """ import sys from time import time from sklearn import svm from sklearn.metrics import accuracy_score sys.path...
b0aab40a70aa6d20572a7f357aa7c87364de3ffc
kuldeep7688/Algorithms-Design-and-Analysis-Part-1
/week_1/problem_assignment/count_inversion_solution.py
2,502
4.21875
4
import time import math import random def count_inversion_routine(array_a, array_b): """ Count split inversions and merge arrays routine. Args: array_a (list): sorted array array_b (list): sorted array Returns: list, count : sorted merged list, count of split inversion """ ...
e3faecd3cdcce51263aaa109022c2a239166dc01
jonahhill/mlprojects-py
/TimeSeriesRegression/data_explore/__init__.py
1,402
3.625
4
import matplotlib.pyplot as plt from matplotlib import colors def create_fig(): fig_number = create_fig.fig_number + 1 plt.figure(fig_number, figsize=(20,10)) create_fig.fig_number = 0 def draw_simple_scatterplot(x,y , x_title, subplotnum): print x.shape,y.shape , x_title, subplotnum plt.subplot(...
b4a180b632612162d0607cc7b0f3ea2ec3d6a5ae
akaliutau/cs-problems-python
/problems/tree/Solution199.py
585
3.5625
4
""" Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. Example: Input: [1,2,3,null,5,null,4] Output: [1, 3, 4] Explanation: 1 <--- bfs level 0 / \ 2 3 <--- ...
4f54d02fbf4029b734daa4e36193f4d7c72447a4
zzploveyou/predict_knockout
/knockout_result.py
3,638
3.578125
4
# coding:utf-8 from collections import defaultdict from copy import deepcopy WIN_SCORE = 1 LOSS_SCORE = 0 TIE_SCORE = 0 class Team: def __init__(self, name, score): self.name = name self.score = score def win(self): global WIN_SCORE self.score += WIN_SCORE def loss(self...
b2dc061718edc18aed81120c2f3981d793be6fd7
sumanes4u/Anaconda-Projects
/vehicle reservation/CreditCardCalc.py
3,550
4.25
4
# Credit Card Calculation Program (Final Version) def displayWelcome(): print('This program will determine the time to pay off a credit') print('card and the interest paid based on the current balance,') print('the interest rate, and the monthly payments made.') def displayPayments(balance, int_rate, mont...
913037b885af99cea7057e32ecb441420e39d482
bowlofbap/PingPongTrackerPython
/elo.py
4,582
3.8125
4
# Python 3 program for Elo Rating import psycopg2 import math import sys # Function to calculate the Probability def Probability(rating1, rating2): return 1.0 * 1.0 / (1 + 1.0 * math.pow(10, 1.0 * (rating1 - rating2) / 400)) # Function to calculate Elo rating # K is a constant. # d determines whether # Playe...
76651f4059bbd69cbc52ceb1cb71fad5a0943b97
ethanmyers92/90COS_IQT_Labs
/Lab 2H.py
1,172
4.125
4
#Lab 2H print "Enter the grades for your four students into your gradebook! Enter grade first then name!" student_dict = {raw_input("Enter first student's name: ") : int(raw_input("Enter first student's grade: "))} student_dict[raw_input("Enter second student's name: ")] = int(raw_input("Enter second student's gra...
d902683dd52743ec53197e53c91514512c80b7d9
nvidda-hub/Leet-Code-Programs
/Maximum Product of Two Elements in an Array.py
615
3.796875
4
num_list = [] n = int(input("Enter number of elements:- ")) for i in range(n): print("Enter", i + 1, "th element :- ", end="") ele_input = int(input()) num_list.append(ele_input) print("list : ", num_list) count = 0 max_value = 0 for i in range(n): for j in range(n): if i != j: ...