blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
9156a2dab4ccb9dce11be4b6918fbfb81266c84d
thomas-rohde/Classes-Python
/exercises/exe41 - 50/exe045.py
129
3.6875
4
#for par in range(0, 51): # if par % 2 != 1: # print(par, end=' ') for par in range(2, 51, 2): print(par, end=' ')
dbd29974b3537835d722953d9d39df7319f1115c
hinesk7862/Casio-Program-Collection
/Vectors/Projection/ProjectionVector.py
906
4.03125
4
#Author: Kevin Hines #Date: 10/20/2021 #This is a calculator that takes vector V and W with an angle and calculates #the projection of W onto V import math print("This is a vector projection calc") print("(projecting W onto V)") print("Vector V's components") Vx = float(input("Vx: ")) Vy = float(input("Vy: ")) Vz = f...
85c00ca3e17f79fdf75bd8fe64b77d3bd3849e3e
aby180182/PythonCore
/Lesson_6(Function)/class_task4.py
1,170
4.34375
4
# 4. Написати програму, яка обчислює площу прямокутника, трикутника та кола # (написати три функції для обчислення площі, і викликати їх в головній програмі в залежності від вибору користувача) from math import pi def square_rectangle(): a = float(input("Enter first side of rectangle: ")) b = float(inp...
920ba871377444bbdc83d0cbd42e0d9798ebe492
Yassie-0243/roboter
/roboter/roboter.py
5,732
3.59375
4
import csv import os CONVERSATION_BREAK = "==============================" class AnswerError(Exception): pass def ask_name(robot_name): """ 名前を尋ねる。アイスブレイクは大事。 :param robot_name: roboter()から渡しています。 :return: ユーザーの名前を返します。 """ print(CONVERSATION_BREAK) print("{robot_...
3e8152fe232d82f89d980405f80018ae2d765718
gutaors/ToolBox
/DATA LEAKAGE.py
15,626
3.9375
4
#!/usr/bin/env python # coding: utf-8 # **[Intermediate Machine Learning Home Page](https://www.kaggle.com/learn/intermediate-machine-learning)** # # --- # # Most people find target leakage very tricky until they've thought about it for a long time. # # So, before trying to think about leakage in the hou...
996ecde0be96ed36fd5a5f8aedf850d637cd7376
intermezzio/war-card-game
/war_cards.py
3,211
3.78125
4
import random from CardsPlayer import CardsPlayer NUM_PLAYERS = 3 players = dict() def playGame(): global players """ Make a deck, players, and a pile 2-10 is 2-10 11 = J, 12 = Q, 13 = K, 14 = A """ finishingPlaces = [] # List of players in order of losing deck = [i for i in range(2,15)] * 4 random.shuffl...
e40588c07dc56e77be954e3fb1ab38f9dc64aff3
ten2net/Leetcode-solution
/104. Maximum Depth of Binary Tree.py
751
3.734375
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def maxDepth(self, root): """ :type root: TreeNode :rtype: int """ from collectio...
df339ca6969875a6edb7623fbabd3d34791e57d2
ccollins12000/get_running_shoe_data
/get_shoe_data.py
4,029
3.515625
4
""" Scrape running shoe information This module contains code for web scrapping data about running shoes from the Brooks web page and writing the data to a csv Attributes: detail_expressions (dict): Contains instructions/expressions for extracting various product details """ import re import requests fro...
bdff65875f33200615a8b072e280ddd0df49001e
khodwe56/Pong-game
/pong.py
3,793
4.28125
4
### A simple pong game. import turtle import os ## Creating a window and defining it window = turtle.Screen() window.title("pong game") window.bgcolor("black") #Dimmensionality starts from center of screen. window.setup(width = 800, height=600) ##Everything has to be updated manually window.tracer(0) ###Paddle 1...
e5ef169a08e1826df745424973f2a977a5fc56f9
maxLatoche/byte_work
/01_bash_git_fundamentals/title_case_3/title_case_3.py
312
3.96875
4
def titlecase(string, emph): my_string = string for i in range(0,len(emph)): if emph[i] in string: my_string = my_string.replace(emph[i],emph[i].upper()) return my_string print(titlecase("optimus prime and the autobots assembled to fight the decepticons",['optimus', 'prime', 'autobots', 'victorious']))
00912d726e2049153109869488cd6e47e175de55
nishantchaudhary12/w3resource_solutions_python
/Tuple/dataTypes.py
153
3.953125
4
#Write a Python program to create a tuple with different data types. def main(): x = tuple() x = (1, 'string', 2.0, True) print(x) main()
73c5f033c8a163d911f964ebc945521b23833c78
Brian1231/LeetCodePython
/Minimum Index Sum.py
1,009
3.75
4
def findRestaurant(list1, list2): """ :type list1: List[str] :type list2: List[str] :rtype: List[str] """ def findRestaurant(self, list1, list2): """ :type list1: List[str] :type list2: List[str] :rtype: List[str] """ dict = {} for i in r...
7ab1d75d4747b35714d2b897eed0017304d7063e
linuxemb/python
/decor_reuse2.py
2,767
3.53125
4
class Animal: def __init__(self, name, num_of_legs): self.name = name self.num_of_legs = num_of_legs def get_number_of_legs(self): print(f"I have {self.num_of_legs} legs") class Dog(Animal): def __init__(self, name, num_of_legs): super().__init__(name, num_of_legs) def bark(self): prin...
c108884a7e82a8867eedce7a63fe0cc5521eda7b
Junnicesu/Leetcode
/python/tree_q4(Symmetric).py
1,263
3.796875
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 isSymmetric(self, root: TreeNode) -> bool: curRow = [] if root: curRow = [ro...
c8761d9eb3e8e5d0f36182bde1aa2fbc46734b87
shiznet/leetcode
/progress1/ReverseInteger.py
489
3.96875
4
class Solution: # @return an integer def reverse(self, x): minus = False reversed = 0 if x < 0 : minus = True x = 0 - x while x > 0: last = x%10 reversed = reversed*10 + last x = x /10 if minus: rever...
3b6bef581c527ab75a0f8db47120967f619334bd
beninghton/notGivenUpToG
/Tree/112. Path Sum.py
1,343
3.65625
4
# -*- coding: utf-8 -*- class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None p = TreeNode(1) l = TreeNode(2) p.left = l #r = TreeNode(3) #p.right = r q = TreeNode(1) l = TreeNode(2) q.left = l root = q q = q.left r = TreeNode(3) q.left = r class Solutio...
b63ef4f45c33a568f8a6fddf107ecdf14d0f1451
jonathangueedes/python-alura
/Jogos/adivinhacao.py
1,621
3.953125
4
import random def jogar(): print("************************************") print("* Bem vindo ao jogo da adivinhação *") print("************************************") numero_secreto = random.randrange(1,101) # numero_de_tentativas = 0 pontos = 1000 rodada = 0 print("Qual o nive de dific...
d991a9048c3410f21b9ba260a8436fe6e110b77c
ZhekunXIONG/Andorra_RNC
/ZHEKUN/3_Combine_CSV.py
2,359
3.6875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sep 25 2017 Categorize the csv files produced by "2_File_Differ_in_Day.py" into differnt days, and combine for each day e.g. combine 20160705_10.csv and 20160705_11.csv, and produce "20160705.csv" ** If using "2b_File_Differ_in_Day_SHORTCUT.py", we can ski...
8a0b09112639dd3fc067f1b6f5f32ebe779bbcee
johntelforduk/advent-of-code-2019
/15-oxygen-system/part_2.py
1,283
3.5
4
# Part of solution to day 15 of AOC 2019, "Oxygen System". # https://adventofcode.com/2019/day/15 from oxygen_search import World from copy import deepcopy this_world = World() this_world.load(filename='world.txt') # File produced by part_1. this_world.print(include_droid=False) oxygen = [this_world.oxyge...
e6fdfcf6701602536c8dbb7da2c268947ae3b380
Uxooss/Lessons-Hellel
/Lesson_04/4.1 - all_square_numbers.py
571
3.828125
4
# По данному целому числу n распечатайте все квадраты натуральных чисел, # не превосходящие n, в порядке возрастания. n = int(input('\nВведите целое, положительное число:\t')) t = '\nКвадраты чисел, не превосходящие число {}\n - это числа:\t{}' n = abs(n) a = 0 s = 0 i = '' while s < n: s = a + 1 a += 1 ...
d6d5592d7155f3feedffcaa0b8ab7f3482bc0fc3
XMK233/Leetcode-Journey
/py-jianzhi-round3/JianzhiOffer30.py
2,390
4.03125
4
''' [剑指 Offer 30. 包含min函数的栈 - 力扣(LeetCode)](https://leetcode-cn.com/problems/bao-han-minhan-shu-de-zhan-lcof) 定义栈的数据结构,请在该类型中实现一个能够得到栈的最小元素的 min 函数在该栈中,调用 min、push 及 pop 的时间复杂度都是 O(1)。   示例: MinStack minStack = new MinStack(); minStack.push(-2); minStack.push(0); minStack.push(-3); minStack.min(); --> 返回 -3. minS...
5b00d02fa513bcd47f4d187bb77631346f707e8d
caterinalorente/mooc
/python_challenge/src/15riddle.py
947
3.796875
4
''' -- Riddle 15 -- http://www.pythonchallenge.com/pc/return/uzi.html <!-- he ain't the youngest, he is the second --> <!-- todo: buy flowers for tomorrow --> whom? - 1756, Mozart -------------- ''' #import calendar # #calendario = calendar.TextCalendar(6) #for i in range(1006, 1997, 10): # p...
d66b30c4a93b8150c10788b84b25e5f4fc13980a
nabhani97/Testing
/linearSearch.py
349
3.515625
4
# -*- coding: utf-8 -*- """ Created on Mon Jun 10 10:56:32 2019 @author: nabha """ #list = [2,5,7,3,4,12,9] list = [2,5,7,3,4,12,9,4,35,54,45,6,5,2,878,9,0] x = 9999 found = 0 for i in range(0,len(list)): #print(i) print(list[i]) if x == list[i]: found = 1 print('Found = ' ...
63e50955402789b91fe4c4551af0590b5fd9a272
faille/repo1
/git5.py
291
3.5
4
from microbit import * x = 0 while True: if button_b.was_pressed() and x < 5: for y in range(5): display.set_pixel(x, y, 9) x += 1 elif button_a.was_pressed() and x > 0: for y in range(5): display.set_pixel(x -1, y, 0) x -= 1
e5bd9c85004ac748669c5c153c983b564bc8aaf6
cjvalverde/animation
/bubble.py
1,370
4.15625
4
from graphics import * import random from math import * class Bubble: """Definition for a bubble as a white circle""" def __init__(self, win, x_position, speed): """constructs a bubble as a light blue circle""" # bubble center1 = Point(x_position, 400) self.bubble = Circle(ce...
fde89262e25cc84f96ad344c8329f0af5d676e3d
hikoyoshi/hello_python
/example_5.py
415
3.640625
4
#!-*-coding:utf-8 -*- #星星的層數 star = 5 ''' 第一種星星排法 * ** *** **** ***** ''' for i in range(star): print ('*'*(i+1)) ''' 第二種星星排法 * ** *** **** ***** ''' for i in range(star): print (' '*(star-i)+'*'*(i+1)) ''' 第三種星星排法 * *** ***** ******* ********* ''' for i in range(st...
712ba3e68cd764f06bf579d744e511e38c885212
tmonfre/cs1homework
/labs/Lab3/city.py
3,151
4.46875
4
# Author: Thomas Monfre # Date: 10/30/17 # Course: Dartmouth College CS1, 17F # Purpose: This program defines the class City that stores information about various cities in objects of this class. # Additionally, this class has methods to draw boxes representing each city and animate them. The animation # ...
1e8b8634b86b0bc4e750922805a7ead015874bf1
mwisslead/Random
/number_to_word_usa/number_to_word.py
2,424
3.53125
4
import sys import math NUMWORDS = [ '', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen...
aaa38e130bed31cf8ec47d217be0ba3502394399
qq714412541/leetcode
/leetcode_offer/32_printTree/printTree.py
413
3.6875
4
import queue class Solution:#BFS def levelOrder(self, root): myqueue = queue.Queue() res = [] myqueue.qsize() myqueue.put(root) while not myqueue.empty(): x = myqueue.get() res.append(x.val) if x.left: myqueue.p...
e1a235d013b4eb67a526af24e4aa3e48996b3bc8
cwtopel/python
/forkids/builtinfunctions.py
3,516
4.1875
4
############################ # abs = absolute value ############################ print(abs(10),'equals',abs(-10)) steps = -3 if abs(steps) > 0: print('Character is moving') # same as this: # steps = -3 # if steps < 0 or steps > 0: # print('Character is moving') ############################ # bool = boolean # ty...
780058623d902515ab129551fe1c8b6c6237a71b
KIMSUBIN17/Code-Up-Algorithm
/Python/1082 [기초-종합] 16진수 구구단.py
88
3.5
4
a = str(input()) b =int(a,16) for i in range(1,16) : print("%s*%X=%X"%(a,i,b*i))
6dfc861263265a6832adc3362135651bdb09288a
Rickdickulous/Keepsakes
/loggingModule.py
1,374
3.828125
4
import logging import logging2 def main(): logging.basicConfig(filename='logFile.log', level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s") logger = logging.getLogger(__name__) # # At this point, string...
c2f97cb46688625fd6819f0de13d61b4add77e1d
rtakasu/practicing
/quicksort.py
712
3.953125
4
import sys def quicksort(unsortedArray): if len(unsortedArray) == 1 or len(unsortedArray) == 0: return unsortedArray pivot = unsortedArray[-1] wall = 0 for i in range(len(unsortedArray) - 1): if unsortedArray[i] <= pivot: unsortedArray[wall], unsortedArray[i] = unsortedArray...
2a30e07c6a3f5e51e88855be81f2f50f5a209389
r00t22553/hesapmakinesi
/hesapla.py
508
4.09375
4
#orta düzey hesap makinesi# a = input("ilk Sayıyı Giriniz : ") a = float(a) c = input("Yapılacak İşlem : ") b = input("İkinci Sayıyı Giriniz : ") b = float(b) if c=="+": print("Sonuç : ",a+b) elif c=="-": print("Sonuç : ",a-b) elif c=="/": print("Sonuç ...
034188ec985da3b0b2f9aa5bcb76876ec5d36cb4
kibanana/Study-Python-With
/yewon/ch05/class_calculator.py
326
3.703125
4
# -*- coding: utf-8 -*- class SimpleCalculator: def __init__(self): self.sum = 0 def add(self, num): self.sum += num class Calculator(SimpleCalculator): # 다중상속 가능 def say(self): print(self.sum) if __name__ == "__main__": test = Calculator() test.add(500) test.say() print(type(test))
337e71895257bd1b1d22287bfd661960cd2effcb
andysitu/algo-problems
/leetcode/300/297_serialize_deserialize_bintree_slow.py
1,818
3.65625
4
import queue # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Codec: def serialize(self, root): """Encodes a tree to a single string. :type root: TreeNode ...
b26c30e5c3b4b0f0fc834713e1167d24dd5dc51b
EDalSanto/ThinkPythonExercises
/sed.py
804
3.5
4
import sys def sed(pattern,replacement,source,dest): """ Read the first file and write contents into second file. If the pattern string appears anywhere in the in the file, it should be replaced with the replacement string. pattern: string replace: string source: string filename dest: stri...
f615c26ef96d848f05ab8f86f9cdb1aad578d35c
hasanHIDIROGLU/pythonexamples
/sayi.problemi.py
653
3.78125
4
# S.1. Altı rakamlı bir sayıdan tersini çıkarınca elde edilen sayı, ilk iki rakamının oluşturduğu sayı ile son iki rakamının oluşturduğu # sayının çarpımına eşittir. Bu sayıyı bulan uygulamayı geliştiriniz. # Rakamların sayı oluşturmaları ile ilgili örnek: Sayı 987654; ise tersi 456789, ilk iki rakamın oluşturduğu sayı...
63c5b2c0a32112bd6d50f69d64063af85e692323
Wriley-Herring/Library_Project-Phase_2
/driver.py
1,187
3.75
4
''' @author: wrileyherring ''' #import packages from book import Book from patron import Patron from library import Library def main(): #declare books and patrons book1 = Book("Of Mice and Men", "Steinbeck") book2 = Book("The Great Gatsby", "Fitzgerald") book3 = Book("1984","Orwell") book4 = B...
7ace15fb6c40d46640167983a16d0bbf23e29597
Chiazam99/Learning-python
/Operators_intro.py
900
4.03125
4
x = 2 y = 10 addition = x+ y print(addition) sub = x - y print(sub) mult = x * y print(mult) div = 10/2 print(div) floor_div = y // x print(floor_div) remainder = y % x print(remainder) p = 'ada' z = 'obi' print(p,z) # Program to calculate 10% of school fees Fee = 2000 discount = 10 #discount percent given discount...
5bdea7fa6f5849b32cb62a614fbcc2d342db13c9
saeedeMasoudinejad/Chatroom
/chatroom/test.py
1,057
3.890625
4
import sqlite3 my_connerctio = sqlite3.connect("test.db") my_cursor = my_connerctio.cursor() # table_name = 'a' # values = "id integer primary key autoincrement, age int, gender boolen, country varchar(256), status int" # my_cursor.execute("create table {}({})".format(table_name, values)) # my_connerctio.commit() # my...
1fb315e4d2284dc74f29f649669630f405f7e2a1
santoshr1016/squish_python
/101/set_0/week1/some_more_fun/unpacking_1.py
554
3.546875
4
record = ('Dave', 'dave@example.com', '773-555-1212', '847-555-1212') name, email, *phone = record print(name) print(email) print(phone) records = [ ('foo', 1, 2), ('bar', 'hello'), ('bar', 'mr'), ('bar', 'white'), ('foo', 3, 4), ] def do_foo(*args): print("Inside...
07237bc83676127029d96e62fa7baae0f5d6779b
kotori233/LeetCode
/[0640]_Solve_the_Equation/Solve_the_Equation.py
925
3.78125
4
class Solution(object): def solveEquation(self, equation): """ :type equation: str :rtype: str """ def solve(polynomial): x_cnt, d_cnt = 0, 0 flag, cnt = 1, '' polynomial += '+' for i in polynomial: if i == 'x':...
10115db66b044fef5e52a34e284c1598562f87f7
alitadodo/BTVN
/a_square.py
183
3.59375
4
from turtle import* speed(0) shape("arrow") color("green", "yellow") begin_fill() for i in range(4): forward(100) left(90) forward(100) left (90) end_fill() mainloop()
30648af98862f3b49355b701f3cd589279854181
BonnieFX/Python_Tool
/beautiful/testbs4.py
1,067
3.78125
4
# coding=utf-8 """ @company:广东浩迪创新科技有限公司 @version: ?? @author: AA-ldc @file: testbs4.py @time: 2017/3/31 16:57 @function:beautifulsoup """ html_doc = """ <html><head><title>The Dormouse's story</title></head> <body> <p class="title"><b>The Dormouse's story</b></p> <p class="story">Once upon a time there were thre...
c3c644a34cbdfea5d14b1217bacf9255974caa11
johnngugi/python_snippets
/factorial.py
263
4.03125
4
def factorial(n): # print str(n) if n == 1: return 1 else: result = n * factorial(n-1) return result def printer(): s = int(raw_input("Which number?")) print factorial(s) printer()
87201ba87269011744d41ae6054088eeeab481d3
wilsonGoei/CP1404-Wilson-Gujatno-Practicals
/Wilson CP1404 Practical_04/lottery_ticket_generator.py
798
4.0625
4
import random NUMBERS = [] def random_number(): random_numbers = [] for x in range(6): rand_num = random.randint(1,45) if rand_num in NUMBERS: rand_num = random.randint(1, 45) NUMBERS.append(rand_num) NUMBERS.append(rand_num) random_numbers.a...
3b2a165ea98119d3c004bf4fb26068d97a9dd791
prince1998/Python-Tkinter
/tkinter5.py
192
3.796875
4
from tkinter import * root = Tk() def printName(): print("Hello, my name is Priyansh") button_1 = Button(root,text = "Print my name", command = printName) button_1.pack() root.mainloop()
9b09fb442ec27d361052d3cefa98caec450d59e1
GLO1900/Battleship
/Bateau.py
2,463
3.625
4
class Bateau(): """ un Bateau est construit avec un nom (string) une longueur(int) et une paire de coordonnee(tuple) je pense qu'on pourrait ne pas envoyer les coordonnee au constructeur puisque c'est toujours (0, 0) avant de les placer """ def __init__(self, nom, longueur, coordonnee): ...
1a5eea4b768047f74df5483e1553ff7c0b591a0a
giebasjo/FC_III
/hw3/breadth_first_search.py
2,261
3.734375
4
# Author(s): Lucas Duarte Bahia # Jordan Giebas # Harveen Oberoi # Daniel Rojas Coy # breadth_first_search.py class Tree: def __init__(self, value, parent): self._value = value self._parent = parent def BFS(G, root, target): # Pythonish pseudocode ...
42ed808aaae5095ebd96e5cb6f4093391cb9fb39
flaskur/leetcode
/explore/linked_list/is_palindrome.py
908
4.21875
4
# Given a singly linked list, determine if it is a palindrome. # Easiest solution is to traverse a populate a list, then compare the list with its reverse. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def isPalindrome(self, head: L...
b9b329934dc1865548940c95d89b3d6a1052f4a5
nikithapk/coding-tasks-masec
/fear-of-luck.py
423
4.34375
4
import datetime def has_saturday_eight(month, year): """Function to check if 8th day of a given month and year is Friday Args: month: int, month number year: int, year Returns: Boolean """ return True if datetime.date(year, month, 8).weekday() == 5 else False # Test cases prin...
b3cd54d641c48dca59a7d57e8956cef454dadfe0
shakorj/PracticeProjects
/ws13a.py
230
4.09375
4
import random num = int(input("Enter the number of Fibonnaci numbers: ")) b = random.randint(0,1000) a = [b,b] for x in range(num - 2): a.append(a[-1] + a[-2]) print(a) #Creating Fibonnaci numbers beginning at a random number
995657c4fe9cdad6e5411e34ec79565c35f6e25a
lgc13/LucasCosta_portfolio
/python/practice/personal_practice/lpthw/e29_what_if.py
661
4.25
4
# Learn Python the hard way # Exercise 29: What If print "LPTHW Practice" print "E29: What If" print "Done by Lucas Costa" print "Date: 02/09/2016" print "True and False is true :-D" print "" people = 20 cats = 30 dogs = 15 if people < cats: print "Too many cats! The world is doomed!" if people > cats: prin...
d943b3894bcec394eff841b618ccf5c2dbe47441
haibinj/lecture_notes
/lecture_jan31/note_jan31.py
833
4
4
import numpy as np import pandas as pd # in terminal run this file. # data frame: df n = 5 t = pd.date_range('20190101',periods=n) print(t) #this give a string variable. python recognize the numeric pattern of a string. # this is an easy way to generate the date variable n = 100 t = pd.date_range('20190130',pe...
e41007b43ec4480462f9d75a53d51671502b3cdf
dmunozbarras/Practica-3-python
/ej3-2.py
584
3.984375
4
# -*- coding: cp1252 -*- """DAVID MUÑOZ BARRAS - 1º DAW - PRACTICA3 - EJERCICIO 2 Escribe un programa que pida el peso y la altura de una persona y que calcule su índice de masa corporal (imc). El imc se calcula con la fórmula imc = peso / altura """ peso=float(input("Introduce su peso:")) altura=float(raw_input...
651e92dd95b7401038392eb721002fe497738932
mutater/euclid
/proposition 01.24.py
804
3.65625
4
import sys, pygame from pygame.locals import * pygame.init() screen = pygame.display.set_mode((600, 600)) screen.fill((255, 255, 255)) # If two triangle have the two sides equal to two sides respectively, but have the one of the angles contained by the equal straight lines greater that the other, # they will also ha...
2a6ec5e5d21a58022cb0a91a8ab3f3522c0e3a77
warsang/CCTCI
/chapter8/8.6/hanoi.py
457
3.8125
4
def hanoi(n,source,helper,target): if n > 0: #Move tower of size n-1 to helper hanoi(n-1,source,target,helper) #Move disk from source to target if source: target.append(source.pop()) #move tower of size n-1 from helper to target hanoi(n-1,helper,source,tar...
88fa8403c0c4e187ec4ef9773f4ba7475e640254
cblanks/market-data
/investigations/histogram.py
2,065
4
4
#!/usr/bin/python # Filename: histogram.py author = "Chris Blanks" version = 1.0 import math class Histogram(): """ A simple histogram class. """ # attributes # private def __init__(self, name = "Hist", xmin = 0.0, xmax = 1.0, nbins = 20): """ Initialise the histogram object...
aa764e659567df5484ee2ee9bd5cfeea09f0be5f
Tifinity/LeetCodeOJ
/54.螺旋矩阵.py
383
3.53125
4
class Solution(object): def spiralOrder(self, matrix): # 使用zip,每拿一行,逆时针旋转矩阵 res = [] while matrix: res += matrix.pop(0) matrix = list(map(list, zip(*matrix)))[::-1] return res a = [ [1, 2, 3, 4], [5, 6, 7, 8], [9,10,11,12] ] s = So...
7fd92dac5c7dfb975d050d28d876fb0055d3eb5d
117542544/tetris
/score_board.py
10,470
3.71875
4
import pygame class ScoreBoard(): """记分板类""" def __init__(self, screen, game_settings): self.screen = screen self.screen_rect = self.screen.get_rect() self.game_settings = game_settings # 字体与颜色设置 self.text_color = (255, 255, 255) self.rect_color = (128, 128, 12...
820a4d5e4d99cb66e352a87d38c1c67ad66c8c0c
everbird/leetcode-py
/2015/SymmetricTree_v2.py
1,358
4.0625
4
#!/usr/bin/env python # encoding: utf-8 # Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def __repr__(self): return str(self.val) class Solution: # @param {TreeNode} root # @return {boolean} ...
b95d5b3583e0949f6e5cc7d01acc215237939e6b
LukeSillifant/Data21Notes
/hangman.py
3,225
4.03125
4
import random import math # from lists import word_list name_check = True play_again = True word_list = ['Word', 'another', 'other', 'something', 'seemed'] def game_display_update(game_progress_list): print("\nGuess the word: " + "".join(str(count) for count in game_progress_list) + "\nAlready played:"...
a527c910be44a400dbbbee2713fdd941d30117b5
dandra12011995/BDNR
/Scripts de Carga de Datos - Hoberman/peliculas.py
3,095
3.640625
4
import json from json import JSONDecodeError def get_database(): from pymongo import MongoClient import pymongo # Provide the mongodb atlas url to connect python to mongodb using pymongo CONNECTION_STRING = "mongodb://localhost:27017/?readPreference=primary&appname=MongoDB%20Compass&directConnec...
f503e932345501b435d7d0b7ffe8b3ea66da1018
swestwood/talkingbear
/pitch_shift_echo.py
1,746
3.5625
4
#!/usr/bin/python """Listens to the user and pitch/duration shifts back the same audio References: https://stackoverflow.com/questions/40704026/voice-recording-using-pyaudio https://pypi.org/project/SpeechRecognition/ https://realpython.com/python-speech-recognition/ pyaudio """ import random import time from aupyom ...
3ba1a35737f715e87078dc65860b91469a0135e8
savadev/leetcode-2
/check_online/671-secondMinimumNodeInABinaryTree.py
1,724
3.796875
4
from pdb import set_trace import heapq class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def findSecondMinimumValue(self, root): min_1 = None min_2 = None stack = [root] seen = set()...
1579225a46359c3d4b64c095bd6b41d1194660e3
lsnvski/SoftUni
/Exam March 28/02/02. Cat Walking.py
368
3.921875
4
lenght_min = int(input()) times_per_day = int(input()) calories = int(input()) calories_burned = lenght_min * times_per_day * 5 if calories_burned >= calories * 0.5: print(f"Yes, the walk for your cat is enough. Burned calories per day: {calories_burned}.") else: print(f"No, the walk for your cat is not enoug...
cb6456bea978e1c3473146838aea2c394c52c90e
uran001/Small_Projects
/Hot_Potato_Game/hot_potato_spicy.py
1,193
3.875
4
from queue import ArrayQueue import random def hot_potato_spicy(name_list, num): """ Simulates the Hot potato game "spiced up" with lives and randomness :param name_list: a list containing the name of the participants and their number of lives :param num: the counting constant (e.g., the length of e...
ab01b82f5f6f15398d0ac7072f4318d3a518417f
JoseAdrianRodriguezGonzalez/JoseAdrianRodriguezGonzalez
/python/Cuarto.py
185
3.828125
4
import math r=float(input("Digite el radio: ")) area= r**2*math.pi longitud=2*math.pi*r print(f"El área de tu circulo es: {area:.2f}\n La longitud del círculo es: {longitud:.2f}")
177b11dac75bb383ae14e7545e8f3a530e9d1dc3
Norlice/koda-med-alice
/Month-2-Random/risky.py
584
3.53125
4
import random print('*** RISKY BUISSNESS ***') print('Du börjar på 100 men varje gång du klickar ENTER dras det av 1-30. Du får poäng för varje gång du klickar ENTER, men förlorar om du hamnar under 0! Skriv stopp när du tror att du inte kan klicka längre.') kvar = 100 score = 0 while kvar > 0: print('Det är', k...
1f42278036717722af2df10c710b7664058f6628
duochen/Python-Beginner
/Lecture01/Labs/magicians.py
488
3.984375
4
magicians = ["Duo", "Jie", "Lillian"] def show_magicians(magicians): for magician in magicians: print(magician) def make_great(magicians): great_magicians = [] for magician in magicians: great_magicians.append("Great " + magician) return great_magicians show_magicians(magicians) ...
e0e1cbef14504d96d067b872208fb13412a18adb
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/226/users/4165/codes/1637_2703.py
124
3.640625
4
idade = int(input("idade ")) if(idade > 18): mensagem = "eleitor" else: mensagem = "nao_eleitor" print(mensagem.lower())
9406ac83ec7bcddcdc12d256a0e9fe7113d869d1
jfuentess/multicore-programming
/CilkTutorial/print_image.py
668
3.5
4
import sys import matplotlib.pyplot as plt import numpy as np def fill_matrix(f): in_file = open(f) nrow = int(in_file.readline()) ncol = int(in_file.readline()) print nrow, ncol m = np.zeros((nrow,ncol)) x = 0 y = 0 with in_file as f: for line in f...
84b343d6f2c5ec96948e2b09abfca7fc867dde8c
GabrielCavalcanti13/Algorithms__Data-structures-IF969
/Estruturas de Dados/doubly_linked_list.py
1,516
3.65625
4
class Node(): def __init__(self,item = None, previus_node = None, next_node = None): self.item = item self.previus_node = previus_node self.next_node = next_node def __str__(self): return str(self.item) def __repr__(self): return self.__str__() class List(): def __init__(self, item = None): self.len ...
6ea6ef8ed6b224893377a685eb23940d77447185
liuwenwen313/store
/列表数据的翻转.py
123
3.65625
4
list = [1,2,3,4,5,6,7,8,9] list2=[] a=0 while a<len(list): a = a + 1 list2.insert(a,list[len(list)-a]) print(list2)
2c470f4d76f90fad3dcf9ba5e2843480e4fd1602
prabhatcodes/Python-Problems
/Leetcode/binary-tree-inorder-traversal.py
1,517
3.8125
4
# 94. Binary Tree Inorder Traversal # https://leetcode.com/problems/binary-tree-inorder-traversal/ # Given the root of a binary tree, return the inorder traversal of its nodes' values. # Input: root = [1,null,2,3] # Output: [1,3,2] # Example 2: # # Input: root = [] # Output: [] # Example 3: # # Input: root = [1] # Ou...
c7e6bdd4c7a2274536eb4f3672e9e73f736a6aba
Phaneendra-Kumar-347/Python-Programs
/maximum number among three numbers.py
456
4.3125
4
#write a program to find maximum among three numbers #using only conditional operator first_num=int(input("enter first number")) second_num=int(input("enter second number")) third_num=int(input("enter third number")) if (first_num >= second_num) and (first_num >= third_num): print("the greatest number is ",first_n...
25678703713b6f2cd38db1fcdaf48bc777c0d4a7
sunny-lhy-zqw/api_demon
/test_03/testcasse/game/game.py
396
3.5625
4
class Game: def __init__(self,hp,power): self.hp=hp self.power=power def figth(self,enomy_hp,enomy_power): final_hp = self.hp-enomy_power enomy_final_hp = enomy_hp-self.power if final_hp>enomy_final_hp: print("我赢了") elif final_hp<enomy_final_hp: ...
94d81ec937e6e62fb14de4954ab924f8fc558e57
stevengates90/StevenLee_ITP2017_PythonExercises2.0-5.0
/More_Guest.py
386
3.796875
4
guest = ['Kendall Jenner ','Kylie Jenner','Kendrick Lamar','Calvin Harris'] mail = ', You are invited to a dinner' guest.insert(0, "Rihanna, ") guest.insert(2, "Drake, ") guest.append('Travis Scott, ') print(guest[0] + mail) print(guest[1] + mail) print(guest[2] + mail) print(guest[3] + mail) print(guest[4] + mail) pri...
93883fa5fc5abc63b8536f8365a7aaa357d98035
Sa4ras/amis_python71
/km71/Likhachov_Artemii/9/Task2.py
200
3.9375
4
def power(a,n): if a <= 0 and not n.isdigit(): return 'Error' res = a for i in range(n-1): res*=a return res x = float(input()) y = input() print(power(x,y))
ed6e65104e36ba41e3079d3fadb4164fdbc7f615
karen15555/Intro-to-Python
/Lecture5/Practical5/Problem2.py
326
4.15625
4
def is_even_num(l): evennum=[] for n in l: if n%2==0: evennum.append(n) return evennum print(len(is_even_num([1, 2, 3, 4, 5, 6, 7, 8, 9]))) num = int(input("Enter a number: ")) if (num % 2) == 0: print("{0} is Even number".format(num)) else: print("{0} is Odd number".format(n...
17117a505f38000fc36e42edf69bec5db54a5fe1
hyunjun/practice
/python/problem-matrix/find_word_snake_inside_a_matrix.py
2,462
3.671875
4
# https://codebasil.com/problems/word-snake # Wrong Answer def wordSnake0(board, word): if board is None or 0 == len(board) or 0 == len(board[0]): return False if word is None or 0 == len(word): return True R, C = len(board), len(board[0]) def search(r, c, chars): q = [(r,...
696e76949afb249871c8eeb61550a43f8f440397
Jonathan-aguilar/DAS_Sistemas
/Ene-Jun-2019/Practicas/1er Parcial/Examen/facade.py
1,011
3.65625
4
class Componente(object): """docstring for Componente""" def __init__(self, nombre=''): self.nombre = nombre def __str__(self): return 'Componente: {}'.format(self.nombre) class Computadora(object): """docstring for Computadora""" componentes = [] def __init__(self, marca, co...
53995a1b1b9952407f55cd8e6fa78d42f83090db
hjabbott1089/Pelican-tamer
/files.py
676
3.84375
4
name_file = open("name.txt", "w") name = input("What is your name? ") name_file.write(name) name_file.close() read_file = open("name.txt", "r") name = read_file.read().strip() read_file.close() print("Your name is", name) with open("name.txt", "r") as read_file: name = read_file.read().strip() pri...
aa30aab587d6d7a5809bd6870102f30d98f08831
Clearyoi/advent2018
/6/part2.py
1,029
3.53125
4
class Parser(object): def __init__(self, nodes): self.nodes = nodes self.left = min(self.nodes, key=lambda x: x[0])[0] self.right = max(self.nodes, key=lambda x: x[0])[0] self.top = min(self.nodes, key=lambda x: x[1])[1] self.bottom = max(self.nodes, key=lambda x: x[1])[1] ...
2fa72a1055df35a7382662cde3ea348402464277
Aasthaengg/IBMdataset
/Python_codes/p03834/s144686328.py
132
3.859375
4
a = input() for i in a: if (i != ','): print(i, end = "") else: print(end=" ") print("");
7ef8dce6c92fac01227b5d3e2179ca6a28600f55
JordanLeii/JordanLei
/Desktop/Missionbit Projects/challenges.py/mypythonfile.py
163
3.625
4
def square_point(x, y): x_2 = x*x y_2 = y*y return x_2 , y_2 x_squared , y_squared = square_point(2, 4) print(str(x_squared) + " " + str(y_squared))
cb23364b768f12f18249d0a25b4fab97c206b963
guruc-134/Py_programs
/editing.py
626
3.5625
4
text1=input() n1=len(text1) text2=input() n2=len(text2) cols=n1 rows=n2 t=[[0 for i in range(cols+1)] for j in range(rows+1)] for i in range(cols): t[i][0]=i for j in range(rows): t[0][j]=j #print(t) #print(cols) for i in range(1,rows+1): for j in range(1,cols+1): ins=t[i][j-1]+1 dele=t[i-1][j]+1 ...
045b113e7ac2799d772c216e18be17371367e1a5
josemorenodf/ejerciciospython
/Ejercicios Tuplas/Tuplas5.py
939
3.75
4
# Almacenar en una lista de 5 elementos tuplas que guarden el nombre de un pais y la cantidad de habitantes. # Definir tres funciones, en la primera cargar la lista, en la segunda imprimirla y en la tercera mostrar el nombre del país con mayor cantidad de habitantes. def cargar_paisespoblacion(): paises=[] for...
e3f46ddddfc27cbe556589ee378192fb8ba1533f
AdamZhouSE/pythonHomework
/Code/CodeRecords/2629/48117/291862.py
246
3.515625
4
questNum = int(input()) for quest in range(questNum): n = int(input()) if n == 101: print(4) elif n == 95: print(6) elif n == 71: print(4) elif n == 66: print(2) else: print(n)
719071484836b9e6dad0d48f07e53543d4093ee7
Cattleman/python_for_everybody_coursera
/if_then_else.py
398
3.71875
4
#classic if then else for week 5 conditional execution hrs = float(raw_input('Enter your hours: ')) rate = float(raw_input('enter your rate: ')) ovrt = float(raw_input('enter your overtime rate: ')) if hrs > 40: ovr = float(hrs - 40) opay = float(ovr * ovrt) totpay = float(opay + (hrs * rate)) ...
2c2c665eb1b63dbbc0fa75f46d93a985c91dafc1
cgazeredo/cursopython
/mundo01/aula-06_03-leia-algo-mostre-informacao.py
336
4.09375
4
digite = input('Digite algo: ') print('O tipo deste dado é:', type(digite)) if digite.isnumeric(): print('É um numero.') if digite.isalnum() and not(digite.isnumeric()): print('É um alfanumérico.') if digite.isupper(): print('Todas são maiusculas.') else: print('Nem todos são maiusculos.') print(digite....
979aaf75b500065efce175b3e0a9966eaa49b1c5
saman-rahbar/Tree_search
/Package.py
1,327
4
4
from AStar import Problem, AStar class Package: """ The Package class is used to represent a package. \- It contains a current location for the package, a source and a destination """ def __init__(self, source, destination, ID, graph): """ Initializes a package :param sour...
b02a04434d642cfbb976b2f8d33a8bace6c44809
priyankamadhwal/MCA-201-DS
/mergeSortFiles/intermediate.py
1,505
3.609375
4
import pickle, os, time blockSize = 2 def changeBlockSize(new): ''' OBJECTIVE : To change the blockSize. INPUT : new : New blockSize. RETURN : None. ''' global blockSize blockSize = new def getFileEnd(file): ''' OBJECTIVE : To find the end of a fil...
fcd0035f18edb21dfbfb15d22be34778e8acfe6a
QiaoLei-88/learnPython
/step-4/step-4.py
300
3.859375
4
def normalize(name): return name[0].upper() + reduce(lambda l,c: l+c.lower(), name)[1:] # Regular way to do: # return name.lower().capitalize() if __name__ == '__main__': L1 = ['adam', 'LISA', 'barT'] print 'Imput: ', L1 print 'Normalized:', list(map(normalize, L1))
0153d297d49195181954865066ea27fed9315c8c
banalybe/my-coding-portfolio
/Python Scripts/first_script.py
626
4.0625
4
largest = None smallest = None while True: set = input ("Enter a Number: ") if set == "done": break try: x = int(set) except: print('Invalid input') continue for the_lrg in [x]: if largest is None: largest = the_lrg...
639dfe4d50f368e3511fd3e88deea7aaead9d1c6
wchian2/Python_Health
/Automate_the_boring_stuff_with_python/chapter6_manipulating_strings.py
1,441
4.125
4
print("William"[:-3]) # Output "Will" ... this gives me an idea... name = "This place" print(name.upper()) # THIS PLACE print("william".isalpha()) # True print("William".startswith("Will")) # True print("William".center(50, '-')) # ---------------------William---------------------- def printPicnic(itemsDict, leftW...
fdad515316880c87f37637b0c1d7ff37a4e833da
L200170122/prak_ASD_D
/Modul_6/partisi.py
1,033
3.734375
4
def partisi(A, awal, akhir): nilaiPivot = A[awal] penandaKiri = awal penandaKanan = akhir selesai = False while not selesai: while penandaKiri <= penandaKanan and A[penandaKiri] <= nilaiPivot: pendanaKiri = penandaKiri + 1 while A[penandaKanan] >= nilaiPivot...
b8033de3562291bd611abea02bffccc78e49218e
liuyang1/test
/course/AlgoDesign/4/meeting/meeting.py
1,623
3.578125
4
#! /usr/bin/python # 2012-04-17 14:57:04 liuyang1 @ dorm # homework 4-1 @ AlogDesing #------------------------------------------------------------------------------ # 1,transfer to GRAPH COLORING problem # 2,using max degree number of Node FISRT Welsh-Powell algo # ref:http://hi.baidu.com/nkhzj/blog/item/761411306c918c...
9c5fc8c940e7bf9888ffe198d65c930d87d46b37
dave5801/CodingChallenges
/leetcode/minBSTDepth.py
947
3.71875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None 516 314 4773 class Solution: def minDepth(self, root): """ :type root: TreeNode :rtype: int """ if not root: ...