blob_id stringlengths 40 40 | repo_name stringlengths 5 119 | path stringlengths 2 424 | length_bytes int64 36 888k | score float64 3.5 5.22 | int_score int64 4 5 | text stringlengths 27 888k |
|---|---|---|---|---|---|---|
c8b4c021b72053cd93bb5799e6d87d8f446d16c7 | shahroze911/Practice-Codes | /Assignment_Functions/Q#1.py | 146 | 3.875 | 4 | def calcArea(rad,pi=3.1416):
result=pi*pow(rad,2)
return result
radius=int(input("Enter Radius of Circle" ))
print(calcArea(radius)) |
44d2c1aad96f24fcac08ab5d226782ae57ba13ae | 40309/Lists | /2D Lists Example.py | 666 | 3.734375 | 4 | #Tony K.
#Class Work
#2D List
def table(players):
length = len(players)
longest = 0
for player in range(length):
player = player - 1
temp = len(players[player][0])
if temp > longest:
longest = temp
print(longest)
print("-"*31)
print("|{0:... |
6d9736c4859d4be3f1bdb993a7e039c66e110618 | sdanil-ops/stepik-beegeek-python | /week4/task23.py | 1,042 | 4.25 | 4 | # -----------------------------------------------------------
# Copyright (c) 2021. Danil Smirnov
# Write a program that reads two integers and a string
# from the keyboard. If this line is a designation of
# one of the four mathematical operations (+, -, *, /),
# then output the result of applying th... |
f1929a8a56d02c049365561983085395f15919be | hemanth1011/coding-dump | /3LawsofMotion.py | 115 | 4 | 4 | # Law of Motion: f=m*a
m = float(input("Enter Mass"))
a = float(input("Enter Acceleration"))
print("Force=",m*a) |
0ef7cd8d1c0a7dc8cb9e0e8d276a814866118e4d | Nivimurugesan/nivi1 | /nivi19.py | 86 | 3.546875 | 4 | z=input()
L=[]
for y in z:
if y not in L:
L.append(y)
else:
break
print(len(L))
|
fef605ac8096656968c5e0c521a048755cb98850 | ssears1108/python-learning | /python-learning-main/basic projects/numberGuess/guessing1.py | 957 | 4.21875 | 4 | import random
import math
#intro user interactions stuff
print("Hello Gamer Lets Play the Number Guessing Game!")
print("Let us start by choosing our range of numbers to guess from\n")
#getting inputs
lower=int(input("Enter Lower Bound: "))
upper=int(input("Enter Upper Bound: "))
#creating the random number the user... |
7e1d9693b395edd11eb7eb0cd8b26736146530d6 | kastnerkyle/rnn_ctc | /print_utils.py | 1,069 | 3.921875 | 4 | def slab_print(slab):
"""
Prints a 'slab' of printed 'text' using ascii.
:param slab: A matrix of floats from [0, 1]
"""
for ir, r in enumerate(slab):
print('{:2d}¦'.format(ir), end='')
for val in r:
if val == 0: print(' ', end=''),
elif val < .25: print(... |
e3c31ac07ea2df4b816998546e07bffafff5e6b1 | Z-SC/2D-Ulam-Spiral | /2DUlamSpiral.py | 5,093 | 4.09375 | 4 | #
# This program creates a circular 2D Ulam spiral comprised of rings around one another.
# These rings are constructed by a series of segments. These segments are created as follows:
# An inner arc of a circle is traced using a specified angle, this is called the inner circle
# A normal line of length 1 is trace... |
1a9e9c7fe18631365258f4dce38272e91edda205 | zcf1998/zcf1998 | /ex14.5.py | 240 | 3.765625 | 4 | a=(1,2,3)
b={1,2,3}
for i in a:
print i
print 1+3
print "%%%%%%%%%%%%%%%%"
for i in b:
print i
print "%%%%%%%%%%%%%%%%"
for i in range(3):
print a[i]
print "%%%%%%%%%%%%%%%%"
c={1:'a',2:'b',3:'c'}
for i in b:
print c[i]
|
deb81ccf7cce46e1cf6e655044c0445110c56cf8 | San1357/Leetcode_FebruaryChallenge2021 | /LongestWordinDictionarythroughDeleting.py | 568 | 3.640625 | 4 | '''Problem : Longest Word in Dictionary through Deleting'''
#CODE :
class Solution:
def findLongestWord(self, s: str, d: List[str]) -> str:
def helper(s,target):
i = 0
j = 0
while i<len(s) and j<len(target):
if s[i] == target[j]:
i+=... |
cec94cae06f86195d0588f42f56e29b0f8c75158 | khmahmud101/python-practice-code | /regex/rerepeat.py | 2,358 | 3.5625 | 4 | import re
s= "Afganistan, America, Bangladesh, Cananda, Denmark, England, Greenland, Iceland, Netherlands, New Zealand, Sweden, Switzerland"
#countries = s.split(",")
#print(countries)
#li = [item for item in countries if item.endswith("land") or item.endswith("lands")]
#print(li)
s="Bangladesh is our homeland"
#resu... |
451afe57ba39f075c7d362fc80a811fd396b95d0 | QingquanBao/VAD | /utils/vad_utils.py | 5,859 | 3.578125 | 4 | from pathlib import Path
def parse_vad_label(line, frame_size: float = 0.032, frame_shift: float = 0.008):
"""Parse VAD information in each line, and convert it to frame-wise VAD label.
Args:
line (str): e.g. "0.2,3.11 3.48,10.51 10.52,11.02"
frame_size (float): frame size (in seconds) that i... |
2d1c49d550e611deccda072e0415b9dee4e4516c | transelvania/repo-github | /lesson_03/3.1.py | 327 | 3.703125 | 4 | def my_div(arg1, arg2):
return arg1 / arg2
a = int(input("Введите делимое:"))
b = int(input("Введите делитель,не равный нулю:"))
while b == 0:
b = int(input("Введите делитель,не равный нулю:"))
print(f"Частное равно ", (my_div(a, b)))
|
00fe7f6bb8c22b979e0b03c8027cbc6dd6864b42 | bazsheikh/Hyperskill | /practice.py | 1,423 | 3.671875 | 4 | import random
import string
print('H A N G M A N')
words = 'python', 'java', 'kotlin', 'javascript'
random_word = random.choice(words)
word = '-'.split() * len(random_word)
lives = 8
bank = []
def redo(x):
while lives > 0:
if len(x) != 1:
print("You should input a single letter")
x ... |
f5feaaa1e966a496e1c37e616c10891715cfd359 | grace713/python-challenge | /PyBank/main.py | 1,299 | 3.84375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[16]:
import csv
import sys
# In[17]:
with open('budget_data.csv') as csvfile:
data = csv.reader(csvfile, delimiter=',')
datalist=list(data)
# In[18]:
print(datalist)
# In[24]:
moneysum = 0
months = 0
monthlychanges = []
previousRevenue = 0
datalist.pop... |
af32786902c0c92a3abe815a3e8ecca73ff7d29a | sosdarko/Problem-Solving | /leetcode.python/letter_phone_number.py | 1,648 | 3.765625 | 4 | # https://leetcode.com/problems/letter-combinations-of-a-phone-number/
# Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.
'''
idea:
first make list of available letters list
'27' -> [[a,b,c], [p,q,r,s]]
traverse all possible indexes in... |
776ad18ff91a475ded5a6dbef9769539767ce5a1 | wangweihao/Python | /13/13-8.py | 823 | 4 | 4 | #!/usr/bin/env python
#coding:UTF-8
class Stack(object):
stack = []
def __init__(self, obj):
self.stack = obj
def pop(self):
if 'pop' in dir(self.stack):
return self.stack.pop()
else:
index = len(self.stack)-1
ret = self.stack(index)
... |
8480d26ef34317c7626720b1dd9bf1bbd0d378bf | johnjosephhorton/visibility_allocation | /simulations/sequential_market.py | 3,232 | 3.640625 | 4 | # John Horton
# January 4th, 2011
# oDesk
import time, random
NOTES = """
This code implements the "sequential market"
approach to the algorithm problem.
We probably don't want to store a simplex of length a million -
we probably want to create a data structure like this:
{(0.0,.1):{1,2,3}, (1.0, 2.0):{4,5,6}... |
f4f2511d9ef77e858d57e3207d204b701697d0ae | yinglao/Leetcode-Lintcode | /3Sum.py | 1,842 | 3.921875 | 4 | #Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
#
# Notice
#Elements in a triplet (a,b,c) must be in non-descending order. (ie, a ≤ b ≤ c)
#
#The solution set must not contain duplicate triplets.
#
#
#Example
#F... |
4b8c24b785254aae1a3c7e6b52ba9662ec997875 | dudrill/Python_generation_basics | /6_Datatypes/6_2_3_mean_values.py | 138 | 3.9375 | 4 | from math import *
a, b = [float(input()) for i in 'ab']
print((a+b)/2)
print(sqrt(a*b))
print(2*a*b/(a+b))
print(sqrt((a**2 + b**2)/2)) |
b3286cb85074812906954b0febcb6561e83415a4 | SimonCK666/pythonBasic | /basic_python/Variable.py | 595 | 3.953125 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
import random # 导入随机数random模块
# python variables
a = 3 # a is of type int
b = 2.3
c = 1j # c is of type complex
# 指定变量的数据类型
d = int(23)
e = float(4.6)
f = str("s2")
x = "Steve" # x is of type String
y = float(a) # 将整数转换为浮点数
z = complex(b) # 将float转换为复数
print(x)
prin... |
c08a07acdf25b511781f70a9ca2f86c4503c6217 | MrGarri/exercism_python | /pythagorean-triplet/pythagorean_triplet.py | 468 | 3.90625 | 4 | def triplets_with_sum(sum_of_triplet):
return set(triplet for triplet in triplets_in_range(3, sum_of_triplet) if is_triplet(triplet))
def triplets_in_range(range_start, range_end):
for a in range(range_start, range_end // 2):
for b in range(a + 1, range_end // 2):
c = range_end - b - a
... |
a61d2b8c3112d77d88af01ec291adef6503b5084 | academia04-2019/303-exercicios-e-redes | /exercicio3.py | 314 | 3.921875 | 4 | qtd_notas = int(input("Digite o número de notas"))
soma = 0
for i in range(qtd_notas):
soma += int(input("Digite a nota"))
print(soma/qtd_notas)
lista = []
for index in range(qtd_notas):
lista.append(int(input("digite o valor")))
for i in range(qtd_notas):
soma += lista[i]
print(soma/qtd_notas) |
7b9cbdf2960112758c3623f765fa753bc6fded37 | ego6ua/pp1 | /06-ClassesAndObjects/16.py | 1,212 | 3.609375 | 4 | print('Książka e-book')
print(15 * '=')
class Ksiazka_elektroniczna():
def __init__(self, tytul, autor, liczba_stron):
self.stan_k = False
self.tytul = tytul
self.autor = autor
self.liczba_stron = liczba_stron
self.nr_bieżącej_strony = 1
def otwarta(self):
se... |
ee9f3fa9a0edb099246a6f4199f55d45d5902408 | Floozutter/project-euler | /python/p003.py | 956 | 4.125 | 4 | """
Project Euler - Problem 3
"What is the largest prime factor of the number 600851475143?"
"""
from math import sqrt
def largest_prime_factor(n: int) -> int:
"""
Returns the largest prime factor of a natural number greater than 1.
"""
lpf = n # current candidate for the largest prime fac... |
56be974a267d9602f5e8550791f55a3f48103602 | melissa-24/advent-of-code-2020 | /December 03/day03.py | 369 | 3.5 | 4 | import sys
if len(sys.argv) < 1:
print("Input file expected", file=sys.stderr)
sys.exit(1)
with open(sys.argv[1]) as infile:
x = 0
trees = 0
for slope in infile:
slope = slope.strip()
if slope[x % len(slope)] == '#':
trees += 1
x += 3
print(f"You hit {... |
e5d34256edcfd7dd76f9f28a7b60797800bbaa9b | UWPCE-PythonCert-ClassRepos/Wi2018-Online | /students/ssankura/lesson02/fizzbuzz.py | 521 | 4.40625 | 4 | #Lesson2 - FizzBuzz Assignment
#Print all numbers from 1 to 100
#Print FizzBuzz instead of the number if it is divisible by 15
#Print Fizz instead of the number if it is divisible by 3
#Print Buzz instead of the number if it is divisible by 5
def fizzbuzz():
startnum = 1
endnum = 100
for i in range(startnum,endnum+... |
dae7727349d14038c5d4f7711f3367b78dbbb2a5 | saanvitirumala/python-beginner | /ananthsir-python-class/day-10.py | 705 | 3.65625 | 4 | import turtle
turtle = turtle.Turtle()
#define pen size
turtle.pensize (5)
#define pen color
turtle.pencolor ("Blue")
#for outer bigger circle
turtle.fillcolor ("red")
turtle.penup ()
turtle.goto (0, -200)
turtle.pendown ()
turtle.circle (200)
#for eyes
turtle.penup ()
turtle.goto (-100,50)
turtle.pendown ()
tu... |
ccc06c41f6f04aec1e1dea99f5241dee8dfdb214 | alzhang99/SlackTats | /venv/lib/python3.7/site-packages/githubcli/utils.py | 2,265 | 4.375 | 4 | def listify(items):
"""Puts each list element in its own list.
Example:
Input: [a, b, c]
Output: [[a], [b], [c]]
This is needed for tabulate to print rows [a], [b], and [c].
Args:
* items: A list to listify.
Returns:
A list that contains elements that are listifie... |
91b78d2b19436f5e6c02e1b88d0f3945122ba2ab | liulehui/LintcodeSolution | /lintcode algo ladder/57. 3Sum.py | 965 | 3.890625 | 4 | # coding:utf-8
def threeSum(numbers):
# write your code here
numbers.sort()
results = []
length = len(numbers)
for i in range(0, length - 2):
if i and numbers[i] == numbers[i - 1]:
continue
target = -numbers[i]
left, right = i +... |
c015a92769ddfd9fbb8eaddb723f4aed8e9a0911 | swittrock/Othello | /main.py | 3,662 | 3.515625 | 4 | from tkinter import *
from simplified_logic import *
class Option_popup:
def __init__(self):
self.row_selection = 0
self.column_selection = 0
self.first_turn_selection = ''
self.win_lose_selection = ''
self.options_pop_up = Toplevel()
self.options_pop_up.title('Opt... |
c3e76aa6923229069b401cb3148e1418bf50dd92 | paik11012/Algorithm | /test/7월말평가/02.py | 732 | 3.71875 | 4 | # 파일명 및 함수명을 변경하지 마시오.
def alphabet_count(word):
"""
알파벳을 key로, 갯수를 value로 가지는 딕셔너리를 반환합니다.
"""
new = list(word)
n_dict = {} # 빈 딕셔너리 만들기
for i in range(len(new)): # 5
n_dict[new[i]] = 0 # 모두 0인 딕셔너리 만들기
for i in new: # 알파벳 한 개씩 가져오기
if i in new:
n_dict[i] += ... |
568e5e76b4541ef9218f42b6242a6119624ba81b | BEPCTA/Coding_Games | /hold_at_strategy.py | 879 | 4.1875 | 4 | # -----------------
# User Instructions
#
# In this problem, you will complete the code for the hold_at(x)
# function. This function returns a strategy function (note that
# hold_at is NOT the strategy function itself). The returned
# strategy should hold if and only if pending >= x or if the
# player has reached the g... |
bbf74e88a6778fdd72f78dde4b08e4428fb662be | rcorrero/thermidor | /thermidor/functions/date_extractor.py | 2,946 | 3.671875 | 4 | # Author: Richard Correro
import pandas as pd
def date_extractor(X, date_col='index',
start_date=None, end_date=None,
drop_nonfloat_cols=True,
drop_na_rows=True, drop_na_cols=True):
'''Selects date ranges from arrays indexed by date and optionally
drops... |
07d58256ac9502baa019cead9d31bd4656779b76 | ralitsapetrina/Programing_fundamentals | /functions_and_debugging/multiply_even_odds.py | 369 | 4 | 4 | def mult_nums(num):
result_even = 0
result_odd = 0
while num > 0:
last_dig = num % 10
if last_dig % 2 == 0:
result_even += last_dig
else:
result_odd += last_dig
num = num // 10
return result_even * result_odd
if __name__ == "__main__":
number... |
1f317684d1a024004a119a2302cfcd196ffcc28b | whistle59/mySnippets | /python/file_handling/with.py | 597 | 4.3125 | 4 | # https://www.geeksforgeeks.org/with-statement-in-python/
# file handling without with
###########################
# 1) without using with statement
file = open('file_path', 'w')
file.write('hello world !')
file.close()
# 2) without using with statement
file = open('file_path', 'w')
try:
file.write('hello worl... |
d73302617d3947823dd8d1ffbeb6173412e91d99 | colephalen/SP_2019_210A_classroom | /students/JoeNunnelley/session04/dict_lab.py | 3,067 | 4.40625 | 4 | #! /usr/bin/env python3
"""
Session 04: Dictionaries and Sets Lab
Author : Joe Nunnelley
"""
def dictionaries_one():
"""
Dictionaries 1
Create a dictionary containing “name”, “city”, and “cake” for “Chris”
from “Seattle” who likes “Chocolate” (so the keys should be: “name”,
etc, and v... |
02de6f9de0fc6b7080cdd054d15db99406dbd92f | SorawatSiangpipop/Python | /come_x_pay_y.py | 590 | 3.765625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 19 09:31:25 2019
@author: ssiangpipop
"""
# come 3, pay 2
# come 4, pay 3
# input -> process -> output
# input
#come_x = 4
#pay_y = 3
per_head = 100
pax = 9
# process
#print((pax // come_x) * (pay_y * per_head))
#print((pax % come_x) * per_head)... |
25a6e599b20d7026f4a8817adf0cfa66f8e37c02 | BrettMcGregor/udemy-python-tim | /io_challenge.py | 967 | 4.25 | 4 | # Write a program to append the times tables to our jabberwocky poem
# in sample.txt. We want the tables from 2 to 12 (similar to the output
# from the For loops part 2 lecture in section 6).
#
# The first column of numbers should be right justified. As an example,
# the 2 times table should look like this:
# 1 times... |
2555503defd46c624eed2628be8365d01b873a4f | RideGreg/LintCode | /Python/card-game.py | 3,210 | 3.859375 | 4 | '''
1448. Card Game
A card game that gives you two non-negative integers: totalProfit, totalCost, and n cards'information. The ith card
has a profit value a[i] and a cost value b[i]. It is possible to select any number of cards from these cards, form a scheme.
Now we want to know how many schemes are satisfied that al... |
fc5f78e3fd530109e688a49bbdbf73ae51405df8 | swordmaster2k/botnav | /BotNav/model/cell.py | 557 | 3.90625 | 4 | '''
A Cell class for use on a Map grid. The cell contains (x, y) coordinates,
data for planners to manipulate, and a state for graphical representation.
'''
class Cell:
'''
Initialises a new cell.
'''
def __init__(self, x, y, data, state):
self.x = x
self.y = y
self.data = data
self.state = state # 0 = Unkn... |
3c6703d247dccf9ed2ea634770754efb4b53a302 | donghee-jung/3rd_study | /reduce_ex01.py | 216 | 3.640625 | 4 | from functools import reduce
no_cpu = int(input('NO of CPU? '))
work_tuple = input('Every processing time: ')
total = reduce(lambda x,y:x+y, work_tuple)
print("Type of result variable", type(total))
print(total)
|
be444fcbc05ed46a77291862f57f9ae078fa8f79 | whglamrock/leetcode_series | /leetcode245 Shortest Word Distance III.py | 1,057 | 3.6875 | 4 |
class Solution(object):
def shortestWordDistance(self, words, word1, word2):
dick = {}
for i in xrange(len(words)):
if words[i] not in dick:
dick[words[i]] = [i]
else:
dick[words[i]].append(i)
def findshortest1(lst):
lst.... |
15c14ad080d5685008522140964c8df956645ca3 | sunn-u/CodingTest | /Programmers/Lv1/pop_dolls.py | 664 | 3.5 | 4 | # 2019 카카오 개발자 겨울 인턴십 : 크레인 인형뽑기 게임
def solution(board, moves):
answer = 0
pre_dolls = ['']
line_dict = {idx: 0 for idx in range(1, len(board)+1)}
for mov in moves:
which_line = line_dict[mov]
if which_line > len(board) - 1:
continue
mov -= 1
while board[whi... |
c0098b1331df00327d63eff93f82a33b74e28f9b | rduvalwa5/Mux | /Mux_Gui/Get_Artist_GUI.py | 2,019 | 3.71875 | 4 | '''
Updated 04/05/2023
@author: rduvalwa2
'''
from tkinter import *
from Music_Get_Functions import musicGet_Functions
class Application(Frame):
"""Application main window class."""
def __init__(self, master=None):
"""Main frame initialization (mostly delegated)"""
Frame.__init__(self, mast... |
ae63b6c624cd77e4c58bbd34283f02d1d4df213a | CTISM-Prof-Henry/pythonScopes | /escopo/experimento_4.py | 334 | 3.671875 | 4 |
def main():
x = 10
def minha_funcao():
print('ola mundo!')
print('Estou acessando a variável x da função main, de dentro da minha_funcao, e seu valor é %d' % x)
minha_funcao()
print('Estou acessando a variável x da função main, e seu valor é %d' % x)
if __name__ == '__main__':
m... |
dd20952c0af6fc72f472dea6b585c5c67d1f31ba | xiesong521/my_leetcode | /数组/#26_删除排序数组中的重复项.py | 1,593 | 3.625 | 4 | #!/user/bin/python3
#coding:utf-8
"""
Author:XieSong
Email:18406508513@163.com
Copyright:XieSong
Licence:MIT
"""
# 给定一个排序数组,你需要在原地删除重复出现的元素,使得每个元素只出现一次,返回移除后数组的新长度。
## 不要使用额外的数组空间,你必须在 原地 修改输入数组 并在使用 O(1) 额外空间的条件下完成。
# 给定数组 nums = [1,1,2],
# 函数应该返回新的长度 2, 并且原数组 nums 的前两个元素被修改为 1, 2。
# 你不需要考虑数组中超出... |
1ee2be512bf1cd14cc5a254ddacdb1ba037d6f1a | MattEveritt/Testing | /testing/Triangle problem/triangle.py | 285 | 4.03125 | 4 | def checkTriangle (a,b,c):
if a == b and b == c:
print ("equilateral")
return 'equilateral'
elif a == b or b == c or a == c:
print ("Isosceles")
return 'isosceles'
else:
print ("Irregular")
return 'irregular'
# Matthew Everitt
|
886af5fbfd074fc197d7ad6154d23005d3ea1e7c | edu-athensoft/stem1401python_student | /py210110d_python3a/day09_210307/homework/stem1403a_hw_8_0228_KevinLiu.py | 871 | 4.1875 | 4 | """
[Homework]
2021-02-28
Show and Hide a label in a window
Due date: By the end of next Sat.
"""
"""
score:
perfect
"""
# tkinter module
from tkinter import *
# hide label function
def hide(widget):
return lambda : Pack.forget(widget)
# show label function
def show(widget):
return lambda: widget.pack(si... |
e9e602dd8a3f806268fa3adc63fcc43f3c7a59f7 | rhender007/python-ps | /hacker_rank_python/setIntersection.py | 292 | 3.6875 | 4 | """
https://www.hackerrank.com/challenges/py-set-intersection-operation
Set-> intersection operation. Can also be expressed as & like A&B
"""
n1 = int(input())
setA = set(map(int, input().split()))
n2 = int(input())
setB = set(map(int, input().split()))
print(len(setA.intersection(setB)))
|
4d1e46ea12dbc2b12311c16322f6b9add4c8dbd3 | MilletMorgan/projets-sciences-U | /Python/Bin2Dec/bin2dec.py | 2,024 | 3.890625 | 4 | def deciConvers(decimal):
if decimal > 1:
deciConvers(decimal//2)
return decimal % 2
def binConvers():
binary_list = []
decimal = []
binary = int(input("Enter your binary number : "))
for i in str(binary):
binary_list.append(int(i))
binary_list.reverse()
for i in ra... |
d2c3cbfe9d280370337b7858fcbbd3f8a2aeffc5 | gkapfham/seed | /seed_download.py | 1,412 | 3.6875 | 4 | """ seed_download.py downloads a JSON file from SimpleForm and saves files """
import json
import requests
import seed
JSON_FILENAME = "seed.json"
MAILING_LIST_FILENAME = "recipients.csv"
def seed_download(seed_simpleform_token):
""" Download the JSON file from SimpleForm using the provided token """
simpl... |
023df36abb89ede4a23db5dd33085c430256d6c7 | AlvaroSMoreno/progra_avanz1 | /sesion3.py | 503 | 3.59375 | 4 | ### EJERCICIO (Funciones)
# Somos una caja registradora...
# El cliente nos paga con "x" cantidad de dinero, y compra un articulo de "y" precio
# Cuanto nos sobra? (imprimir)
# Podemos tener varios clientes (tenemos que usar un ciclo)
pago = float(input('Ingrese la cantidad de dinero: '))
precio = float(input('Ingrese... |
f9c5ca3845129ac5febec951586e6c7b66695d53 | maosa/codecademy | /python/ml/find_the_flag.py | 3,952 | 4.3125 | 4 | ##### DESICION TREES - FIND THE FLAG PROJECT
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier
import matplotlib.pyplot as plt
##### Row 0 to be used as the header
flags = pd.read_csv('~/Desktop/programming/codecademy/python/ml/flags.csv', header... |
52046ed95d712a6489df8e176a78f3ddb4b213c2 | thruc/practice_python | /sandbox/prevent_repetition.py | 227 | 3.5625 | 4 | fresh_fruit = {
'apple': 10,
'banana': 8,
'lemon': 5,
}
# countに代入をしながら判定
if (count := fresh_fruit.get('apple', 0)) >= 4:
print("make_cider_{}".format(count))
else:
print("out_of_stock") |
fa462ab6a09c0b94f7c7c1747487ef846bc7422d | fenggu/MINIST_tensorflow | /test.py | 113 | 3.578125 | 4 |
from numpy import *;
L =array(['Michael', 'Sarah', 'Tracy', 'Bob', 'Jack'])
L=mat(L);
print(L[:1, 0:3].shape[0]) |
c5d83ebbd60231089238a9c4d70fa4932a58b24e | hiimharry/adventofcode2020 | /day10/day10.py | 833 | 3.71875 | 4 | f = open("input.txt", "r")
voltages = f.readlines()
voltages.append("0")
voltages = sorted([int(x.replace("\n","")) for x in voltages])
oneJumps = 0
threeJumps = 1
prevVoltage = 0
for v in voltages:
if v - prevVoltage == 1:
oneJumps+=1
elif v - prevVoltage == 3:
threeJumps +=1
prevVoltag... |
ca29f9f8fdc58d5f7a68be980a2dead4775a8000 | daniel-reich/ubiquitous-fiesta | /rPnq2ugsM7zsWr3Pf_14.py | 178 | 3.8125 | 4 |
def find_all_digits(nums):
k=[]
for i in nums:
for j in str(i):
if(j not in k):
k.append(j)
if(len(k)==10):
return i
return "Missing digits!"
|
280ca1a3b4ec76a1ce7fe0f419aa3f9f5f123465 | gsandoval49/stp | /function_input_squared.py | 208 | 4.21875 | 4 | a = input("type a number:")
"""
input is entered as a string
need to convert to integer
int can now be used as formula which should square the number entered.
"""
b = int(a)**2
print("squared number is", b)
|
b168d85a097e9478b3b5aa42180928fd6ef39a54 | trriplejay/pypractice | /my_utils/bst.py | 7,216 | 3.765625 | 4 | import unittest
import random
import copy
class node(object):
def __init__(self, data=None, depth=0, left=None, right=None):
self.data = data
self.left = left
self.right = right
self.depth = depth
class bst(object):
"""
currently not a balanced bst implementation, so orde... |
69e05dfea940440129e1e2b770c932e4075ff539 | edu-athensoft/stem1401python_student | /py200727_python2/day33_py208024/sample/guess_number_leon.py | 1,373 | 3.953125 | 4 | """
"""
"""
app: Guessing Number Game
By: Leon Li
"""
import random
answer1 = random.randrange(1, 101)
def compare(x, answer):
flag = False
if x > answer:
print("Too big")
elif x < answer:
print("Too small")
else:
print("Bingo!")
flag = True
return flag
def validate... |
41a0b2c5cae8405c13b15f81615b1ad931987128 | BVlad917/Graph-Algorithms | /Assignment 1/Directed Graph - Python/Lab 1 Assignment - Python Implementation/main.py | 1,565 | 3.5625 | 4 | from directed_graph import read_graph, create_random_graph
from errors import GraphException
from presentation import UI
"""
The files graph1k.txt, graph10k.txt, graph100k.txt, and graph1m.txt were downloaded from the assignment page
and were used to test the program (i.e., to see if the program can work with su... |
7b4015e70da809642aac7de15932963a1d50c301 | derick-droid/pirple_python | /ifhomework.py | 416 | 4.125 | 4 | # Create a function that accepts 3 parameters and checks for equality between any two of them.
# Your function should return True if 2 or more of the parameters are equal, and false is none of them are equal to any of the others.
def comparison (one, two, three):
if one == two and three:
return True... |
8aa426ef4df8c3421329e0cda9e716c56680255a | manusri2430/positive | /Alphabet.py | 135 | 4.09375 | 4 | ch = raw_input()
if ((ch>='a' and ch<='z') or (ch>='A' and ch<='Z')):
print("is an alphabet")
else:
print("is not an aphabet")
|
990627dc04f9b71210af825bb739a99d6beb1a39 | KarlClinckspoor/Tese | /python/converting_files2.py | 2,294 | 3.6875 | 4 | # ... continuação
elif append == '2':
oldlist = open('INPUT.LIS', 'r') # todo: check for file missing
contents = [line.strip() for line in oldlist]
oldlength = int(contents[0])
del (contents[0]) # removes the counter at the beginning of the file.
... |
fd214db761ee293c47c9f401e5b23682a9c4643f | daikiante/tensorflow | /gen_data.py | 1,617 | 3.5625 | 4 | """
No.2
このセクションでは取得した画像データを画像データをTensorFlowが扱いやすいようにnumpyで配列型式に変換していく
scikit-learn
Pythonの機械学習用のライブラリ
クロスバリデーション : 交差検証
データを分離して学習と評価を行う手法
glob : グローブ
パターン一致でファイル一覧を取得する
"""
from PIL import Image
import os, glob
import numpy as np
from sklearn import model_selection
from sklearn.model_selection import cross_val_sc... |
2d10813ba862b9ec629f8e2102239ddbaf633494 | pushrax/se101 | /final/sensors.py | 1,192 | 3.515625 | 4 | from myro import *
from math import *
import time
class Sensors:
def __init__(self, _robot, _movement):
self.robot = _robot
self.movement = _movement
def getSensors(self):
get = self.robot.get("obstacle")
result = (get[0] + get[1] + get[2]) > 1000
count = 0
while result and count < 3:
get = self.robo... |
da61bacb3e9202e134525fa9e4d57a2d8df59cc8 | aparnake/pythonPrograms | /table.py | 73 | 3.671875 | 4 | i=0
while i<109:
print("Ram")
i=i+1
print("end of while loop")
|
71cc70cf7050cecd05c9ef6f6a278f7367ba0501 | HugoAquinoNavarrete/python_scripting | /bin/08-autoincremento-variables.py | 755 | 4.03125 | 4 | # Script para explicar el uso del auto incremento de variables
# Define variables
Variable_1 = 5
print ("Valor inicial de \"Variable_1\": " + str(Variable_1))
Variable_1 = Variable_1 + 3
print ("Ahora el valor \"Variable_1\" es: " + str(Variable_1))
Variable_1 = Variable_1 // 2
print ("Ahora el valor de \"Variable_1\"... |
a2ff1572c7072d4149177693f45eba33bb2726c3 | dereklearns/dereklearns.github.io | /code/bunny2.py | 1,029 | 4.15625 | 4 | class Bunny:
def __init__(self, name):
# Calling Bunny() now takes 1 parameter, name
self.name = name
def __str__(self):
return self.name
def display_bunnies(bunnies):
for bunny in bunnies:
print bunny
bunnies = []
names_of_bunnies = ['ted', 'fred', 'jenny']
for name in names_of_bunnies:
bunnies.app... |
8f5ebfdf14d3000ce80e48fd6d103ea62cbef570 | Nojap/Sandbox | /PP_Exercise_1.py | 836 | 4.34375 | 4 | # Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old.
# Extras:
# --> Add on to the previous program by asking the user for another number and printing out that many copies of the previous message. (Hi... |
625256df3d925f911cad3d186aa3ca0947ceb052 | edivaldoleitao/python | /desafio54.py | 283 | 3.890625 | 4 | import datetime
count = 0
for c in range(0, 7):
anoNascimento = int(input('digite o ano de nascimentop'))
if datetime.date.today().year - anoNascimento >= 18:
count += 1
print('existem {} pessoas que são adultos, e {} que não são'.format(count, 7 - count))
|
13b43515da467d9798ebc267a8be2a5230f1b0e1 | jesusa2624/master-python | /06-bucles/bucle-while.py | 716 | 3.890625 | 4 | """
# WHILE
WHILE condicion:
BLOQUE DE INSTRUCCIONES
//actualizacion de contador
"""
contador = 1
while contador <= 100:
print(f"Estoy en el numero {contador}")
contador += 1
print("----------------------")
contador = 1
muestrame = str(0)
while contador <= 100:
muestrame = muestrame + "," + s... |
34b4631a2d1f422d09b3baaee7d10225ea57b29c | luozhaoyu/leetcode | /min-stack.py | 2,359 | 3.71875 | 4 | class MinStack:
def __init__(self):
self.data = []
#: store the index of data, so the value need to be referred by data
self.heap = []
def get_value(self, i):
return self.data[self.heap[i]]
def get_left_value(self, i):
return self.data[self.heap[i * 2 + 1]]
def... |
5bdc0f32ae432b2fc0978135c0486063fcfedb73 | ecamellini/frequency-analysis | /rot13.py | 835 | 4.40625 | 4 | import sys
def substitute(text, dictionary):
"""Substitute each char in 'text'
using 'dictionary' as a map for the
substitution pattern."""
output = ""
for i in text:
output = output + dictionary[i]
return output
def rot13_dict():
"""Generate the rot13
substitution dictionary... |
cae52b58ac7fd5c3beeff3f0f1224a68b041836a | MrHamdulay/csc3-capstone | /examples/data/Assignment_4/mclemi002/ndom.py | 875 | 3.546875 | 4 | def ndom_to_decimal (a):
a=str(a)
if len(a)==3:
return 36*eval(a[0])+6*eval(a[1])+eval(a[2])
if len(a)==2:
return 6*eval(a[0])+eval(a[1])
else:
if eval(a)<=5:
return eval(a)
else:
return eval(a)+4
def decimal_to_ndom (a):
... |
1381660841b36dbf299b93d40d9d554aa9478be1 | nazariofernando/CreateTeam | /solution.py | 1,181 | 3.53125 | 4 | from math import sqrt
def find(array, solution):
best = 0
newRole = 0
newPerson = 0
best = max(array)
indexOfMax = array.index(best)
result = solution
if best == -1:
return result
else:
if indexOfMax <= 2:
newRole = 0
elif 3 <= indexOfMax <= 5:
... |
c5a017a2520ae0196d0bdd007873614abd29c5f0 | wangshaobo08/algorithm | /06_merge_sort.py | 888 | 3.765625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2018-12-10 20:50:47
# @Author : sober (wangshaobo08@gmail.com)
# @Link : https://www.jianshu.com/u/b2d5110e9a57
# @Version : $Id$
def merge_sort(arr):
n = len(arr)
if n <= 1:
return arr
mid = n // 2
left_li = merge_sort(arr[:mid])
... |
26ea3723ae41c57ecc35862c9487ec7b2626c932 | choice17/git-note | /algorithm/python/_quicksort.py | 764 | 3.8125 | 4 | import numpy as np
import sys
import random
import time
#import __funture__
sys.setrecursionlimit(1000)
def _quicksort(array_in):
if len(array_in) <2:
return array_in
smaller = []
equal = []
bigger = []
pivot = random.choice(array_in)
for i in array_in:
if i < pivot:
smaller.append(i)
elif i == piv... |
8e1268be28669a526208228449ae2290700a6828 | Ewelina0/js_zad3 | /main.py | 535 | 3.84375 | 4 | def what_word(key, attempt):
succeded = False
print("Zgadnijmy jakie słowo wpisałeś!")
for i in range(attempt):
word = str(input())
if word != key:
print("Spróbuj ponownie")
else:
succeded = True
break
print("Gratulacje! Odgadłeś/aś słowo kluc... |
a88bcb8e0b6801252990e67c82e825246956030d | daniellaah/Data-Structure-and-Algorithms | /lintcode/code/115_Unique_Paths_II.py | 1,219 | 4.03125 | 4 | '''Unique Paths II
Follow up for "Unique Paths":
Now consider if some obstacles are added to the grids. How many unique paths would there be?
An obstacle and empty space is marked as 1 and 0 respectively in the grid.
Example
For example,
There is one obstacle in the middle of a 3x3 grid as illustrated below.
[
[0,... |
b546b4ef7438c17b61b0ab610c43149145a9cc1b | beefinbj/Project_Euler | /16.py | 535 | 3.65625 | 4 | def solve():
power = 1
digs = 1
first_dig = 1
while power <= 10:
first_dig = first_dig * 2
if first_dig > 9:
first_dig = 1
digs = digs*2-9
else:
digs = digs*2
print "Power: " + str(power)
print "First dig: " + str(first_dig)
... |
f29e96d8fe14d2b1bf5d86f9afe395e91fcca2b9 | xuziyan001/lc_daily | /85-max-rec.py | 2,233 | 3.59375 | 4 | from typing import List
"""
给定一个仅包含 0 和 1 的二维二进制矩阵,找出只包含 1 的最大矩形,并返回其面积。
"""
"""
给定一个最大矩形,其高为 h, 左边界 l,右边界 r,在矩形的底边,区间 [l, r]内必然存在一点,其上连续1的个数(高度)<=h。若该点存在,
则由于边界内的高度必能容纳h,以上述方法定义的矩形会向上延伸到高度h,再左右扩展到边界 [l, r] ,于是该矩形就是最大矩形。
若不存在这样的点,则由于[l, r]内所有的高度均大于h,可以通过延伸高度来生成更大的矩形,因此该矩形不可能最大。
综上,对于每个点,只需要计算h, l,和 r - 矩形的高,左边界和右边界。
... |
c380c2c3cefd4c645f985cc708399ce5d3b81d8d | 108krohan/codor | /hackerrank-python/learn python/Validating-list-of-email-addresses-with-filter - string manipulation, llist.py | 1,064 | 3.796875 | 4 | """validate list of email addresses with filter at hackerrank.com
"""
"""
"""
#import string
def conditions (oneRecord) :
## lst = list(oneRecord)
## #print lst
## atRate = lst.index('@')
## dot = lst.index('.')
atRate = oneRecord.find('@')
dot = oneRecord.find('.')
## print dot
... |
96a78b7cbe5a48efee9061cd1e917dc8666c57cf | warlockee/leetpy | /algos/redundant-connection.py | 2,421 | 3.71875 | 4 | # DFS
"""
For each edge (u, v), traverse the graph with a depth-first search to see if we can connect u to v. If we can, then it must be the duplicate edge.
Time Complexity: O(N^2)
Space Complexity: O(N)
"""
from collections import defaultdict
class Solution(object):
def findRedundantConnection(self, edges):
... |
4e77d21317e29d0f8b9c7c4446b7f820fb0fa669 | shivashriti/dataPy | /5. Read_flat_files.py | 959 | 3.84375 | 4 | # Open a file: file
file = open('moby_dick.txt', 'r')
# Print it
print(file.read())
# Check whether file is closed
print(file.closed)
# Close file
file.close()
# Read & print the first 3 lines
with open('moby_dick.txt') as file:
print(file.readline())
###########################################################... |
7b0ca220ffeb7593e91d9b0ae4125d622628e0f9 | miguel-dev/holbertonschool-higher_level_programming | /0x0A-python-inheritance/100-my_int.py | 548 | 3.984375 | 4 | #!/usr/bin/python3
"""Module MyInt"""
class MyInt(int):
"""Definition of MyInt"""
def __init__(self, number):
"""Initializes the number"""
self.__number = number
def __eq__(self, other):
"""Redefined equal comparison operator"""
if self.__number == other:
retur... |
b6fe9ce584b44496159e6a3a197fa85322b6260a | ravitkhurana/watchout | /watchout/main.py | 7,833 | 3.8125 | 4 | import pygame
import enum
class Color(enum.Enum):
"""
Enumeration for common colors
"""
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
BLUE = (0, 0, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
class Constants(object):
"""
Class to hold constants used in game
"""
GRAVITY =... |
4af23482443141f9ccdd8bc3e1ee52b4722b787c | KeepFloyding/DSToolboxpy | /DSToolbox/df_transform.py | 3,870 | 3.703125 | 4 | # Package for dataframe transformation
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
"""
Function to prepare timeseries dataframe. Divides timeseries data into event_legs and groups by group_array
Inputs:
- df: dataframe with timeseries dataframe
- start_date: pandas series with time ... |
982bf1e0df3a3ed1b04ba59f45e294cbc2b558ef | naliang0305/LessonPy | /Lesson/vM2.py | 2,573 | 3.953125 | 4 | # 函式版販賣機
flag = True # 控制迴圈是否繼續執行
balance = 0 # 使用者餘額
drinks = [
{'name': '可樂', 'price': 20},
{'name': '雪碧', 'price': 20},
{'name': '茶裏王', 'price': 25},
{'name': '原萃', 'price': 25},
{'name': '純粹喝', 'price': 30},
{'name': '水', 'price': 20},
]
#以上為全域變數
def deposit():
"""
儲值
:return: ... |
7fb05fc34ee6fa602724fd56cfd4f383cc43fca0 | ehdgjs/pythonstudy | /quiz3.py | 368 | 3.8125 | 4 | def std_weight(height, gender):
height = height/100
if gender == "남자":
return height * height * 22
elif gender == "여자":
return height * height * 21
height = int(input())
gender = input()
avg_weight = round(std_weight(height, gender), 2)
print("키 {0}cm {1}의 표준 체중은 {2}kg입니다.".format(height, g... |
4063847fe8ed812b598cad7874fa60b843180b0d | die-zwei-Freunde/extrem-epic-excessive-enthusiastic-elf-elevator | /classes/enemy/enemy.py | 1,616 | 3.6875 | 4 | '''
Introducing: the enemy.
It is ... not your friend, I guess.
'''
class Enemy():
'''
Enemy (short: NME)
base class for future enemies which will be clubbed to death for entertainment.
Maybe they should scream a bit?
'''
def __init__(self, name):
self.name = name
self.HP, sel... |
a4754629cbdbf6690f61ea84a8346c1f9a32a7a5 | sctu/sctu-ds-2019 | /1806101055官学琦/day/20190611/最小栈.py | 1,109 | 4.03125 | 4 | class Minstack:
def __init__(self):
self.data=[]
self.min_stack=[]
def get_min(self):
return self.min_stack[len(self.min_stack)]
def push(self,num):
self.data.append(num)
if len(self.min_stack)==0:
self.min_stack.append(num)
elif self.get_min(... |
fb9be7a88682953449973b3249f95243d7924819 | alis70929/01_Lucky_Unicorn | /LU_Component4_PaymentMechanics.py | 536 | 3.671875 | 4 | # Lucky Unicorn Component 4
# Payment mechanics
#assume starting amount is $10
total = 10
#Allow manual input of token for testing
token = input("Which token would you like?:")
#Adjust total correctly for given token
if token == "unicorn":
total += 5
feedback = "Congratulations, You won $5.00 "
elif token ==... |
272cfcd72210c9b47b21296c7fcb1630b3ac560d | makeTaller/Python | /month.py | 563 | 4.125 | 4 | # Working with the string spliter
# Calendar Program
# by: Kirk Tolliver
def main():
# months is a list used as a lookup table
#months = "JanFebMarAprMayJunJulAugSepOctNovDec"
months=[ "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]
n = eval(input("Enter a month number (1-12):... |
9c017acd8b90a101d4bbd80f1fcb8ab4c760a0f4 | ZhengweiHou/python-learn-hzw | /算法/有效的括号.py | 680 | 3.78125 | 4 |
class Solution:
sol_dict={')':'(',']':'[','}':'{'}
def isValid(self,s:str) -> bool:
stack = []
for c in s:
if self.sol_dict.__contains__(c):
tempc = '$' if len(stack) < 1 else stack.pop()
if tempc != self.sol_dict[c]:
return False... |
1937317a1f5fc902101234d1ebb9768d8f47b100 | milson389/python-project | /Fundamental/src/Collection/Tuple.py | 163 | 3.78125 | 4 | # Python Tuples
# Collection with Ordered Sequence
# Similar to List, but elements in tuples are unchangeable
t = (5, 'Program', 1+3j)
print(t[1])
print(t[0:3])
|
894452b76c790430c45783aa654ecca9bdfd8312 | adya-13/project-euler | /prob_6.py | 131 | 3.828125 | 4 | def sum_square(n):
return ((n*(n+1))/2)**2
def square_sum(n):
return (n*(n+1)*(2*n+1))/6
print(sum_square(100)-square_sum(100)) |
6be300eefe0714047e10e6c40663d4fe18441a2d | philliplu1990/pynet_test | /string_exercise01.py | 165 | 3.625 | 4 | name1 = 'Jarrod Phelps'
name2 = 'Phil Lu'
name3 = 'Mike Meeker'
print "{:>30}{:>30}{:>30}".format(name1, name2, name3)
name4 = raw_input('Print your name please:')
print name4
|
cf5701e79e4f18476d90ad0fd1da33da20fb0a1f | Vasudevatirupathinaidu/Python_Harshit-vashisth | /72_func_practice.py | 346 | 4.15625 | 4 | # Function Practice
# Example 1
# def last_char(name):
# return name[-1]
# name1 = input("Enter your name: ")
# print(last_char(name1))
# print()
# Example 2
def odd_even(num):
if num % 2 == 0:
print("It's an even number")
else:
print("It's an odd number")
num1 = int(input("Enter a n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.