blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
0f0c609d0cd9fa1711bdbbfd534f20eb390a5492
haodayitoutou/Algorithms
/LC150/lc103.py
1,192
4.09375
4
r""" Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). For example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 return its zigzag level order traversal as: [ ...
18397ad8b07f2c633314da27aa0d4f2621656d77
haodayitoutou/Algorithms
/LC50/lc40.py
1,008
3.65625
4
""" Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each number in C may only be used once in the combination. Note: All numbers (including target) will be positive integers. The solution set must not contain duplicate combi...
330702d009fa1a583bf94834988f87f2a13bbe48
haodayitoutou/Algorithms
/LC150/lc148.py
1,712
4.0625
4
""" Sort a linked list in O(n log n) time using constant space complexity. """ class ListNode(object): def __init__(self, x): self.val = x self.next = None def sort(head): if head is None or head.next is None: return head parent, mid, last = None, head, head while last and l...
592d90ad144de1e189499f9e92a64da9ed9b147d
aliceliang22/Algorithms
/NestingBoxes.py
3,400
3.796875
4
# Name: Alice Liang # EID: axl84 # Unique Section Number: 84825 # Assignment: #9 # Date: 7/12/20 # Input: box_list is a list of boxes that have already been sorted # sub_set is a list that is the current subset of boxes # idx is an index in the list box_list # all_box_subsets is a 3-D list that ha...
8a6b6ca0c0bec50fef51648359bcec2bb4677d44
tjlqq/python
/python/笔记/list.py
925
4.03125
4
1.列表:只读的,不可修改的 a.index(2) a.index(2,a.index(2)+1) 2.元祖:不可修改 列表和元祖可以互相转换。 list(a) tuple(a) 3.开发替换小程序 #!__*__ coding:utf-8 __*__ import sys,os if len(sys.argv) <= 1: print "usage:./file_replace.py old_text new_text filename" old_text,new_text = sys.argv[1],sys.argv[2] file_name = sys.argv[3] f = file...
60e707bac444c492b46ed76e10756c37e452fc94
LisaArnauta/HW2
/Example2.py
227
3.8125
4
def lowest_int_index(input_list): input_list = [10, 11, 2, 3, 5, 8, 23,11, 2, 5, 76, 43, 2, 32, 76, 3, 10, 0, 1] minimum = min(input_list) index_of_minimum = input_list.index(minimum) print(index_of_minimum)
74d12fc130fce7aef571c649ab5ed7144cc1ff65
sergal/python-learning
/iter-1.py
743
3.8125
4
from collections import Iterator import itertools def cycle(iter): """ >>> i = iter([1, 2, 3]) >>> c = cycle(i) >>> c.next() 1 >>> c.next() 2 >>> c.next() 3 >>> c.next() 1 """ if not isinstance(iter, Iterator): raise TypeError return itertools.cycle(iter...
cb7e9f1ce1457c94115b8e1aa22ef313fbb80630
ZhangBin0719/Machine_Learning
/05SLR/SLR.py
1,272
3.6875
4
''' 作者:张斌 时间:2019.3.24 版本功能:简单线性回归的实现,为了使得建立的模型使得方差最小 从而获得回归线y=b1x+b0 ''' #简单线性回归:只有一个自变量 y=k*x+b 预测使 (y-y*)^2 最小 import numpy as np def fitSLR(x,y): ''' :param x: 自变量 :param y: 因变量 :return: 模型参数 ''' n=len(x) dinominator = 0 numerator=0 for i in range(0,n): nume...
b360a61fe2a00a939b966fc42f394e3729a58613
Swapnasheel/Swapnasheel.python_code.io
/circle_out_of_squares.py
570
3.890625
4
import turtle def draw_sqr(some,length): for j in range(0,100): for i in range(0,4): some.forward(length) some.right(90) some.right(5) limit =+ 1 turtle.exitonclick() def draw_art(length): window = turtle.Screen() window.bgcolor("red") sqr = ...
14bc76ad4d1175b938babab8e9b232f856611c29
Mahaveer173/Word-guessing-game
/Word_guess.py
11,115
3.75
4
from tkinter import * from random import * win = Tk() l1 = Label(win, text="Enter your guess: ") l1.grid(row=0, column=0) e1 = Entry(win, width=3, borderwidth=3) e1.grid(row=0, column=1) words = ["Planet", "Football", "Cricket", "Ant", "Galaxy", "Earth", "Horse", "Grass"] word_secret = words[randint(0, 7)] if len(...
c54478336f80e7f1e2a50684a6bcaf8d1fe0700b
jmlippincott/python_principles
/src/24_thousands_separator.py
557
4.25
4
# Write a function named format_number that takes a non-negative number as its only parameter. # # Your function should convert the number to a string and add commas as a thousands separator. # # For example, calling format_number(1000000) should return "1,000,000". def format_number(number): number = str(number) ...
e40d3a077df245414fcc3b170784193a4aa7ee64
jmlippincott/python_principles
/src/16_leading_zeros.py
729
4.125
4
# The goal of this challenge is to analyze a binary string consisting of only zeros and ones. Your code should find the biggest number of consecutive zeros in the string. For example, given the string: # # "1001101000110" # The biggest number of consecutive zeros is 3. # # Define a function named consecutive_zeros that...
def69b893064aaf5f26e228a53fb1c2f9c100472
krishnaveni-7198/python
/cycle-5/filedemo.py
367
3.734375
4
#open and read a file file1 = open("demo.py", "r") print("file: ",file1) print() print(file1.read()) file1.close() #edit a file file2 = open("demo.py", "r") print("file: ", file2) print("before editing:") print() print(file2.read()) print() print("after editing") file2 = open("demo.py", "w") file2....
068793e2c33de1f63216a6d73bee7f8e72275f63
satoshun-algorithm-example/leetcode
/1038.binary-search-tree-to-greater-sum-tree.py
713
3.578125
4
# # @lc app=leetcode id=1038 lang=python3 # # [1038] Binary Search Tree to Greater Sum Tree # # @lc code=start # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def bstToGst(self, root: ...
b00a9444df169d9deef109876b2bce4bfd8d4673
satoshun-algorithm-example/leetcode
/23.merge-k-sorted-lists.py
655
3.71875
4
# # @lc app=leetcode id=23 lang=python3 # # [23] Merge k Sorted Lists # # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def mergeKLists(self, lists: List[ListNode]) -> ListNode: s = [] for l in lis...
f399057dcc22e521f5ec8fa5a4640c118a45a639
satoshun-algorithm-example/leetcode
/1104.path-in-zigzag-labelled-binary-tree.py
487
3.578125
4
# # @lc app=leetcode id=1104 lang=python3 # # [1104] Path In Zigzag Labelled Binary Tree # from typing import List # @lc code=start class Solution: def pathInZigZagTree(self, label: int) -> List[int]: res = [] depth = 1 while label >= 2 ** depth: depth += 1 while label...
5a575c4bfc19b599c3a9c8c2cb4f653b6934999e
satoshun-algorithm-example/leetcode
/1022.sum-of-root-to-leaf-binary-numbers.py
759
3.59375
4
# # @lc app=leetcode id=1022 lang=python3 # # [1022] Sum of Root To Leaf Binary Numbers # # @lc code=start # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def sumRootToLeaf(self, root:...
e51cf4b64138f069d6856f830440447b0104d16a
satoshun-algorithm-example/leetcode
/872.leaf-similar-trees.py
571
3.8125
4
# # @lc app=leetcode id=872 lang=python3 # # [872] Leaf-Similar Trees # # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def leafSimilar(self, root1: TreeNode, root2: TreeNode) -> bool: ...
cd3733c7ad7052b9b78c6f8a44704d3edb55ac41
satoshun-algorithm-example/leetcode
/684.redundant-connection.py
684
3.5625
4
# # @lc app=leetcode id=684 lang=python3 # # [684] Redundant Connection # from typing import List # @lc code=start class Solution: def findRedundantConnection(self, edges: List[List[int]]) -> List[int]: parent = [0] * len(edges) def find(x): if parent[x] == 0: return x...
e9f8b722e963b89a78713d1721dac570c6e59bd3
Hussein-Hossam-Idris/tic-tac-toe
/assignment1.py
3,518
3.8125
4
PB=[0,0,0,0,0,0,0,0,0] fill=["_","_","_","_","_","_","_","_","_"] choose=[0,1,2,3,4,5,6,7,8] indexVS=["0","1","2","3","4","5","6","7","8"] playerOneList=[1,3,5,7,9] playerTwoList=[0,2,4,6,8] condition = True print ("*******Hello in Tic-Tac-Toe Game Made By Hussein*******") #player one options while conditi...
8a9b43f5f598b065b77f31e452145df0e41061f5
gadadprajwal/Leet-Code-Solutions
/#872-Leaf Similar Trees.py
1,262
4.125
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 listofleaf(self,root, lis): # Base Case - Whenever you find a leaf node append it to the list if...
e95b1111fc35aa7e20716e9cb4520e8f56362c15
DrGMark7/CodingProblem
/loop4.py
193
3.984375
4
n = int(input('Enter the number of rows: ')) for row in range(n): for col in range(n-row-1): print(end=" ") for col in range(row+1): print("*", end="") print()
48a14d4491ff6911bb7ce9eea2cb4b8f05262f76
DrGMark7/CodingProblem
/Alphabet Coun.py
373
3.515625
4
T = '' TE = [] while '' in T : T = str(input('Enter string: ')).lower() if 'end' in T : break TE.append(T) TA = ''.join(TE) print('*'*30) print('* Alphabet Counting *') print('*'*30) C = "abcdefghijklmnopqrstuvwxyz" for char in C : count = TA.count(char) if count > ...
0e28a03efb18e3ff92aa791cb8bbc5c3743148cf
DrGMark7/CodingProblem
/FuntionDiscount.py
409
3.890625
4
Cargo = str(input('Enter product type: ')) Price = float(input('Enter price: ')) def discount() : if 'food' in Cargo : N = Price-(Price*0.03) elif 'shoes' in Cargo : N = Price-(Price*0.2) elif 'medicine' in Cargo : N = Price-(Price*0.01) else: N = Price ...
8ef60fb39b9daf18ce9f6a8eb8349f018b8f8d66
DrGMark7/CodingProblem
/Binary.py
139
3.96875
4
Decimal = int(input('Enter number: ')) Binary = bin(Decimal) N_Binary = Binary[2:] print('{} is {} in base 2.'.format(Decimal,N_Binary))
6331ec69d2dc05298232be06dea643e9ca410425
DrGMark7/CodingProblem
/BMI1.py
660
3.84375
4
G = str(input('Enter Gender (M/W): ')) if G != 'M' and G != 'W' : print(G,"is not M or W") exit() Y2 = int(input('Enter current year: ')) Y = int(input('Enter your birth year: ')) W = float(input('Enter your weight (kg): ')) H = float(input('Enter your height (cm): ')) print('- '*6) ΔY = Y2 - Y...
13b69bf95ae689c751b2208f3ee0baebafe26850
DrGMark7/CodingProblem
/loop6.py
199
4.03125
4
num = int(input("Enter the number of rows: ")) for i in range(num,0,-1): for j in range(num-i,0,-1): print(end=" ") for j in range(i,0,-1): print("*",end="") print()
226081adf3faba34bcc72dd5296855f8730bca94
DrGMark7/CodingProblem
/Factorial.py
221
4.125
4
import math Num = int(input('Enter number: ')) if Num < 0: print('Cannot get {}!'.format(Num)) exit() else: if Num >= 0 : Y = math.factorial(Num) print('{}! = {}'.format(Num,Y))
211b861bb0e1cc0abca161f379a3cdd889210092
cj2009/TMSim
/Cell.py
571
3.796875
4
''' Created on Dec 2, 2014 @author: c A Cell object represents one cell of memory on the Turing Machine's tape. A cell contains a symbol; initially, the cell's content is delta, which denotes that it's empty (the underscore char is used to represent delta). Cells are connected together as a doubly-connected ...
5f5a935c8c570b72560ee13b3caa6b26ceb73bc0
44601/buivantai_ca18a1a
/BuiVanTai_44601/project/project_04_page62.py
189
4.125
4
""" Author: bui van tai Date: 30/08/2021 width = int(input("enter the width: ")) height = int(input("enter the height: ")) area = width*height print("The area is : ", area, "square units") """
c7796eced52998164b2f2a3366da5da3020b734d
44601/buivantai_ca18a1a
/BuiVanTai_44601/project/project_06_page62.py
153
4.03125
4
""" Author: bui van tai Date: 30/08/2021 radius = float(input('enter the radius: ')) area = 3.14*radius*2 print("area a circle: ", area, "square untis") """
6a5c20f63af6c302804f3a256960fd660f6f2555
44601/buivantai_ca18a1a
/Buivantai_44601_04/Exercises/page109_exercise_01.py
1,263
4.0625
4
""" Authon: Bui Van Tai Date:25/09/2021 problem:Write the encrypted text of each of the following words using a Caesar cipher with a distance value of 3: a. python b. hacker c. wow solution: a,plainText = input("python: ") distance = int(input("3: ")) code = "" for ch in plainText: ordValue = o...
e23c06929218b5179c09e9db87ac49ccf7eb636c
justinformentin/simple-neural-network
/nntest.py
2,478
4.03125
4
from numpy import exp, array, random, dot class NeuralNetwork(): def __init__(self): # Seed the random number generator, so it generates the same numbers every time the program runs random.seed(1) # We model a single neuron with 3 input connections and 1 output connection # we assi...
6c19004448aae37e1e29397c4069f83c911d59b4
Yashg2910/LeetCode
/Top Interview Questions/Easy/LinkedList/PalindromeLinkedList2.py
1,186
3.953125
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, val=0, next=None): # self.val = val # self.next = next ## REVERSING THE LIST AFTER HALF AND COMPARTING BOTH THE SIDES class Solution(object): def isPalindrome(self, head): """ :type head: ListNod...
dfa556f08b2808178b695ccc2df72bc6092c3a00
Yashg2910/LeetCode
/Top Interview Questions/Medium/Arrays/3Sum.py
785
3.5
4
## BRUTE FORCE. TLE!!!!! class Solution(object): def threeSum(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ size = len(nums) if size<3: return [] nums.sort() result = [] ...
b62e8db14dd5f58410a74c69b444ec178b28dda4
PangJunying/T-Teacher_Programe
/homework/phaseI/phase1_1_ringbuffer_3.py
636
3.6875
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- ### 一种实现 """ [理解Python中的RingBuffer环形缓冲区_漫步量化-CSDN博客_python 环形缓冲区] (https://blog.csdn.net/The_Time_Runner/article/details/106456174) """ class RingBuffer: def __init__(self, size): self.data = [None for i in range(size)] def append(self, x): self....
3ef643bfc52c777218103b02c10e09810d8fbfde
karinasamohvalova/OneMonth_python
/API.py
2,102
3.546875
4
""" This program allows you to find some information about some book using Knowledge Graph Search API from Google The original code from google contains errors because its imported urllib that don't includes methods parse and request, required for new lib version, so I corrected code from google :))) """ # Key...
551429aa4b1d81b84d8ae41bc0f3c20dc818c793
karinasamohvalova/OneMonth_python
/happy_hour.py
454
3.890625
4
import random clothes = ["Trousers", "Skirt", "Shirt", "Boots", "Dress"] colour = ["Red", "White", "Pink", "Yellow", "Black", "Orange"] random_clothes = random.choice(clothes) random_colour_one = random.choice(colour) random_colour_two...
cf70a5b06ce77df30c03dcd82ea4f5150c739a7e
jaebooker/MakeSchool
/Courses/CDDev1.1/mad.py
747
4.09375
4
word1 = raw_input("Enter a name: ") word2 = raw_input("Enter a verb: ") word3 = raw_input("Enter another verb: ") word4 = raw_input("Enter a noun: ") word5 = raw_input("Enter an ajective: ") word6 = raw_input("Enter a verb: ") word7 = raw_input("Enter a noun: ") word8 = raw_input("Enter a verb: ") word9 = raw_input("En...
48f81c5f111a0b2225793b8ff98ba99d268cc876
MikeCardona076/Using-Pandas
/project.py
599
3.890625
4
#This is a little project with Pandas #Here is Pandas import pandas as pd name = [] power = [] origin = [] num_warrirors = int(input("How many warriors are there? ")) for i in range(num_warrirors): name_warrior = input("Insert name of warrior : " ) name.append(name_warrior) power_warrior = input("Inse...
91daf1665ad71683d28de9443127b54125f950bb
GoldenBeeHF/Image-Retrival
/quang_recognize/readXML.py
665
3.53125
4
from xml.dom import minidom from student import SinhVien #parse an xml file by name def readXML(): sinhviens = [] mydoc = minidom.parse('dataSV.xml') dataSV = mydoc.getElementsByTagName('Data') # all item attributes svs = mydoc.getElementsByTagName("sinhvien") sinhvien = SinhVien() for ...
64390849f871ac3d82812a90b7f2ee4831c0d84d
paulinewn/iprep
/tree.py
1,660
4.09375
4
BST: Given a node determine if a valid BST --------------------------------------------------- class Node: def __init__ (self, x): self.val=x self.left= None self.right= None class Solution: def isValidBST(self, root): return self.isValidBSTRec(root, float("-infinity"), float("infinity")) def isValidBSTRe...
7e2423379d996683e766aa37c849e44c0f82c4b4
corentin6941/AI_2
/hminimax.py
11,493
3.59375
4
from pacman_module.game import Agent from pacman_module.pacman import Directions class PacmanAgent(Agent): def __init__(self, args): """ Arguments: ---------- - `args`: Namespace of arguments from command-line prompt. """ self.args = args self.dictExpanded...
bfd5710491dfd873577f3b1e91d49cbc94771097
cnnrznn/project_euler
/7/main.py
389
3.53125
4
#!/usr/bin/python inf = open("primes1.txt") inf.readline() counter = 0 prime = -1 def find_prime(): global inf global counter global prime while True: line = inf.readline().split() for i in range(len(line)): counter += 1 prime = line[i] if counter...
d8a1c29dd13337193b5bfd87f3f730d49e724089
priti0802/MUSIC_PLAYER
/_music_player_.py
6,223
3.71875
4
from tkinter import * from tkinter import filedialog import os import pygame class MusicPlayer: def __init__(self,root): self.root = root self.root.title("Music-Player") self.root.geometry("697x250+300+220") self.root.resizable(0,0) # initializing pygame construct...
d89aab337b40304278d5e27773ea1f8da662bec7
ommr101/web_crawler
/core/counter.py
440
3.6875
4
import threading class Counter: def __init__(self, initial=0): self.value = initial self._lock = threading.Lock() def __add__(self, other): with self._lock: self.value = self.value + other return self def __lt__(self, other): return self.value < other...
eab20f029ed545a144368764e0c99de980019ad2
nakayamaqs/PythonModule
/Learning/carrace.py
1,183
4.15625
4
# from http://maryrosecook.com/post/a-practical-introduction-to-functional-programming # The code is still split into functions, but the functions are functional. # There are three signs of this. # First, there are no longer any shared variables. time and car_positions get passed straight into race(). # Secon...
3336534b7c8f9dc8fdd24a461d63732bcc4706b3
zbowman1994/sportsSimulator
/simulate.py
2,845
4.25
4
import random # A text-based simulator that outputs the final score of a simulated sports game def main(): while True: sport = input('Choose a sport:\n 1) Football\n 2) Basketball\n 3) Soccer\n 4) Quit\n Choice: ') if sport == "1": # Football matches = input('\nFootball! Enter the # of matches to simulate: ')...
fe5db76c31b0af45d9234d8100eda9447f8f75c0
ravgeetdhillon/hackerrank-algo-ds
/Absolute_Permutation.py
636
3.671875
4
def displayPermutation(arr): for i in arr: print(i, end = ' ') print() def createPermutation(n, k): arr = [] for i in range(1, n + 1): if ( (i - 1) // k ) % 2 == 0: arr.append(i + k) else: arr.append(i - k) displayPermutation(arr) tests = int( input(...
1514eba50466f5a82e676033755184c01765bd79
ravgeetdhillon/hackerrank-algo-ds
/Almost_Sorted.py
1,165
3.71875
4
def isSorted(arr): for i in range(n - 1): if arr[i] > arr[i + 1]: return False return True def getLeft(): for i in range(n - 1): if arr[i + 1] < arr[i]: l = i break else: return "sorted" return l def getRight(): for i in range(n - 1, ...
720b642d8048583ec37ff1c49e089976fce42805
kwonte/shingu
/1.py
119
3.703125
4
print "Tell me your age?" myage=int (raw_input()) if myage < 30: print "welcome" else: print "oh!"
a4fc8e5feb2aa98754ea13bda12a6f42ed553a39
adrianlow97/O1-Speed-Random-Data-Generator
/voseRunner.py
2,007
3.609375
4
from AliasMethod import VoseAlias import os, random, re, sys, time, csv def main(): #get the number of data sets needed to be generated numInputs = int(input("Please enter the number of data sets to generate: ")) #initialize empty arrays to store the generated data labelArray = [] dataArray =[] #get the la...
2f99e81597963ac3fce5d1aa9297071c03a0742e
sophiiasun/Dominoes
/DominoHand.py
3,468
3.625
4
# ============================= C R E D I T S ============================= # Authors: Sophia Sun, Thomas Wang # Date: June 25, 2020 # Purpose: Dominoes Game with GUI Interface # Note: Special Thanks to Mr. Smith of ICU3U1 at Milliken Mills High School # ================================================================...
2297f4a6bf459195c1db55c0549ce69f754183d6
Mikailuo/PY.learn
/10.3.py
516
3.8125
4
# def position(dt,speed): # posx=speed[0]*dt # posy=speed[1]*dt # return(posx,posy) # # move=position(60.0,(10,-5)) # print("physics displacement:({0},{1})".format(move[0],move[1])) # def square(num): # list_n=[] # for i in range(1,num+1): # list_n.append(i*i) # # print(list_n) # re...
b8bd29a816e53bd06b430cbae8814dc1f80b0a45
TonyDeng0514/cs107_lab4
/stackADTimpl.py
1,789
3.921875
4
""" stackADT: an implementation of a stack represented as listADT >>> stk = stackADT() >>> assert stk.empty() >>> stk.push("omega") >>> assert not stk.empty() >>> assert stk.top() == "omega" >>> stk.pop() >>> assert stk.empty() more test cases!!! >>> stk.push('alpha') >>> stk.push('beta') >>> assert stk.top() == 'be...
593005a8d2ea5ff11ceb6e83a911cf828d471963
UNH-at-Manchester/wegive
/wegive/wegiveapp/tags.py
1,666
3.578125
4
""" Module for tags. Includes the tags list, and methods to deal with tags from the database. NOTE: It would probably be a good idea to put at least the names of the tags in the database. """ import csv tags = ["Religious", "Animals", "Education", "Public Opinion", "Other",] class Echo(): """ Class for a bog...
a83d1dc7a1835e3e29e27b86f585735b5ef6f48d
mkarimi20/python
/while_loop.py
1,344
4.28125
4
# count = 0 # while(count < 9): # print('the count it: ', count) # count = count+1 # print('Out of loop') # The Infinite Loop # A loop becomes infinite loop if a condition never becomes FALSE. You must be cautious # when using while loops because of the possibility that this condition never resolves to a # F...
2a8443a22fdd66b831f6a09bd749594d43513ada
mkarimi20/python
/tax.py
700
3.578125
4
usd_to_afs = 80 currnet_income = 1500 income_in_afs = usd_to_afs*currnet_income def tax_calculator(income_in_afs): if income_in_afs >= 100000: tax_in_afs = (((income_in_afs) - 100000) * (20/100)) + 8900 print("your tax in Afghani will be " + str(tax_in_afs)) tax_in_usd = tax_in_afs/usd_to_af...
4314811a219d2a6807fd56a5b3b9a3908e9c5146
mkarimi20/python
/class_song.py
310
3.578125
4
class songs: def __init__(self, lyrics): self.lyrics = lyrics def sing_me_a_song(self): for sing_me_a_song in self.lyrics: print(sing_me_a_song) Song = songs(["May god bless you, ", "Have a sunshine on you,","Happy Birthday to you !"]) print(Song.sing_me_a_song())
199c1b89600e19af36d7e9bdf810c7022b329703
mkarimi20/python
/class_if.py
435
3.78125
4
class lunch: def __init__(self, menu): self.menu = menu def menu_price(self): if self.menu == 'menu_1': print("your lunch price is $12") elif self.menu == 'menu_2': print("your lunch price is $13.40") else: print("no such menu is a...
dfbcbe0475eab2bccc2c7e3f435ae01cd71b5bbf
mrvarbik25/check-for-repetition
/main.py
11,020
3.84375
4
# program to check for repetition. # example to run with arguments: python3 main.py namefile.txt space no import sys import os template = 'Кол-во повторений: {0}\nПовторения: {1}' with_out_turns = [] # обявление списков и констант turns = [] text = [] choice_simvol_separator = None file_name = None def work_with_args(...
f2b73610d835b1bf6136e497f4147ef546b93330
artem-zeltinsh/python-scripts
/primes.py
732
3.890625
4
import math def sieve(n): """ Finds prime numbers up to a given n with the sieve of Eratosthenes. :param n: sieve boundary :return: prime numbers less or equal to a given n """ if n < 2: return [] sieve_size = n + 1 sieve = [True] * sieve_size sieve[0] = sieve[1] = False ...
cea96e65d5d0c8cf13c2242ebd305f440aa49708
gzaf5466/gzaf5466
/practice/chapter 2 practice/add.py
155
3.734375
4
a= input("first number u want to add ") a=int(a) b= input("second number u want to add in 1st no.") b=int(b) print("your addedn numbers here:",a*b)
8448b190295b93285998d0a67196fcb1f0480d96
gzaf5466/gzaf5466
/practice/chapter 2 practice/rabab kabab.py
106
3.59375
4
a=input(" enter your name ") b=input("enter your chid ") c=(a+b) print("your good name is here",c)
4a185e3f241b8c102e76c84f955528691d57919a
JoCrimes/Scientific-Computing-with-Python-Projects---Arithmetic-Formatter
/arithmetic_arranger.py
3,671
4.03125
4
def arithmetic_arranger(problems,solution=False): # Returns the problems arranged vertically as described in the readme.txt import string arranged_problems = '' top = [] bottom = [] operand = [] line = [] answers = [] topStr = '' bottomStr = '' operandStr = '' ...
09b842da1aa7d67270e6a2079e5e3c1b01e089b9
taddeus/advent-of-code
/2019/03_wires.py
709
3.640625
4
#!/usr/bin/env python3 import sys def read_wire(f): return [(x[0], int(x[1:])) for x in f.readline().split(',')] def trace(wire): multipliers = {'U': (0, -1), 'D': (0, 1), 'L': (-1, 0), 'R': (1, 0)} x = y = steps = 0 visited = {} for direction, distance in wire: dx, dy = multipliers[direct...
84723082a44cf53bb8065a79031942ad00a5e7c8
taddeus/advent-of-code
/2017/06_realloc.py
587
3.71875
4
#!/usr/bin/env python3 import sys def redistribute(banks): i = max(range(len(banks)), key=banks.__getitem__) blocks = banks[i] banks[i] = 0 while blocks > 0: i = (i + 1) % len(banks) banks[i] += 1 blocks -= 1 def cycle_iter_len(banks): seen = set() cycles = 0 tup = ...
a77b7afe2b34ed1737d46e2ca56e40113918d655
taddeus/advent-of-code
/2019/11_paintrobot.py
1,004
3.578125
4
#!/usr/bin/env python3 import sys from intcode import read_program, run_getter def paint(firmware, color): robot = run_getter(firmware, lambda: color) painted = set() white = set() x = y = 0 dx, dy = 0, -1 for make_white in robot: painted.add((x, y)) (white.add if make_white els...
1a5ce52cdd08533849f26c60553670cc8a0256d1
linmenggui/Udacity-Project-3-Data-Wrangling
/project_code_repository/audit_street_type.py
1,090
3.828125
4
# this code is written in python 3 import re import mapping from update_street_name import update_street_name street_type_re = re.compile(r'\b\S+\.?$', re.IGNORECASE) expected = ['Delhi', 'Street', 'Nagar', 'Sadan', 'Marg', 'Road', 'Avenue', 'Circle', 'Mayur' 'Place', 'Sector', 'Vihar', 'Enclave', 'Block'...
2df6e713a500bf5c61165a89bf7f3c43da3b1d55
rrodero83-python-projects/decoding-american-civil-war-ciphers
/route_cipher_decrypt.py
4,068
4.09375
4
"""Decrypt a path through a Union Route Cipher. Designed for whole­word transposition ciphers with variable rows & columns. Assumes encryption began at either top or bottom of a column. Key indicates the order to read columns and the direction to traverse. Negative column numbers mean start at bottom and read up. Posi...
7122c59ff3bd404cf78d753bf17d28b80a7ac794
KeyG518/Linear-Regression
/polynomial_regression_1d
1,114
3.65625
4
#!/usr/bin/env python import assignment1 as a1 import numpy as np import matplotlib.pyplot as plt (countries, features, values) = a1.load_unicef_data() targets = values[:,1] x = values[:,7:] x = a1.normalize_data(x) N_TRAIN = 100 x_train = x[0:N_TRAIN,:] x_test = x[N_TRAIN:,:] t_train = targets[0:N_TRAIN] t_test = ...
67ab6fc3c498b55e097c56214b8eaa74b631e829
stigi99/python_matura
/check language.py
346
3.78125
4
from googletrans import Translator translator = Translator() y_n = "" while y_n !="Y" or y_n !="y": verb = input("Podaj jakieś słowo a powiem Ci w jakim ono jest języku: ") try: translated = translator.detect(verb) print(translated) except: print("Złe dane") y_n = input("Czy chc...
d7e67f097a87335b2c7eb5bfafa76e7616ade0d3
onlyjackma/little_tools
/retemplates.py
471
3.59375
4
#!/usr/bin/env python import fileinput,re field_pat = re.compile(r'\[(.+?)\]') scope = {} def replacement(match): code = match.group(1) print "code :",code try: gg = str(eval(code,scope)) #gg = str(eval(code)) print "result :",gg #print "scope :" ,scope return gg except SyntaxError: print 'hello' exec...
edfb4aacbe4801c5df98c3e022ed4a9bc39b5755
stephanieoh/ProjectEuler
/choosefunction.py
181
3.703125
4
from fractions import Fraction def factorial(n): if n==0: return 1 else: return n*factorial(n-1) def choose(n,r): return Fraction(factorial(n),factorial(r)*factorial(n-r))
780cde4c92d1b9d2ca73c9838c441fbb948e45ad
soumyax1das/soumyax1das
/string_join_and_split.py
401
4.03125
4
#!/usr/bin/env python3 """ This library has example of string join and string split. """ def str_join(a,sep): joined_str=sep.join(a) return(joined_str) def str_split(a,sep): SS=a.split(sep) return(SS) if __name__ == '__main__': ###Join Strings### JS=str_join(['Soumya','Aarush','Paramita'],'|')...
97ec7fa2bad1273ea250cf6ac678d93915ceb0c7
soolaimon/puzzles
/hotplate2.py
2,266
3.53125
4
import math import sys row_amount = int(raw_input("How many rows? ")) column_amount = int(raw_input("How many columns? ")) plates = row_amount * column_amount hot_plate = [] test = [] for i in range(0, plates): hot_plate.append(0.0) test.append(0.0) middle_1 = (plates / 2) + (column_amount / 2) middle_2 ...
2ad28bd8b39462f9dc176d0b1f77101a4a10eb15
zedzorander/rock-paper-scissors
/project.py
1,232
4.0625
4
import random # create list lst = ('r', 'p', 's') beatsLst = ('p', 's', 'r') # list that shows what beats each choice in lst playerWins = False # welcome user print("Welcome to Cole's Rock, Paper, Scissors game!") while playerWins != True: # ask user what to play print("Make your choice and then press e...
9e8814104238bf723327260c52e9be57646a86b6
ocwjay/Python-Practice-Coin-Flip-game
/coinflipgame.py
1,226
3.984375
4
# coin flip game # gotta be able to use random module import random # create list as global variable coinSide = ["heads", "tails"] #score globals scoreHeads = 0 scoreTails = 0 #define the game function def gameTime(): #request input for flip and assign to variable flipQ = input("Would you like to flip a coin...
c460bee5f9dbda85748a9f85986a85944c7cdefe
mmajis/iot_capstone
/LED/MessageDisplay.py
991
3.59375
4
from LEDProcessor import LEDBlock import time import math # Number of devices (we used two) numOfDevices = 2 led = LEDBlock(numOfDevices) # Time for letter shift (seconds) T = 0.2 try: while True: string = raw_input("Message: ") if string == None: break else: ...
8c65ec53f0c7b7de8f78b0478e2e901f59a3c979
antoniocastro98/proyectolm
/Ejercicio.py
2,921
4.21875
4
from lxml import etree from Funciones import listar, contar, buscar, informacion, libre datos=etree.parse("archivoxml.xml") print(''' MENU 1.Listar información: Mostrar el nombre de las canales de los que tenemos información. 2.Contar información: Mostrar la cantidad de canales que son de deportes. 3.Buscar o filtr...
bf609d226511a8870741294cea77d747269e3ad4
jennyjj/classes-melons
/melons.py
2,552
4.3125
4
"""Classes for melon orders.""" import random class AbstractMelonOrder(object): """An over-arching melon class""" def __init__(self, species, qty, shipped=False, country_code='USA', order_type="domestic", tax...
cd52c81273e0cbc12e684f5d9312809372dd53be
doananth/pyactr-driving
/Position.py
1,174
3.765625
4
import math # Class representing position in space in the simulation class Position: def __init__(self, xArg, zArg): self.x = xArg self.y = 0 self.z = zArg def __init__(self, xArg, yArg, zArg): self.x = xArg self.y = yArg self.z = zArg def add(self, l2): ...
a16e3ddbe75190d9e4a2260a6a1cf4b69dfeeeeb
sapkalrohit0909/Blood_Distribution_Database_System
/Application_File/App.py
9,441
3.53125
4
import requests import json def reveiverFunctionalities(): print("===========================================") print("0.EXIT") print("1.NEW RECEIVER") print("2.OLD RECEIVER") receiverChoice = input("Enter your choice :") if receiverChoice == 0: return if receiverChoice == 1: ...
2f6511a53be4b3950fd9795c3a6bf28d2f33469b
Baobab470/IlearnPY
/venv/C2LAB3.py
305
4.15625
4
grade = input("Enter a grade: ") grade = int(input("Enter your grade: ")) if grade >=90: print("A") elif grade >= 80: print("B") elif grade >= 70: print("C") elif grade >= 65: print("D") elif grade >= 0: print ("F") else: print("Error: Grades cannot be nefative numbers or words.")
e10f0a05c75051489e733aa0c192e4cbd81e435e
yang-official/LC
/Python/5_Dynamic_Programming_and_Math/991_broken_calculator.py
1,156
4.0625
4
# https://leetcode.com/problems/broken-calculator/ # On a broken calculator that has a number showing on its display, we can perform two operations: # Double: Multiply the number on the display by 2, or; # Decrement: Subtract 1 from the number on the display. # Initially, the calculator is displaying the number...
65f69808305035e4dceacf89fe03d64724b864c4
yang-official/LC
/Python/1_Lists_and_Strings/1_dictionary_storage/128_longest_consecutive_sequence.py
837
3.90625
4
# https://leetcode.com/problems/longest-consecutive-sequence/ # 128. Longest Consecutive Sequence # Given an unsorted array of integers, find the length of the longest consecutive elements sequence. # Your algorithm should run in O(n) complexity. # Example: # Input: [100, 4, 200, 1, 3, 2] # Output: 4 # Explanation: The...
19999ff06cd51ef3359b6e0a294a8bc25130d68c
yang-official/LC
/Python/5_Dynamic_Programming_and_Math/984_string_without_aaa_or_bbb.py
955
3.96875
4
# https://leetcode.com/problems/string-without-aaa-or-bbb/ # Given two integers A and B, return any string S such that: # S has length A + B and contains exactly A 'a' letters, and exactly B 'b' letters; # The substring 'aaa' does not occur in S; # The substring 'bbb' does not occur in S. # Example 1: # Inp...
da2293d8ce5e408c39d02b084a6b41460fed63ed
yang-official/LC
/Python/1_Lists_and_Strings/3_index_tracking/15_3sum.py
850
3.671875
4
# https://leetcode.com/problems/3sum/ # Given an array nums of n integers, are there elements a, b, c in nums # such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. # Note: # The solution set must not contain duplicate triplets. # Example: # Given array nums = [-1, 0, 1, 2, -1, -4...
d9177b3caaf975c6a9ff2ae82979dcc95a1859f9
yang-official/LC
/Python/1_Lists_and_Strings/5_string_functions/1295_find_numbers_with_even_number_of_digits.py
911
4.3125
4
# https://leetcode.com/problems/find-numbers-with-even-number-of-digits/ # 1295. Find Numbers with Even Number of Digits # Given an array nums of integers, return how many of them contain an even number of digits. # Example 1: # Input: nums = [12,345,2,6,7896] # Output: 2 # Explanation: # 12 contains 2 digits (even num...
6aaa05cc7f15acd9c00d3c67fc1a9b4aee911c8f
yang-official/LC
/Python/2_Linked_Lists/1_Redirecting_Nexts/2_add_two_numbers.py
1,041
3.90625
4
# https://leetcode.com/problems/add-two-numbers/ # 2. Add Two Numbers # You are given two non-empty linked lists representing two non-negative integers. # The digits are stored in reverse order and each of their nodes contain a single digit. # Add the two numbers and return it as a linked list. # You may assume the two...
5de584e89a883b5c4997a996951a9317ae562dc1
yang-official/LC
/Python/5_Dynamic_Programming_and_Math/22_generate_parentheses.py
866
3.9375
4
# https://leetcode.com/problems/generate-parentheses/ # 22. Generate Parentheses # Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. # For example, given n = 3, a solution set is: # [ # "((()))", # "(()())", # "(())()", # "()(())", # "()()()" # ] # Recurs...
c0891bb1f7ace91608f5b62c864e6543c9dae97c
yang-official/LC
/Python/4_Trees_and_Graphs/1_Tree_Traversal/100_same_tree.py
1,656
3.984375
4
# # https://leetcode.com/problems/same-tree/ # 100. Same Tree # Given two binary trees, write a function to check if they are the same or not. # Two binary trees are considered the same if they are structurally identical and the nodes have the same value. # Example 1: # Input: 1 1 # / \ / \ ...
5f6a736613599964c13cd6dcaf2f29e898817a8f
yang-official/LC
/Python/4_Trees_and_Graphs/1_Tree_Traversal/543_diameter_of_binary_tree.py
961
4.15625
4
# https://leetcode.com/problems/diameter-of-binary-tree/ # 543. Diameter of Binary Tree # Given a binary tree, you need to compute the length of the diameter of the tree. # The diameter of a binary tree is the length of the longest path between any two nodes in a tree. # This path may or may not pass through the root. ...
78a1208f62b948c598e3aff537fac1d04f708bdc
yang-official/LC
/Python/5_Dynamic_Programming_and_Math/78_subsets.py
625
3.921875
4
# https://leetcode.com/problems/subsets/ # 78. Subsets # Given a set of distinct integers, nums, return all possible subsets (the power set). # Note: The solution set must not contain duplicate subsets. # Example: # Input: nums = [1,2,3] # Output: # [ # [3], # [1], # [2], # [1,2,3], # [1,3], # [2,3], # [1...
fe22b98706e91bcb9bf97d3a76b7ae71322764ad
yang-official/LC
/Python/5_Dynamic_Programming_and_Math/70_climbing_stairs.py
1,087
4
4
# https://leetcode.com/problems/climbing-stairs/ # 70. Climbing Stairs # You are climbing a stair case. It takes n steps to reach to the top. # Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? # Note: Given n will be a positive integer. # Example 1: # Input: 2 # Output: 2...
31bebef5578039dc6257dfeddce9d4e0f95ace24
yang-official/LC
/Python/2_Linked_Lists/1_Redirecting_Nexts/23_merge_k_sorted_lists.py
901
4.0625
4
# https://leetcode.com/problems/merge-k-sorted-lists/ # 23. Merge k Sorted Lists # Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. # Example: # Input: # [ # 1->4->5, # 1->3->4, # 2->6 # ] # Output: 1->1->2->3->4->4->5->6 # Definition for singly-linked list. # cl...
f9d1a5e9e73a6d09a913c2bfda909d3644ae06ba
infmas/Tecnicas_Exercicios01
/Exercicio04.py
867
3.84375
4
"""" Aluno: Marco Antonio Schwertner Disciplina: Técnicas de Programação Professor: Luiz Gonzaga da Silveira Junior Semestre: 2018/1 Trabalho: Lista de exercícios 01, exercício 04 """ def ValidaPreco(preco): try: precoValidado = float(preco) if precoValidado < 0: precoValidado = -1 #i...
3fe3f802b05e888c819597af09e99a78f44ab474
Rishi253/Rishi
/Rishi.py
246
4.125
4
# Rishi a=int(input("Enter the n.o=")) fact=1 if(a<0): print("Factorial of negative n.o doesnot exist") elif(a==0): print("Factorial of 0 is 1") else: for i in range(1,a+1): fact=fact*i print("Factorial of",a,"is:-",fact)
ecf2dce54c3842facd3ee9ff7ab1b2e3562f875e
fjdurlop/TallerArduinoPython2020-1
/Tkinter/Tkinter/gui6Ejercicio.py
750
3.796875
4
# Ejercicio ENTRY from tkinter import * from random import choice raiz = Tk() label = Label(raiz, text = "Hola a todos!!") entrada = Entry(raiz) btnCambiarColor = Button(raiz, text = 'Cambiar color') btnCambiarText = Button(raiz, text = 'Cambiar texto') var = StringVar() entrada.config(textvariable = var) colores =...
3d4a3a036d0bee699e1238afd6a9421d520833be
fjdurlop/TallerArduinoPython2020-1
/Tkinter/Tkinter/gui1.py
750
3.578125
4
# ROOT Y LABEL from tkinter import * # Generalmente tkinter se importa de esta forma # Para tener acceso a sus servicios root = Tk() # Clase Tk # Se genera una ventana raiz # root window # Nos permite tratar a los widgets en una ventana como objetos # Lo que nos sale es la instancia de la clase Tk widget = Label(roo...