blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
25ef353976938a1b7cb51b20f372d7f2ec3696c8
JasonkayZK/Python
/Python_Fundamental_Lesson/5_Functional_Programing/Lambda_Anonymous_Function.py
280
3.9375
4
def my_func(f, arg): return f(arg) result = my_func(lambda x: 2 * x * x, 5) print(result) # Named function def polynomial(x): return x**2 + 5*x + 4 print(polynomial(-4)) # Lambda print((lambda x: x**2 + 5*x + 4) (-4)) # Assignment double = lambda x: x*2 print(double(7))
bbbfba95729a8cee12ab7d0527abd8cbc29cde5f
easazade/python-learning
/topics/statements.py
1,309
4.0625
4
# if statement age = 4 if age >= 10: print("he is big boy") print("he is, isn't he") elif age <= 5: print("he is a baby") print("he is a baby") print("he is a baby") else: print("he is alright") # for loop # everything that is iterable in python can be looped over like strings value = "" for x ...
f3c1f1cbe5113a768838b1a27a4bea9b20053e8d
alcool91/Algorithms
/InsertionVsMerge.py
4,893
3.546875
4
# -*- coding: utf-8 -*- """ Created on Wed Mar 17 20:13:27 2021 @author: Allen """ import sorting.merge_sort import sorting.insertion_sort import timeit import random import math from scipy.stats import truncnorm import numpy as np import matplotlib.pyplot as plt RADIUS = 1000 MAX_LIST_SIZE = 125 ITERATIONS = 5 NUM...
6a928f1db2b023aa83ad954ed93e78ece48eaa9c
joaovictor-loureiro/data-science
/data-science/exercicios/livro-introducao-a-programacao-com-python/capitulo-6/exercicio6-1.py
340
3.859375
4
# Exercício 6.1 - Modifique o programa da listagem 6.6 para ler 7 notas em vez de 5. notas = [] print('\n') i = 0 while i < 5: nota = int(input('Informe a nota: ')) notas.append(nota) i += 1 soma = 0 for nota in notas: soma += nota media = soma / len(notas) print('\nSua média final é %.2f!...
d48b8666a703d00efcadb65ebe059478fd1a2964
Maryamx21/INF101
/TP7/3.7.1.py
909
4.0625
4
def swapPositions(list, pos1, pos2): first_ele = list.pop(pos1) second_ele = list.pop(pos2-1) list.insert(pos1, second_ele) list.insert(pos2, first_ele) return list def tri_insertion(liste): new = [] min = liste[0] i_rm = 0 i = 0 while (len(liste) != 0): w...
6c517c93f2c263452a0257dd21076ca527e5c6e7
mriegler/Euler
/Python/euler_5.py
703
3.609375
4
# Euler 5 # Smallest number divisible by everything from 1..20 from euler_3 import smallest_divider def main(): numbers = xrange(2, 20) primes_list = [] dicts =[] for i, n in enumerate(numbers): primes_list.append(smallest_divider(n,n)) dict = {} for elem in primes_list[i]: if elem in dict: dict[ele...
f568bf1256ecac67ff22196342cb746f7d49080a
kthr3e/python3
/practice/2次元リストの読み込み.py
406
3.53125
4
# 標準入力から、2次元リストを読み込む # 標準入力のデータ # 0,0,1,1,0,0 # 0,1,0,0,1,0 # 1,0,0,0,0,1 # 1,1,1,1,1,1 # 1,0,0,0,0,1 # 1,0,0,0,0,1 # _ letter_A = [] while True: line = input() if line == "_": break # ここに、読み込んだデータをリストに追加するコードを記述する letter_A.append(line) print(letter_A)
2e4b7e7379f3be18f2d30f2feb8973a371037981
wodishenga/python
/pyBasic/generatorYield.py
125
3.578125
4
def fibo(times): n = 0 a,b = 0,1 while n<times: yield b a,b=b,a+b n+=1 return 'done' for x in fibo(5): print(x)
02cc5a22ac7178762af6832779a3efe582dc2676
corne12345/Amsterdam_carbage_thesis
/Code/visualisation.py
6,561
3.515625
4
"""Code to visualise results of algorithms for display and analysis.""" import pandas as pd import geopandas as gpd from bokeh.plotting import figure, show from bokeh.models import GeoJSONDataSource, ColumnDataSource, HoverTool from .helper_functions import initial_loading,\ add_shortest_distances_to_all_househo...
707be6ae380347ab815706edf4223c832822e596
HoYoung1/backjoon-Level
/backjoon_level_python/14681.py
274
3.796875
4
def solve(x, y): if x > 0 and y > 0: return 1 if x < 0 and y > 0: return 2 if x < 0 and y < 0: return 3 if x > 0 and y < 0: return 4 if __name__ == '__main__': x = int(input()) y = int(input()) print(solve(x, y))
1a6ac15cc418690f588d6704c529a73327b645e0
johnarley2007/UPB
/PYTHON/RETO 3/ALEX/reto3alex.py
5,203
3.921875
4
from os import system import os system("clear") x = 51634 y = 43615 coordenada = [] def ingresarCoordenada (coordenadaInicial): coordenadaDuplicada = list(coordenadaInicial) for x in range (0,3): coordenadaDuplicada.append([]) lat = input("Ingrese la latitud: ") while lat == "" or lat ...
50aa6ad35c2eac5468c43cd5597768c2cd153f3b
AnetaStoycheva/Programming0_HackBulgaria
/Week 1/user_to_user.py
193
4.03125
4
a = int(input('Give me a number: ')) b = int(input('Give me a number again: ')) while a <= b: print(a) a += 1 if a > b: a = b b = a while a <= b: print(a) a += 1
daffbc3530e7dde4a8d5715ea31915fd383b38b8
CTingy/DSA-coursera
/graph/week1_graph_decomposition1/reachability.py
1,336
3.609375
4
# WARN: counter result cannot represent the all the possibilities. # If want to find all possible route, one pass is not enough. def reachability(node1, node2, edges, visited_edges): nodes = edges.get(node1) if not nodes: return 0 res = 0 for node in nodes: visited_edge = (node1, node)...
e2e87f1493eb40edd10dd7be55fc1f32255946eb
hoangtunglamm/hoangtunglam-lab3-c4e13
/homework/turtle3.py
259
3.984375
4
from turtle import * def draw_square(lenght, color): pencolor(color) for i in range(4): forward(lenght) left(90) mainloop() length_ = int(input("Enter length: ")) color_ = input("Enter pen color: ") draw_square(length_, color_)
9932b1c27a02d7abad0b93d8552c14d1e8790117
michael-c-gao/CLRS
/ch6/.1/heapsort.py
1,083
3.9375
4
#heapsort #O(nlgn) #sorts in place def left(i): return ((2*i)+1) def right(i): return ((2*i)+2) def maxheapify(array,i, heapsize): l = left(i) r = right(i) if ((l <= heapsize) and (array[l] > array[i])): largest = l else: largest = i if((r <= heapsize) and (array[r] > a...
e756a37fe4a72f15f1bea34d6c15032c6eff979f
Helen-Sk-2020/Loan_Calculator
/Topics/Elif statement/The army of units/main.py
234
3.609375
4
n = int(input()) if n < 1: print('no army') elif 1 <= n <= 9: print('few') elif 10 <= n <= 49: print('pack') elif 50 <= n <= 499: print('horde') elif 500 <= n <= 999: print('swarm') else: print('legion')
3a30bb930d92d554d6666c8afb1672ef3541a722
dhvip9/Beginner
/Day8 Encode Decode.py
2,037
4
4
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', ' ','+', '-', '*', '/', '"', ',', 'X', '_', '.', '(', ')', '[', ']', '%', '?', '{', '}', '!', "'", "=", ":", "^", '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' ] len_char = ...
e18820b872b4f726c6136679084c199b63db173d
rajkiya-engineering-college-azamgarh/funTask
/SWG.py
990
3.921875
4
# funTask import random print("Player 1 turn : Snake(s) Water(w), Gun(g) ? ") randm = random.randint(1, 3) if randm== 1: comp ="s" elif randm==2: comp ="w" elif randm==3: comp ="g" you = input("Player 2 turn : Snake(s) Water(w), Gun(g) " ) def game(comp, you): if comp==you: r...
6f82a7c7ac5a1313a89b41f7cae3f619ecc00742
marceloigor/ifpi-ads-algoritmos2020
/Fabio01_Parte01/q12 aumento salario 25 por cento.py
318
3.578125
4
# 12. Leia o salário de um trabalhador e escreva seu novo salário com um aumento de 25%. # Entrada salario = float(input('Digite o valor do salário: ')) # Processamento aumento = (salario / 100) * 25 novo_salario = salario + aumento # Saída print(f'Seu novo salário é de R$ {novo_salario} reais.')
1ccc8629a29844fa51a231bb023f52910229949a
kfisc88-lsc-repos/chapter_8
/ch8_p3_kfischer.py
1,998
4.03125
4
""" Author: Kelley Fischer File: ch8_p3_kfischer.py This is a simple text editor that allows a user to open, create, edit, and save text documents. """ from breezypythongui import EasyFrame import tkinter.filedialog class TextEdit(EasyFrame): def __init__(self): EasyFrame.__init__(self, title = "Tex...
a81973b92110025598121040cdb2dd08ca9ee6a4
saulquispe/My-Solutions-to-The-Python-Workbook-By-Ben-Stephenson-122-of-174-
/Loop Exercises/ex67.py
1,136
4.09375
4
''' Exercise67: AdmissionPrice A particular zoo determines the price of admission based on the age of the guest. Guests 2 years of age and less are admitted without charge. Children between 3 and 12 years of age cost $14.00. Seniors aged 65 years and over cost $18.00. Admission for all other guests is $23.00. C...
613d3d2f61f216338e2f577fe5adea72342982f5
cpt-r3tr0/mathematics
/Number Theory/PrimeSums.py
552
3.859375
4
import random def isprime(n): if n<=1 or n==4 : return False if n<=3: return True k=10 while k: a=2+random.randint(1,n-4) if pow(a,n-1,n)!=1: return False k-=1 return True for _ in range(int(input())): n,k=map(int,input().split(' ')) if n<2*k: prin...
1cbaafc293742907883d5a931f3d64c295cea410
sss-0916/backups
/PythonApplication2/PythonApplication2/threeD_overlying.py
1,195
3.515625
4
#coding=gbk import numpy as np # author = "" # date = "2019/04/08" # ͼ global_threeD_list = [[0, 0, 0]] * 3 * 2 * 3 #print(global_threeD_list) #һ5*3*3ľ a = np.random.randint(-50, 50, size = (3, 2, 3)) b = np.random.randint(-50, 50, size = (3, 2, 3)) c = np.random.randint(-50, 50, size = (3, 2, 3)) d = np.random.r...
4db95d089d9e35adcc7cecb26e4262ba6b4f5cf3
CharlieYuChi/practice
/py1_week6_function.py
217
3.796875
4
#practice function def computepay(h,r): t = 0 if h > 40: t = h - 40 h = 40 return h * r + t * r * 1.5 hrs = float(input("Enter Hours: ")) rate = float(input("Enter rate: ")) p = computepay(hrs, rate) print(p)
a05535e6be57d7e2cded2d8dc7f41993eaec1995
larlyssa/checkio
/scientific_expedition/angles_of_triangle.py
1,432
4.46875
4
""" DIFFICULTY: ELEMENTARY You are given the lengths for each side on a triangle. You need to find all three angles for this triangle. If the given side lengths cannot form a triangle (or form a degenerated triangle), then you must return all angles as 0 (zero). The angles should be represented as a list of integers ...
0bf3c4e3d2a27208715f9a7b69d4aab372ce32bf
Saintroi/CS250
/Project_2/textreader.py
631
3.59375
4
import string class TextReader: def __init__(self, filename): self._f = open(filename, 'r') def get_word(self): token = None chars = [] # while True: c = self._f.read(1) while c: # if c not in [' ', '\n', '\t']: if c not in string.whites...
e0b1725be3f68f3c28093cb14dcd05beeb955fee
khushbu014/8Bit_wh23
/a.py
58
3.5
4
j={"Namo":['1','2','3']} for x in j["Namo"]: print(x)
c185a3970b7c8cdd227b8fa5daba1be386c43233
surjanajoshi/assignment_II
/surjana_assignment2/q10.py
279
3.9375
4
dic1 = {1:10, 2:20} dic2 = {3:30, 4:40} dic3 = {5:50, 6:60} dic = {} for i in dic1.keys(): print(i) dic[i] = dic1[i] for i in dic2.keys(): print(i) dic[i] = dic2[i] for i in dic3.keys(): print(i) dic[i] = dic3[i] for i in dic.items(): print(i)
acab43e808aeb9b0b0ae36d5cd0e4a5e0f8e0db6
VenetaBebrevska/Python-challenge
/PyBank/Solved/main.py
1,151
3.859375
4
# This is main.py in PyBank # Import modules import os import csv csvpath = os.path.join('..', 'Resources', 'budget_data.csv') # Read CSV with open(csvpath, newline='') as csvfile: # CSV reader specifies deimiter csvreader = csv.reader(csvfile, delimiter=',') print(csvreader) # Read header row ...
35ca39e10307019e75818edcf3c70a2d5bef5d25
stoneeve415/LintCode
/sort.py
3,838
3.890625
4
# -*- coding: utf-8 -*- """ @title: 各种排序算法 @author: evestone """ def bubble(nums): _len = len(nums) for i in range(_len-1): j = 1 while j < _len-i: if nums[j-1] > nums[j]: nums[j-1], nums[j] = nums[j], nums[j-1] j += 1 return nums def select(nums):...
d2f251040a789bb6bc0dfd34f191a37963774236
HBalija/data-structures-and-algorithms
/04-sorting-algorithms/03-insertion-sort/03-insertion-sort.py
505
4.1875
4
#!/usr/bin/env python3 def insertion_sort(lst): # start from second element for i in range(1, len(lst)): current_value = lst[i] # work backwards j = i - 1 while j >= 0 and lst[j] > current_value: # while in loop, copy values to lst[j + 1] position lst[...
c3881593b490c7442d6ec7a239b413f6c4a44246
kmarekspartz/library
/library/models/book.py
750
3.90625
4
""" Defines the Book model. """ from sqlalchemy import Column, Integer, ForeignKey from sqlalchemy.orm import relationship from library.models import Base, Title class Book(Base): """ The Book model represents copies of Books. This is different from the Title model, which represents a book in the ab...
bd3b08008bbf2b08b4875ce79f3680cefded81d8
amolpattill/snake-game-with-python
/snakegame.py
3,452
3.78125
4
import pygame import random pygame.init() # Variables width = 700 height = 500 fps = 60 # Color red = (255,0,0) yellow = (255,255,0) black = (0,0,0) white = (255,255,255) window_screen = pygame.display.set_mode((width,height)) clock = pygame.time.Clock() def snake(window,color,snake_List,snake...
c3b87c7184e7c9da069dd0ba4aa3dbdd44af90d5
april-april/CTCI
/LinkedList/3-delete_middle_node.py
301
4.21875
4
from LinkedList import LinkedList # delete middle node by copying contents of next node to middle/current # node. The next node will be deleted after contents of next node are # copied over to middle node. def delete_middle_node(node): node.value = node.next.value node.next = node.next.next
8181cba9ae0bba7e490eab59d7f75a4f32e23643
aaku1234/gittest
/aaku1.py
715
4.125
4
#1. '''radius = int(input("ënter the radius of sphere ")) def sphere(radius): sphere = 4*3.14*radius*radius return sphere print("area: ",sphere(radius))''' #2. '''i = int(input("enter the number ")) for num in range(1,11): a= i*num print(i,"*",num,"=",a)''' #3. '''a= int(input("enter the number")) b= ...
ccd2c71f887746dd3cbefefc78b779e13843b305
nanvel/compy
/compy/outcome.py
619
3.640625
4
class Outcome: def __init__(self, is_positive: bool, is_hard: bool): self.is_positive = is_positive self.is_hard = is_hard def __eq__(self, other): return other.is_positive == self.is_positive and other.is_hard == self.is_hard def __str__(self): return f"{'hard' if self.is...
9096886ad91caa163ec2cbd30b3f6aeed90cd617
anusha-sharma/bits-wilp
/MFDS_Assignments/gauss_elim.py
4,096
3.515625
4
import numpy as np import sys import copy import math from numpy.random import RandomState np.set_printoptions(suppress=True) random_state = RandomState(1240) # Round numbers according to significant digits def my_round(d, x): return d - int(math.floor(math.log10(abs(x)))) - 1 print("Welcome to the Gauss...
c4a90239f38d74d9420dcba2a17c1f13459b8389
szymonbalasz/Pybites
/176/chessboard.py
428
3.890625
4
WHITE, BLACK = ' ', '#' def create_chessboard(size=8): """Create a chessboard with of the size passed in. Don't return anything, print the output to stdout""" for row in range(0, size): div = 0 if row % 2 == 0 else 1 line = "" for block in range(0, size): if block % ...
8c8de5ecf83cb442bb175788d6b99f20e8250960
simon-ha/codecademy-python
/supermarket.py
494
4.03125
4
#codecademy python - a day at the supermarket - 9. something of value #challenge - how to do a sumproduct prices = { "banana" : 4, "apple" : 2, "orange" : 1.5, "pear" : 3, } stock = { "banana" : 6, "apple" : 0, "orange" : 32, "pear" : 15, } total = 0 for x in prices: total = ...
8abb9fe209a6334671a6c7fc4919e44d2b55c4a9
aaronjoseph/Datascience_Coding
/Python_Set/Fibonacci.py
991
4.125
4
# Given below is the fibonacci function which gives the nth fibonacci values # Correct the function such that it provides the right output def fibonacci(n): a = NULL b = NULL if n < 0: pass elif n == 0: return False elif n == 1: return False else: return True "...
d6d50a7d3128f155e7717415a5509477169105ec
UjwalAgrawal/Data-Structure-Algorithms
/Doubly Linked List.py
889
4.03125
4
class Node: def __init__(self, data): self.data = data self.next = None self.prev = None class DoublyLL: def __init__(self): self.head = None def length(self): cur = self.head c = 0 while(cur.next): c+=1 cur = cur.next ...
fbbdc24d2d03ef68631408b9056226549aa819c9
nraghuveer/leetcode
/contest/2020/october_dialy/week2/sortlist.py
2,018
4.15625
4
# Given the head of a linked list, return the list after sorting it in ascending order. # Follow up: Can you sort the linked list in O(n logn) time and O(1) memory (i.e. constant space)? # lets use the merge sort with the linked lists # Definition for singly-linked list. class ListNode: def __init__(self, val=0...
697b184707bcf3ec4e7497323b982f36cff8fa17
itspratham/Python-tutorial
/Python_Contents/data_structures/sorting/Insertion_sort.py
334
4.03125
4
sort = input("Enter the numbers: ").split() def insertion_sort(sort): sort = list(map(int, sort)) for i in range(0, len(sort)): for j in range(0, len(sort)-1): if sort[i] > sort[j]: sort[i], sort[j + 1] = sort[j + 1], sort[i] x = list(sort) return x print(insertio...
6b4a52e83fc2e57f17f68bf40f5ccc77a3ac0861
shishirjindal/search
/search.py
392
4
4
import os print "Enter The name of directory u want to search:" s = raw_input() print "Enter name of drive to search file" drive = raw_input() for root, dirs, files in os.walk(drive+"://", topdown=False): for name in files: if(name == s): print(os.path.join(root, name)) break for name in dirs: ...
a55f3cde6be1f3ffb8cbca60e458af7375356194
Xelanos/Intro
/ex2/calculate_mathematical_expression.py
1,982
4.15625
4
def subtract(num1, num2): """ return the remainder of subtracting the 2nd number inputted from the first """ return num1 - num2 def add(num1, num2): """ return the addition of the two inputted numbers """ return num1 + num2 def divide(num1, num2): """ return the quotient between the two ...
6eef0a5ac38f164da5529ca0894644da2c964dc4
MiniFullC/PythonCode
/Mooc-Exercise/Activationcode.py
661
3.859375
4
''' 做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用生成激活码(或者优惠券),使用 Python 如何生成 200 个激活码(或者优惠券)? ''' import uuid # 生成 num 个验证码,每个长度为lengths,可设置默认长度 def create_num(num, lengths=10): result = [] while num > 0: uuid_id = uuid.uuid1() # 删去字符串中的'-',取出前lengths 个字符 temp = str(uuid_id).replace('-', '')...
d965c83015e153e73508feda81d3741f6d3fc904
gdh756462786/Leetcode_by_python
/Dynamic Programming/Maximal Square.py
1,072
3.796875
4
# coding: utf-8 ''' Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. For example, given the following matrix: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 Return 4. ''' class Solution(object): def maximalSquare(self, matrix): """ :type ma...
2e307c7d166ef72006d596836b3f5fdb1b26a383
Ismael-Jonatas/SistemaBancario-Python
/func1.py
7,186
4.09375
4
# Funcao para printar o menu def menu (): print("\nSelecione a opcao desejada:\n(c) Cadastrar contas.\n(d) Digitar movimento financeiro.\n(a) Critica do movimento financeiro.\n(p) Processar movimento.\n(i) Importar arquivo CSV:\n > contas.\n > movimnentacao financeira.\n(x) Exportar dados:\n > contas.\n >...
63ac2b3a136749eb45053c1410a9d09316f84f91
rgornik/testniprojekt
/narascajoce_true.py
318
3.71875
4
#program sporoci True, ce je seznam narascujoc, drugace vrne False input_list = 1, 2, 3, 4, 5 def strictly_ascending(input_list): previous = input_list[0] for el in input_list[1:]: if el <= previous: return False previous = el return True print strictly_ascending(input_list)
1c762c0d61d5378c989966d1cc4a4d0f7902afd8
issa-me-sush/complete-python
/section4and5.py
3,083
4.1875
4
#comparison operators print(2.0==2)#T print('hello'=='Hello')#F print(2==2)#T print(3>=5) print(3<=5) print(3!=5) print(5!=5) print(5>10) print(5<10) print('chaining comparison operators - logical operators') print(1==1 and 'H'=='h') print(1==1 or 'H'=='h') print(not(1==1 or 'H'=='h')) print(1>2<3)#same as 1>2 and 2<3 ...
5d172a46e574cfa353b047bf7c53a20727eabb6c
klaus0904/exercise
/python/sort/sort_test.py
560
3.5625
4
import random import sort if __name__ == "__main__" : unsorted_array = [] for i in range(20) : unsorted_array.append( random.randint(0, 1000) ) print "beforsort:" print unsorted_array unsorted_array_copy_one = unsorted_array[:] print "quick_sort:" sort.quick_sort(unsorted_array...
c4e4e61fc6e54de90707b14e3dcfe21a1473e979
zenyichong/advent-of-code-2020
/day_07/day_07.py
1,402
3.578125
4
#! /usr/bin/env python3 """--- Advent of Code Day 7: Handy Haversacks ---""" from typing import List from collections import defaultdict import re import functools FILENAME = "day_07.txt" TARGET = "shiny gold" bags = defaultdict(list) def parse_input(inp: List[str]) -> None: outer = r"^([a-z ]*?) bag" inne...
13c5e6f0dca03b01841ad3e2b494ae4556b450d4
sanpadhy/GITSOURCE
/src/Datastructure/ArrayList/DC069/solution.py
891
4.0625
4
# Given a list of integers, return the largest product that can be made by multiplying any three integers. # For example, if the list is [-10, -10, 5, 2], we should return 500, since that's -10 * -10 * 5. # You can assume the list has at least three integers. import sys pairProduct = list() def getPairProduct(arr)...
bd7fe70836a14cb0f78fa7af745f34fac4d01635
rtate7/CSS-225-Module-8
/is_leap_year.py
600
4.3125
4
# Robert Tate # 3/6/2021 # is_leap_year is a function that takes a year as a parameter and returns True if the # year is a leap year and False if it is not. # is_leap_year_ui implements is_leap_year for testing and demonstration. def is_leap_year(year): return (year % 400 == 0) or (year % 100 != 0 and year % 4 =...
29502e2075a3aa47ef61aab1bde6a6d9cc301449
Simon-Smith-NKU/A-star
/MainDemo.py
7,625
3.546875
4
import turtle from tkinter import messagebox import win32api, win32con from Database import * from time import sleep redfinished, greenfinished, bluefinished = False, False, False global src , printer def main(): global src,printer length = win32api.GetSystemMetrics(win32con.SM_CXSCREEN) # 获得屏幕分辨率X轴 widt...
2e8a7f71bb603779d2285957999de909a41e4a84
pytthonguru/starter
/ifelse.py
126
4.09375
4
age=int(input("enter your age")) if(age>=18): print("you are eligble to vote") else: print("you are not eligble to vote")
61d6efb6c7e248ace27b602cc3df623322d121c4
zeal706/python_test
/name_cases.py
809
3.53125
4
first_name = "Lihailing" last_name = "Hello baby" full_name = first_name + " " + last_name print(full_name) name = "lihailing" print(name.upper()) name = "lihailing" print(name.title()) name = "LIHAILING" print(name.lower()) name = "Lishanglong" message = "we can't forget our mind" full = name + " " + message print(ful...
28c5b55a746a084a9360c1bc9497a94bb637cb95
emmanuelmacharia/algorithms-and-data-structures
/30daysofcode/day1.py
677
4.0625
4
'''Given a non-empty array of integers, every element appears twice except for one. Find that single one.''' def singleton(arr): ''' finds the single element in the array Uses the XOR operator where n ^ n = 0 and n ^ 0 = n therefore, every duplicating number's XOR will equal 0 and the result wil...
ed0eca695529347f291b2162a7eb78e6a6c40fca
supremepoison/python
/Day11/Code/test_global.py
547
3.796875
4
# 练习: # 写一个函数hello,部分代码如下: # count = 0 # def hello(name): # print("您好",name) # ... # 当调用hello 函数时,全局变量count自动加1操作来记录hello被调用的次数 # 如: # hello("To") # hello("jerry") # print("hello函数共被调用%d次" % count) count = 0 def hello(name): global co...
89fe707ba62b93ed7eab33b0c935c82a55e935b2
grahamplata/advent-of-code
/2019/day04/main.py
1,554
4.0625
4
#!/usr/bin/env python3 """Day04 Day 4 of Advent of Code """ import argparse from collections import Counter def runner(file_input): """runner """ with open(file_input) as file: line = file.readline().strip().split('-') min_val, max_val = [int(i) for i in line] password_count_1 = 0...
e7f9589582664e6beb2d58f3f48fa74c33abca1d
Michalos88/practice-py
/algorithms/remove_element_inplace.py
1,070
3.828125
4
"""Removing values from array in-place""" class Remover(object): "Methods for removing objects from data structures" def val_from_list(self, nums: list, val: int) -> int: n = len(nums) idx = 0 while idx < n: if nums[idx] == val: nums[idx], nums[n-1] = nums[n...
6639fc2e3fa368cf2503f3c656c0044caa623f79
shedolkar12/DS-Algo
/Tree/inorder_stack.py
616
3.671875
4
class Node: def __init__(self, x): self.val = x self.left = None self.right = None def inorder(A): stack = [] ret = [] curr = A done = 0 while not done: if curr: stack.append(curr) curr = curr.left else: if len(stack)>0...
48f9104388421d3a364ca52ecc0182aa5715beb5
yutake27/Atcoder
/abc/abc217/d_bst.py
1,377
3.53125
4
l, q = map(int, input().split()) class Node: def __init__(self, data): self.data = data self.left = None self.right = None class BST: def __init__(self, root_data): self.root = Node(root_data) def insert(self, data): e = self.root new_node = Node(data) ...
5ab391a8e7de46161ec71fa45a5596dfa7362be9
jktambit7/CursoPython
/HojaTrabajo02/Ejercicio2.py
277
3.953125
4
# Ejercicio 2 print("Ejercicio 2") print("===========") print("") num = int(input("Ingrese un número entero positivo: ")) n = num if num < 0: print("El número no es positivo") else: for x in range(num+1): print(n, end = ", ") n = n - 1
446b5b7ab9fb3136b2c8752da60294354a408096
bugrasrt/Pys
/word_List.py
1,183
4.03125
4
from itertools import permutations # Enter several word or letter then it will create unique words and sort it. # You can write it to your txt file def word_create(): words = input('Enter the words(Exit 0): ') if words == '0': exit(1) else: char_List = [char if char != ' ' else '' for char...
92d9c61277852d9b8b24e6e71e22cf6118a274d3
Macielyoung/LeetCode
/173. Binary Search Tree Iterator/BST.py
1,344
3.828125
4
#-*- coding: UTF-8 -*- class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class BSTIterator(object): def __init__(self, root): """ :type root: TreeNode """ self.i = 0 self.vals = [] nodes = [] ...
fbf458dd63536222b5079f7aa4bb9d5e0d10f905
recroot89/exercism
/python/collatz-conjecture/collatz_conjecture.py
304
3.78125
4
def steps(number): if number < 1: raise ValueError('Number must be positive') def iter(num, count): if num == 1: return count if num % 2 == 0: return iter(num / 2, count + 1) return iter(num * 3 + 1, count + 1) return iter(number, 0)
481e790149815ceec8aba9c5f871ad707f6ba82d
georgekj98/Leetcode_solutions
/Python/Remove Nth Node From End of List.py
627
3.71875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode: ts = ListNode() tf = ListNode() ts = head tf = head ...
f09928b1b78ec8f50adb8bc7f8be372948217ede
Nikita1409/codingTest
/code_project.py
4,794
3.71875
4
#!/usr/bin/env python # coding: utf-8 # # I used the reference provided to draw the ellipse. Then I connected it's two focii by a dotted line and I also drew lines that pass through the focii. Since the number of ellipses were passed as input, i tried implementing the first draw ellipse code but then the direction of ...
6b739cbbbb09dff0470f542984b91730b2c32838
Pshypher/tpocup
/ch02/projects/proj_02.py
833
4.375
4
# Program design to solve the paper folding puzzle # prompt the user for the total folds # initial thickness of the paper is 1/200 # number of folds = 0 # while the number of folds is less than the limit of the total folds entered # by the user # fold the paper by half and increase the thickness by 1/200 # incremen...
d3cf6c93753efe67596c36dc75518971d903aadd
kharicha/hkarthikbabu
/leetcode/palindrome_deque.py
697
3.578125
4
class deque: def __init__(self): self.item = [] def addFront(self, val): self.item.append(val) def addRear(self, val): self.item.insert(0, val) def removeFront(self): return self.item.pop() def removeRear(self): return self.item.pop(0) def size(self)...
3dffcfd63dfbefd6e7fd4f040a18c277dd02ce32
wss939/yhzy
/02_pan duan yu ju.py
213
3.609375
4
if __name__ == '__main__': s = int(input("请输入你的成绩:\n")) if s>90: print("成绩优秀") elif s >=50 and s< 90: print("成绩及格") else: print("不及格")
ba5474aee3b32e9a9d6afe6fb9a0c80dcc82c960
MattJGordon/PR301Assignment1
/Assignment 1/Python Files/FileHandler.py
715
3.609375
4
class FileHandler(object): def __init__(self, file): self.file = file def get_file(self): with open(self.file) as txt_file: half_split = [] for line in txt_file: half_split.append((line.replace("\n", "")).split(',')) #print(half_split...
1dfbc9bbbd427f71d9f8131f88d3b46fd4693538
vbukovska/SoftUni
/Python_fundamentals/More_exercises/softuni_reception.py
369
3.75
4
first_employee = int(input()) second_employee = int(input()) third_employee = int(input()) students = int(input()) people_per_hour = first_employee + second_employee + third_employee time = 0 if students > 0: while students > 0: students -= people_per_hour time += 1 if time % 4 == 0: ...
0ebbb629bc17fab5ef70ffc3637431ed4b150124
AHavlovick/DiceRoller
/test_dice_roll.py
1,304
3.515625
4
import dice_roll import unittest class TestDice(unittest.TestCase): """ Test the roll functionality """ def test_single_roll(self): d = dice_roll.Dice(6) t = d.roll() self.assertTrue(1<=t and t<=6) class TestDiceRoller(unittest.TestCase): """ Test multiple roll functionality """ def test...
a9b54e9fad23fa2bafe03d69b16e76985aff890d
TheCodeSummoner/SecurityPi
/server.py
13,627
3.84375
4
""" Server for RaspberryPi (Python 3.6) This is a server written during the internship with dr. Charles Morisset, Newcastle University. Its purpose is to teach security in live but safe environment, with the help of Raspberry Pi. **Author** Kacper Florianski **Usage** Run *$ python server.py* where *...
76c54bbf7e795c96bd77e69e1b5dbd2908ccefd5
hanrick2000/LeetcodePy
/leetcode/word_ladder.py
1,230
3.59375
4
import collections # # @lc app=leetcode id=127 lang=python # # [127] Word Ladder # class Solution(object): def ladderLength(self, beginWord, endWord, wordList): """ :type beginWord: str :type endWord: str :type wordList: List[str] :rtype: int """ dct = collect...
0a0a2ba94d5da89ab7d00f9c8104b9cee211e2a0
jacealan/eulernet
/level2/40-Champernowne's constant.py
954
3.71875
4
#!/usr/local/bin/python3 ''' Problem 40 : Champernowne's constant An irrational decimal fraction is created by concatenating the positive integers: 0.123456789101112131415161718192021... It can be seen that the 12th digit of the fractional part is 1. If dn represents the nth digit of the fractional part, find the value...
81c6e900476df1da69f8db49d7eabb7277fd7be3
EmilioAlzarif/intro-to-python
/week 5/Practical/P12.py
99
3.96875
4
def power(max): for x in range(max + 1): yield 2**x value = power(5) print(list(value))
48f1d4bcd12eb66839b9ca47ffc1864564c44486
Krugger1982/Algoritmes_SD
/Less_2_2.py
11,512
3.5625
4
class BSTNode: def __init__(self, key, val, parent): self.NodeKey = key # ключ узла self.NodeValue = val # значение в узле self.Parent = parent # родитель или None для корня self.LeftChild = None # левый потомок self.RightChild = None # правый потомок class BSTFind: # про...
baf15345247dd9e45ac56367fd09dc5b149d9b97
lukowar/study
/CW_25_02_20.py
2,525
3.765625
4
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 22:39:24) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> ====== RESTART: C:/Users/Adm/SoftServe/task_1_25Feb Triangle_Rectangle.py ====== >>> class Polygon: def __init__(self, no_of_sides): ...
8136799e65ffc5c95a98bc6bda99a7f69e607549
liceyo/liceyo-study-python
/example/test4/test31.py
525
3.96875
4
# 题目:请输入星期几的第一个字母来判断一下是星期几,如果第一个字母一样,则继续判断第二个字母。 weed = { 'm': 'Monday', 'tu': 'Tuesday', 'w': 'Wednesday', 'th': 'Thursday', 'f': 'Friday', 'sa': 'Saturday', 'su': 'Sunday' } letter = input("INPUT:").lower() if letter in weed.keys(): print(weed[letter]) else: letter = letter + input("INPUT s...
25f4fa4fce46f0953c9361fa8294ce6704d9d61f
yasirroni/PrisonersDilemmaTournament
/code/strats/gradual.py
468
3.5
4
def strategy(history, memory): if memory is None: memory = (0, 0) defections = memory[0] count = memory[1] choice = 1 if count > 0: if count < defections: choice = 0 count += 1 elif count == defections: count += 1 elif count > defections: count = 0 elif history.shape[1] >= 1 and history[1,-1]...
8567d7d14c352cc83ba6c532036bb2bbe178b622
EnusNata/conhecendo-linguagens
/python/exercicios/6.3.py
1,049
4.0625
4
#6.3 – Glossário: Um dicionário Python pode ser usado para modelar um #dicionário de verdade. No entanto, para evitar confusão, vamos chamá-lo de #glossário. #• Pense em cinco palavras relacionadas à programação que você conheceu #nos capítulos anteriores. Use essas palavras como chaves em seu glossário e #armazene seu...
6637e99939bcc97f64451242e691681926fba7ad
lishulongVI/leetcode
/python3/812.Rotate String(旋转字符串).py
2,694
3.921875
4
""" <p>We are given two strings, <code>A</code> and <code>B</code>.</p> <p>A <em>shift on <code>A</code></em> consists of taking string <code>A</code> and moving the leftmost character to the rightmost position. For example, if <code>A = &#39;abcde&#39;</code>, then it will be <code>&#39;bcdea&#39;</code> after one sh...
9f48e509916ded1fff3562e3497050b0e436458f
nicholas-vogt/modeling-march-madness
/src/scrape-sportsreference-cbb.py
4,108
3.796875
4
#!/usr/bin/python # In Unix, an executable file that's meant to be interpreted can indicate # what interpreter to use by having a #! at the start of the first line, # followed by the interpreter (and any flags it may need). # http://stackoverflow.com/questions/2429511/why-do-people-write-usr-bin-env-python-on-the-fir...
f330ee1f42fc9157256da26c31501752f9f6967a
livepo/lc
/TOP100/19.remove-nth-node-from-end-of-list.py
989
3.796875
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None # class Solution(object): def removeNthFromEnd(self, head, n): """ :type head: ListNode :type n: int :rtype: ListNode """ if n...
ccf93027f2120e6e3e06ecad5fffa7c2ebada342
Robert-Hatfield-TUD/python_year2
/DecimaltoBinary.py
478
4.3125
4
# decimal number will be converted to binary and then further down the line binary will be converted to decimal again #Author: Robert Hatfield #Date: 26/09/19 #Compiler: PYcharm number = int(input("Enter any decimal number: ")) if number<0: print("Number is negative") quit else: # print e...
bb86408af6b99bfa860ef0da5f4831529d2ad163
prameya21/python_leetcode
/Monte_Carlo_simulation.py
1,057
3.796875
4
import random def random_walk_01(n): """Return coordinates after" n block random walk""" x=0 y=0 for i in range(n): dir=random.choice(['N','S','E','W']) if dir=='N': y+=1 elif dir=='S': y-=1 elif dir=='E': x+=1 else: ...
9b979a2661f290485bd7515f8a6e234f9840a0a3
SuryakantKumar/HackerRank-Problem-Solving
/Easy Level/Strong-Password.py
2,004
4.40625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jan 13 16:30:26 2020 @author: suryakantkumar """ ''' Problem : Louise joined a social networking site to stay in touch with her friends. The signup page required her to input a name and a password. However, the password must be strong. The website co...
7cc348870ee0d0035986efd763baae5281d22f35
kaitoyokohamaa/cs50
/Week6/pset6/cash/cash.py
594
3.75
4
from cs50 import get_float def calcCash(): while True: n = get_float("Change owed:") if (n > 0): break cents = n * 100 coin = 0 while True: if cents >= 25: coin += 1 cents -= 25 elif (cents >= 10) and (cents < 25): coin +...
0ee488eb4fbea4658b47869b25f6f539bd1f192d
OhkumaTakumi/ex-01-g19-22
/leapmonth.py
924
4.09375
4
import sys def leap(year): ''' うるう年なら1を,平年なら0を返す ''' if year%4 != 0: return 0 elif (year%4 == 0)&(year%100 != 0): return 1 elif (year%4 == 0)&(year%100 == 0): return 0 elif (year%900 == 200)|(year%900 == 600): return 1 def get_days(year,month): ...
29021d99093380d9c7f50606b6ff3029e43cb9e9
HaeSeon/p2_201611097
/W6Main.py
1,236
3.796875
4
def upanddowngame(): trycount=0 inputnumber=input("input number") mynumber=input("my number") while inputnumber!=mynumber: if inputnumber>mynumber: print "High!" mynumber=input("Guess number!") trycount=trycount+1 ...
20b55e7dea26ec5c1e44bbd017afedf047b7a511
yuan-kai24/Python_Algorithm
/Jump.py
566
3.65625
4
# 跳一跳 def jump(): scan = input() scan = scan.split(" ") jump = 0 tag = 1 for num in scan: if num == "0":# 等于零时退出 break if num == "1":# 跳上去,没跳到中心情况 tag = 1 jump = jump + tag if num == "2":# 跳到中心情况 if tag == 1:# 第一次跳到中心 ...
c4a7b1cfcf2399475ed589a7d4b74fb8b9250310
Shiqan/daily-coding-problem
/problem-050/main.py
698
3.953125
4
#!/usr/bin/env python """ Problem 50 daily-coding-problem.com """ class Node: def __init__(self, value, left=None, right=None): self.value = value self.left = left self.right = right def __repr__(self): return self.value def evaluate(root: Node) -> int: left, right = "", ...
b16601487a6973482362106a7151dfa3e0bdc8ca
kuzovkov/python_labs
/4/task4.1.py
795
4.03125
4
# # def fact_1(n): n=int(n) f=1 for i in range(1,n+1): f=f*i return f # def fact_2(n): if n>1: return n*fact_2(n-1) else: return 1 # reduce def fact_3(n): def mul(x,y): return x*y ls=range(1,n+1) return reduce(mul,ls)...
53971127268251e1747f194d653527e788b04ae1
grieneis/rbot205
/week1/sorting_algorithms.py
1,314
4.15625
4
#! /usr/bin/python import numpy as np import matplotlib.pyplot as plt import time def bubble_sort(data): print('Bubble sort not implemented') return data def merge_sort(data): print('Merge sort not implemented') return data def sort(algorithm, data): # Here is where you can implement your sorting algorithm...
ed8c69b7a70ba99e3b98482f760fb7ed93012ed6
abhaysinh/Data-Camp
/DataCamp-Project-Solutions-Python/Name Game Gender Prediction using Sound/notebook.py
11,325
3.640625
4
# coding: utf-8 # ## 1. Sound it out! # <p>Grey and Gray. Colour and Color. Words like these have been the cause of many heated arguments between Brits and Americans. Accents (and jokes) aside, there are many words that are pronounced the same way but have different spellings. While it is easy for us to realize their...
7e822e356a492e8efe59aeaa421f559bc70de8c3
DrDoobie/python
/apps/grid.py
678
4.21875
4
from tkinter import * root = Tk() label1 = Label(root, text = "Username: ") label2 = Label(root, text = "Password: ") # Entry is a form of taking user input entry1 = Entry(root) entry2 = Entry(root) # Sticky is used for alignment. It used NESW (North, East, South, West) for direction. label1.grid(row = 0, sticky = ...
9e7aaa92d084bcfdb0047dd32d8895faf71a0699
hkxIron/hkx_tf_practice
/test_numpy/test_sklearn/plot_cv_predict.py
777
3.546875
4
from sklearn import datasets from sklearn.cross_validation import cross_val_predict from sklearn import linear_model import matplotlib.pyplot as plt lr = linear_model.LinearRegression() boston = datasets.load_boston() y = boston.target # cross_val_predict returns an array of the same size as `y` where each e...