blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
5106f81f58237ea7f4d845d8f60b39823a051c62
syuuhei-yama/python_01
/datetime_sample.py
994
3.765625
4
from datetime import datetime, timedelta,timezone, date import time my_date = datetime(2020,11,11,18,15,25) print(my_date, type(my_date)) now_datetime = datetime.now() utc_datetime = datetime.utcnow() print(now_datetime,utc_datetime) print(now_datetime.year, now_datetime.month,now_datetime.microsecond) #文字列から変換 tim...
fb930b03f42024b5b150fb545eb4829534465421
Hanniwell/Final-Project
/python/Player.py
4,615
3.53125
4
""" ------------------------------------------------------- [Program Description] ------------------------------------------------------- Author: Einstein Oyewole ID: 180517070 Email: oyew7070@mylaurier.ca __updated__ = "" ------------------------------------------------------- """ # Import import random from ...
1f6a4532ffdd302083c2a0a4cb14a077fe25cbae
HamzhSuilik/data-structures-and-algorithms
/python/challenges/tree_intersection/tree_intersection.py
1,171
3.671875
4
try: from tree import BinaryTree,TNode,Stack from hashtable import Hashtable except: from challenges.tree_intersection.tree import BinaryTree,TNode,Stack from challenges.tree_intersection.hashtable import Hashtable def tree_intersection(tree_1,tree_2=0): arr = [] hashtable = Hashtable() top = tree...
85b1fd9507fada4bf97c9641e9d69244a4341e96
rainvestige/pytorch_tutorials
/intro_to_pytorch.py
3,428
4.15625
4
# coding=utf-8 '''What is pytorch? It's a python-based scientific computing packages targeted at two sets of audiences: - A replacement for Numpy to use the power of GPUS - A deep learning research platform that provides maximum flexibility and speed ''' '''Tensors Tensors are similar to nu...
4dbd2b0178d8e56d04c2d23399984ebdfab54ba6
Serhii999/Homework
/DZ5/avgmark.py
516
3.875
4
students = {"Karenov_S":[80,70,75, 60, 75], "Kalaychev_G":[80, 90, 80, 75, 85], "Drulev_D":[60, 50, 45, 70, 65], "Khamza_I":[75, 90, 75, 70, 85], "Gerasimenko_M":[70, 65, 80, 75, 60]} avg =[] for name, marks in students.items(): avg.append(sum(marks)/len(marks)) s...
1ded2100d8a70309310efdbbef7e29ff3095aeab
ChawinTan/algorithms-and-data-structures
/Dynamic_programming/unique_path_2.py
2,681
3.765625
4
#forward solution class Solution(object): def uniquePathsWithObstacles(self, obstacleGrid): """ :type obstacleGrid: List[List[int]] :rtype: int """ col, row = len(obstacleGrid[0]), len(obstacleGrid) if (len(obstacleGrid[0]) == 1 and obstacleGrid[0][0] == 1) o...
410c08cdecae9799af600b010a3e710a20837b59
SanmatiM/practice_problem_sets
/elesearch.py
184
3.90625
4
lst=[] strg=input("Enter the elements") lst=strg.split() search=input("Enter the element to be searched") for ele in lst: if ele==search: print("True") break else: print("False")
17670f05f2bfad3310c4af50859d500fc382c090
lakshyatyagi24/daily-coding-problems
/python/18.py
1,879
4.0625
4
# ------------------------- # Author: Tuan Nguyen # Date: 20190531 #!solutions/18.py # ------------------------- """ Given an array of integers and a number k, where 1 <= k <= length of the array, compute the maximum values of each subarray of length k. For example, given array = [10, 5, 2, 7, 8, 7] and k = 3, we sho...
7af7b7675df0088f0f2501c5f40e30521dc9354a
eriklau/Mercedes-Car-Price-Prediction
/LinearModel.py
1,389
3.9375
4
import pandas as pd import matplotlib.pyplot as plt import predictor as data import numpy as np dataset = data.DataCleaner().process_data() X = dataset.iloc[:, 1].values dataset_result = data.DataCleaner().process_data() y = dataset.iloc[:, 0].values # Splitting the dataset into the Training set and Test set from skl...
cf12876fca1e11bebde977057ab2f204c2a78c96
python15/homework
/4/sunyuanjun/zuoye.py
526
4.25
4
numbers = [2,1,3,5,8,7] group = {8,3,1} def sort_priority(numbers,group=None): if group == None: group = [] target1 = [] target2 = [] for i in numbers: target1.append(i) if i in group else target2.append(i) target1.sort() target2.sort() new_num = [i for i in target1] fo...
084dd9af3fbd97e4025b2d9848409ebec869db05
okccc/python
/basic/06_迭代器和生成器.py
2,511
4.25
4
# coding=utf-8 """ 可迭代对象:可以作用于for循环的对象,包含iter()方法,可用isinstance(**, Iterable)判断 迭代器:有返回值的可迭代对象,包含iter()和next()方法,可用isinstance(**, Iterator)判断 iter():迭代器一定是可迭代对象但可迭代对象不一定是迭代器,iter函数可以将可迭代对象变成迭代器 生成器:使用yield关键字的函数不再是普通函数,调用该函数不会立即执行而是创建一个生成器对象,调用next()时运行 yield作用:中断函数并返回后面的值,然后在下一次执行next()方法时从当前位置继续运行,减少内存占用 优点:列表和字典等容器是先...
909ebc59829e66a55dc147364fade884f6b36562
oumingwang/----Python
/PycharmProjects/91个建议/cookbook/数据结构/collections_deque.py
2,561
3.984375
4
#coding:utf8 #简单匹配行,输出匹配 from collections import deque ''' def search(lines,pattern,history = 5): pre_lines = deque(maxlen=history) for line in lines: if pattern in line: yield line,pre_lines pre_lines.append(line) if __name__ == '__main__': with open('hello.txt') as f : ...
0c11f5021004b46aae7f4032c3694eaeb94aadb3
subedibimal/iw-assignments
/assignment/5.py
197
3.515625
4
my_info = ("Bimal", "Subedi", 20) people = [] people.append(my_info) people.append(("Sagar", "Karki", 20)) people.append(("Susan", "Shakya", 20)) people.sort(key=lambda x: x[-1]) print(people)
8416c807ac7fbf9e56d7a82d04ff9235e12022f7
hz336/Algorithm
/LeetCode/DP/M Perfect Squares.py
607
3.9375
4
""" Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. Example 1: Input: n = 12 Output: 3 Explanation: 12 = 4 + 4 + 4. Example 2: Input: n = 13 Output: 2 Explanation: 13 = 4 + 9. """ import math """ Time Complexity: O(n * sqrt(n)) """ class ...
f0716450d6565c7715f6caf6078c4e0f7d338ccc
dsli208/ScriptingLanguages
/hw1/Py3_David_Li_110328771_HW1/hw1_q5_p1.py
1,853
3.953125
4
def passwordCheck(s): # define tests the password must pass to be deemed string lengthTestValue = lengthTest(s) numTestValue = False alphaTestValue = False specialTestValue = False noIncValTestValue = True distinctCharTestValue = False # Numeric, alphabet, and special test # Also te...
0991fc9c42caf60963563cfa2b9aff53ca883461
JustWon/MyKakaoCodingTestSolution
/Quiz3/Quiz3.py
2,750
3.609375
4
class Node: def __init__(self, _key, _val, _prev=None, _next=None): self.key = _key self.val = _val self.prev = _prev self.next = _next class LRUCache: # @param capacity, an integer def __init__(self, capacity): self.counter = 0 self.capacity = capacity self.dic = dict() self.head = Node(None, None...
a9078a18657923ff24ef0b066d73183af07ba487
bobyaaa/Competitive-Programming
/CCC/CCC '06 J2 Roll the Dice.py
355
3.78125
4
#Solution by Andrew Huang dice1 = input() dice2 = input() total = 0 fails = 0 for x in range(dice1): for y in range(dice2): if x+y == 10: total += 1 else: fails +=1 if total == 1: print 'There are '+ str(total) + ' ways to get the sum 10.' else: print 'There is '+...
dd9a4940acf27314c110da47f0522d72c09366c6
vijayjag-repo/LeetCode
/Python/LC_Sum_of_Left_Leaves.py
719
3.828125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def sumOfLeftLeaves(self, root): """ :type root: TreeNode :rtype: int """ ...
8b1c61df388e942cdd272cdc8ba5d79fc943f4b4
pavanimallem/pavs4
/guvi31ply.py
171
3.765625
4
string=raw_input() a=0 b=0 length=len(string) for i in range(0,length): if(string[i]==')'): a+=1 elif(string[i]=='('): b+=1 if(a-b==0): print"yes" else: print"no"
772c0267444435ccfc9e73aeef94ff74ef031f46
hoi-nx/Python_Core
/Helloworld/For.py
245
3.609375
4
#range(begin,end,step) step bước nhẩy range(10) range(1,10) range(1,10,2) range(10,0,-1) #for ngược n=10 s=0 if n%2==0: for x in range(2,n+1,2): s=s+x else: for x in range(1,n+1,2): s=s+x print("Tổng s= ",s)
36661e997c38bae86272e0174f36951022ac4958
gabriellaec/desoft-analise-exercicios
/backup/user_195/ch47_2019_03_19_18_40_55_134564.py
195
3.734375
4
pergunta=input("Qual o mês?") i=0 L=["janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"] while pergunta!=L[i]: i+=1 print (i+1)
5274217eed60d74967edb7d62a4525e973f83434
fernandochimi/Intro_Python
/Exercícios/057_Media_Listas_Digitadas.py
216
3.5
4
notas=[0,0,0,0,0,0,0] soma=0 x=0 while x < 7: notas[x] = float(input("Nota %d: " % x)) soma += notas[x] x += 1 x = 0 while x < 7: print("Nota %d: %6.2f" % (x, notas[x])) x += 1 print("Média: %5.2f" % (soma/x))
375a05197e7b9b943561add6fd5731233599febf
HernandezCesar/Firework-hw-due-9-29-17
/lab 6
2,637
4.78125
5
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Sep 27 08:37:09 2017 Lab 6. . Main objective: creating and working with lists. . Other objecives: working with random numbers, defining and calling function @author: Alvaro Monge alvaro.monge@csulb.edu @author: Cesar Hernandez hernandezcesar746@gm...
11b834f225f09e4f9687961ebbc5b26e95916e30
MTGTsunami/LeetPython
/src/leetcode/bfs/286. Walls and Gates.py
1,884
4.03125
4
""" You are given a m x n 2D grid initialized with these three possible values. -1 - A wall or an obstacle. 0 - A gate. INF - Infinity means an empty room. We use the value 231 - 1 = 2147483647 to represent INF as you may assume that the distance to a gate is less than 2147483647. Fill each empty room with the distanc...
95b01387d6b6294e0d3b67539ee3f003ad73055d
PLUTOLEARNS/computerprogramsreal
/randomfunction07072020.py
264
3.890625
4
"""i school fest , three randomly chosen students out of 100 students have to present bouquets to guests """ import random s1 = random.randint(1,100) s2 = random.randint(1,100) s3 = random.randint(1,100) print ("The selected students are : " ,s1,s2,s3)
2dbdd93450eb80452f0a4eedb64e7786106366f7
wizardlancet/ICS-Fall-2014
/ICS-Lab2/fizzbuzz/fizzbuzz-students.py
497
4.4375
4
""" The FizzBuzz Problem ==================== Write a program that prints the numbers from 1 to 100. But for multiples of three, print “Fizz” instead of the number. For the multiples of five, print “Buzz” instead of the number. For numbers which are multiples of both three and five, print “FizzBuzz”. """ for x in ran...
835270726e65a3a75fd5bb630f329fcdc5deabc5
nobe0716/problem_solving
/leetcode/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list.py
1,102
3.625
4
from typing import List class Node: def __init__(self, fc): self.idx = fc[0] self.v = set(fc[1]) self.child = [] def try_insert(self, node): if self.v.intersection(node.value) != node.value: return False if any(e.try_insert(node) for e in self.child): ...
38ecb19b0e45c28001e107ffc1ed6fc18eb118ea
IgoryanM/Python
/les_2/2_2.py
564
3.71875
4
my_list = [] new_list = [] while True: value = input('Enter some data or type esc for quit: ') if value == 'esc': break else: my_list.append(value) print(my_list, '- your list') if len(my_list) % 2 == 0: for i in range(0, len(my_list), 2): new_list.append(my_list...
d16b156a874e9179f71688e9a4693e49a3367de6
csernazs/misc
/aoc/2018/aoc02b.py
605
3.53125
4
#!/usr/bin/python3 def common_letters(str1, str2): for c1, c2 in zip(str1, str2): if c1 == c2: yield c1 def difference(str1, str2): retval = 0 for c1, c2 in zip(str1, str2): if c1 != c2: retval += 1 return retval lines = [x.strip() for x in open("aoc02.txt")]...
0be64ec96a954dc8e5085204e060866097af81e1
Snehagit6/G-Pythonautomation_softwares-Sanfoundry_programs
/Basic_Programs/Decorators/higher_functions.py
358
3.75
4
# def outer(x, y): # # def inner1(): # return x+y # # def inner2(z): # return inner1() + z # # return inner2 # # # f = outer(10, 25) # # print(f(15)) def outer(x, y): def inner1(): return x+y def inner2(): return x*y return (inner1, inner2) (f1, f2) = ...
e31d8bb975f1f86d799643910402ee387e0417da
jz33/LeetCodeSolutions
/T-1277 Count Square Submatrices with All Ones.py
1,441
3.765625
4
''' 1277. Count Square Submatrices with All Ones https://leetcode.com/problems/count-square-submatrices-with-all-ones/ Given a m * n matrix of ones and zeros, return how many square submatrices have all ones. Example 1: Input: matrix = [ [0,1,1,1], [1,1,1,1], [0,1,1,1] ] Output: 15 Explanation: There are 10...
56ed05a6fc29fca3547142b6603e74a0f6951bd1
poliwal/DSA-Practice
/Array/Longest Peak.py
556
3.828125
4
# O(n) time | O(1) space def longestPeak(array): longestPeakLength = 0 i = 1 while i < len(array)-1: if array[i-1] < array[i] and array[i] > array[i+1]: left = i - 2 while left >= 0 and array[left] < array[left+1]: left -= 1 right = i + 2 while right < len(array) and array[right] < array[right-1]...
bd01642f900443a34614eef8604be8bbe6aad543
ar012/python
/learning/function_def.py
646
3.921875
4
# Defining the function named hello def hello(): print("Hello World") #print(2+8) # Calling the function hello to use it hello() # Again calling the function hello hello() # Defining the function area def area(): PI = 3.14159 redius = 2 print("Area of the circle:", PI*redius*redius, "unit") # C...
c0fc73e28d94cb7ae25761f4b80aaa5d59865f85
yogendratamang48/secured_communication_fibonacci
/decrypt.py
746
3.53125
4
import json import encrypt FILE_TO_DECODE = 'message.txt' def start_decript(rawSecurityCode): asciiLetters = encrypt.getAsciiLetters() encoded_hexes = eval(open(FILE_TO_DECODE, 'r').read()) if len(rawSecurityCode)==1 and rawSecurityCode[0] in asciiLetters: _decimals = [int(_hex, 16) for _hex in enc...
269055cbca853f415b04dc48865e8dc4a1322fc0
jetboom1/python_projects
/kr1/Franko_KR1_1_Variant1.py
462
4.09375
4
x = float(input('Введите первое число')) y = float(input('Введите второе число')) z = float(input('Введите третье число')) if x+y+z<1 and x<y and y<z: x = (y+z)/2 print(x,y,z) if x+y+z<1 and y<x and x<z: y = (z+x)/2 print(x,y,z) if x+y+z<1 and z<y and y<x: z = (y+x)/2 print(x,y,z) if x+y+z>=1 an...
b689d2d94469d38fad83eb3ab1e13ba816f87b68
xuzuoyang/mypackage
/mypackage/core.py
586
3.84375
4
from copy import deepcopy def dict_substract(dict1, dict2): '''Substract dict2 from dict1 and return dict1. Args: dict1: supposed to be the minuend. dict2: supposed to be the subtrahend. Returns: difference dict from the substraction. ''' if isinstance(dict1, dict) and isin...
4691e76e6f3ad884548ed71b699ee234755e43aa
ramona-2020/Python-OOP
/06. Iterators and Generators/05. Fibonacci Generator.py
327
4.21875
4
def fibonacci(): current_num = 1 previous_num = 0 yield previous_num yield current_num while True: next_num = previous_num + current_num yield next_num previous_num = current_num current_num = next_num generator = fibonacci() for i in range(5): print(next(gener...
e53577147aeff98db68c83767085e43d57c103e6
standy66/h2-async-benchmarks
/curio_server.py
2,548
3.8125
4
#!/usr/bin/env python3.5 # -*- coding: utf-8 -*- """ curio-server.py ~~~~~~~~~~~~~~ A fully-functional HTTP/2 server written for curio. Requires Python 3.5+. """ import mimetypes import os import sys from curio import Event, spawn, socket, ssl, run import h2.config import h2.connection import h2.events # The maxi...
9d27b7f19491915f1c783dd5753587597a1e9f05
buzumka/GB_Python
/l3_ex3.py
448
4.28125
4
""" Реализовать функцию my_func(), которая принимает три позиционных аргумента и возвращает сумму наибольших двух аргументов. """ def my_func(num_1, num_2, num_3): """ возвращаем сумму наибольших двух аргументов""" return (num_1 + num_2 + num_3 - min(num_1, num_2, num_3)) print(my_func(10, 20, 15))
6c5b6e85993b5da846fa996ced0dff56bc318381
Dimitarleomitkov/Obirah
/Obirah/RngPatchTileGenerator.py
455
3.515625
4
import sys import random # Count the characters on a line and the lines if (len(sys.argv) != 3): print ("You need to provide width and height."); exit(); width = sys.argv[1]; height = sys.argv[2]; usable_tiles = ["T", "*", "~", " "]; new_file_name = "z_rngterrain.txt" fw = open (f"{new_file_name}", "w"); for i i...
b0b6eef61fa74968fa7f825698ded7eb004d0654
JCGit2018/python
/HomeTask5/SwapStrings.py
196
4.1875
4
# 1. WAP to input 2 strings and swap the strings s1 = input('Enter the 1st string: ') s2 = input('Enter the 2nd string: ') print(s1) print(s2) temp = s1 s1 = s2 s2 = temp print(s1) print(s2)
95ef5bbec568f499553b2ca1ed6ea9abd0f10038
IdenTiclla/guess
/main.py
1,055
4.03125
4
from colorama import Fore, Style import random def main(): min_number = 1 max_number = 20 guess_taken = 0 username = input("Hello what is your name?: ") random_number = random.randint(min_number, max_number) print(Fore.YELLOW + f"Well, {username}. I am thinking in a number between {min_number}...
a13d4cf552632ed6284afe9f877e0f804b46d8b3
bitoffdev/Learn-Python
/15-1.py
555
4.4375
4
#This line imports the arguments given to the program at start using sys module from sys import argv #This line puts argv values into two variables script, filename = argv #This line opens the file given to the program using argv txt = open(filename) #This line outputs the argv filename input print "Here's your file...
5997a28d146fb769a216097207930a74e002ac65
PedroSDD/Python-challenges
/CheckPair.py
585
3.71875
4
#INPUT SAMPLE: Your program should accept as its first argument a filename. # This file will contain a comma separated list of sorted numbers and then the sum 'X', separated by semicolon. #Ignore all empty lines. If no pair exists, print the string NULL import itertools def fileReader(path): with open(path) as fi...
80538107e0223af517b7124ccd1de0b2d8a70af2
mertcanozturk/HumanPoseEstimationAndUnityIntegration
/PythonScript/sendData.py
1,489
3.59375
4
import socket def sending_and_reciveing(): s = socket.socket() print('socket created ') port = 1234 s.bind(('127.0.0.1', port)) #bind port with ip address print('socket binded to port ') s.listen(5)#listening for connection print('socket listensing ... ') while True: c, addr = s.accept...
a5e23138b12ba9ca50eaa8e3346810946edba92b
astrodoo/pyds
/tools/today.py
501
3.84375
4
""" filename: today.py PURPOSE: generate the string that indicates the today with the format of "yymmdd_" Written by: Doosoo Yoon University of Amsterdam History: Written, 1 October 2018 """ import datetime class today: """ generate the string that indicates...
0931417feb07eac9cd1cc47cadada8633ce28308
parutechie/Python
/app.py
369
4.21875
4
#Simple Python Program for Converting KiloGram(kg) to Pounds or Converting Pounds to KiloGram(kg) Using "if else statement" weight = int(input("Weight: ")) unit = input("(L)bs or (k)g: ") if unit.upper() == "L": converter = weight * 0.45 print(f"yor are {converter} Kilos") else: converter = weight //...
439e1c218953f39922d7c6c302a412c3fd184b89
adimanea/sla
/1-nlp/lab1/python_list_categ.py
638
3.53125
4
############################################################ # Se dă o listă de cuvinte. Să se afișeze cuvintele, # împreună cu numărul aparițiilor lor (case insensitive). ############################################################ lista = ["haha", "poc", "Poc", "POC", "haHA", "hei", "hey", "HahA", "poc", "H...
c9c34f695e793a93fde90b89a9b0ef57afbed88b
Drlilianblot/tpop
/TPOP Python 3.x Practicals/huffman.py
3,737
3.578125
4
''' Created on 17 Nov 2016 @author: lb1008 ''' class HuffmanTree(object): ''' classdocs ''' def __init__(self, left = None, right = None, symbol = None, frequency = 0): ''' Constructor ''' self._right = right self._left = left self._frequency = frequen...
679e27b7ef3c88a19f88dc9ded1965195210ca90
zzztpppp/TicTacToe-AI
/in_game_types.py
459
3.5625
4
# Chess piece data type is defined in this file from typing import NewType ChessPiece = NewType('ChessPiece', int) CIRCLE = ChessPiece(1) CROSS = ChessPiece(-1) Reward = NewType('Reward', int) WINNING_REWARD = 2 # Reward for winning a game DRAWING_REWARD = 0.5 # Reward for a tied game LOSING_REWARD = 0 # Rewar...
bba1c9d6dfbdf552ffedb0a9d3a9eda286d440ad
DikijXoloDilnik/Learning-repo
/lesson1/Hw1_ex3.py
408
3.921875
4
# Узнайте у пользователя число n. Найдите сумму чисел n + nn + nnn. # Например, пользователь ввёл число 3. Считаем 3 + 33 + 333 = 369 var = input('Введите число n: ') result = int(var) + int(var * 2) + int(var * 3) print(f'после преобразования из числа n получилось - {result}')
41d345d3b16d902b4ff11e454a11a6cf098da68d
So-so1/My-first-blog-
/scripts.py
479
3.984375
4
print('Hello world!') age = 17 #Teste sur les conditions if age >= 18 : print("Vous êtes majeur, merci.") else: print("Vous êtes mineur, merci.") age = 7 #Teste de plusieurs conditions en un même temps,interval if(age > 10 and age <= 16): print(" et en même temps adolescent :).") elif (age > 16 and age <= 3...
bcc3be48390e2da4ce04c64e37a961e60a0ad0ac
ronaldoedicassio/Pyhthon
/Arquivos Exercicios/Exercicios/Ex046.py
176
3.5625
4
""" Faça programa que conte regresivamente de 10 ate 0, e com uma pausa de 1 segundo """ import time for c in range(10,-1,-1): print(c) time.sleep(1) print("Uhuuuuuu")
e9b48e0f43358f39a251734e4f5aef93646fd2d6
Mercrist/Intermediate-Python-Solutions
/slopes.py
1,209
4.46875
4
class Point: """ Point class represents and manipulates x,y coords. """ def __init__(self, x=0, y=0): """ Create a new point """ self.x = x self.y = y def distance_from_origin(self): """ Compute my distance from the origin """ return ((self.x ** 2) + (self.y ** 2)) ...
5af61be3efc4ad70ea9dd5075719328807c5d9f1
Amfeat/Python_learning
/lesson_002/04_my_family.py
992
3.671875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Создайте списки: # моя семья (минимум 3 элемента, есть еще дедушки и бабушки, если что) my_family = ['Дима', 'Марина', 'Арина'] # список списков приблизителного роста членов вашей семьи my_family_height = [ # ['имя', рост], [my_family[0], 178], [my_family...
0a2b398d96a42150fc062314f3db51cadc2e597c
PitPietro/python-project
/math_study/numpy_basics/numpy_array/array_information.py
2,279
4.65625
5
import numpy as np from array_creation import py_arrays def number_of_axes(array): """ Parameters ---------- array Python array Returns ------- Number of axes (dimensions) of the array. """ return np.array(array).ndim def shape(array): """ The dimension of the array is a...
420a258fa6ff51e48320b8ef074133a3aad4b9a7
CamilliCerutti/Python-exercicios
/Curso em Video/ex077.py
419
3.953125
4
# CONTANDO VOGAIS EM TUPLA # Crie um programa que tenha uma tupla com várias palavras (não usar acentos). Depois disso, você deve mostrar, para cada palavra, quais são as suas vogais. palavras = ('exceto', 'cinico', 'idoneo', 'ambito', 'nescio', 'merito') for p in palavras: print(f'\nNa palavra {p} temos ', end=...
32fb12f02af038a5abc5d1d4d6522cfc097c881f
heyalexchoi/fun_exercises
/knn/knn.py
4,404
4.21875
4
import os import csv import random import math import operator from collections import namedtuple, defaultdict """ following along with https://machinelearningmastery.com/tutorial-to-implement-k-nearest-neighbors-in-python-from-scratch/ to implement K-nearest neighbors. format of iris.data: ➜ knn head iris.data 5.1,...
46a6dafa451c14c30530840f24c033a75b425334
obedmr/smart_parking
/json_loader/loader.py
302
3.515625
4
import json # JSON to dict Converter from file def json_to_dict(filename): dictionary = None try: with open(filename) as filename: dictionary = json.loads(filename.read()) except IOError: print("Cannot open file {}".format(filename)) return dictionary
053bdbff49d803cb173b1e161c11d0b098a330b3
yqz/myalgoquestions
/lowest_free_id.py
2,714
3.703125
4
#!/usr/bin/python """ QUESTION: Give an array of ids, find the minimum non-negative id that is not in the array. Example: [3,1,0,2,5], the min value should 4 that is not in the list. """ def partition(a, l, h, x): """ Partition function that will make elements that are less than x on one side of the array. An...
9c4d833668ad43480c2055e96b7adad916e133f5
tec109/Physo
/conversion.py
1,828
3.671875
4
units = {} class Unit: def __init__(self, unit_type, standard): self.unit_type = unit_type self.standard = standard self.variations = {} def add_variation(self, variation, conversion): self.variations[variation] = conversion def get_conversion(self, variation): re...
ee93458fbb3edd1d53ef97e897d2f380a03610f6
lungen/Project_Euler
/p15_lattice_paths_01.py
239
4
4
# -*- coding: utf-8 -*- def factorial(n): num = 1 while n >= 1: num = num * n n = n - 1 return num zaehler = factorial(40) nenner1 = factorial(20) nenner2 = factorial(20) print(zaehler / (nenner1 * nenner2))
d25e7f26e82e87a7b33e54f3d46406c79f7926ea
wduffell/cmpt120duffell
/table2.py
129
3.6875
4
# table 2 def main(): temp = "{:d} {:5b} {:5o} {:5x}" for i in range(1,21): print(temp.format(i,i,i,i)) main()
99ea204bbf14490758932a0ec092a193f8ffbd6c
ArthurBottcher/simulador_fa
/simulado_drives.py
903
3.515625
4
def drive(pi, pqb, nd, oj): from random import randint inicio_jogada = pi - pqb #de onde a bola sai jardas_ganhas = randint(0, 10) #quantia de jardas ganhas pf = inicio_jogada + jardas_ganhas objetivo = oj print("Será first down na linha de {} jardas".format(objetivo)) if pf >= objetivo: print("...
4e8aeb5154285d54806776a5de52938a80a4fa00
bookhub97/pythonproject
/Data Files/Ch_07_Student_Files/randomwalk.py
457
4.25
4
""" File: randomwalk.py A turtle takes a random walk. """ from turtle import Turtle import random def randomWalk(t, turns, distance = 20): for count in range(turns): degrees = random.randint(0, 270) if count % 2 == 0: t.left(degrees) else: t.right(degrees) ...
769874043a86c67556dd961eefe10c9691dd0bf4
CucumentoJolaz/delayed-fluorescense-analysis
/test.py
276
3.53125
4
from matplotlib import pyplot as plt plt.ion() plt.plot([1,2,3]) # h = plt.ylabel('y') # h.set_rotation(0) plt.ylabel(-0.1, 0.5, 'Y label', rotation=90, verticalalignment='center', horizontalalignment='right', transform=plt.ylabel.transAxes) plt.draw()
8786be597cb08d22b49e903f4e0a7c77e6c75807
EricaEmmm/CodePython
/TEST/趋势科技2_凑零钱找组合_改OK暴力.py
848
3.5625
4
# 凑零钱找组合 # 输入: # 6 5 4 3 2 1 # 11 # 输出: # 12 def process(ChargeNum, targetNum): # ChargeSet = [1, 5, 10, 20, 50, 100] # ChargeList = {} # for i in range(len(ChargeNum)): # ChargeList[ChargeSet[i]] = ChargeNum[i] res = 0 for i in range(ChargeNum[0]+1): for j in range(ChargeNum[1]+1)...
ee5d93f698866e629aa092544838094fe51c7a2d
matthewzapata/python-exercises
/4.4_function_exercises.py
8,178
4.21875
4
# Define a function named is_two. It should accept one input and return True # if the passed input is either the number or the string 2, False otherwise. def is_two(x): if x == '2' or x == 2: return True else: return False print(is_two(2)) print(is_two('2')) print(is_two(3)) print('---------...
a7b5facc15e7e239df0bbecbee41b74f9dddf714
maelizarova/python_geekbrains
/lesson_2/task_1/main.py
147
3.75
4
a = [1, 10] data = [1, '1', {'one': 1, 'two': 10}, (1, 10), set(a)] for el in data: print(f'Type of element {el} in data is {type(el)}')
2ddd048c20129df609d29c18a41d772352bbe52a
Luolingwei/LeetCode
/Tree/Q144_Binary Tree Preorder Traversal.py
670
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 Solution: # Solution 1 iterative # def preorderTraversal(self, root): # return [] if not root else [root.val] + self.preorderTraversal(...
e9ed1a3c54078a49751d065d86b0b28b4501b594
ibrahim85/match
/Lexile/lexile.py
2,359
3.84375
4
import re from collections import defaultdict from math import log from statistics import mean from nltk import sent_tokenize, regexp_tokenize class Lexile: def __init__(self, string): self.sentences = sent_tokenize(string.lower()) self.words = regexp_tokenize(string.lower(), "\w+") self....
6a4a13d3a1ca8135d6d1d16d1bc4dac2508cbd1a
GuiMarthe/olcourses
/PFE/Course2/maxemail.py
1,366
3.75
4
## Write a program to read through the mbox-short.txt and figure out who has ## the sent the greatest number of mail messages. The program looks for ## 'From ' lines and takes the second word of those lines as the person ## who sent the mail. The program creates a Python dictionary that maps the ## sender's mail ad...
57214a3f98f652ca3204df0c4770967d2f57c984
kdunn13/Project-Euler-and-Topcoder-Solutions
/Euler-Solutions/Euler4.py
269
3.515625
4
def isPalindrome(num): num = str(num); numCopy = num; numCopy = numCopy[::-1] if(numCopy == num): return 1; return 0; max = 0; for i in range(100, 1000): for j in range(100, 1000): num = i * j if(isPalindrome(num) and num > max): max = num; print max;
fd2153cfdc6290f7079b55710f20639842e3c9dd
daniel-reich/ubiquitous-fiesta
/MbPpxYWMRihFeaNPB_9.py
142
3.96875
4
def sum_of_evens(lst): even_sum = 0 for i in lst: for x in i: if x % 2 == 0: even_sum = even_sum +x return even_sum
29cec421dd42b7f0909d04cc162afb6fecf5bb49
vikramforsk2019/FSDP_2019
/day02/sorting.py
424
3.78125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jun 6 08:05:11 2019 @author: vikram """ student_list = [] while True: user_input = input("Enter name, age and score: ") if not user_input: break name, age, marks = user_input.split(",") print(name) student_list.a...
270dca5a2b9e70054a0086803f999a3c3ff9b0d2
JheisonBeltran/Taller-Excerism
/taller2.py
5,986
3.5625
4
# -*- coding: utf-8 -*- """ Created on Mon Apr 5 17:49:01 2021 @author: Jbeltrant """ # TALLER DE EXCERISM - CORTE 2 # EJERCICIO 1 - Binary # Convierta un número binario, representado como una cadena. def binarizar(decimal): binario = '' while decimal // 2 != 0: binario = str(decimal % 2) + binario...
58227893a19ef8a5c22290e46207529435254a70
pascalmcme/myprogramming
/week3/testTypes.py
604
3.859375
4
aninteger = 5 afloat = 6.7 aboolean = True astring = "hello world!" alist = ["Monday","Tuesday","Wednesday"] print("variable {} is of type: {} and the value is {}" . format('aninteger',type(aninteger),aninteger) ) print("variable {} is of type: {} and the value is {}" . format('afloat',type(afloat),afloat) ) print("va...
406b4b1f38f3eae373cd437d5882aa4fc499c18e
kritikyadav/Practise_work_python
/simple-basic/11.py
116
3.59375
4
a=int(input("devisor= ")) b=int(input("divident= ")) c=a//b ##where c is qutient d=a-b*c print("Reminder= ",d)
b4831b59c783594f575970e5e3def1eb2f572ab2
JLtheking/cpy5python
/promopractice/3.4.2.py
2,556
3.609375
4
def HashKey(ThisCountry): mySum = 0 for i in range(len(ThisCountry)): mySum = mySum + ord(ThisCountry[i]) ans = mySum % 373 + 1 return ans def CreateCountry(): with open("COUNTRIES.txt","r") as infile: line = infile.readline() countryArr = [] while line != "": for i in range(len(line)): if 48...
b0731a0db4fb006660391fb18530de1aa50f6a5b
frank217/Summer-Coding-2018
/Regular practice/ World CodeSprint 13/ Group Formation.py
4,090
3.6875
4
""" World Code sprint 13 Group formation(medium) Detail : https://www.hackerrank.com/contests/world-codesprint-13/challenges/group-formation/problem Expected output: C D E _______ C D E F G _______ no groups _______ Hulk IronMan SpiderMan Thor """ """ Runs in assessing input is O(n) making group: for each value in...
9609e0b4452511e9981ab059ff0c4cee727f1524
Jeblii/Rush-Hour---Heuristics
/RushHour-Heuristics/rush_hour/main.py
2,168
3.75
4
from vehicle import Vehicle from vehicle_2 import Vehicle_2 from boards import Board from algorithms.breadth_first import breadth_first_search from algorithms.best_first import best_first_search from algorithms.random import random_search from setup import * from visualization import visualization from datetime import ...
b70046a8af64c21d1d74ce1d0a140a5126911d7b
Sahilpatkar/Ethans
/KeychainShopGui.py
1,413
3.875
4
import tkinter import math L=0 def add(): global L x=int(addkey.get()) L+=x print(L) SetLabel.delete(0,L) SetLabel.insert(0,L) def remove(): global L x=int(removekey.get()) L=L-x if L>=0: print(L) SetLabel.delete(0,L) SetLabel.insert(0, L) elif L...
9e3f58141a03f2a0441261498a75c7926b826245
k-e-v-i-n17/KevCode
/HeadsTails.py
247
3.84375
4
def heads_or_tails(text): import random #text = raw_input("start?") st= 'heads', 'tails' x=st y='Coin Flipped: ' for j in range(0,1): y+=random.choice(x) return y #if file == __main__: for i in range(0,1): print(heads_or_tails('aaa'))
c64d0705276295dd14e22a8d772d212bd187e22c
tsonnen/GMSuite
/markov.py
1,352
3.59375
4
''' 8/11/2016 Generates a name based on a list of strings using a Markov chain algorithm ''' import random class markovname: def __init__(self, nameList, order = 3): self.nameList = nameList self.table = dict() self.order = order for i in self.nameList: i = ...
12b9e8001d934fe7a4b23ac15d1e99ca30ed2dd5
ShourjaMukherjee/Dummy
/11thcodes/Functions/ASSIGN 41 - FUNCTIONS - Prime or not (1).py
358
3.921875
4
def countf(n): count=0 for i in range(2,n/2+1): if n%i==0: count+=1 return count def prime(m): flag=False x=countf(m) if x==0: flag=True return flag m=int(raw_input("Enter Number:- ")) z=prime(m) if z==True: print m,"is a prime number." else: ...
c8dfb4a66332126723ac0ea2da34d40628760e53
XUAN-CW/python_learning
/sundry/io/file05-文件读取-read([size]).py
535
4.15625
4
#测试文件读取 ''' 文件的读取一般使用如下三个方法: 1. read([size]) 从文件中读取 size 个字符,并作为结果返回。如果没有 size 参数,则读取整个文件。 读取到文件末尾,会返回空字符串。 2. readline() 读取一行内容作为结果返回。读取到文件末尾,会返回空字符串。 3. readlines() 文本文件中,每一行作为一个字符串存入列表中,返回该列表 ''' with open(r"e.txt","r",encoding="utf-8") as f: str = f.read(3) print(str)
59b4488c96dec07897fcaa79951a712d9f4aa40c
MananKavi/lab-practical
/src/practicals/set3/secondProg.py
445
3.921875
4
def match_word(words): wordsWithCharacter = [] for word in words: if len(word) <= 5 and (word[0] == 'm' or word[0] == 'M'): wordsWithCharacter.append(word) return wordsWithCharacter wordsList = [] listSize = int(input("Enter size of list : ")) while listSize > 0: wordsToAdd = str...
be31e0570c295fe7bb8eefb0a0058f708e323ab4
kidddw/Item-Build-Prescriber-for-Dota-2
/training/Dota_webscraper.py
14,223
3.546875
4
#!/usr/bin/python -tt """Dota Webscraper - Import match data from www.dotabuff.com - Latest 50 matches frome the currently highest rated players - Info on - Player Name - Match Index (for url identification) - Result (Win / Loss) - Match Duration - Player Hero -...
893a4f0ee78caa71658281840fedcd087d90ccfb
TanyaMozoleva/python_practice
/Lectures/Lec4/p23.py
179
3.578125
4
''' complete the output ''' s = 'Dogs have masters. Cats have staff.' print('1.', s[1: 6]) print('2.', s[:2] * 3) print('3.', s[-3]) print('4.', s[4] + s[1]) print('5.', s[-4:])
2545de1cc4f615545f5a2c81cb9365de8300a3cd
sabrinayeh/hw-9
/solution.py
580
3.703125
4
destinations = [ "Space Needle", "Crater Lake", "Golden Gate Bridge", "Yosemite National Park", "Las Vegas, Nevada", "Grand Canyon National Park", "Aspen, Colorado", "Mount Rushmore", "Yellowstone National Park", "Sandpoint, Idaho", "Banff National Park", "Capilano Suspension Bridge", ] import geocoder # Declare de...
eea2513ebd950622197e3cb6dbe909c9889a05d0
ildarkit/hw1
/deco.py
3,267
3.75
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from functools import update_wrapper def disable(func): ''' Disable a decorator by re-assigning the decorator's name to this function. For example, to turn off memoization: >>> memo = disable ''' return func def decorator(deco): ''' D...
2597820425f822f4945723377071b4d032a7e390
Aakashdeveloper/Python_shaheela
/eightfunction.py
472
3.90625
4
def addition(a,b): print(a+b) def aakash(name): print("SayHi "+name) def addtion(a,b): return a+b def addition1(a,b): if a == 1: return a+b else: return a-b print(addition1(8,9)) #you have make function #that will take input from the user #and tell the user given value i...
a32318dd906d0ba7d9a3d827e09f8b5912f9b20c
hatimmohammed369/py_string_numbers
/arithmetic.py
19,634
3.578125
4
def split_number(a): if not isinstance(a, str): raise TypeError('non-string value for parameter (a),' ' parameter (a) type:'+str(type(a))) if len(a) == 0: a = '0.0' if not a.__contains__('.'): a = a + '.0' decimal_point_index = a.find('.') ...
353b76dcd5e2de7edb82ca6acc976933511e6c80
BryanBattershill/HelperScripts
/Compound interest.py
738
3.75
4
while (True): base = float(input("Base amount?")) interestRate = float(input("Interest rate?")) compound = input("Compound rate? (m/y value)") duration = input("Duration? (m/y value)") if (compound[0] == "y"): compound = int(compound[2:])*12 else: compound = int(compound[2:]) ...
2fe9615c88fe18de01f2a08ad20eb29953776c5d
LisandroGuerra/zombies1
/Lista4/questao04.py
734
4
4
import string texto = '''The Python Software Foundation and the global Python community welcome and encourage participation by everyone. Our community is based on mutual respect, tolerance, and encouragement, and we are working to help each other live up to these principles. We want our community to be more diverse: w...
ccefa2e5c18ebef83ed5a95e2e308271fda298a4
rrabit42/Python-Programming
/문제해결과SW프로그래밍/Lab9-Python Function 2(random, callback)/lab9-1.py
825
3.765625
4
import turtle import random def drawSquare(): length = random.randint(50,100) for i in range(4): t.forward(length) t.left(90) def movePoint(): x = random.randrange(-300,301) y = random.randrange(-200,201) t.up() t.goto(x,y) t.down() t=turtle.Turtle() t.sha...
d8496404c860e3e445ac905400299284e1a8cadb
JoeshGichon/News-App
/tests/news_articles_test.py
907
3.640625
4
import unittest from app.models import News_Articles class ArticleTest(unittest.TestCase): ''' Test Class to test the behaviour of the News_article class ''' def setUp(self): ''' Set up method that will run before every Test ''' self.new_article = News_Articles("The Asso...
f24a97ce06b9a0f5db26b5981338c2dbe6df06cc
archer-yang-lab/manim
/project/start.py
1,393
3.640625
4
from manimlib import * class TextExample(Scene): def construct(self): text = Text("Here is a text", font="Consolas", font_size=90) difference = Text( """ The most important difference between Text and TexText is that\n you can change the font more easily, but can...
69e5a2fa2725a0a5ebaaf0f0a13f21170b708e02
createnewdemo/istudy_test
/1.py
1,112
3.59375
4
# encoding: utf-8 # -*- coding: gbk -*- import time def display_time(func): # 装饰器 也是一个函数 接下来要运行func这个函数 def wrapper(*args): # 这个函数要写的内容是要运行的内容 :做一下计时 可传入参数 t1 = time.time() # 截取时间 result = func(*args) # 运行我要走的函数 可写返回值 t2 = time.time() # 截取另一段时间 print("Total time:{:.4}".for...
b88ce86f72c75ef8889df369918f63b612eda013
caseymacphee/Data-structures
/heap.py
2,244
3.84375
4
class Min_heap(object): def __init__(self, iterable = None): self._pile = [] self._pile.insert(0, None) self.current_size = 0 if iterable is not None: try: populate_iterable = iter(iterable) try: iterate = True while iterate: self.push(populate_iterable.next()) except StopIterat...