blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
b39d713b56ad6bb9852160a2c428c383bcbf987f
Gerard1-11/PythonPractice
/FirstExercises/A4/ventaSoftware.py
1,330
4.03125
4
#encoding: UTF-8 #Gerardo Arturo Valderrama Quiroz #A01374994 #Programa que recibe un número de paquetes comprados e imprimie el descuento y el total de la compra #Funcion que calcula la cifra del descuento de los paquetes comprados def calculardescuento(nuPaquetes): if nuPaquetes >=0 and nuPaquetes <= 9: ...
0725195ed90726b18ff41658f27e5e8e46e14316
franklingu/leetcode-solutions
/questions/maximum-gap/Solution.py
1,438
3.859375
4
""" Given an integer array nums, return the maximum difference between two successive elements in its sorted form. If the array contains less than two elements, return 0. You must write an algorithm that runs in linear time and uses linear extra space.   Example 1: Input: nums = [3,6,9,1] Output: 3 Explanation: The s...
820b0d77982871ba340fa7353992cc473c140716
nervaishere/DashTeam
/python/7th_session/1list.py
170
3.90625
4
number = 3 things = ["string", 0, [1, 2, number], 4.56] print(things[1]) print(things[2]) print(things[2][2]) nums = [1, 2, 3] print(nums + [4, 5, 6]) print(nums * 3)
602ce1b023a134cf7c98d116ae7389e4d3fd9c71
moheeeldin19-meet/YL1-Session4
/animals.py
469
3.65625
4
class animal(object): def __init__(self,sound,name,age,favorite_color): self.sound=sound self.name=name self.age=age self.favorite_color=favorite_color def eat (self,food): print("yummy!! "+ self.name + " is eating " + food) def description(self): print(self.n...
6b648a52b3fa530c66ee17893c75933ab23cc460
catalinc/advent-of-code-2017
/day_2.py
2,099
3.625
4
# Solution to http://adventofcode.com/2017/day/2 import unittest import sys def matrix_checksum(matrix, row_fn): total = 0 for row in matrix: total += row_fn(row) return total def min_max_diff(row): if not row: return 0 min_val = row[0] max_val = row[0] for n in row: ...
c19b2a7f39422c2ceaa66474c5f3ce4d583ae6f0
rebecadiaconu/fmi
/ml/lab/algoritmi/normalizare.py
855
3.53125
4
import numpy as np from numpy.linalg import norm import sklearn.preprocessing as preprocessing a = np.array([10, 20, 30]) print(a) l = norm(a, 1) # 1 pt L1, 2 pt L2 print(l) result = np.divide(a, l) print(result) print("\n------------\n") def normalize(train_data, type=None): if type is None: re...
021cf8f6ae2a04bc6cffbe8109ae9f14a250c65c
SarcoImp682/Simple-Tic-Tac-Toe
/Topics/Split and join/What day is it/main.py
67
3.71875
4
date = input().split('-') for x in range(0, 3): print(date[x])
62248f89b65103b8783414a65300d7ef718dab97
Catalina-AR/python-2020
/python_stack/python/fundamentals/Funciones_intermedias2.py
3,773
3.890625
4
#Actualiza los valores en diccionarios y listas x = [ [5,2,3], [10,8,9] ] students = [ {'first_name': 'Michael', 'last_name' : 'Jordan'}, {'first_name' : 'John', 'last_name' : 'Rosales'} ] sports_directory = { 'basketball' : ['Kobe', 'Jordan', 'James', 'Curry'], 'soccer' : ['Messi', 'Ronaldo', 'Roon...
e756cc71577b3064538656ba465e45b27a445dbd
Amir324/itc_bootcamp_winter2020
/Python/200228154626_List 2.py
3,655
4.125
4
""" This program has been adapted for use by GVAHIM - the main revisions regard pep8 compliance and use of variable names Copyright 2010 Google Inc. Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 Google's Python Class http://code.google.com/edu/languages/goog...
0c14009118cfedeeb9c1206c941f3dc3131ff112
AnelaK/PrimePartitions
/PrimePartitions.py
1,409
3.828125
4
import sys, math def sieveOfEratosthenes(a, b): #returns list of all primes between a and b inclusive using the method Sieve of Eratosthenes primes =[True for i in range(b+1)] primes[0] = False primes[1] = False length = int(math.sqrt(b)) for i in range(length + 1): if (...
28728197681c0b0e63c854a9862a711d0086ed5b
316513979/thc
/Clases/Programas/recursividad.py
718
3.8125
4
# -*- coding: utf-8 -*- def fib(n): """ Calcula el nesimo término de la sucesión de fibonacci con n natural """ if n>2: return fib(n-1)+fib(n-2) else: return 1 print fib(1) print fib(2) print fib(5) print fib(10) def gauss(n): if 1<n: return gauss(n-1)+n else: retur...
959cba0cb76a2ee5871015ec5acbf280183170a6
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/224/users/4446/codes/1596_1016.py
345
3.515625
4
# Teste seu codigo aos poucos. # Nao teste tudo no final, pois fica mais dificil de identificar erros. # Nao se intimide com as mensagens de erro. Elas ajudam a corrigir seu codigo. ladoa=float(input("comprimento do lado a:")) ladob=float(input("comprimento do lado b:")) ladoc=float(input("comprimento do lado c:")) sem...
ccb2a7c0e19b3cee1a6508c55da7aa14629e579e
SushmaBR/FirstPython
/MinutesToYearsConversion.py
185
4.0625
4
min=float(input("Enter the minutes")) hrs=min/60 days=hrs/24 years=days/365.25 yrs=min/60/24/365.25 print("hrs:",hrs) print("days:",days) print("years:",years) print("yrs:",yrs)
1b873ff1371b2d1f9378a401389a4a0f4b0b67be
pseudonative/ultrapython3
/PythonScripts/find_greater_number.py
225
4.03125
4
a=eval(input("Enter your first number: ")) b=eval(input("Enter your second number: ")) if a>b: print(f'{a} is greater than {b}') elif a<b: print(f'{b} is greater than {a}') else: print(f'{a} and {b} are equal')
bdddbda29cbcf377bbb1fed70ae006f0f629ef92
Aigggerim/web_development
/function/a5.py
251
3.609375
4
def min(a, b, c, d): if a > b: A = b else: A = a if c > d: B = d else: B = c if A > B: return B return A a = input().split(" ") print(min(int(a[0]), int(a[1]), int(a[2]), int(a[3])))
a8129ec8eada7c3cb0ea6091c7e33f35d87927d2
mhoogveld/AoC_2016
/aoc-03.py
2,253
3.796875
4
#!/usr/bin/python import re __author__ = "m.hoogveld@elevate.nl" class AoC_03: def __init__(self): pass def run(self): triangle_input_file = "input-03" h_triangle_count = self.horizontal_triangle_count(triangle_input_file) v_triangle_count = self.vertical_triangle_count(tria...
fc080076086e75990adddb88957763106e19d4ff
GenericMappingTools/pygmt
/examples/tutorials/basics/regions.py
7,095
3.828125
4
""" Setting the region ================== Many of the plotting methods take the ``region`` parameter, which sets the area that will be shown in the figure. This tutorial covers the different types of inputs that it can accept. """ import pygmt #########################################################################...
31abf94f557d3d7ac348e859e26b8fc845c76b5c
joudkh/Programming-Languages
/Lecture 10/Lecture 10 (Classes).py
2,654
4.03125
4
# construtor ################################################ # you cannot define multiple constructors class MyClass: def __init__(self): self.value=123 # def __init__(self,thing): # self.value=thing def set(self,value): self.value=value def display(self): print(self....
b635fa6009e093121e45a5d5d2ec1fe998f088ee
qiaosiyi/oj
/test/python/common/strStr.py
1,363
3.65625
4
class Solution(object): def strStr(self, haystack, needle): """ :type haystack: str :type needle: str :rtype: int 给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0开始)。如果不存在,则返回  -1。 示例 1: 输入: haystack = "hello", needle = "ll" 输...
a167346c514c6865854904e59a3fa61ae258c672
abloskas/Flask_projects
/python_class/funWithfunctions.py
1,045
4.21875
4
def odd_even(): for i in range(1,2001): if i%2 == 0: print 'number is {}. this is an even number.'.format(i) else: print 'number is {}. this is an odd number.'.format(i) odd_even() # Number is 1. This is an odd number. # Number is 2. This is an even number....
93cf7fa83d5278ab5ebb9b4fd41286c8144c6712
clui951/python-miscellaneous
/329_longest_increasing_path_matrix/329_longest_increasing_path_matrix.py
2,496
3.6875
4
class Solution: # DFS from each coordinate looking for increasing path, while utilizing DP # O(N * M), DFS will visit each coordinate once, bc DP saves revisiting node and no way to go backwards on path def longestIncreasingPath(self, matrix): """ :type matrix: List[List[int]] :rtype...
8e3ae694cbd6a9d9ebc59f0b3d631f210ed61d4e
Checkmate50/dynkin_diagrams
/src/diagram_manager.py
9,379
3.90625
4
def ddiagram(letter, number=-1): """ Given a dynkin diagram letter and positive number Or the letter and number as a single string Generates the string associated with that diagram Returns "invalid graph" if the input did not describe a possible graph STYLE: o denotes a vertex - denotes...
ab37817dcf5890c695389c0333faed5d225a6776
tangteresa/SnakeGame
/Board.py
947
3.703125
4
import pygame class Board(pygame.sprite.Sprite): def __init__(self, screenWidth, screenHeight, squareSize): super(Board, self).__init__() self.surf = pygame.Surface((screenWidth, screenHeight)) # size[number of rows, number of columns] size = [screenWidth//squareSize, scr...
d9ea8870d906fb16fe86c17840b78c1b497f55f7
Levber/python-base
/base/001if循环.py
1,237
4.0625
4
''' 猜拳游戏案例 1.出拳 电脑:固定 1,剪刀;随机2 2.判断输赢 1.玩家获胜 2.平局 3.电脑获胜 ''' # 电脑随机出拳 import random player = int(input("请输入数字代表出拳:0-石头,1-剪刀,2-布")) computer = random.randint(0, 2) print(computer) if ((player == 0) and (computer == 1)) or ((player == 1) and (computer == 2)) or ( (player == 2) and (computer == 0)...
3045bde899d21f70decca35a0951107df53ad5be
Aurora-yuan/Leetcode_Python3
/1071 字符串的最大公因子/1071 字符串的最大公因子.py
925
3.59375
4
#label: string difficulty: easy """ 思路: 题目需要求同时满足两个条件的字符串,那就把分别满足一个条件的字符串找出来, 然后取交集,返回长度最长的那个即可。 """ class Solution: def gcdOfStrings(self, str1: str, str2: str) -> str: l1,l2 = len(str1), len(str2) set1, set2 = set(), set() for i in range(l1+1): if self.find(str1, str1[:i]):...
f2ff85065c4b7cc08679c1cf1d211a182e9d30a1
kaiocesar/Listasexerciciosppz
/lista_2/exercicio_4.py
591
3.9375
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- """ Author: Kaio Cesar Exercicio 4 - Lista de exercicios 2 (Curso Python para Zumbis) Faça um Programa que leia três números e mostre o maior deles. """ def maior_numer(): a=float(raw_input('Digite um valor para A? ')) b=float(raw_input('Digite um val...
a1c602a6e16c9a69d94a8f9c1bc1e85c91f8790f
zavr1k/python-project-lvl1
/brain_games/games/calc.py
447
3.796875
4
from random import randrange, choice from operator import sub, add, mul DESCRIPTION = "What is the result of the expression?" OPERATIONS = { '+': add, '-': sub, '*': mul, } def prepare_round(): number1 = randrange(99) number2 = randrange(99) operator = choice(list(OPERATIONS.keys())) que...
994f58bf00635d60e8dfb614f6c599d1e8f32d31
LariDG/Cahn_Hilliad
/Poisson_Mag.py
3,094
4.15625
4
""" Modelling and Visualisation in Physics Checkpoint 3: PDEs Class to initialise 3D potential and magnetic fields of a lattice with a wire through the centre. Done so based on Poisson statistics. Author: L. Dorman-Gajic """ import numpy as np import random import matplotlib.pyplot as plt import matplotlib.animation a...
515d5b9ca5e3fd9947ac4c4de05a326c4b5e9d8a
joseangel-sc/CodeFights
/Arcade/LabOfTransformations/HigherVersion.py
1,222
3.703125
4
'''Given two version strings composed of several non-negative decimal fields separated by periods ("."), both strings contain equal number of numeric fields. Return true if the first version is higher than the second version and false otherwise. The syntax follows the regular semver ordering rules: 1.0.5 < 1.1.0 < 1....
78c3560a52578df150526ab61123bf01b44fd776
ArianaMikel/CSE
/notes/Ariana Mikel- Validator.py
1,888
4.03125
4
import csv # Drop the last digit from the number. The last digit is what we want to check against # Reverse the numbers # Multiply the digits in odd positions (1, 3, 5, etc.) by 2 and subtract 9 to all any result higher than 9 # Add all the numbers together # The check digit (the last number of the card) is the amount ...
08972516d1c3d75980b8fa48bcf236dd5bed23cd
BlakeBeyond/python-onsite
/week_02/07_conditionals_loops/Exercise_06.py
183
4.25
4
''' Using a "while" loop, find the sum of numbers from 1-100. Print the sum to the console. ''' sum_num = 0 num = 1 while num <= 100: sum_num +=num num += 1 print (sum_num)
70e1981f6c1e8f96cb1f8f3dce951d901c3962fb
sgwon96/codingTestPython
/codeUp100/81~100/87.py
157
3.640625
4
n = int(input()) for i in range(1,n+1): if i%3 == 0 : continue print(i,end=" ") # 6087 : [기초-종합] 3의 배수는 통과(설명)(py)
b74559c419417be90e4f5ab07a64ef6739d583ee
cs-cordero/interview-prep
/leetcode/0543_diameter_of_binary_tree.py
611
3.5625
4
from typing import Optional class TreeNode: # Provided by Leetcode ... class Solution: def diameterOfBinaryTree(self, root: TreeNode) -> int: if not root: return 0 longest = float("-inf") def helper(node: Optional[TreeNode]) -> int: if node is None: ...
c146da67e2db2c5d5633dd3f5a371028bc669b8c
Tearrockster/Prepro---Python
/Sublime pt/000012.5.py
472
4
4
"""[Extra] Cryptography EP.3 - Caesar N Cipher""" def main(): """Main function""" num = int(input()) alphabet = ord(input()) if 65 <= alphabet <= 67 and num > 0: alphabet -= num print(chr(alphabet)) if 68 <= alphabet <= 90 and num > 0: alphabet -= num print(chr(alphab...
08d810b67b998ce5efc1b8213916d8ee49080101
TheWildMonk/password-manager-project
/password.py
1,086
3.65625
4
# Password class import random class Password: def __init__(self): self.letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', ...
312444efad2dcc5d9dbeff620638bfec26162178
953250587/leetcode-python
/LowestCommonAncestorOfABinaryTree_MID_236.py
2,674
4.03125
4
""" Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes v and w as the lowest node in T that has both v and w as descendants (where we allow a node to be a descendant of itse...
b34fe77e92780ebde586e00d3ab9745b5ffb1b59
sfwarnock/python_programming
/chapter 7/exercise 7.8.py
940
3.671875
4
# -*- coding: utf-8 -*- """ Created on Tue May 22 2018 @author: Scott Warnock """ # exercise 7.8.py # # A person eligible to be a US senator if they are at least 30 years old and have been # a US citizen for at least 9 years. To be a US represntative these numbers are 25 # and 7, respectively. Write ...
a6ddcabe0f905887fde121fc0f7700f84ffa6b79
GeekGray-Code/python
/PythonWork/work/w6/整数排序.py
738
3.703125
4
# 输入一个字符串列表,将它转换为数字列表 def strListToIntList(strList): return list(map(int, strList)) # 判断是否为整数 def isInteger(strValue): try: num = int(strValue) if isinstance(num, int): return True except ValueError: return False sequenceList=[] countStr=input() integerFlag=isInteger(c...
a60d1001a18a58c1aa2ce66c79817369d14f9e69
grecoe/teals
/4_advanced/designs/1_typing.py
859
3.84375
4
""" Typing helps your API/SDK users know what they should be expecting to pass and recieve from calling a method. Unlike languages like C#, Java, etc.... Python won't enforce method types. Including typing is just a HINT. A HINT because Python uses duck typing. If it's critical for you...
7927aace6b8037445bd904f9be3d758fbcf82af1
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_6_Dictionaries/7-1.RentalCars.py
198
3.828125
4
car = raw_input("What kind of rental car would you like? " + "\nIf you do not want any car , enter 'quit'. ") if car != 'quit': print("Let me see if i can find a " + car.title() + ".")
25cbee5e4b0ea15da9799d8406b7519e63bd2c3f
rwang4/Snake
/inheritance_in_list.py
112
3.578125
4
class A: def __init__(self, v): self.v = v v = 0 a = A(v) for i in range(0, 5): a.v += 5 print(a.v)
bc22594475e78d77c59d944a199e32281c896edd
JayceCaiUMD/XCumd
/学习/DataCleaningchar7.2_movies.py
666
3.53125
4
import pandas as pd import numpy as np # 处理movies数据 分类变量(categorical) # DataFrame中的某行属于 多重分类 mnames = ['movie_id', 'title', 'genres'] movies = pd.read_csv('datasets/movielens/movies.dat', sep='::', header=None, names=mnames) print(movies.head(10)) #取出所有genre的集合 all_genres= [...
97a0c53c8e6c3bb843118982f306cbe0474fb422
Andr-Malcev/SP
/Lab 5/4.1 Средний уровент.py
250
3.65625
4
import random R = 3 listA = [] for i in range(10): listA.append(round(random.random()*10-5, 2)) print('Исходный массив: ', listA) print('Наиболее удаленный элемент: ', (max(listA, key=lambda x: abs(R-x))))
4146378b69e15199c65ed119dedd5c81f7344283
JisooBrianKim1/CompletePythonMastery
/functional_programming/comprehensions.py
594
3.625
4
#list, set, dictionary # my_list = [param for param in iterable] my_list = [char for char in 'hello'] my_list2 = [num for num in range(0, 100)] my_list3 = [num ** 2 for num in range(0, 100)] my_list4 = [num for num in range(0, 100) if num % 2 == 0] # print(my_list) # print(my_list2) # print(my_list3) # print(my_list4)...
3c86348581cfedff5b161c452dc9d6dc4a2fc08a
killbug2004/Snippets
/Algorithm/algorithm/2stackqueue/client.py
648
3.796875
4
from queue import Queue; if __name__ == "__main__": queue = Queue(); queue.enqueue(1); queue.enqueue(2); queue.enqueue(3); queue.enqueue(4); queue.enqueue(5); queue.enqueue(6); queue.show(); print "====================="; print "pop", queue.dequeue(); queue.show(); print "====================="; print "po...
6fbc4852aaa0c3478e97ec3ea407d1c7470985d1
LiXiaofeng-712/-
/Tedu/python/day06/math_game.py
632
3.65625
4
#coding:utf-8 import random def exam(): nums = [random.randint(1,100) for i in range(2)] nums.sort(reverse=True) op = random.choice('+-') if op in '+': result = nums[0] + nums[1] else: result = nums[0] - nums[1] prompt = '%s %s %s = ' %(nums[0],op,nums[1]) answer = int(input...
958f4f37c15cffb9bdf2dff4615a0272ae4578e5
cs-richardson/whosaiditpart1-2-hnguyen21
/whosaidit.py
2,868
4.15625
4
''' The code takes a text as an input. It takes the file name of a text file, reads it and creates a dictionary of unique words. It keeps count of the frequency of each unique word. Then, it creates a score based on how similar the frequency of words appear in each dictionary compared with the user input text. Then it ...
675ee7e6b3c1f2778cb39a2756985e1404af82c4
AndrewMonteith/Programming-Problems
/missing_words.py
1,688
3.9375
4
''' Problem: Missing Words Given 2 sequences s and t, t is a subsequence of s if the words of t occur in s not necessarily in a contiguos sequence but in the same order. "hi there" is a subsequence of "hi there friend" "hi there" is a subsequence of "hi over there friend" "hi there" is a subse...
8846466ad4edb258a0ca0f80dfa791b9fe363c98
chvjak/hr-practice
/inside_poly.py
999
3.5
4
f = open('inside_poly1.txt') def input(): return f.readline() import sys from math import acos, sqrt def pt2normvec(pt0, pt1): x0, y0 = pt0 x1, y1 = pt1 vec1 = [x1 - x0, y1 - y0] v1_norm = sqrt(vec1[0] * vec1[0] + vec1[1] * vec1[1]) vec1[0] /= v1_norm vec1[1] /= v1_norm return vec...
2a0fbe25deb2eed8e67c8ef56b886bbdcf535644
phuwadonop/QueueLab
/Queue.py
1,323
3.859375
4
from collections import deque class Queue : def __init__(self,items = None): if items == None : self.items = deque() else : self.items = deque(items,len(items)) def enQueue(self,i) : self.items.append(i) def deQueue(self) : return self.items.popleft() ...
e6a93233d33af735196d992780e03411924bed03
kuboszek/instruments
/user.py
770
3.609375
4
class User: def __init__(self, nick, avatar, password): self.nick = nick self.avatar = avatar self.rank = 0 self.password = password self.users = [] self.instruments = [] def addFriend(self, user): self.users.append(user) def findFriend(self, nick): ...
caeb47ac3ccfef7816ca2c0d2f97a02c3ad62818
raiscreative/100-days-of-python-code
/day_005/high_score.py
278
4.03125
4
score_list = input('Please enter the list of all students\' score\n') scores = score_list.split() high_score = -100 for score in scores: score = int(score) if score > high_score: high_score = score print(f'The highest score in the class is {high_score}.')
2f132ce7b880a1295325d4ce60d8d09240cb945c
barisceliker1/PYTHON
/whiledöngüsü5.py
364
3.640625
4
gunlukuretim=200 defoluurun=int(input("defolu üürün sayısı giriniz")) kacgunluk=gunlukuretim/defoluurun i=0 while True: i=i+1 if defoluurun>gunlukuretim/100*20: print("defolu ürün miktarınız çok artmıştır") else: print("1 günde üretilen",gunlukuretim,"pantolondan",defoluurun,"tanesi...
48aa9bf025676597e6630ad44e21b34123832d81
devesh37/HackerRankProblems
/Datastructure_HackerRank/Linked List/InsertaNodeAtaSpecificPositionInaLinkedList.py
1,468
3.953125
4
#!/bin/python3 import math import os import random import re import sys class SinglyLinkedListNode: def __init__(self, node_data): self.data = node_data self.next = None class SinglyLinkedList: def __init__(self): self.head = None self.tail = None def insert_node(self, no...
209e192e16194bdcc60e55bc21e7e7a11e18d3d1
NikhilRaghav/Lets-Upgrade-Youtube-Courses
/Data Structure and Algorithm with Python Batch 2 - FEB LetsUpgrade Toutube Pgm/Assignments/Assignment_1_Solution-Ques_1_and_2.py
337
4.15625
4
a=int(input("Enter a number")) b=int(input("Enter another Number ")) #Question 1 print("Addition of two Numbers is ",a+b) print("Subtration of two Numbers is ",a-b) print("Multiplication of two Numbers is ",a*b) print("Division of two Numbers is ",a/b) print("Floor Division of two Numbers is ", a//b) #Question 2 print...
da255daa79c4f468d79e6081d79f2739dd50a406
C-CCM-TC1028-102-2113/tarea-4-A01026608
/assignments/06PromedioConDecision/src/exercise.py
294
3.921875
4
def main(): #escribe tu código abajo de esta línea contador= 0 suma= 0 numero=1 while True: numero= float(input()) if numero<0: break suma= suma+numero contador= contador+1 promedio= suma/contador print( promedio)
ee4b9d815c120fa76678e3fa20b64d0bca78c263
anth7310/Minimax-Tic-Tac-Toe-Python
/minimax.py
4,444
3.890625
4
def checkWinner(board): """ Returns true if winner exist """ states = [ [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5 ,8], [0, 4, 8], [2, 4, 6] ] # flatten board flat_board = [] ...
53d554b118c476038ec15f84af5827cc4353bb02
Fouad-Karam/Python-TurtleCrossing
/main.py
898
3.703125
4
from turtle import Turtle, Screen from player import Player from scoreboard import Scoreboard from cars import Cars import time screen = Screen() screen.setup(width=800, height=600) screen.bgcolor("white") screen.title("TurtleCrossing") screen.tracer(0) player = Player() scoreboard = Scoreboard() new_ca...
d0bea0e62d332e8d28fe606c47f3b091bedb42a7
neoxie/geektime_python
/21_multithread/homework.py
814
3.765625
4
import time import concurrent.futures import threading import multiprocessing def cpu_bound(number): print(sum(i * i for i in range(number))) def calculate_sums(numbers): # for number in numbers: #1 single thread # cpu_bound(number) #1 single thread # with concurrent.futures.ProcessPoolExecutor...
7d15bba70d093b04781e396e07309f8d9aa9ab54
katariasid565/band-generator
/main.py
366
3.53125
4
# ------------------------------------------ print("Welcome to the band Generator..!!") # ------------------------------------------ city = input("what's name of the city you grow up in?\n") # ------------------------------------------ pet = input("what's your pet name?\n") # ------------------------------------------...
9472eb6f69d316dd1da1adb972fa9899662c3e35
Hu-sky/Advance
/Learning Record/3.4 学习记录.py
1,176
3.703125
4
# 1.from datetime import datetime 或import datetime.datetime # 2.获取当前时间:datetime.now() # 指定时间:dt=datetime(2020, 5, 12 ,9, 45) >>> 200-05-12 09:45:00 # 3.epch time记为0,1970-01-01 00:00:00 UTC+00:00时区时刻 # 4.转换:datetime(time).timestamp() >>> 秒.毫秒 class<float> # 5.本地时间:datetime.fromtimestamp(距离epch time秒) # 格林威治时间:dateti...
8ba19ee0a4811e3f73a66d95e82614ac2b553973
weifengli001/pythondev
/vendingmachine/test.py
2,787
4.28125
4
""" CPSC-442X Python Programming Assignment 1: Vending Machine Author: Weifeng Li UBID: 984558 """ #Global varable paid_amount = 0.0#The total amount of insert coins total = 0 #The total costs change = 0 # change drinks = {"Water" : 1, "Soda" : 1.5, "Juice" : 3} # The drinks dictionary stores drinks and their price sn...
cd97e9b2fbc8ec1fcdb65f8910370af463920652
herasj/Constructor_Imagenes
/list_ops.py
6,018
3.578125
4
import copy import numpy as np def sumar_subl(l,h): #Sumar los valores de cada sublista newl=[] temp=0 for x in range(0,4): for y in range(0,h): temp=temp+l[x][y] newl.append(copy.deepcopy(temp)) temp=0 return newl def restar_l(l1,l2,h): #Restar dos listas de bordes...
a024492e898a17c1c0beb3b1dc6f02c2ff5e5b33
xysey/python100
/P20.py
353
3.796875
4
''' Question 20 Level 3 Question: Define a class with a generator which can iterate the numbers, which are divisible by 7, between a given range 0 and n. Hints: Consider use yield ''' def gen_seven(r): i = 0 while i < r: ri = i i = i + 1 if ri % 7 == 0: yield ri for num ...
acbeffd870b4682008e3b1cc10fd790f35225b0b
ebrahimsalehi1/python_codes
/day181020_graphic.py
606
3.75
4
import turtle import time pos = 20 turtle.speed(1) turtle.goto(1,1) #turtle.sety(10) for i in range(1,41): turtle.forward(50) turtle.left(90) if i == 1: turtle.color("red") elif i == 2: turtle.color("green") elif i == 3: turtle.color("brown") elif i == 4: turtle.color("black") ...
53ce049b13811b428bb84d04ec7ba3eef6357705
Aasthaengg/IBMdataset
/Python_codes/p03293/s393886000.py
173
3.671875
4
s = input() t = input() flag = False for i in range(len(s)): if s == t: flag =True s = s[-1] + s[0:len(s)-1] if flag: print("Yes") else: print("No")
16d327fe9c580c23480d803b0b6f21a0e778db06
UCSD-CSE-SPIS-2021/spis21-lab03-Jeremy-Raj
/lab03Warmup_Jeremy.py
590
4.34375
4
import turtle def draw_picture(the_turtle): ''' Draw a simple picture using a turtle ''' the_turtle.forward(20) the_turtle.left(40) the_turtle.forward(100) the_turtle.left(90) the_turtle.forward(100) the_turtle.left(90) the_turtle.forward(100) the_turtle.left(90) my_turtle = tu...
7b1783ca0f41176fc39b177b461975abeea283b3
EduLH/Python
/fibo.py
212
3.640625
4
import time start = time.time() def fib(n): a,b = 1,1 for i in range(n-1): a,b = b,a+b return a print (fib(894651)) end = time.time() elapsed = end - start print ("tempo percorrido de:") print (elapsed)
b561a95c27b1f45823d9fb84b0d75291cb596873
Edwincamilo/ejercicios-elaborados-2
/prg 16 funciones.py
1,107
3.734375
4
# -*- coding: utf-8 -*- """ Created on Tue Mar 16 18:59:05 2021 @author: 57314 """ #factura a pagar def f_titulo(): print("calculo valor factura") def f_despedida(): print("gracias por su compra") def f_valorfactura(): #encabezado de la funcion #desarollo de la funcion...
71c9db7ef4573085a5741898b36ae53a69ff9938
Benjamin-Huang910/naughty-cat
/程式概論/week14_ex1.py
942
4.1875
4
#Programming 101 #week14 #ex 1 #可以幫忙檢查傳入的參數num是否可成功轉換成浮點數資料型態的自訂函數 #回傳值:True 代表可以成功轉成浮點數 #回傳值:False 代表無法成功轉成浮點數 #請注意:在此函數中會使用到一個區域變數的名稱為result def check_float(num): try: float(num) except: #有發生例外時,將變數result的內容設為False else: #沒有發生例外時,將變數result的...
85cfe14767dc56c896fa60e1a2fee86234e59619
Factumpro/HackerRank
/Python/Practice/Basic Data Types/runner_up.py
271
3.734375
4
#!/usr/bin/env python3 SECOND_PLACE = 1 if __name__ == '__main__': _ = int(input()) runner_scores = list(set(map(int, input().strip().split(" ")))) # [max, ... , min] -> 0, ... , n runner_scores.sort(reverse=True) print(runner_scores[SECOND_PLACE])
782999e012f515689eb9b938beb9e995acd6fc40
Manju9072/pythonpractise
/tic.py
320
4.03125
4
def tictactoeboard(size, col): for e in range(size): print(' ---' * col) print(('|' + " " * 3) * (int(col) + 1)) print(' ---' * col) print("Welcome to tic tac toe!!!!") size = int(input("Enter the row board size:")) col = int(input("Enter the column board size:")) tictactoeboard(size, col)
d74c4aa9303e41cc42b8c21679d409bc7efef382
SergioMD15/LinkedList-Sorting
/Main.py
423
3.65625
4
import math import random from LinkedList import LinkedList from sorting.Criteria import Criteria from sorting.Tuples import Tuples from sorting.Centering import Centering def generate_array(size): result = LinkedList() for i in range(size): result.push(int(random.randint(0,1))) return result l = ...
2d129fc9da8e05a43dee426aeb5253b074d6aac6
humat/Python-built-in-functions
/even odd.py
111
4.0625
4
x=int(input("Enter a nuber")) if x%2==0: print(x,"Is even number") else: print(x,"Is odd number")
72948250db04881da120132f3e04d20be0ad4aea
league-python-student/level0-module1-DemirKaya7
/_05_for_loops/_2_badgers/badgers.py
183
3.984375
4
for i in range(2): str1 = "" for i in range(12): str1 = str1 + "Badger, " for i in range(2): str1 = str1 + "Mushroom, " print(str1) print("A snake!!!")
8b4293e7bd7c490645188da8ccd676d0da4a97e4
GerardProsper/Intermediate-Python-Programming-Course
/Function Arguments.py
3,045
3.765625
4
# difference between arguements and parameters def print_name(name): # name here is parameter print(name) print_name('Gerard') # Gerard here is arguments def fool(a,b,c): print(a,b,c) fool(1,2,3) fool(a=1,c=3,b=2) # this is keyword arguments. order doesnt matter fool(2, b=3, c=5) # this would ...
e2f5c754d64e8066c3669423f9066db332b4f831
Cbkhare/Codes
/GeekForGeeks_DetectLoopInLinkedLIst.py
257
3.65625
4
def detectLoop(head): while head: if head.data=='visited': return 1 else: head.data = 'visited' head=head.next return 0 ''' https://practice.geeksforgeeks.org/problems/detect-loop-in-linked-list/1 '''
35b47821f6e335aaef19687549c1f3f7a809f8b0
jsdelivrbot/Ylwoi
/week03/day_3/purple_steps.py
394
3.859375
4
__author__ = 'ylwoi' from tkinter import * root = Tk() canvas = Canvas(root, width='300', height='300') canvas.pack() # reproduce this: # [https://github.com/greenfox-academy/teaching-materials/blob/master/exercises/drawing/purple-steps/r3.png] x = 10 y = 10 for i in range(20): square = canvas.create_rectangle(...
22fedd57d89b3dedf3784b8a97bac7702480af8d
igijon/sge2021_python
/Ejercicios recuperación/examen_ghibli/Character.py
1,672
3.71875
4
class Character(): def __init__(self, name, gender = None, age = None, film = None, specie = None): self.name = name self.gender = gender self.age = age self.film = film self.specie = specie @property def name(self): return self.__name @property ...
ae40a0301bcf9785e4ab98e0b02044c888854f12
cold-pumpkin/FC-Algorithms
/problems/section1/7490.0_만들기.py
930
3.671875
4
# 7490. 0 만들기 import copy # 연산자 배열 채우기 def recursive(arr, n): if len(arr) == n: operators_list.append(copy.deepcopy(arr)) return # 1) 공백 arr.append(' ') recursive(arr, n) arr.pop() # 연산자 조합 길이가 n인 경우 하나 빼기 # 2) 덧셈 arr.append('+') recursive(arr, n) arr.pop() #...
a662a3dbc476610bba4242e7609e59bd3a5856d7
mjmccollister/ALGS200x
/MaximumPairwiseProduct.py3
216
3.703125
4
# Uses python3 n = int(input()) a = [int(x) for x in input().split()] largest_integer = max(a) a.remove(largest_integer) second_largest_integer = max(a) result = largest_integer * second_largest_integer print(result)
8d28ef16fdae0a812f34a4e6123f61bce76dbe0c
The-Jay-M/CODE-NOUN
/python-jerry/lottery.py
412
3.65625
4
from random import randint doNotPick= [] while (len(doNotPick) < 6): generate= randint(1, 37) if (generate in doNotPick): pass else: doNotPick.append(generate) #To print out values from the doNotPickList we need an index. #Indexing starts from 0. print(doNotPick[0]) print(doNotPi...
e2915d6ec52d4bf7bf4c7f2e1ca8cf38c635441a
t1610427/100knock
/chapter1/1syou01.py
171
3.5
4
target="パタトクカシーー" ans='' ans += target[0] #1文字目を連結 ans += target[2] ans += target[4] ans += target[6] print("answer:{}".format(ans))
b535e91bdbf1e5a4c68ff4358a6c04982ac72f0c
BDafflon/adventofcode2019
/day3/main.py
1,009
3.671875
4
def calc_points_with_steps(path): curx = cury = step = 0 directions = {'R': (1,0), 'L': (-1,0), 'U': (0,1), 'D': (0,-1)} points = {} for segment in path: dx, dy = directions[segment[0]] for _ in range(int(segment[1:])): curx += dx cury += dy step +=...
18be460d78a4a7177852a40e463d53a7be0c8dfb
miraceti/Python_script
/CodingPrivacy2.py
486
3.6875
4
import tkinter as tk import PIL from PIL import Image, ImageTk root =tk.Tk() root.title("resize image in label") root.geometry("300x150") #1rst approach photo = tk.PhotoImage(file="mando2.png") #2nd approach photo2 = Image.open("mando2.png") resized_image = photo2.resize((300,150), Image.ANTIALIAS) converted_image =...
2e8c15faf3495b5925dadbefd311e30faaa79194
xiaohuanlin/Algorithms
/Leetcode/1775. Equal Sum Arrays With Minimum Number of Operations.py
3,283
4.40625
4
''' You are given two arrays of integers nums1 and nums2, possibly of different lengths. The values in the arrays are between 1 and 6, inclusive. In one operation, you can change any integer's value in any of the arrays to any value between 1 and 6, inclusive. Return the minimum number of operations required to make ...
92a92f854c64f234fd322eaa4d7d1ee3c60dcd35
abaah17/Programming1-examples
/w3s1_pick_your_flag.py
1,938
3.890625
4
# Basic example for keyboard control. 3 keys are linked to 3 functions, each function draws a flag from aluLib import * window_width = 1500 window_height = 900 # These functions are the same as the solution def benin(): left_rectangle_width = window_width / 3 right_rectangle_height = window_height / 2 s...
152b34f3f9419e16112b70f6c2a1274f146e9791
amanda-pullan/COSC367-Artificial-Intelligence
/Labs/11 Games/alpha_beta.py
1,905
3.78125
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 14 20:01:21 2020 @author: Amanda """ from math import inf def max_value(tree, alpha, beta): """Given a game tree, returns the utility of the root of the tree when the root is a max node.""" if type(tree) is int: return tree v = -inf for x in...
cfccc5ac37858b6c2e4af5940860600517204d4d
v-sukt/misc_code
/pycode2/ex44c.py
523
4.34375
4
#!/usr/bin/env python2.7 """This example is to demonstrate the inheritance - using parent's behaviour After/before changed child's behaviour Internally calls tha parent function uspng super()""" class Parent(object): def altered(self): print "Parent's altered()" class Child(Parent): def altered(self...
43251bc844c701e640866b166aa62235285ec8b4
kiwi-33/Programming_1_practicals
/p4-5/p5p4.py
655
4.25
4
number = int(input("Enter a number: ")) if number =0: print ("Number is equal to 0") elif 0<number>=20: print ("Number is greater than 0 and less than or equal to 20") elif 20<number>= 40: print ("Number is greater than 20 and less than or equal to 40") elif 40<number>= 60: print ("Number is gre...
ddc4a671b5ab10d19c8c64702324c99dd9d9575e
smilezjw/LeetCode
/P01_Two Sum/TwoSum.py
1,359
3.609375
4
# _*_ coding:utf8 _*_ __author__ = 'smilezjw' def twoSum(num, target): #首先是我自己的写法。。弱爆了 # for n1 in num: # for n2 in num: # if n1 + n2 == target: # index1 = num.index(n1) # index2 = num.index(n2) # found = True # if found is True: # ...
029229b707e7245c99049523dcfd845e2ea33a14
deepakcr26/2017_02_PHILIPS_PYTHON
/Examples/ex12.py
712
3.515625
4
class Phone(object): def __init__(self): print("Constructing the Phone object...") def info(self): print("Currently no info available in Phone class") class Camera(object): def take_photo(self): print("click click click..") def take_photo_with_flash(self): print("Ligh...
82eea78112abad83f606572256cc106ea9bdf0d0
Tenebrar/codebase
/hacker/util.py
730
3.84375
4
def x_max(iterable, amount=1, key=None): """ Returns the largest items in the input :param iterable: An iterable :param amount: The amount of results :param key: The key with which to compare items :return: An iterable containing the 'amount' largest items in the 'iterable' """ return s...
c35a8a6a1d387bd6cb58116c5d7b4c59f9e980d4
jankovicgd/gisalgorithms
/kd_tree/test.py
383
4.0625
4
# 1.1 Computational concerns for algorithms # Listing 1.3: Binary search to find point p0 in a tree # Import from kd_node from kd_node import * # Define points pts =[Point(6,7), Point(4,6), Point(9,4), Point(2,3), Point(3,7), Point(7,4), Point(9,6)] print(str(pts)) root = kd_node(p=pts[0]) kd_tree = kd_tree(root) f...
3cae0c98b4241809dc85082969c570711b951220
sudhirmd005/PYTHON-excerise-files-
/dec_with_para.py
771
3.78125
4
# This is the example of decorators with parameter import time def deccorator_parameter(*args, **kwargs): begin = time.time() print(" this is the inital start of the decorator parameter") def inside(argu): # defining the wrapper function inside the decorator function print(" this is begining o...
8ecd5cc616ca257aa7c16e4aacbe638d1bab7479
stebbinscp/Example-Class-Work
/Chicago_Schools_cvs.py
4,301
3.5
4
from math import asin, sin, cos, sqrt, radians, degrees import csv from webbrowser import open_new_tab EARTH_RADIUS = 3961 class School: def __init__(self, data): self.id = data.get("School_ID") self.name = data.get("Short_Name") self.network = data.get("Network") self.address = dat...
90a7cddaa492df26fbac0ef47f1980e16f99b2ff
zhaocheng1996/pyproject
/algorithm_test/saima/股神.py
799
4.09375
4
''' 有股神吗? 有,小赛就是! 经过严密的计算,小赛买了一支股票,他知道从他买股票的那天开始,股票会有以下变化:第一天不变,以后涨一天,跌一天,涨两天,跌一天,涨三天,跌一天...依此类推。 为方便计算,假设每次涨和跌皆为1,股票初始单价也为1,请计算买股票的第n天每股股票值多少钱? 输入 输入包括多组数据; 每行输入一个n,1<=n<=10^9 。 样例输入 1 2 3 4 5 输出 请输出他每股股票多少钱,对于每组数据,输出一行。 样例输出 1 2 1 2 3 ''' while 1 : x =int(input()) k = 3 n = 3 while x-k>=n: n+...
0ee290372503fc1aa25aba4471d8d40dcbc525c6
monkeylyf/interviewjam
/str/leetcode_Word_Pattern.py
1,469
3.9375
4
"""Word pattern leetcode Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str. Examples: pattern = "abba", str = "dog cat cat dog" should return true. pattern = "abba", str = "do...
2b4036f84c1cbe177a97e3a749a4e5e66b09b0fb
Tarun4444/Algorithms
/merge_overlapping_interval.py
312
3.765625
4
def merge(A): B=[] A.sort(key=lambda x:x[0]) B.append(A[0]) for i in range(1,len(A)): if A[i][0] > B[-1][1]: B.append([ A[i][0],A[i][1] ]) elif B[-1][1] < A[i][1]: B[-1][1]=A[i][1] print(B) merge( [ (1, 10), (2, 9), (3, 8), (4, 7), (5, 6), (6, 6) ])
e5df21812c6c5107ce39ea43d4221dab17d66ca8
ghldbssla/Python
/개념 배우기/day06/Comprehention.py
388
3.765625
4
#comprehention.py #0~9가 담긴 리스트 #arData=[i for i in range(10)] #print(arData) #1~1000중 짝수만 담긴 리스트 #arData=[i for i in range(1,1000,1) if i%2==0] #print(arData) #(1,2),(1,4),(1,6),(2,2),(2,4),(2,6),(3,2),(3,4),(3,6)--1 #arData=[(i,j) for i in range(1,4,1) for j in range(2,8,2)] #print(arData) #arData=[(i//3+1,(i%3+1)...