blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
8ce392826544ef888ea49ea02a3e85364f6926f7
grupyrp/dojos
/2016-03-24/batalha_naval.py
10,652
3.640625
4
#!/usr/bin/env python import itertools import unittest import random from copy import deepcopy class BattleShipTest(unittest.TestCase): def test_board_size(self): game = BattleShip() assert game.get_size() == 100 def test_ships_qt(self): game = BattleShip() assert len(game.ge...
804e72977310b47f5127ce844c7d7083a106577c
David-GaTre/Python-the-hard-way
/pythonPractice/ex25.py
2,763
4.25
4
#the split() divides whatever you have, between the () you put the separater #by default is a ' ', we write it anyways def break_words(stuff): """This function will break up words for us.""" words = stuff.split(' ') return words #sorts the sentence, but it always put capital letters at the beggining #to avoid this...
2a5ec1cf241e6417a8843c5181d8d6d8d0cbb6be
houdinis/python-study
/regression/work1/rhombus.py
365
4.03125
4
# 打印下面的菱形 # * # *** # ***** # ******* # ***** # *** # * # number = 7 def rhom(number): num = number // 2 for row in range(num, (-num-1), -1): star = row if row >= 0 else -row print(" " * star + "*" * (number - 2 * star...
1e413d5450c139654a9f8fde42da8dee9fcd5435
xiangliang-zhang/newcode_test
/中级班/第一章/class4.py
1,520
3.703125
4
class Heap: def __init__(self): self.value = [] def get_parent_index(self, index): if index == 0 or index > len(self.value) - 1: return None else: return (index - 1) >> 1 # >> 二进制右移运算符,相当于除以2 def swap(self, index1, index2): self.value[index1], self....
67425a9288a28c466311ef747afb6085c47b88bf
meherchandan/python-exercise
/ListOverlap.py
232
4.03125
4
def listoverlap(): a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] result = set(item for item in a if item in b ) print(result) if(__name__=="__main__"): listoverlap()
2d9e1b3e8905d0c87d9b60470483136759083152
dvpcloud/py_entry_cert
/bio.py
473
4.25
4
name = input ("what is your name ? ") colour = input("what is your favourite colour ?") age = int(input("what is your age ? ")) print(f"{name} is {age} years old and favourite colout is {colour}") #other way of printing things print(name,end=" ") print("is "+ str(age) + " years old", end = " ") print("and likes colou...
0676fde8578e5d4fb97e4fe65309538e65083834
yabeiwu/das
/das/dataset/box.py
4,090
3.53125
4
import numpy as np class LatticeError(Exception): """ Exception class for Structure. Raised when the structure has problems, e.g., atoms that are too close. """ pass class Box: def __init__(self, matrix): try: m = np.array(matrix, dtype=np.float64).reshape((3, 3)) ...
599a8c4825ea36f15d4952e9cff2426578e9a388
uathena1991/Leetcode
/Interview coding problems/gray number_two numbers 2.py
356
3.6875
4
class Solution(object): def isgray(self,x,y): """ judge if two values are gray numbers or not. :param x: in binary format :param y: in binary format :return: True or False """ res1 = x ^ y count = 0 while res1 > 0: res1,remain = divmod(res1,2) if remain == 1: count += 1 return count == 1 ...
3edcb08cb587a525eded328e6216b34745800a3d
Linkaje/RandomPasswordGenerator
/main.py
505
4.25
4
# Imports the random library import random # Asks the user for the length of the password and transforms it to int type passlen = int(input("Enter the length of the password: ")) # Stores the available characters for the random password s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%*()?" # ...
81396a941f4e2a6727494b91d320f19dc877602f
StefanoCiotti/MyPython01
/MyFirstFl40.py
599
4.25
4
# list comprehension form = [item for item in range()] example = [item for item in range(1, 10, 2)] # ex1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ex1 = [num1 + 1 for num1 in range(10)] # ex2 = [3, 6, 9, 12] ex2 = [num2 * 3 for num2 in range(1, 5)] # ex3 = [2, 4, 6, 8, 10] ex3 = [num3 for num3 in range(2, 12, 2)] # ex1 = [0...
ae87652b95821654fe535ce515c1ca953e5f493d
swjmy/do-something-with-Python
/the_way_to_learn_algorithms/sorting.py
5,429
4.09375
4
#后面各种排序需要用到的,交换l数组中的x,y def swap(x,y,l): l[x], l[y] = l[y], l[x] #可能你也发现了,python中swap操作很方便,不需要单独写一个函数 #但是既然写了,就留下来当做笔记吧 #冒泡排序 def bubble_sort(l): for j in range(len(l),0,-1): for i in range(j): # 循环到最后一个 if i == len(l) - 1: break # 排序结果为递增 ...
127bbb6061ea37db6d1174d9a324d187785ec101
felipsdmelo/Numerical-Calculus
/Numerical Solution for ODE/euler_method.py
1,255
3.90625
4
def euler_method(x0, y0, xf, h, f) : ''' Approximates the value of an ODE using Euler's Method Keyword arguments: x0 - initial value of x y0 - initial value of y xf - final value of x h - size of the intervals (step) f - function of x and y (usually the right side of the equation) ...
703a6ab4588cf0a467e81a1b218b8d2449ccbaaa
JohannesBuchner/pystrict3
/tests/expect-fail23/recipe-113657.py
670
3.765625
4
def classmethod(method): return lambda self, *args, **dict: method(self.__class__, *args, **dict) class Singleton: count = 0 def __init__(klass): klass.count += 1 print(klass, klass.count) __init__ = classmethod(__init__) def __getattr__(klass, name): return getattr(klass, ...
a508948bab2c16c730e79736d127ed06f30020ee
yglj/learngit
/PythonPractice/乱七八糟的基础练习/判断字符串是否为数字.py
352
3.734375
4
import unicodedata def is_number(): s = input() try: if( unicodedata.numeric(s) or float(s) ): return True except (ValueError,TypeError): print("不是数字") return False #is_number() if ( True or 3/0): print("逻辑短路") try: if (3/0 or True): print(0) except : pri...
a074452428044d20cb799a705f4f652e193ba795
xJuggl3r/PY4E
/Assignments/12_3.py
719
4.03125
4
# Exercise 3: Use urllib to replicate the previous exercise of # (1) retrieving the document from a URL, # (2) displaying up to 3000 characters, and # (3) counting the overall number of characters in the document. # Don't worry about the headers for this exercise, simply show the first 3000 characters of the docume...
47e0fb2b2d5e3a79ef6b5eb530225f7c6b8cec7f
rednikon/python-programming-book
/circles.py
386
4.25
4
# pg. 76, problem 1: Mathematical expressions import math def get_volume(): radius = int(input("Let's calculate the volume and area of a circle. Please enter a value for the radius: ")) volume = 4 / 3 * (math.pi * radius**3) area = 4 * math.pi * radius**2 print("The circle's volume is: ", round(volume...
2049176f7ae9e0dfcc29ebca6f574be21312041e
antonin-lfv/plot_picture-python
/Convertir image en niveau de gris.py
1,803
3.75
4
import numpy as np import matplotlib.pyplot as plt import matplotlib.image as mpimg from PIL import Image from PIL.Image import * """ import the picture """ file = 'picture_path.png' picture = open(file) """ plot the picture """ def rgb2gray(rgb): return np.dot(rgb[...,:3], [0.299, 0.587, 0.144]) def plot_gra...
8be4e1bd22a2158d11664bcf24e6869c353df3a3
AJAY-AGARIAN/guvipgms
/17c.py
136
3.703125
4
u=int(input()) u1=u d=0 while(u>1): c=0 c=int(u%10) d=d+(c**3) u=u/10 if(d==u1): print("yes") else: print("no")
e9031cc2fc141dabdb384c8ee26b7232a450e291
robertjrodger/data-structures-and-algorithms
/src/data_structures/lru_cache.py
2,712
3.671875
4
from collections import OrderedDict class Node: def __init__(self, key, value): self.key = key self.value = value self.right: Optional[Node] = None self.left: Optional[Node] = None class LRUQueue: def __init__(self): self.left_end: Optional[Node] = None self.r...
2e9b66ca43b45ca724d6de35750c7a853b776c3b
Warrlor/IlyaUdin
/4zad.py
424
3.828125
4
a=int(input("от ")) b=int(input("до ")) c=int(input("дают остаток ")) d=int(input("при делении на ")) if a<b: print("в отрезок входят ") for i in range(a, b): if (i%d==c): print(i) elif a>b: print("в отрезок входят ") for i in range(b, a): if (i%d==c): ...
87bb3854a948dfd7056fd1095c9f810f27727c98
bingwin/python
/python/面向对象/函数/参数/global.py
261
3.53125
4
# -*- coding: utf-8 -*- # coding: utf-8 age = 18 def happy_birthday(): global age # 定义为global后,可以使用 print "age {}, happy birthday ~".format(age) age += 1 happy_birthday() print "your age is {}".format(age)
84e785c8419d398697612b2ea5567e3b6868e464
adityaKoteCoder/codex
/as2_5.py
91
3.53125
4
x = [1,2,3,4] y = [5,6,7,8] z = [] for i in range(len(x)): z.append(x[i]+y[i]) print(z)
44658e1a3dfbafc489d3f0d15925280fc37efa71
zexhan17/Problem-Solving
/python/a6.py
3,151
4.28125
4
""" There are two main tasks to complete. (a) Write a function with the name calculate_sgpa . The semantics of this function are the same as in the previous grades assignment. However, this time, we will not be passing in three inputs. We will instead be passing in a single list which has the grades in its elements. ...
8a7ac855a3f974e54a77dcba27e226d9e49e62fd
GustavoSousaPassos/Estudos
/python/ex028.py
153
3.9375
4
from random import randint num = int(input('Escreva um número de 0 a 5')) v = randint(0,5) print('Você venceu!' if num == v else'O computador venceu!')
03e6b69e358d523aaab1c213e761dc8ee6062223
iamieht/intro-scripting-in-python-specialization
/Python-Data-Representations/Week2/Ex7_W2_list_reference.py
537
3.96875
4
""" Analyze an example of a list reference situation """ # Initial list list1 = [2, 3, 5, 7, 11, 13] # Another reference to list1 list2 = list1 # Print out both lists print(list1) print(list2) # Update the first item in second list to zero list2[0] = 0 # Print out both lists print(list1) print(list2) # Explain wh...
da536ffbfe555249dee98d8a7724ad2c8fb309a2
deepikaGit/SelfLearn
/Assignment.py
281
4.03125
4
from numpy import array # Adding two array using for loop a = array([2,1,4,5,3]) b = array([8,4,0,2,3]) for i in range(5): temp = a[i] + b[i] print(temp,end=" ") # Max value from an array max = a[0] for i in range(1,5): if max < a [i]: max = a[i] print(max)
6aff3901c408e4b79a8b585d203878bd0637e053
sss6391/iot_python2019
/01_Jump_to_python/5_APP/5_native_function/244_sorted.py
126
3.5625
4
my_list = [3,1,2] print(sorted(my_list)) print(my_list) my_list.sort() print(my_list) my_str = 'acb' print(sorted(my_str))
eceaf0a48c48d643a5153d52b502272498e4cc80
zarkle/code_challenges
/dsa/trees/tree_level_order.py
454
4.0625
4
"""Given a binary tree of integers, print it in level order. The output will contain space between the numbers in the same level, and new line between different levels.""" class Node: """Node class for binary tree.""" def __init__(self, val=None): self.left = None self.right = None sel...
34d42c0a3f014798dc1fbc5f7c494edc859c55d5
amshapriyaramadass/learnings
/Hackerrank/itertools/itertools._combinations.py
663
3.5
4
from itertools import combinations from itertools import combinations_with_replacement # if __name__ == "__main__": # string,number= input().split() # # c = combinations(sorted(string),int(number)) # for i in range(1,int(number)+1): # for c in combinations(sorted(string),i): # print(''....
56463992a6e05743ae11c931de6cc32320edca17
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/meetup/90965d16552f49a495a2be2d3fa358bd.py
963
3.71875
4
from calendar import day_name, Calendar from datetime import date class Meetup: def __init__(self, year, month): self.year = year self.month = month self.cal = Calendar() @property def monthly(self): return self.cal.monthdatescalendar(self.year, self.month) def weeks(...
476122f8a8454eb6a2f51e89aa1ba3a0a33fe76a
alantort10/CS161
/project-2c-alantort10/change.py
721
4
4
# Author: Alan Tort # Date: 6/22/2021 # Description: Project 2c # A program that asks for an integer number of cents from 0 to 99 and outputs # how many of each type of coin would represent that amount with the fewest # total coins print("Please enter an amount in cents less than a dollar.") cents = int(input(...
9c173b42e1bc9a1c35021f7130724b219194b952
ruslaan7/Sort
/bubble.py
229
4.125
4
def bubble_sort(array): length = len(array) - 1 for i in range(length): for j in range(length-i): if array[j] > array[j+1]: array[j], array[j+1] = array[j+1], array[j] return array
753008821036643f543605f3b0fb17c6a73cf9cf
lyggnsj/pessimism-recsys-2021
/src/agents/abstract.py
8,968
3.8125
4
import numpy as np import pandas as pd import math from datetime import datetime # FIXME class Agent: """ This is an abstract Agent class. The class defines an interface with methods those should be overwritten for a new Agent. """ def __init__(self, config): self.config = config def...
3d89292611fe4effa147db3e540aab3488c5f66a
NinaS0220/coursera
/provierka-chisla-na-prostotu.py
272
3.84375
4
# -coding:utf-8 # сложность алгоритма O(корень из n): def IsPrime(n): d = 2 while d * d <= n and n % d != 0: print(d, d*d, n%d) d += 1 return d * d > n if IsPrime(int(input())): print("YES") else: print("NO")
09e602455590f646f63020719e6b0ae2abb5c935
JohnKepplers/a3200-2015-algs
/lab14/Kravchenko/t_sort.py
1,676
3.5
4
from sys import stdin, stdout class Graph: def __init__(self): self.a = [[42],[0]] self.k = 14 / 88 self.list = [] self.d = {42:1} def size_of_matrix(self): return len(self.a) def print_matrix(self): return self.a def size_of_list(self): retur...
ec9d7e59a4c3fd3c5cde09b62b82f5a410758a33
wildbill2/python_projects
/favorite_number.py
711
3.8125
4
# Module imports import json def check_for_number(): """Checks if a favorite number is already stored.""" filename = 'favorite_number.json' try: with open(filename) as f_obj: number = json.load(f_obj) except FileNotFoundError: return None else: return number ...
3f59f6ee2af656e9fd9a0ad114169bcbbb8c47d6
ne7ermore/playground
/python/linkedlist/reverse.py
678
3.578125
4
class Node(): def __init__(self, val=None): self.val = val self.next = None def arr2linked(arr): res = cur = Node(arr[0]) for a in arr[1:]: cur.next = Node(a) cur = cur.next return res def link2arr(link): list = [] while link: list.append(link.val) ...
9df6e0af5d39023673d3f6119b51a57c0aeba170
Fares84/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/4-print_square.py
506
4.1875
4
#!/usr/bin/python3 """ a square printing function: print_square(): >>> def print_square(1): # """ def print_square(size): """ Argument: size {[int]} -- [size of square] Raises: TypeError: [if size is not int] ValueError: [if size < 0] """ if not isinstance(size, int): ...
73daf20cf998a47a6ef0c1787983695e64bee1e8
phu-n-tran/LeetCode
/monthlyChallenge/2020-09(septemberchallenge)/9_30_FirstMissingPositive.py
4,136
4.03125
4
# -------------------------------------------------------------------------- # Name: First Missing Positive # Author(s): Phu Tran # -------------------------------------------------------------------------- """ Given an unsorted integer array, find the smallest missing positive integer. Example 1: ...
4b585bc30981c7ba7b185562e24539cbde9ecab4
benzoxyl/vector-product
/vectorproduct.py
2,446
3.5625
4
from tkinter import Tk, Label, Entry, Button, mainloop, messagebox from PIL import Image, ImageTk def formatFloat(num): if num % 1 == 0: return int(num) else: return num def vectorProduct(): a = [None] * 3 b = [None] * 3 n = [None] * 3 # Abfrage der a1-3 und b1-3 W...
d11d40d029bce7831791a2b81c5eebf5ea1a58c4
pbwis/training
/HackerRank/HR_ch10/test.py
131
3.78125
4
import collections z = [1,2,3,2,1,5,6,5,5,5] print(z) print([item for item, count in collections.Counter(z).items() if count > 1])
b661dcdc1747ac4f839d31c998aca0c25b0c65e3
dsbrown1331/Python1
/Introduction/hello_world.py
229
3.625
4
print("Hello World!") print('Python is fun!') print('We can make the computer talk!') print("You can print a single quote like this, 'hi'.") print('You can also print double quotes, "hey there!", inside single quotes, "voila".')
c14de042f14c928588dee98b9515fbdcb65c1ffb
jishak13/PythonCourse
/printFormats.py
488
3.828125
4
# -*- coding: utf-8 -*- """ Created on Sat Dec 16 09:14:54 2017 @author: JoeRemote """ from __future__ import print_function print "This is a string" s = "String" "s stands for string" print "Place my variable here: %s" %(s) print 'Floating point number: %1.2f' %(13.1245) print 'Convert to String %s' %(123) ...
7a524bd1c4c2e019c86aa2e02170ce546c095f6b
limdongjin/ProblemSolving
/python-lab/test_performance_named_tuple.py
1,313
3.625
4
import unittest class MyTestCase(unittest.TestCase): def test_something(self): from datetime import datetime N = 3000 # N*N 개의 tuple 을 리스트에 저장하고. 요소에 접근하는 시간을 측정한다. start = datetime.now() items = [(y, x) for x in range(N) for y in range(N)] for item in items: ...
783ca6462599afb01b7fead7841f40ddbe6c3569
ngvinay/python-projects
/PythonBasics/src/functions.py
1,648
4.3125
4
def changeme( mylist ): #"This changes a passed list into this function" '''All parameters (arguments) in the Python language are passed by reference. It means if you change what a parameter refers to within a function, the change also reflects back in the calling function.''' mylist.append([1,2,3,4]);...
ca0d1171d218ed8c55c82c6df9ee9c4d6e90f679
ahmettkara/class2-functions-week04
/11.equal_reverse.py
387
4.375
4
def equal_reverse(*args): "The function that controls the given inputs whether they are equal with their reverse writing or not." result="" for i in args: if i == i[::-1]: result += f"{i} ---> True\n" else: result += f"{i} ---> False\n" return result print(equal...
8b40b24762024f6453b2d1bd31e9a26e0a657ebf
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_87/44.py
1,659
3.703125
4
def int_input(): return int(raw_input()) def list_int_input(): return map(int, raw_input().split()) def list_char_input(): return list(raw_input()) def table_int_input(h): return [list_int_input() for i in range(h)] def table_char_input(h): return [list_char_input() for i in range(h)] def run_p...
20a1ccf8df33f44540833686cd871acf029f1364
haegray/Python-and-Java-Files
/sumStrings.py
221
3.546875
4
#sumStrings.py def sumStrings(strList): toNumbers=[] sum = 0 for i in strList: num = eval(i) toNumbers.append(num) for num in toNumbers: sum = sum + num print(sum) sumStrings()
3efac7da878be7b0989d0d7ea20a4b067801042b
Guilherme-full/Python-jogo-
/JogodoParOuImpar.py
866
3.765625
4
from random import randint v = 0 while True: jogador = int(input('Diga um número: ')) computador = randint(1, 10) total = jogador + computador tipo = ' ' while tipo not in 'PI': tipo = str(input('P/I: ')).strip().upper()[0] print(f'Você disse o número {jogador}, e o computador pensou no...
647c6be4723f430cf80848df293488e526b52584
prachichikshe/filehandling
/assign13.py
982
3.96875
4
#Write a Python program to combine each line from first file with the corresponding line in second file. with open('abc.txt') as fh1, open('pc.txt') as fh2: for line1, line2 in zip(fh1, fh2): # line1 from abc.txt, line2 from pc.txtg print(line1+line2) ...
03c87cd55c2fc53e4f4171fd803d314beb6ac05f
mkozel92/algos_py
/linked_lists/remove_duplicates.py
943
4.15625
4
from linked_lists.linked_list import LinkedList def remove_duplicates(a_list: LinkedList): """ removes duplicates from a linked list by keeping track of seen elements complexity O(N) :param a_list: a linked list to process """ seen = set() current = a_list.head seen.add(current.data) ...
dbc51636535ab001530582f82156ef1363f01631
Rodolfo-SFA/FirstCodes
/aula021b.py
505
3.640625
4
def funcao(): n1 = 4 print(f'N1 dentro vale {n1}') n1 = 2 funcao() print(f'N1 fora vale {n1}') def teste(b): # Escopo local global a a = 8 b += 4 c = 2 print(f'A dentro vale {a}.') # --> Receberá o "a" local print(f'B dentro vale {b}.') # --> Receberá o "a" local print(f'C dent...
be90357ee0f1e513353be47f67952a6ef81473d6
rovin/Python
/dict.py
489
4.1875
4
# Enter a line of text and find the most common word counts = dict() line = raw_input("Enter a line of text: ") words = line.split() print 'Words: ', words bigcount = None bigword = None for word in words: counts[word] = counts.get(word,0) + 1 print " Total count: ",counts for word,count in counts.items(): ...
a970e08641de98a7a10948a5728d53c4a1fb7692
AshishGoyal27/Face_detection
/face_detection/face_detect.py
493
3.6875
4
import cv2 #load the pre-trained face detection model face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_alt.xml') #choose an image on which we want to test our code img = cv2.imread('image2.jpg') #detect faces in an image faces = face_cascade.detectMultiScale(img, 1.1, 4) #draw rectangles around the ...
4897a9090d5f70b104877414f3c670cfb4eac48c
zakuro9715/aoj
/10018.py
159
3.984375
4
s = raw_input() a = "" for c in s: if c >= 'A' and c <= 'Z': a += c.lower() elif c >= 'a' and c <= 'z': a += c.upper() else: a += c print a
9203898fff5a4d4d8397846dbe7bf5e4c9cd58b3
IsseW/Python-Problem-Losning
/Uppgifter/1/1.33.py
1,189
3.984375
4
""" Övning 1.33 - Ränta på ränta När man sätter in pengar på banken får man ränta på insatt kapital, dvs. kapitalet som är insatt i banken ökar med ett viss en procent varje år. Om man till exempel sätter in 10 000 kronor med 4% ränta har man 10000 · 1.04 = 10400 kronor efter första året. Andra året har man 10400 · 1.0...
1a3052985193cb8c8fe387ef7dc1e64f2c179d42
Hu-Wenchao/leetcode
/prob214_shortest_palindrome.py
753
4.1875
4
""" Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation. For example: Given "aacecaaa", return "aaacecaaa". Given "abcd", return "dcbabcd". """ class Solution(object): def s...
163ea54ac945fe2ba7cacccd3e258ab1fe190a93
umoqnier/programas_IA
/vectores.py
6,243
3.953125
4
# Programa que realiza operaciones con vectores # !/usr/bin/python # -*- coding: utf-8 -*- # Universidad Nacional Autonoma de Mexico / Facultad de Ingenieria # inteligenica Artificial # Alumnos: # Almazán García Giovanni # Barriga Martínez Diego Alberto # Bustamante Carrera Manuel Alejandro # Juárez Pasc...
a30c9e168f60d3635e846803a4e7a5ce5e00ecda
DavidS48/Flavour-Graph
/graphs.py
9,786
3.546875
4
test_nodes = [1,2,3,4,5,6] test_links = { 1 : [2,3], 2 : [1,3,5], 3 : [1,2], 5 : [2] } def is_complete(graph): pass def makes_complete(graph, new_node, links): for node in graph: if node not in links or new_node not in links[node]: ...
4fd8c924a6140ff2394ef5a317e8d23d8d1dfe39
anaypaul/Codeforces
/Contest Questions/DIV2/CFR_85_DIV2_A.py
269
3.78125
4
def main(): first = input() second = input() first = first.lower() second = second.lower() if(first == second): print("0") elif( first < second): print("-1") else: print("1") if __name__ == '__main__': main()
970b282851f1610fc766758cad8273e64cdb547c
solaimanhridoy/penguin-swe-intern
/task_3/services/Routine.py
484
3.5625
4
class Routine(): def __init__(self, dayIndex:list, hourIndex:list, courseIndex:list): # super().__init__(course_name, teacher_name) self.day = dayIndex self.hour = hourIndex self.course = courseIndex def show_routine(self): courses = ["English Grammar", "Mat...
7c6f1a254c796a55a8b2b74de1ef4cbe1bb11ee3
saml/x
/py/bible_ko_niv_json.py
878
3.515625
4
import sqlite3 if __name__ == '__main__': conn = sqlite3.connect('bible_ko_niv.sqlite') c = conn.cursor() book_names = {rowid: (ko_name, en_name) for rowid,ko_name,en_name in c.execute('SELECT rowid,ko,en FROM books')} tree = [] bible = { 'ko': {ko:book_id-1 for book_id,(ko,_) in book_names...
74f7e9159655212aa05dc35626a378b8f43119fb
reemnasserr/AImancala
/heuristic1.py
2,533
3.5625
4
# scoring ratio from typing import Tuple stealing_score = 1.2 farther_score = 1 repeating_score = 0.8 prevent_stealing = 0.5 # * number of balls prevented from stealing def score_evaluation(board, turn, stealing=True): heu_score = [0,0,0, 0,0,0, 0 ,0,0,0, 0,0,0, 0] # heuristic 2 prefere again a...
11c508d884685726f9df64e3b0da87dacf9506c5
Boissadax/school-projects
/school-projects/Maths/euler.py
449
3.78125
4
def euler1(a,h): x=1 y=0 while x<a: x = x + h y = y + h / x print("f(",a,") = ",y,"avec h =",h) return """ euler1(2,1) euler1(3,1) euler1(7,1) euler1(2,10) euler1(3,10) euler1(7,10) """ def euler2(a,h): x=1 y=0 if a>1: while x<a: x=x+h y+...
1713abb88185b2087dd469706a371d15c979ca56
y43560681/y43560681-270201054
/lab12/example3.py
1,013
3.78125
4
class DNA: def __init__(self, dna): self.dna = dna def count_nucleotides(self): nucleotides = {} a, c, g, t = 0, 0, 0, 0 for i in self.dna: if i == "A": a += 1 elif i == "C": c += 1 elif i == "G": ...
0b03ba48ff915e6ecb5ab7af7fa96b1096f42070
ananiastnj/PythonLearnings
/LearningPrograms/Fibo.py
136
3.625
4
def fib(n): result=[0] a,b=0,1 while b<n: a,b = b,a+b result.append(a) #print(result) return result
bcea72ba2947e64e6a2457f3e31d84aafff5c896
frankkarsten/MTG-Math
/DwarvenMine.py
9,045
3.828125
4
''' MULLIGAN RULE: Consider a red-blue deck. • A 7-card hand is kept if it has 2, 3, 4, or 5 lands. • For a mulligan to 6, we first choose what to put on the bottom and decide keep or mull afterwards. To get a good mix, we bottom a spell if we drew 4+ spells and we bottom a land if we drew 4+ lands. Afterwards, we...
dea957cc7bed1973b12cfa34be33a77c203b47b6
Rodagui/Cryptography
/Gammal.py
2,146
3.84375
4
from exponenciacion import* from generadorPrimos import* from inversoModular import* from primalidad import* from random import * # Python Program to find the factors of a number def obtenerFactoresPrimos(n): factores = set({}) if n % 2 == 0: factores.add(2) while n % 2 == 0: n = n // 2 ...
070f9aecf4abaf13851962f2aa41ec963108cb35
GeorgeTzan/python
/mathites.py
282
4
4
students = 8 grades = [] for i in range (students): grade = input("Bathmos: ") grades.append(grade) total = int(sum(grades)) average = total / 8 print "xamhloteros bathmos: ", min(grades) print "megistos mathmos: ",max (grades) print "mesos oros: ", average
81f716596aecad70307dc869efa3f13063c35f61
helloallentsai/leetcode-python
/268. Missing Number.py
691
3.9375
4
# 268. Missing Number # Easy # 1312 # 1726 # Add to List # Share # Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. # Example 1: # Input: [3,0,1] # Output: 2 # Example 2: # Input: [9,6,4,2,3,5,7,0,1] # Output: 8 # Note: # Your algorithm should ...
655e9451619a546784a2fc03cff3dc6fdd986b07
higashizono33/python_stack
/_python/python_fundamentals/functions_basicII/functions_basicII.py
2,378
4.3125
4
# Countdown - Create a function that accepts a number as an input. Return a new list that counts down by one, # from the number (as the 0th element) down to 0 (as the last element). # # Example: countdown(5) should return [5,4,3,2,1,0] # my function↓ # def countdown(num): # new_list = [] # for i in range(num, ...
70b5f1d2e9c9743feb19604ab7546ef3772e8d7f
solenebutruille/MultiArmBanditProblem
/src/E-greedy_Reward.py
3,273
3.59375
4
# -*- coding: utf-8 -*- """ @author: Butruille Solène """ import sys import numpy as np import matplotlib.pyplot as pyplot import time # Display percentage of advancement def advance_statut(update): sys.stdout.write("\r%d%%" % update) # Epsilon_greedy algorithm def epsilon_greedy(epsilon, number_o...
c7976f29fa46ba976a059dd20ab977717483e87b
MarvickF/Coding-from-School-2020
/randompatterns.py
1,569
4.09375
4
""" Marvick Felix 11/24/2020 File: randompatterns.py Draws a radial pattern of squares in a random fill color at each corner of the window. """ from turtle import Turtle from polygons import * import random def drawPattern(t, x, y, count, length, shape): """Draws a radial pattern with a random fill color ...
7a1e572a360e1d065f6efbeb3a6b3e42790b5516
horseTom/Test
/study-python/Day07.py
2,881
4.09375
4
def t_str(): str1 = "hello World!" print(len(str1)) print(str1.capitalize()) print(str1.upper()) print(str1.find('shit')) #不存在的返回 -1 print(str1.index('or')) #不存在的报异常 print(str1.startswith('he')) #返回FALSE 或者 TRUE print(str1.endswith('lo')) #返回FALSE 或者 TRUE print(str1.center(50, '*'))...
9c31d78c6a4d96781bac88859e7001b9502dc832
ambergooch/urban-planner
/main.py
843
3.84375
4
from building import Building from city import City eight_hundred_eighth = Building("800 8th Street", 12) eight_hundred_eighth.purchase("Fred Flintstone") eight_hundred_eighth.construct() # print(eight_hundred_eighth) three_hundred = Building("300 Plus Park Blvd", 6) three_hundred.purchase("Barney Rubble") three_hund...
fcc820614a6c175395ba72a0ca1fc7e1d72f58f6
1234567890boo/ywviktor
/MachineLearning/Boxplot.py
322
3.890625
4
import matplotlib.pyplot as plt figure=plt.figure(1,figsize=(9,6)) #makes the boxplot axes=figure.add_subplot(111, title="Boxplot Are cool") #adds name axes.boxplot([[1, 2, 3, 4, 5], [6,7,8,9,10],[11,12,13,14,15]])#shows the axes each list in the list is 1 box plot axes.set_xticklabels(["Dogs","Cats","Bats"]) plt.show...
d3b34dddcee328b6ee47c70777a4eeff8b29f69f
enyel2/Script_python_Basic
/referencias_variable_lista.py
560
3.65625
4
#varibles #spam = 42 #cheese = spam #spam = 100 #print(spam) #print(cheese) #listas #primero = [0, 1, 2, 3, 4, 5] #segundo = primero #segundo[1] = 'Hello' #print(primero) #print(segundo) #las listas generan un solo id que puede se llamado por diferentes nombres #def eggs(someParameter): # someParameter.append('...
8608308b8bffff6e52ac5afebad0feaff672e07b
rustiri/Mission-to-Mars
/scraping.py
6,338
3.53125
4
# Import Splinter and BeautifulSoup from splinter import Browser from bs4 import BeautifulSoup as soup #import pandas import pandas as pd import datetime as dt import html5lib #function to scrape all the data and create dictionary def scrape_all(): #initiate headless driver browser = Browser("chrome", executa...
bfca9de088a0f1fd5578db938e934bd44d6ef09b
baibhab007/Database-operation
/connectDB_createTB.py
756
3.53125
4
import sqlite3 def register(NAME, AGE, SEX, INITIAL_AMOUNT): con = sqlite3.connect('TEST.db') cursor = con.cursor() sql1 = 'DROP TABLE IF EXISTS CUSTOMER' sql2 = ''' CREATE TABLE CUSTOMER ( NAME CHAR(20) NOT NULL, AGE INT, SEX CHAR(1), INITIA...
a891d9a214698836877778116d3ce391f0bbc148
etherwar/MITxWordgame
/wordgame.py
20,288
3.734375
4
# The 6.00 Word Game import random from randomdict import RandomDict import threading import queue import textwrap VOWELS = 'aeiou' CONSONANTS = 'bcdfghjklmnpqrstvwxyz' HAND_SIZE = 7 SCRABBLE_LETTER_VALUES = { 'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j': 8, 'k': 5, 'l': 1, 'm': ...
638fa45799bb6c7ce2687b37c8df46d362f2fb70
meighanv/05-Python-Programming
/LABS/Labs-3-1/lab3-1-8.py
617
4.15625
4
#Setting variable for tip and sales tax salesTax = 0.07 tip = 0.15 #User input for amount of meal purchase purchase = input("Input amount of meal purchase: \n") #Input validation for numeric #Using .replace to get rid of decimal to validate input is numeric while purchase.replace('.','').isnumeric() == False: purc...
820b496eb033c91342bd2bd281c36b6c093e63b8
adam7395/bioinformatics_algorithms
/textbook_track/burrows_wheeler/BWMatching_1.py
4,251
3.75
4
''' ############################################################################ ############################################################################ # Finds the number of occurences of finding a pattern in a text given only # the first and last column, the pattern, and the lastToFirst # http://rosalind....
7d78a8a72e0bb2ff4f79555fdba5ff28a6744324
ryanA998/LeetCode-Problems
/LeetCode_1480_Sum_1D_Array.py
798
3.9375
4
#LeetCode Problem 1480: Returing Sum of 1D Array #Author: Ryan Arendt #Verified: 11/15/2020 #Description: # Goal: Return the Sum of a 1D array. # Given an array nums. We define a running sum of an array as # runningSum[i] = sum(nums[0]…nums[i]). # Return the running sum of nums. # Example: # Input:...
b1314e61d4a75b2a7981ce598b496fb705bc6254
maleks93/Python_Problems
/algos/merge_sort.py
1,095
3.859375
4
# Merge Sort # Avg Time complexity: O( NlogN ) # Worst/Best case Time complexity: O( NlogN ) # Space complexity: O(N) class Solution(object): def sortArray(self, nums): """ :type nums: List[int] :rtype: List[int] """ # Merge sort if len(nums) < 2: ...
6544c7f0fcb16fec60daa8b2abc1768f470660d7
Mapashi/Ejercicios-Python
/Actividad 1.1.py
324
3.71875
4
#1.1 Introduciendo la hora del día en horas, minutos y segundos, calcular cuántos segundos han transcurrido desde el comienzo del día horas = int(input("Introduce la hora: ")) minutos = int(input("Introduce los minutos: ")) segundos = int(input("Introduce los segundos: ")) total = segundos + minutos * 60 + horas * 3600...
c11bdad489a95b521c00c1d473432109a5c313fd
KwantomSolace/joint-project
/game.py
21,715
4.0625
4
#!/usr/bin/python3 from introendings import * from map import rooms from player import * from items import * from gameparser import * from debate import * import os global game_over game_over = False global debate_over debate_over = False def list_of_items(items): """This function takes a list of items (see item...
884a20f648777191b43b56d3476d75c4ca12c6e3
rosepcaldas/Cursoemvideo
/ex086.py
508
4.28125
4
''' EXERCÍCIO 86 - MATRIZ EM PYTHON Crie um programa que crie uma atriz de dimensão 3 x 3 e preencha com valores lidos pelo teclado. No final mostre a matriz com a formataçã correta ''' matriz = [[0,0,0], [0,0,0], [0,0,0]] for lin in range(0, 3): for col in range(0, 3): matriz[lin][col] ...
695ba511215b1d0c3e68845a665b5fc246b40bda
apan64/basic-data-structures
/Programming Assignment 4.py
1,637
3.578125
4
import math import sys class AdjMatrixGraph: def __init__ (self): self.n = 0 self.array = [] self.arraynames = [] def display (self): for x in range (self.n): for y in range (self.n): print ("{0:2}".format(self.array[x][y]), end=" ") ...
11c23a8be509cee389ad06657ea5e8ec9b6618b4
tanshen/py_leetcode
/test.py
239
3.6875
4
from collections import OrderedDict a = dict() a['e'] = 1 a['a'] = 2 a.update({'banana': 3, 'apple':4, 'pear': 1, 'orange': 2}) a = OrderedDict(sorted(a.items(), key=lambda x:x[1])) print(a) d = a.popitem(0) print(d[1]) print("a" < "aa")
77e7403094acb65850c8db5b29a503128394e86c
neelup84/Python
/requests.py
273
3.984375
4
import random import string def password_generator(size=8, chars=string.ascii_letters + string.digits + string.punctuation): return ''.join(random.choice(chars) for _ in range(size)) print(password_generator(int(input('How many characters in your password?'))))
e6136cfcd1d8477b5065eb795c1932ba0af5b37d
ChenYingLong2016/basis
/src/basis/magic_methods_rewrite.py
1,228
4.125
4
# coding = utf-8 ''' Created on 2016年11月17日 @author: 陈应龙 ''' '''魔法方法,总是被双下划线包围,如学过的__init__, __init__这个方法返回值必须为None。这个方法的作用 终于想到了,就是函数必须被调用才会执行,可是这个方法 不需要调用也一样执行了。也就是说类里面不需要调用, 最先执行的就是__init__方法。''' class Rectangle: def __init__(self,x,y): self.x = x self.y = y def getPeri(self): return (self.x + self.y) * 2 ...
13b66388f73e9a3898c656684ef163c0a01ab9e6
ahmedlela/learnpython
/sum.py
521
3.8125
4
# recursive/recursion def recSum(arr): if len(arr) == 0: # Base case return 0 return arr[0] + recSum(arr[1:]) # [20,5,30] = 55 # 20 + sum([5,30]) = 20 + 35 # 5 + sum([30]) = 35 # 30 + sum([]) = 30 # print(recSum([20, 5, 30])) # Find max def recMax(arr): if len(arr) == 0: # Base case ...
39b921acb839f4df33a603c64dbd4843c40c86ff
tylerharter/caraza-harter-com
/cs220_tools/anonymize_whoAreYouSurvey.py
986
3.75
4
import hashlib import csv ################################################################################ # This program requires the response to "Who are you" survey as a csv file named # "Who_are_you_responses.csv" # # Run simply as python3 anonymize_whoAreYouSurvey.py #############################################...
100f70885fa3b806f2231ecc1e0e5bbdb2de4161
LauDAW/dam2020
/ejercicio5.py
343
3.96875
4
print("== Convertir números binarios en enteros ==") binario = int(input("Introduce un número binario para transformar: ")) def binario_a_entero(binario): decimal = 0 binario = str(binario) decimal = int(binario, 2) return decimal print("El número binario", binario, "equivale a", binario_...
bcc2b8848661e371ea6bc57bfb4d93c3254113ed
talesritz/Learning-Python---Guanabara-classes
/Exercises - Module I/EX023 - Separando números.py
397
4
4
#Faça um programa que leia um número de 0 a 9999 e mostre na tela cada um dos dígitos separados. print('-=-'*9) print('EX023 - Separando números') print('-=-'*9) print('\n') num = int(input('Digite um número: ')) print('Milhar: {}' .format(num//1000%10)) print('Centena: {}' .format(num//100%10)) print('D...
c910bfd37005593afb9d0d13506e6bf90f5efc9c
Ardhra123/Python-Programming
/decimals.py
523
3.828125
4
a = 3.1415926 b = -12.9999 c = 314.987 d = 11.09875 e = 20.987656 print("\nOriginal Number: ", a) print("Formatted Number with sign: "+"{:+.5f}".format(a)); print("Original Number: ", b) print("Formatted Number with sign: "+"{:+.5f}".format(b)); print("\nOriginal Number: ", c) print("Formatted Number with sign: "+"{:+....
37c350c2c306011d0f85712d0baa9403ae5df265
BlakeMcMurray/Coding-Problem-Solutions
/Arrays/sumToValue.py
345
3.78125
4
#finds indexes of values that sum to val #O(n) sol def sum_to_value(val,arr): hash_t = {} pairs = [] for i in arr: if i not in hash_t: hash_t[val - i] = i else: if (i,val-i) not in pairs: pairs.append((i,val-i)) return(pairs) print(sum_to_value(5,...
6d5c3a40f25d54dc204aebba0b52b12e6615a880
ethan786/hacktoberfest2021-1
/Python/Blinding Auction/blindAuction.py
1,229
4.21875
4
# This program is designed so that we can organize blind auction at a small platform import os logo = ''' ___________ \ / )_______( |"""""""|_.-._,.---------.,_.-._ | | | | ...
efa1a59598a735e445c3b804b6a8f1c0e31eada3
sliwkam/Beginning
/a18_Cows_And_Bulls.py
1,098
3.734375
4
import random def cows_and_bulls(number, rand_number): # counts number of 'cows' count = 0 for i in range(0, 4): if number[i] == rand_number[i]: count += 1 return count if __name__ == "__main__": rand_num = str(random.randint(1000, 9999)) su = 1 attempts = 0 # exp...
499538bd5b71be56e68f31e12e720c2e8f5a5c68
AruN227/python
/tikinter.py
582
3.65625
4
from tkinter import * window = Tk() window.wm_title("India X1") l1 = Label(window, text="Virat Kohli(C)") l1.grid(row=0, column=2) l2 = Label(window, text="Rohit Sharma(Vc)") l2.grid(row=0, column=3) l3 = Label(window, text="MS Dhoni(WK)") l3.grid(row=3, column=0) l4 = Label(window, text="KL Ragul") l4.grid(row=3,...