blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
603ca9e3c1b50f264b96b648794cd5ea2f5c7576 | shinan0/python2 | /约瑟夫环问题.py | 1,574 | 4 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
def move(players,step):
#移动step前的元素到列表末尾
#将如何step的元素从列表中删除
num = step - 1
while num > 0:
tmp = players.pop(0)
players.append(tmp)
num = num - 1
return players #根据step做了元素的移动
def play(players,step,alive):
"""
模拟约瑟夫问题... |
62bc3309b00d22adaaae76c3cd1cc333b96d5237 | jinshah-bs/Function_2 | /Test_19.1_Class_HW_Shapes_jb.py | 1,324 | 3.828125 | 4 | import math
class Shapes:
def __init__(self, name, a, b=1.0):
self.name = name
self.dim1 = a
self.dim2 = b
self.area = 0
self.perimeter = 0
self.calc_prop()
def calc_prop(self):
if self.name.casefold() == "circle":
self.area ... |
6475c1db8e5799bf132d30fd6b795d54809c373c | sam1208318697/Leetcode | /Leetcode_env/2019/8_24/Powerful_Integers.py | 2,253 | 3.734375 | 4 | # 970.强整数
# 给定两个正整数x和y,如果某一整数等于x ^ i + y ^ j,其中整数i >= 0且j >= 0,那么我们认为该整数是一个强整数。
# 返回值小于或等于bound的所有强整数组成的列表。
# 你可以按任何顺序返回答案。在你的回答中,每个值最多出现一次。
# 示例1:
# 输入:x = 2, y = 3, bound = 10
# 输出:[2, 3, 4, 5, 7, 9, 10]
# 解释:
# 2 = 2 ^ 0 + 3 ^ 0
# 3 = 2 ^ 1 + 3 ^ 0
# 4 = 2 ^ 0 + 3 ^ 1
# 5 = 2 ^ 1 + 3 ^ 1
# 7 = 2... |
05cb6a1952bb13b27e4989a9c452a69f809d2d45 | mba811/mkdocs | /mkdocs/toc.py | 2,536 | 3.609375 | 4 | # coding: utf-8
"""
Deals with generating the per-page table of contents.
For the sake of simplicity we use an existing markdown extension to generate
an HTML table of contents, and then parse that into the underlying data.
The steps we take to generate a table of contents are:
* Pre-process the markdown, injecting... |
6c69dd20c5cb0610d16a46d4ce0b7590530dbc49 | hidayatkhan013/Numpy-and-Pandas | /CS 160 Assignment/Question 1/part2.py | 248 | 3.921875 | 4 |
import numpy as np
ndarray = np.random.randint(1, 27, size=(3, 3, 3))
print(ndarray )
print("Sum of all elements : \n",np.sum(ndarray))
print("Sum of each column: \n",np.sum(ndarray, axis=1))
print("Sum of each row: \n",np.sum(ndarray, axis=2))
|
31ae39d2c2882972396a6a8baf33806bdfaab803 | shvechikov/algorithms_area | /solutions/leonid.py | 521 | 3.65625 | 4 | def solve(rectangles):
if not rectangles:
return 0
area = 0
x_points = set()
for start, end, height in rectangles:
x_points.add(start)
x_points.add(end)
x_points = sorted(x_points)
prev_x = x_points[0]
for x in x_points:
max_height = 0
for x1, x2, h... |
31fcde0cab1ad2ba5fdac68933edb79b02ffda3c | araujocristian/progrmas-python | /zumbiTWP272_2.py | 138 | 3.78125 | 4 | vetor = []
i = 1
while i<=10:
n = int(input("Numero: "))
vetor.append(n)
i+=1
print ("Vetor é:", vetor[::-1])
|
f0770a23527912903b74800b924bb9330a86d167 | elijahdaniel/Graphs | /projects/graph/util.py | 946 | 4.1875 | 4 |
# Note: This Queue class is sub-optimal. Why?
# for queue we're appending, so we're backing this with an array so we
# enqueue: append (goes to the back)
# comes in from the right to come out to the left
# so when we pop from the left in a queue (first),
# it's addressing right at that exact spot (chunk of cells in o... |
8f8b4a9df200987b6fa5ce755f5061c2ce349883 | jliberacki/Jason-Drawer | /main.py | 813 | 3.59375 | 4 | import sys
import argparse
from os import path
import json
from drawer import draw
def main():
if len(sys.argv) < 2: raise Exception("Please provide json file")
argparser = argparse.ArgumentParser(description='Parse and draw from json')
argparser.add_argument('input', help='path to json')
argparser.add... |
57e71ce11dda1ee129bf4f15e4e134020ec39f69 | hamologist/HackerRank | /algorithms/implementation/medium/count-triplets-1/main.py | 832 | 3.765625 | 4 | import fileinput
import os
from typing import Dict, Iterator, List
def count_triplets(nums: List[int], r: int) -> int:
triplets = 0
num_map: Dict[int, int] = {}
r_map: Dict[int, int] = {}
for num in reversed(nums):
jump = r * num
r_count = r_map.get(jump)
if r_count:
... |
6bddf86da70647116d1fa90ec52eb7b299b7800d | heschmidt04/working-examples | /scripts/python/suitcase.py | 599 | 4.03125 | 4 | suitcase = []
suitcase.append("sunglasses")
# Your code here!
suitcase.append("shampoo")
suitcase.append("undies")
suitcase.append("shirts")
list_length = len(suitcase)
# Set this to the length of suitcase
print "There are %d items in the suitcase." % (list_length)
print suitcase
# This is slicing the list
sui... |
66cbce13c0ef8a4d4d10dc36a2012d526d3a6b50 | G00398258/myWork | /Week07/messingWithFiles.py | 348 | 3.875 | 4 | # Week 07 lab - Write a function that reads in a number from a file that already exists(count.txt)
# test the program by calling the function and outputting the number
# Author: Gillian Kane-McLoughlin
fileName = "count.txt"
def readNumber():
with open(fileName, "rt") as f:
number = int(f.read())
... |
f8b34a02c37cfcfaf16dfacae6f63583bc4a4606 | ArielArT/Python-for-everyone | /PY4E_Exercise_11.py | 1,924 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 20:13:41 2019
@author: Zakochani
Write a simple program to simulate the operation of the grep command on Unix.
Ask the user to enter a regular expression and count the number of lines that
matched the regular expression:
$ python grep.py
"""
import re
# dane od uzy... |
e6d15d6c0361fdc4187de7e4beb08c5cf213e781 | temur-kh/simple-search-engine | /shared/soundex.py | 1,130 | 4.125 | 4 | def get_soundex_form(word: str) -> str:
if not word:
return word
elif len(word) == 1:
return word.upper()
upper = word.upper()
# step 1 according to lecture slides
raw_soundex = upper[0]
# step 2-3
for ch in upper[1:]:
if ch in ['A', 'E', 'I', 'O', 'U', 'H', 'W', 'Y']... |
5da23c6ef219416876386040f5b53dc7aec6f587 | bgoonz/UsefulResourceRepo2.0 | /MY_REPOS/INTERVIEW-PREP-COMPLETE/notes-n-resources/Data-Structures-N-Algo/_DS-n-Algos/__MY_OPRIGINAL_DS/_Extra-Practice/08_greedy_algorithms/python/01_set_covering.py | 771 | 3.921875 | 4 | # You pass an array in, and it gets converted to a set.
states_needed = set(["mt", "wa", "or", "id", "nv", "ut", "ca", "az"])
stations = {}
stations["kone"] = set(["id", "nv", "ut"])
stations["ktwo"] = set(["wa", "id", "mt"])
stations["kthree"] = set(["or", "nv", "ca"])
stations["kfour"] = set(["nv", "ut"])
stations["... |
7f1ca40649cc43e41083479c9681d38ca2a89972 | Tlepsh64/Lighbot-Kernel | /Lightbot.py | 3,218 | 3.625 | 4 | # level 1 terrain: write column by column, ex: [ [0,1,0], [2,1,0] ] is a 2x3 terrain
height = [ [0, 1, 1, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 1, 1, 0] ]
isBlue = [ [True,False,False,False], [False,False,False,False], [False,False,False,False], [False,False,False,False], [False,False,False,True] ]
isOn =... |
e006c5149709cd60bde03fae0830d20541f90c24 | C1ARKGABLE/adventOfCode19 | /day_3/main.py | 3,033 | 4 | 4 |
with open("wires.csv","r") as file:
wires = [line.rstrip().split(",") for line in file.readlines()]
def dist(p1, p2=(0, 0)):
"""Calculates the Manhattan distance between two points"""
return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])
def trace(step, pos):
"""Draws the line formed by applying a step (`s... |
7ff451ef2fbb1ddf6881979cc08ca318f7b071d4 | Cricsudheer/Flight-Management-System | /users.py | 5,350 | 3.5 | 4 |
# encapsulation
class users:
def __init__(self, flight_manager):
self.db = flight_manager
self.db_cursor = flight_manager.cursor()
def auth(self , username , password):
sql_form = "select * from user where username = '{}' and password ='{}'".format(username , password)
... |
fddcf9eddc71a2379e0dbc485e30ba4bab6f74f3 | pphan00/BIOL5153 | /dna_percentage.py | 641 | 3.8125 | 4 | #!/usr/env python3
input = "dna.txt"
inputfile = open(input, "r")
dna_sequence = inputfile.read().lower()
print(dna_sequence)
a_count = dna_sequence.count("a")
g_count = dna_sequence.count("g")
t_count = dna_sequence.count("t")
c_count = dna_sequence.count("c")
total_length = len(dna_sequence)
aper = round(a_count/tota... |
b6c46c2da2b1512724ff6e08e9f02ac53bb1eee1 | ndombrowski20/pdes_python | /NMP/SIM_2.py | 345 | 3.8125 | 4 | # Simple iterations method with a while loop same example as SIM_1.py
x = 10 # unlike last time this is the new arbitrary value because of how the abs is constructed
xnew = 0 # this is our "guess"
i = 0
while abs(xnew - x) >= .0000001:
i += 1
x = xnew
xnew = (2*x**2 + 3)/5
print('the root: %f' % xnew)
pr... |
e659f17ca3e2a6038ed3690a799b53b8c55ef9ba | JasonWuGenius/Nowcoder | /BigComp_2018_Python/continousNumCompare.py | 1,146 | 3.59375 | 4 |
'''
题目描述
对于任意两个正整数x和k,我们定义repeat(x, k)为将x重复写k次形成的数,例如repeat(1234, 3) = 123412341234,repeat(20,2) = 2020.
牛牛现在给出4个整数x1, k1, x2, k2, 其中v1 = (x1, k1), v2 = (x2, k2),请你来比较v1和v2的大小。
输入描述:
输入包括一行,一行中有4个正整数x1, k1, x2, k2(1 ≤ x1,x2 ≤ 10^9, 1 ≤ k1,k2 ≤ 50),以空格分割
输出描述:
如果v1小于v2输出"Less",v1等于v2输出"Equal",v1大于v2输出"Greater".
... |
539dff8ed8076da54f84516ce32b410bb51028f1 | ahmedhamza47/Advanced_Topics | /18)shallow vs deep copy.py | 404 | 3.984375 | 4 | import copy
# shallow copying is only one level deep
original = [1,2,3,4,5]
cpy = original.copy()
cpy[0] = 10
print(original)
print(cpy)
org2 = [[1,2,3,4,5],[6,7,8,9,19]]
cpy1 = org2.copy()
cpy1[0][1] = 20
print(org2)
print(cpy1) # both org2 and cpy1 has same value cuz shallow copy is one level deep
# so to make a d... |
38a8956b3368088efbfe75504b832f32ac71455c | BJV-git/leetcode | /math/perfect_no.py | 404 | 3.703125 | 4 | # logic: can use the shortcut methods mentioned and then we go for normal stuff
# i.e. we see if every things is fact or not and then add them up
# in normal process lets keep track of left where we can stop early
def perf_no(n):
i = 2
t = 0
while t < n:
t = (2**(i-1)) * ((2**i)-1)
if t ... |
f27b849a716f5578c32a48678078eb1b6b2a7395 | prompt-toolkit/python-prompt-toolkit | /examples/telnet/toolbar.py | 1,117 | 3.5 | 4 | #!/usr/bin/env python
"""
Example of a telnet application that displays a bottom toolbar and completions
in the prompt.
"""
import logging
from asyncio import Future, run
from prompt_toolkit.completion import WordCompleter
from prompt_toolkit.contrib.telnet.server import TelnetServer
from prompt_toolkit.shortcuts impo... |
678cdd5f4ed1ce1d85b600a07fac62d6d251df67 | catboost/catboost | /contrib/tools/python/src/Lib/string.py | 21,548 | 3.90625 | 4 | """A collection of string operations (most are no longer used).
Warning: most of the code you see here isn't normally used nowadays.
Beginning with Python 1.6, many of these functions are implemented as
methods on the standard string object. They used to be implemented by
a built-in module called strop, but strop is n... |
d8e41d1e8238eb8a604778395ffbe3658b2f532c | brachbach/project-euler | /prob12.py | 1,142 | 3.875 | 4 | import math
def nth_triangular_number(n, prev_triangular = 1, prev_int = 1):
if n == prev_int:
return prev_triangular
new_int = prev_int + 1
return nth_triangular_number(n, prev_triangular + new_int, new_int)
assert nth_triangular_number(1) == 1
assert nth_triangular_number(2) == 3
assert nth_tria... |
0a07aa8a9c6846cd44c1107718c76bc41d91b68e | ucsd-cse-spis-2018/spis18-lab03-Dario-Manuel | /drawLetter_Dario.py | 221 | 3.828125 | 4 | #Turtle will draw the letter D
import turtle
def drawD(theTurtle):
theTurtle.left(90)
theTurtle.forward(100)
theTurtle.right(90)
theTurtle.circle(-50,180)
myTurtle = turtle.Turtle()
drawD(myTurtle)
|
b1499329a7356f63565db28faa41c0c5ae8e376f | melinazik/crypto | /src/ex12.py | 2,535 | 3.71875 | 4 | '''
Textbook RSA
Exercise 12
Melina Zikou (2021)
'''
import math
import base64
# Converts a rational x/y fraction into
# a list of partial quotients [a0, ..., an]
def rationalToContFrac(x,y):
a = x // y
q = []
q.append(a)
while a * y != x:
x, y = y, x - a * y
a = x /... |
00f774425fef375c49488ab6a600fd7a6446eaa9 | AdyGCode/Python-Basics-2021S1 | /Week-14-1/gui-3-guessing-game.py | 5,734 | 3.921875 | 4 | # --------------------------------------------------------------
# File: Week-13-2/gui-3-guessing-game.py
# Project: Python-Class-Demos
# Author: Adrian Gould <Adrian.Gould@nmtafe.wa.edu.au>
# Created: 13/05/2021
# Purpose: GUI Guessing Game version 3
#
# Duplicate the second version of the guessing game.
#
# ... |
678a62748a48000a387e3362c1d6362ffc2efe36 | yanshengjia/algorithm | /leetcode/Tree & Recursion/117. Populating Next Right Pointers in Each Node II.py | 4,362 | 3.6875 | 4 | """
Given a binary tree
struct Node {
int val;
Node *left;
Node *right;
Node *next;
}
Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL.
Initially, all next pointers are set to NULL.
Example:
Input: {"$id":"1","left":{"$id":"... |
7fccdb9b0145514e945891bfb736eae8c2ae45a3 | Sbarcenas/exercims_python | /pangram/pangram.py | 178 | 3.8125 | 4 | import re
from string import ascii_lowercase
def is_pangram(sentence):
pangram = re.sub('[^a-z]','',sentence.lower())
return set(pangram) == set(ascii_lowercase) |
5c89e76d0ebd23a53463a270ba739e41d7a07d15 | IbrahimDaurenov/Incoop-cohort-1 | /Week 2/Day 4 (July 20)/mylists.py | 452 | 4.0625 | 4 | names = ['Ibrahim', 'Nabi', 'Alikhan', 'Yaroslav', 'Daulet', 'Bekzat']
print(names)
names.append('Daniyar')
print(names)
print(names[0]) # 'Ibrahim'
print(names [-1] ) # 'Daniyar'
names[0] = 'Ibra'
print(names)
names.remove('Daniyar')
print(names)
names.pop(0)
print(names)
new_names = names.copy()
names.cl... |
6ef145d4ab1cd77f84fce30da07e8048745a1ae1 | quangbk2010/Courses-MITx-6.00.1x | /Midterm/Problem9/Is_list_permutation.py | 3,159 | 3.828125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jul 6 17:32:11 2017
@author: quang
"""
def compare_2_dict (d1, d2):
'''
d1, d2: Assumes 2 non-empty dictionaries contain interger -> interger
Returns True if d1==d2, else False
'''
for key in d1.keys():
val2 = d2.get (key, None)
if val2 =... |
6ccd69104c393b404949de13b495a6c7e049e311 | herolibra/PyCodeComplete | /Others/Classes/super/super_init2.py | 358 | 3.578125 | 4 | # coding=utf-8
# 子类(派生类)并不会自动调用父类(基类)的init方法
# 需要子类主动调用父类的init
# 方法2
class Foo(object):
def __init__(self):
self.val = 1
class Foo2(Foo):
def __init__(self):
super(Foo2, self).__init__()
print self.val
if __name__ == '__main__':
foo2 = Foo2() |
a3c1e3b823842536dc3fbee1200d17feb49fd934 | mamanipatricia/pythonFundamentals | /03.loops.py | 659 | 4.21875 | 4 | my_variable = "hello"
# print(my_variable[0])
# print(my_variable[1])
# print(my_variable[2])
# print(my_variable[3])
# print(my_variable[4])
# iterating "for" loop
# iterables are strings, lists, sets, tuples, and more
for character in my_variable:
print(character)
# its a very common mistake call variables th... |
ace237444464e69a55fe7a8611973df1182d011c | luisC62/Master_Python | /21_tkinter/10_ejercicio_plus.py | 2,868 | 3.765625 | 4 | '''
CALCULADORA:
Refactorización del código del ejercicio anerior
Se crea la clase Calculadora
'''
from tkinter import *
from tkinter import messagebox as MessageBox
#Definición de la clase Calculadora
class Calculadora:
def __init__(self, alertas):
#Variables
self.numero1 = StringVar()
... |
d3eb8ad0b4661215f10fd6e9ee3fa4713c93e405 | koukan3/basicPython | /basics/09继承.py | 711 | 3.671875 | 4 | #coding:utf-8
class Animal(object):
name="动物"
def say(self):
print("父类的函数")
class Parent(object):
def __init__(self):
self.age=20
def work(self):
print("父类Parent的函数")
def say(self):
print("父类Parent的函数")
class Dog(Parent,Animal):
__instance=None
def __i... |
c8e0d2949abd724f74d428ffc4b0aedaa668f791 | iavorskiy/count_holes | /count_holes.py | 437 | 3.59375 | 4 |
b = input("Enter the number to count the holes: \n")
def count_holes(b):
if type(b) != int and type(b) != str:
return("ERROR")
try:
int(b)
except ValueError:
return "ERROR"
c = str(b)
counter = 0
for x in c:
if x in "0469":
... |
6270d438ab41abc580603f0747d6c1d551cf5930 | anguswilliams91/stan_predict | /stan_predict.py | 4,103 | 3.796875 | 4 | """A simple example of how one might use samples from Stan for prediction.
This example uses a simple model
y ~ N(theta_0 + theta_1 * X, 1).
A stan model is fitted, and the resulting posterior samples are cached.
Then, when predictions are required, a separate piece of stan code with only a
generated quantities bloc... |
945403b02d8065e060468e5d7e03cc08d912d746 | Taysem/Mypython_study | /笔试题目/找重.py | 692 | 3.578125 | 4 | #如何在排序数组中
# ,找出给定数字出现次数? 比如:{0,1,2,3,3,3,3,3,3,3,3,4,5,6,7,13,19}
k = {0,1,2,3,3,3,3,3,3,3,3,4,5,6,7,13,19}
def binFindUp(arr, key):
low = 0
high = len(arr) -1
while(low < high):
print("%d,%d" % (low, high))
mid = (low + high) / 2
if (arr[mid] <= key):
low = mid
e... |
6bb04b5439007939731c87b21ad6f8bb9caf3343 | 1325052669/leetcode | /src/DP/easy/303_Range_Sum_Query_Immutable.py | 533 | 3.546875 | 4 |
from typing import List
class NumArray:
def __init__(self, nums: List[int]):
self.cul_sum = [sum(nums[:i + 1]) for i in range(len(nums))]
def sumRange(self, i: int, j: int) -> int:
if i == 0:
return self.cul_sum[j]
return self.cul_sum[j] - self.cul_sum[i - 1]
# Your NumA... |
c14a4e2d112f04020cadcbae628c636bb0792e85 | dilshod-Cisco/PythonBasics | /dictionaries.py | 1,264 | 4.09375 | 4 | # Dictionaries - data structure, mutable, {key1: value1, key2: value2}
# in Java > Hashmap, Hashtable, Hashset >> hashing algoritm to store the key-value pairs
# recap: list - data structure, mutable, [a,b]
cars = ['lexus', 'bugatti', 'bmw', 'ferrari']
# recap: Tuple - data structure, immutable, (a,b)
cars = ('le... |
478156b8bab8b770b932bb2690a2c178c2d4ca0d | gv1410/it-academy_homework-4_ifelse_and_BMI_calc_v.20 | /homework_ifelse_ХолдеевАлексей.py | 2,124 | 3.984375 | 4 | cycle = True
while cycle:
a_value = int(input('Введите первое значение (Значение А): '))
b_value = int(input('Введите второе значение (Значение Б): '))
c_value = int(input('Введите третье значение (Значение С): '))
# Если нет ни ондого нуля - вывести: "Нет нулевых значений!!! :
a_value > 0 and... |
a0c4e2a0847b0a97ad751c8fc1cf58f77015ce43 | liuliqiu/study | /competition/euler/source/p048.py | 413 | 3.734375 | 4 | ##The series, 1^1 + 2^2 + 3^3 + ... + 10^10 = 10405071317.
##
##Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000.
def f(n):
result = 1
for i in range(1, n + 1):
result = (result * n) % (10 ** 10)
if result == 0:
return 0
return result
de... |
25c9fb84ff75f764049e7273410bdb6a67a71bea | mitra97/Calculator | /Calculator.py | 5,528 | 3.5625 | 4 | import math
from tkinter import *
#save numbers to a string, then just convert it to an int.
class Calculator:
def __init__(self):
self.opcode = ""
self.firstIn = ""
self.secondIn = ""
self.total = 0.0
self.window = Tk()
self.entry = Entry(self.window, width... |
725e7b28cbec85d659d2bde65624f4ada215ecfe | Jimmykusters/DroneCamBase | /Cam_View.py | 494 | 3.578125 | 4 | import math
def f(h, alpha, beta, input_is_degree=False):
if input_is_degree:
alpha = math.radians(alpha)
beta = math.radians(beta)
c = h/math.cos(alpha/2)
l1 = 2*(math.sqrt(math.pow(c, 2) - math.pow(h, 2)))
# l1 = (c*2 - h)*0.5 * 2
print("l1 = " + str(l1))
c2 = h/math.cos(bet... |
908ee1b01377141b0f58317fb7035c935cc313cc | zhangfuli/leetcode | /手把手刷动态规划/贪心类型问题/55. 跳跃游戏.py | 1,043 | 3.53125 | 4 | # 给定一个非负整数数组nums ,你最初位于数组的 第一个下标 。
# 数组中的每个元素代表你在该位置可以跳跃的最大长度。
# 判断你是否能够到达最后一个下标。
#
# 示例1:
#
# 输入:nums = [2,3,1,1,4]
# 输出:true
# 解释:可以先跳 1 步,从下标 0 到达下标 1, 然后再从下标 1 跳 3 步到达最后一个下标。
# 每一步都计算一下从当前位置最远能够跳到哪里,
# 然后和一个全局最优的最远位置 farthest 做对比,通过每一步的最优解,更新全局最优解,这就是贪心。
class Solution:
def canJump(self, nums):
far = ... |
d825cb3caaef587e172c6c7351613f1d2e987fa7 | akshays0911/CodeCamp | /MIscellaneous/Google/Google_interview_question2.py | 1,192 | 3.921875 | 4 | """
Consider an undirected tree with N nodes, numbered from 1 to N.
Each node has a label associated with it, which is an integer
value. Different nodes can have the same label.
Write a function that, given a zero indexed array A of length N,
where A[j] is the label value of the (j + 1)-th node in the tree
a... |
38b28278f5c8028066ee6a1b45a1185c3355e3cd | Dioni1195/holbertonschool-higher_level_programming | /0x0C-python-almost_a_circle/models/rectangle.py | 4,171 | 3.765625 | 4 | #!/usr/bin/python3
""" This module contains the class Rectangle """
from models.base import Base
class Rectangle(Base):
""" This class is to build a rectangle with different
parameters
args:
__width(int): The width of the rectangle
__height(int): The height of the rectangle
... |
7e97e2291242bda807b55d994b2cdc091e2a7259 | tor1414/python_programs | /131_h2_comparing_circles.py | 6,855 | 4.21875 | 4 | """
Victoria Lynn Hagan
Victoria014
2/10/2014
Homework 2 - CSC 131
"""
import math
class Circle2D(object):
"""A circle is represented by the value of it's radius and the corrdinates of it's center"""
def __init__(self, x = 0, y = 0, radius = 0):
"""Intializes the X-corrdinate of the center""... |
350594cc5401599935cb05d485e7ad7b2878b00f | Xanonymous-GitHub/main | /python/3n+1 uva.py | 1,493 | 3.609375 | 4 | import sys
sys.setrecursionlimit(10000000)
# > The recursive range of the title requirement may exceed the limit.
while True:
# > The problem requires multiple test materials.
try:
i, j = map(int, input().split())
# > i,j is the range of data entered by user.
except:
bre... |
a57c7ded65cacaff1d33a7a039dceed0803ea656 | adonaifariasdev/CursoemVideo | /jokenpo.py | 2,968 | 3.578125 | 4 | from random import randint
from time import sleep
from os import system
opcao = 's'
contPC = 0
contUS = 0
while opcao != 'N':
print('='*40)
print('{:=^40}'.format(' JO KEN PO 2.0 '))
print('{:=^40}'.format(' Ceated By: Ten Adonai '))
print(' JOGADOR {} x {} COMPUTADOR'.format(contUS, contPC))
... |
b97f777dbf1bb766fb80a08dc358fc25ad8123b8 | jedzej/tietopythontraining-basic | /students/ryba_paula/lesson_11_argparse_and_math/regex_search_arg.py | 695 | 3.53125 | 4 | import re
import os
import argparse
import sys
def arg_input(args):
parser = argparse.ArgumentParser(description="Regex search")
parser.add_argument('-r', '--regex', help="Regex to be checked",
required=True)
results = parser.parse_args(args)
return results.regex
def regex_se... |
401739de61eaa79b8533f46a6587b0180c834dcc | biztudio/JustPython | /syntaxlab/src/play_collection.py | 1,179 | 3.890625 | 4 | names_list1 = ['sTevEn lOBs',
'coCo lee',
'JAck zhaNG',
'LiSa ChEn',
'elSA Y Shen',
'georgE w bUsH',
'PETER cHeN',
'brUce Ho',
'biLL W clinTON',
'ciRAlI Clinton',
'Yang S... |
b719f01edcd0e7424c5d1b459a1e67e93630067c | Seongju-Lee/code-analysis | /pedal/tifa/literal_definitions.py | 1,224 | 3.828125 | 4 |
def are_literals_equal(first, second):
if first is None or second is None:
return False
elif type(first) != type(second):
return False
else:
if isinstance(first, LiteralTuple):
if len(first.value) != len(second.value):
return False
for l, s i... |
5443557bf0ed37926c5e063c92fab3dda1b91207 | jonasc/constant-workspace-algos | /geometry/ray.py | 3,740 | 4.03125 | 4 | """Defines a ray class with various helper methods."""
from typing import Optional, Union
from .line import Line
from .line_segment import LineSegment
from .point import Point
class Ray(object):
"""Defines a ray in R^2."""
def __init__(self, a: Point, b: Point):
"""Initialize a new ray starting at a... |
5e318e667844aa8a12294b7ea8d0390d3ec9c8b1 | adamzoltan/OOP | /Python/Garden/garden.py | 717 | 3.8125 | 4 | from plants import Plant
class Garden():
def __init__(self):
self.plants = []
def add(self, plant):
self.plants.append(plant)
def garden_status(self):
for plant in self.plants:
plant.status()
def count_dry_plants(plants):
counter = 0
for plant in p... |
b52636fb61cac3ee23fb2325f9944bc3922c6488 | Aaron1515/Richmond_High | /Excercise/ex4_3.py | 756 | 3.953125 | 4 | import RPi.GPIO as gpio
import time
gpio.setmode(gpio.BOARD)
gpio.setwarnings(False)
gpio.setup(11, gpio.IN, gpio.PUD_UP)
gpio.setup(13, gpio.OUT)
while True:
button_state = (gpio.input(11)==0)
# Directions: Fill in the conditions for the "if" and "then" statements below
# and the code such that when the button is ... |
c9756c5f2a8a4a73e31b1536e4cbe3f67d2da084 | DanielMGuedes/Exercicios_Python_Prof_Guanabara | /Aulas_Python/Python/Exercícios/Exe072 - contagem por extenso.py | 424 | 3.953125 | 4 | cont = 'zero', 'um', 'dois','três', 'quatro', 'cinco', 'seis', 'sete', '...'
while True:
núm = int(input('Digite um número entre 0 e 20: '))
if 0<= núm <= 20:
break
print('tente novamente. ', end='')
print(f'Você digitou {cont[núm]}')
'''Explicação:
o cont está recebendo o valor que escrevemos por
... |
15a1fc37a817d7024820100d8c1513e922db69cc | charliedmiller/coding_challenges | /flipping_an_image.py | 371 | 3.796875 | 4 | # Charlie Miller
# Leetcode - 832. Flipping an Image
# https://leetcode.com/problems/flipping-an-image/
# Written 2020-11-10
"""
Flip the row, then invert the value in a list comp
"""
class Solution:
def flipAndInvertImage(self, A: List[List[int]]) -> List[List[int]]:
result = [[px^1... |
c4398765581c1260b4d074f49fcb4ee68784eed2 | siddalls3135/cti110 | /P4LAB_Siddall.py | 298 | 3.71875 | 4 | import turtle
t = turtle
t.shape()
t.speed(10)
t.width(3)
t.bgcolor('black')
t.begin_fill()
t.pencolor('silver')
t.fillcolor('teal')
for a in range(8):
for b in range(8):
t.forward(125)
t.left(45)
t.left(45)
t.end_fill()
t.hideturtle()
|
23ebf0e93553d51bf5b5a88489108038642aaaef | devscheffer/desafio-2-2020 | /Assets/Notebooks/personal_function/Model_Missing_Value_Imputer.py | 960 | 3.5625 | 4 | # Criação de um objeto SimpleImputer
from sklearn.impute import SimpleImputer
from sklearn.impute import KNNImputer
import numpy as np
def Missing_Value_imputer():
imputer = KNNImputer(
n_neighbors=5
,missing_values=np.nan # os valores faltantes são do tipo ``np.nan`` (padrão Pandas)
,cop... |
0e52d3c0e24e81e0afb04cf29e6b840d59caf808 | wenquanlu/DP-Operations-Research-App | /app.py | 1,886 | 3.96875 | 4 | from resource import resource_allocation
from knapsack import knapsack_problem
print("#######\n" +
"# # ##### ###### ##### ## ##### # #### # # ####\n"+
"# # # # # # # # # # # # # ## # #\n"+
"# # # # ##### ... |
0e973a414cc363441a9ac2c0bbf932a4a060f8cb | heyyou3/atcoder | /abc179/c/main.py | 192 | 3.515625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
def resolve():
n = int(input())
ans = 0
for a in range(1, n):
ans += (n - 1) // a
return ans
def main():
print(resolve())
main()
|
79499040a0c83f119807e2b45e32a9ba4f262969 | wwscthjm/python_work | /Chapter4_Deal _with_Lists/dimensions.py | 327 | 3.84375 | 4 | """Tuple-元组"""
dimensions = (200, 50) #object in a tuple is immutable
print('Original dimensions:')
for dimension in dimensions:
print(dimension)
dimensions = (400, 100) #but a tuple is variable
print('\nModified dimension:')
for dimension in dimensions:
print(dimensio... |
7544eec4c12c40ff8d49c49fbdee6ed6b15d8e46 | flerdacodeu/CodeU-2018-Group8 | /ibalazevic/assignment2/q2.py | 4,670 | 4.53125 | 5 | import unittest
class Node:
"""
A class for a node of a binary tree.
- data - int, the content of a node.
- left_child - Node, pointer to the left child
of a current node.
- right_child - Node, pointer to the right child
of a current node... |
3442a672ff0d964c16986cdaeb46fae885681228 | Little-Captain/py | /Lean Python/calc.py | 390 | 3.859375 | 4 | def calc(a, op, b):
if op not in '+-/*':
return None, 'Operator must be +-/*'
try:
if op == '+':
result = a + b
elif op == '-':
result = a - b
elif op == '/':
result = a / b
else:
result = a * b
except Exception as e:
... |
d6193c977ac0aece825498859e3e01bc6e3e2e7e | mizhi/project-euler | /python/problem-52.py | 770 | 3.875 | 4 | #!/usr/bin/env python
# It can be seen that the number, 125874, and its double, 251748,
# contain exactly the same digits, but in a different order.
#
# Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and
# 6x, contain the same digits.
def samedigits(x,y):
xs = list(str(x))
ys = list(str(y))
... |
58d8e4a3a9bf95d34687b65605282aea6418bd7f | lucasmfredmark/PyShips | /classes/BattleshipsGame.py | 4,683 | 3.703125 | 4 | from . import BattleshipsGameSettings
import copy
import random
class BattleshipsGame:
def __init__(self, player):
self.BOARD_SIZE = copy.deepcopy(BattleshipsGameSettings.BOARD_SIZE)
self.ships = copy.deepcopy(BattleshipsGameSettings.SHIPS)
self.board = [['#' for y in range(self.BOARD_SIZE)... |
a99cf6fe24e5bab66224b668c6862c99a86d7b25 | Comyn-Echo/leeCode | /字符串/KMP/1367. 二叉树中的列表.py | 3,374 | 3.765625 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.le... |
35426f58a4dc79302363808940858100f682e3ee | katrin87/assignments-kate_iv | /assignments_4task3.py | 1,635 | 3.96875 | 4 | #! /usr/bin/env python
from __future__ import division, print_function
def matrix_mul(matr1, matr2):
''' Calculates the result of multiplication of two matrices
:type matr1: list
:param matr1: list of lists integer or float numbers
:type matr2: list
:param matr2: list of lists integer or float n... |
5f70cd0c30171bbb7d63ea450438ead88b6b32f3 | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/word-count/021a1dbfab3c43a68e1d302e915031d8.py | 486 | 3.65625 | 4 | def get_next_word(text, pos):
while( text[pos] == ' ' or text[pos] == '\t' or text[pos] == '\r' or text[pos] == '\n' ):
pos = pos + 1
ref = pos
word = ''
while( text[pos] != '' or text[pos] != '\t' or text[pos] != '\r' or text[pos] != '\n' ):
word[pos-ref] = text[pos]
return word
def word_count(text):
wordA... |
2e8e243cd4555828ae12e133f5b536c5a2026e37 | Shavezz/Python-Tech-Degree-Project3-Phrase-Hunters | /phrasehunter/character.py | 435 | 3.625 | 4 | class Character:
def __init__(self, char1):
self.original_char = char1
was_guessed_character = False
def update(self, guess):
if guess == original_char:
was_guessed_character == True
def show_character():
if was_guessed_character == True and len(origin... |
4b86797859715751a034c58d209e8ea7fb110646 | LHTECH-COM/preview_project | /preview_project3/account.py | 4,497 | 3.671875 | 4 | import csv
import json
import datetime
CSV_FILE = "account_03.csv"
NEW_CSV_FILE = "account_03_new.csv"
ID_INDEX = 0
FIRST_NAME_INDEX = 1
LAST_NAME_INDEX = 2
DOB_INDEX = 3
class Account():
"""
A class to represent a user.
Attributes
----------
id: str
id of the person
first_name : str... |
4b21dea5cf4ef6416592ae126d8e2b3c6d8885f7 | mderamus19/dictionary-of-words | /dictionaryOfWords.py | 981 | 4.71875 | 5 |
# Create a dictionary with key value pairs to
# represent words (key) and its definition (value)
word_definitions = dict()
# Add several more words and their definitions
# Example: word_definitions["Awesome"] = "The feeling of students when they are learning Python"
word_definitions = {
"assiduous" : "metic... |
588f15cf0c3858a6cfa764eda6c5f8eab243d329 | ShirleyMwombe/Training2 | /open a file.py | 539 | 3.671875 | 4 | from tkinter import *
from tkinter import filedialog
def openfile():
filepath = filedialog.askopenfilename(initialdir="C:\\Users\\hp\\PycharmProjects\\Training2",
title='open file?',
filetypes=(('text files', "*.txt"), ('al... |
10e279dece483a5450275a773103badf0a327549 | Ashasrinivas/100programs | /ex_74.py | 222 | 3.921875 | 4 | # random.choice is used to pick a randomm elemnt in a list
import random
print(random.choice([x for x in range(11) if x %2 == 0]))
import random
print(random.choice([x for x in range(201) if x % 7 == 0 and x % 5 == 0 ])) |
beb026e2e8c689590529e5c3ac8162261ec1494c | virginiah894/python_codewars | /5KYU/perimeter.py | 313 | 3.515625 | 4 | def perimeter(n: int) -> int:
if n <= 0:
return []
elif n == 1:
return [0]
elif n == 2:
return [0, 1]
D = {0: 0}
result = [0, 1]
for i in range(1, n + 2):
result.append(result[-1] + result[-2])
D[i] = result[i]
return sum(list(D.values())) * 4
|
04f5e7e10239b995d231cbafdddbf6e2c81551b3 | Chamillion1/Girls-Who-Code-Projects- | /Atom/Dictionary.py | 192 | 3.890625 | 4 | names_ages = {
"Kamila": 16,
"Isabella": 12,
"Anabel": 48,
"Omar": 49,}
total=0
#print(names_ages)
for keys,values in names_ages.items():
total= values+total
print(total/len(names_ages))
|
3f6f9db6be0d6e8aa941f0625197ab1974611bf8 | sdzr/python_for_study | /chapter07/practice7_7.py | 244 | 3.65625 | 4 | def dict_change(in_dic):
out_dic={}
for key,val in in_dic.items():
out_dic[val]=key
return out_dic
if __name__=='__main__':
in_dic={'a':1,'b':2,'c':3}
out=dict_change(in_dic)
for i in out:
print(out[i])
|
1161c398adeaaa5dc7c978dabf0fdd3545b158a6 | MurilloFagundesAS/Exercicios-Resolvidos-Curso-em-Video | /Ex010-ConversaoMoeda.py | 124 | 3.640625 | 4 | x = float(input("Quanto Você Tem? "))
conv = x//3.27
print('Você tem R${:.2f} e pode comprar US${:.2f}'.format(x, conv)) |
15d68f8d5ba2aaa9242113f810f2f975856bf01f | kjowong/holbertonschool-higher_level_programming | /0x11-python-network_1/1-hbtn_header.py | 370 | 3.671875 | 4 | #!/usr/bin/python3
"""
Python script that takes in a URL, sends request and displays value
of X-Request-Id in header of the response
"""
import sys
import urllib.request
if __name__ == "__main__":
req = urllib.request.Request(sys.argv[1])
with urllib.request.urlopen(req) as response:
html = r... |
9cc0a19bb24b050acbb1ec24fb8b3e0c9101f9ad | aumaro-nyc/leetcode | /trees/1261.py | 802 | 3.859375 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class FindElements:
def __init__(self, root: TreeNode):
self.val_set = set()
self.root = self.create_tree(root,0)
def find(self, ta... |
ed879bf348f7ebae3b96ef8515347fe6ade84d87 | jmuguerza/adventofcode | /2017/day3.py | 6,196 | 3.984375 | 4 | #/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
PART 1
A new kind of memory is used to store info in an infinite
two dimentional grid. Each square of the grid is allocated
in an spiral pattern starting at a location marked 1, and
then counting up while spiraling outward. Data is carried
always from the square ... |
082cdb2a95cf5414f17423641b110d179a232cc2 | Anjalipatil18/Hackerrank-And-Codesignle-Questions | /paramid_pattern.py | 584 | 3.890625 | 4 | size = 7
m = (2 * size) - 2
for i in range(0, size):
for j in range(0, m):
print(end=" ")
m = m - 1 # decrementing m after each loop
for j in range(0, i + 1):
# printing full Triangle pyramid using stars
print("* ", end=' ')
print(" ")
for i in range (0, rows):
for j in rang... |
e0af6efc91fc7aebe77266300339867ed55536f9 | luokeke/selenium_python | /python_doc/Python基础语法/0.mooc课堂实例/6.2文本词频统计.py | 1,117 | 3.734375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/12/12 14:02
# @Author : liuhuiling
'''
文本词频统计
- 英文文本:Hamet 分析词频
https://python123.io/resources/pye/hamlet.txt
- 中文文本:《三国演义》 分析人物
https://python123.io/resources/pye/threekingdoms.txt
'''
from os.path import abspath,dirname
project_path = dirname(dirname(abspa... |
d6349571afe00c36cce2137fe4936a66a4aa4ef9 | flysaint/RookiePython | /Term01/2019Day07_Term01.py | 3,523 | 3.6875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Mar 9 23:47:43 2019
@author: fly_s
Day07
1. 来排个序
对给定字符串排序。字符串中每个单词都包含一个数字。此数字是单词在在结果中应该具有位置。
注意:数字可以是1到9,因此1将是第一个单词(不是0).
example:
"is2 Thi1s T4est 3a" --> "Thi1s is2 3a T4est"
"4of Fo1r pe6ople g3ood th5e the2" --> "Fo1r the2 g3ood 4of th5e pe6ople"
testcase:
assert order("i... |
a19ff31ed5ebf3d304e3813fff755128dd0b386d | longluo/Python | /functional/filter.py | 446 | 3.65625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Filter
# 2015-07-22 03:12:38
def is_odd(n):
return n % 2 == 1
print filter(is_odd, [1, 2, 4, 5, 6, 9, 10, 15])
def not_empty(s):
return s and s.strip()
print filter(not_empty, ['A', '', 'B', None, 'C', ' '])
# Exercise
# Prime Number
def is_prime(n):
if n == 1:... |
fa7961c360263d53f1e84c3bbfa6a32543a8c484 | ericthansen/fluffy-waddle | /fibo.py | 2,138 | 4.0625 | 4 | def factorial(n):
#print("factorial has been called with n = " + str(n))
if n == 1:
return 1
else:
res = n * factorial(n-1)
#print("intermediate result for ", n, " * factorial(" ,n-1, "): ",res)
return res
print(factorial(5))
def iterative_factorial(n):
result = 1
... |
4a61809e7e5ed2a45d63c36a0a1463d1f7724087 | caowei3002008/python_week4 | /car.py | 909 | 3.84375 | 4 | class car(object):
def __init__(self,price,speed,fuel,mileage):
self.price = price
self.speed = speed
self.fuel = fuel
self.mileage = mileage
self.display_all()
def display_all(self):
print 'Price:',self.price
print 'Speed:',self.speed
print 'Fuel... |
c05daefa993afd70aefb3f14eec3e72d0241297b | andrebor/My-Personal-Projects | /Code Prompts/Pig Latin.py | 555 | 3.796875 | 4 | # Pig Latin is a game of alterations played on the English language game. To create the Pig Latin form of
# an English word the initial consonant sound is transposed to the end of the word and an ay is affixed
# (Ex.: "banana" would yield anana-bay). Read Wikipedia for more information on rules.
consonants = set("bcdf... |
45aef0af80803a9b62be00380418075759f2e202 | Pshypher/tpocup | /ch07/labs/lab06.py | 2,294 | 3.90625 | 4 | # lab06.py
# Unless stated otherwise, each variable is assumed to be a list data type.
import string
def find_mean_score(student_scores):
"""Finds the mean score of the score from four exams. Returns
the mean scores of the student, a float data type."""
total_int = sum(student_scores[1:])
average... |
34c1ec3a9091a586ca5af82bedbc1677d2483fab | mdoprog/Warehouse | /Python/conditionals/positive-or-negative.py | 219 | 3.90625 | 4 | # coding=utf8
# Entrada
num = int (input("Informe um número inteiro: "))
# Processamento
if num >= 0:
a = num
print("Valor positivo: {0}".format(a))
else:
b = num
print("Valor negativo: {0}".format(b)) |
9c0d11ab3d921d3e591d02a79fc92d2e29bdc06b | Raja-mishra1/snake_ladder | /snake_ladder/game.py | 4,552 | 3.859375 | 4 | import time
import random
import sys
from conf.config import SLEEP_BETWEEN_ACTIONS,DICE_FACE,MAX_VAL,player_turn_text,snake_bite,ladder_jump,ladders
class Snake:
def add_snake(self,start,dest):
"""[Add snake to game]
Args:
start ([str]): [starting point of snake]
dest ([str... |
9e2eb0daa07f4d1839946feefc0f2ed6d7f8446a | ICCV/coding | /dfs/q1227.py | 1,800 | 3.5 | 4 | """
当 n>2n>2 时,如何计算 f(n)f(n) 的值?考虑第 11 位乘客选择的座位,有以下三种情况。
第 11 位乘客有 \frac{1}{n}
n
1
的概率选择第 11 个座位,则所有乘客都可以坐在自己的座位上,此时第 nn 位乘客坐在自己的座位上的概率是 1.01.0。
第 11 位乘客有 \frac{1}{n}
n
1
的概率选择第 nn 个座位,则第 22 位乘客到第 n-1n−1 位乘客都可以坐在自己的座位上,第 nn 位乘客只能坐在第 11 个座位上,此时第 nn 位乘客坐在自己的座位上的概率是 0.00.0。
第 11 位乘客有 \frac{n-2}{n}
n
n−2
的概率... |
ce0a5e261bc2711bd6745d47c494cd2585f6be47 | SergicHill/Big_Data_Analytics | /Kafka/hw8p2_prod.py | 1,180 | 3.859375 | 4 | # Illustrates the work of kafka's producer and consumer
# @author Serguey Khovansky
# @version: March 2016
# The problem:
# Construct a producer and a consumer object. Let producer generate one random number
# between 0 and 10 every second.Let both producer and consumer run until you kill
# them. D... |
b650b156bdb6bea383dbaee28cb3d7e2359ac7b0 | lucasljoliveira/OlistCurso | /18.12.2020/CRUD_Console.py | 14,094 | 3.609375 | 4 | class Category:
__id : int
__name : str
def __init__(self, id: int, name: str):
self.__id = id
self.__name = name
def set_id(self, id : int) -> None:
self.__id = int(id)
def set_nome(self, nome : str) -> None:
try:
if nome != '':
self.__n... |
67bcd67d943a6d5a181e1951b51e22265588bf39 | UnstoppableGuy/MNA-4-SEM | /lab2/main1.py | 2,107 | 3.6875 | 4 | import math
import numpy as np
def finding_a_matrix_by_formula():
k = 0
while k < 1:
k = int(input("Enter the variant:"))
size = 0
while size < 2:
size = int(input("Enter the size of matrix:"))
c = [[float(input("Enter the [{0}][{1}] element for matrix c:".format(i, j)))
... |
427e427dcb43914eadaa187cada04cde5246f90f | nazna/archives | /Practice/python/LeapYear.py | 264 | 3.828125 | 4 | # coding: utf-8
print("閏年かどうかを判定します:", end="")
year = int(input())
if (year%4 == 0 and year%100 != 0) or year%400 == 0:
print("{}年は閏年です".format(year))
else:
print("{}年は閏年ではありません".format(year))
|
21dd9e1882a3cae4a42f622a93468fd1928b6654 | tchaiyasena/TDD_work | /compute_stats_refactor.py | 1,330 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
This program computes basic statistics
"""
fpath = r'random_nums.txt'
def read_ints(filePath):
h = open(fpath,'r')
dats = h.read().split('\n')
return [int(x) for x in dats]
def count(lst:list) -> int:
return len(lst)
def summation(nums:list) -> int:
re... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.