blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
50826a332fbbbe9f3cae4ab168bda200dd8184e6
libo-sober/LearnPython
/day13/datetime_demo.py
1,905
4.25
4
""" datetime:日期时间模块 封装了一些和日期时间相关的类 date time datetime timedelta """ import datetime # # date类: # d = datetime.date(2010, 10, 10) # print(d) # 2010-10-10 # # 获取date对象的各个属性 # print(d.year, d.month, d.day) # 2010 10 10 # # # # time类: # t = datetime.time(10, 48, 59) # print(t) # 10:48:59 # print(t.hour, t.minute, t.se...
96c5e935ffd34aa174b4bfd7bb35a35b3a44c463
balloonio/algorithms
/lintcode/dynamic_programming/515_paint_house.py
889
3.6875
4
class Solution: """ @param costs: n x 3 cost matrix @return: An integer, the minimum cost to paint all houses """ def minCost(self, costs): # write your code here if not costs: return 0 n = len(costs) COLORS = 3 # f[i][j] - the lowest cost to bui...
f84abb747a2072f84153e756bbcb1011c4767b0b
GekkouRoid/PycharmProject
/dicetest.py
440
3.734375
4
# Exercise of 9-14 import random class Dice: def __init__(self, sides=6): self.sides = sides def roll_dice(self): x = random.randint(1, self.sides) # print(x) return x dice1 = Dice() dice1.roll_dice() dice2 = Dice(10) seq2 = [] for i in range(10): seq2.append(dice2.ro...
c6214cfbdfd8b68ecb99f7c3b8efab9942bf6014
AbnerZhu/notebook
/00StudyNote/00Technology/01Program-Language/04Python/workspace/chinahoop/decorator/deco1.py
266
3.546875
4
#!/usr/bin/env python # coding:utf-8 # 计算平方和 def square_sum(a, b): print("input: ", a, b) return a ** 2 + b ** 2 # 计算平方差 def square_diff(a, b): print("input: ", a, b) return a ** 2 - b ** 2 print(square_sum(3, 4)) print(square_diff(3, 4))
671fc9412ba99d2c5352fed409be5e54eeeec78d
c-nino-a/UP-ACM-entries
/A.riceofskywalker.py
523
3.59375
4
#!/usr/bin/env pypy import timeit def main(): r=int(input()) w=int(input()) standard=1/3 actual=r/w # if(actual!=standard): # if(actual>standard): # print("WE NEED MORE WATER.") # else: # print("WE NEED MORE RICE.") # else: # print("...
d394d68e203a5dafc2cdbff28951abaca27d3ae3
qmnguyenw/python_py4e
/geeksforgeeks/python/python_all/53_4.py
3,251
4.3125
4
Python – Sort dictionary by Tuple Key Product Given dictionary with tuple keys, sort dictionary items by tuple product of keys. > **Input** : test_dict = {(2, 3) : 3, (6, 3) : 9, (8, 4): 10, (10, 4): 12} > **Output** : {(2, 3) : 3, (6, 3) : 9, (8, 4): 10, (10, 4): 12} > **Explanation** : 6 < 18 < 32...
d4861013c871948c798b48b3841fc54cee42232d
matt-leach/strava-similarity
/utils.py
864
3.578125
4
import math from constants import EARTH_RADIUS def dist(p1, p2): ''' calculates distance from coordinates p1 and p2 ''' # both array lat, lng dlat = p1[0] - p2[0] dlon = p2[1] - p2[1] a = math.sin(dlat / 2)**2 + math.cos(p1[0]) * math.cos(p2[0]) * math.sin(dlon / 2)**2 c = 2 * math.atan2(ma...
41c96a267f3dc5709faca99ed059f0d3528d1110
lihujun101/LeetCode
/Tree/L559_maximum-depth-of-n-ary-tree.py
642
3.71875
4
# Definition for a Node. class Node(object): def __init__(self, val, children): self.val = val self.children = children class Solution(object): def maxDepth(self, root): """ :type root: Node :rtype: int """ if root is None: return 0 #...
98bce2338962dc243e8a4457b80f22214be087c9
luisfmelo/hacker-rank-exercises
/hacker-rank/implementation/1-extra-long-factorials.py
665
3.71875
4
#!/bin/python3 def extra_long_factorial(n): if n < 0 or type(n).__name__ != 'int': raise ValueError('Not a valid input') if n <= 1: return n return n * extra_long_factorial( n - 1) def main(): n = int(input().strip()) res = extra_long_factorial(n) print(res) def test(n, ex...
5c5f09bdd5fd2b0ba9673e88a577339d93166a7b
joshlaplante/TTA-Course-Work
/Python Drills/Python in a Day 2/part 3 - sqlite intro.py
1,604
4.40625
4
import sqlite3 #connect to database 'simpsons.db' conn = sqlite3.connect('simpsons.db') ##Create table named simpson_info (commented out because table already created) #conn.execute("CREATE TABLE SIMPSON_INFO( \ # ID INTEGER PRIMARY KEY AUTOINCREMENT, \ # NAME TEXT, \ # GENDER TEXT, \ # AGE INT, \ # OC...
56f2340e198edc219f939be23421a0138a8a1dc9
leemingee/CoolStuff
/NN/ecbm4040/features/pca.py
1,166
3.75
4
import time import numpy as np def pca_naive(X, K): """ PCA -- naive version Inputs: - X: (float) A numpy array of shape (N, D) where N is the number of samples, D is the number of features - K: (int) indicates the number of features you are going to keep after dimensionality red...
7353865e0b1f731e1ddfb74462653a8708dd13a5
aironm13/Python_Project_git
/Modules_learn/functools_Modules/functools_partial.py
901
4.09375
4
from functools import partial def add(x, y): return x + y # 固定x形参 triple = partial(add, 3) # 只用传入一个参数给y就可以 print(triple(4)) # # Python3.5 # # 源码:使用函数定义 # # def partial(func, *args, **keywords): # def newfunc(*fargs, **fkeywords): # 新的函数 # newkeywords = keywords.copy() # newkeywords.update(f...
4166e92b9d642049b3c01fd35a4b928c54cc1452
b3296/py
/test/filter.py
780
3.859375
4
# -*- coding : utf-8 -*- def _odd_iter(): n = 1 while True : n = n+2 yield n def _not_divisible(n): return lambda x : x % n > 0 def primes(end = 100): yield 2 it = _odd_iter() flag = True while flag: n = next(it) if n > end: flag =False yield n it = filter(_not_divisible(n), it) def divisible(num...
64cf5ba928051f85af746404c8d39bbda954c75b
DJSiddharthVader/PycharmProjects
/PythonPractice/bulls.py
1,530
4.15625
4
''' Randomly generate a 4-digit number. Ask the user to guess a 4-digit number. For every digit that the user guessed correctly in the correct place, they have a “cow”. For every digit the user guessed correctly in the wrong place is a “bull.” Every time the user makes a guess, tell them how many “cows” and “bulls...
02917ff382ada4509f2d1116ce3ef09c338408ec
manishym/algorithms_in_python
/hotpotato.py
446
3.640625
4
#!/usr/local/bin/env python from queue import Queue def hotpotato(names, number): q = Queue() for name in names: q.enqueue(name) while q.size() > 1: for i in range(number): q.enqueue(q.dequeue()) print q.dequeue() + " is out" return q.dequeue() def main(): pri...
34d704d43497bfbd490b80e2003538ffc999e821
BrichtaICS3U/assignment-2-logo-and-action-ahmedm88
/logo.py
1,984
4.25
4
# ICS3U # Assignment 2: Logo # <Ahmed M> # adapted from http://www.101computing.net/getting-started-with-pygame/ # Import the pygame library and initialise the game engine import pygame pygame.init() # Define some colours # Colours are defined using RGB values BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 25...
b3c9ef0e834c5da5c323556af1100aa074605a11
amaner/Udacity-Data-Analysis
/readiness-test/fizzbuzz.py
220
3.796875
4
def fizzbuzz(intList): fizzbuzz = [] for l in intList: value = '' if l%3 == 0: value += "Fizz" if l%5 == 0: value += "Buzz" if l%3 != 0 and l%5 != 0: value = l fizzbuzz.append(value) return fizzbuzz
b1a71b70ffe557491a5978d6bb77f867ace1c52e
TovenBae/study
/python/leetcode/easy/ClimbingStairs.py
883
3.9375
4
import unittest # https://leetcode.com/problems/add-binary/ def climbStairs(n): if (n == 1): return 1 first = 1 second = 2 for i in range(2,n): third = first + second first = second second = third return second class Test(unittest.TestCase): def test(...
2763e5877a8f922ce48ac09df89def174aa4aed8
Sean-Xiao-x/new1
/variable.py
1,070
4
4
#message = 'hello world!' #print(message) #name = 'adA lovelace' ##.title () #print(name.title()) ##.upper() #print(name.upper()) ##.lower() #print(name.lower()) #first_name = 'ada' #last_name = 'lovelace' #space = ' ' #full_name = first_name+space+last_name #print(full_name) #print('hello,'+full_name.title()+'!') #...
b89fe8800a88ae73c81c89c55e0a3632b8b3771e
gitter-badger/python_me
/hackrankoj/collections/word_order.py
789
4.03125
4
#!/usr/bin/python #-*- coding: utf-8 -*- ''' Task You are given words. Some words may repeat. For each word, output its number of occurrences. The output order should correspond with the input order of appearance of the word. See the sample input/output for clarification. Sample Input 4 bcdef abcdefg bcde bcdef Sam...
fa4ac3366e303994b5dcad76bc4c3c07da095619
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/sort/9bc5667f-1abb-4364-9145-30b147188c1a__cb2_5_4_exm_1.py
246
3.78125
4
def _sorted_keys(container, keys, reverse): ''' return list of 'keys' sorted by corresponding values in 'container' ''' aux = [ (container[k], k) for k in keys ] aux.sort() if reverse: aux.reverse() return [k for v, k in aux]
b05db3b68db5cc7d8ae59c01d334b1411322ac8b
MrHamdulay/csc3-capstone
/examples/data/Assignment_9/shrdan007/question2.py
322
3.53125
4
# Text reformatting # Danielle Sher import textwrap x = input("Enter the input filename:\n") y = input("Enter the output filename:\n") z = eval(input("Enter the line width:\n")) a = open(x, "r") b = a.read() lst = textwrap.wrap(b, width = z) string = "\n".join(lst) c = open(y, "w") c.write(string) a.close() c...
ae14bf8c680189652b961a7eaba69e049e1e5a9c
crisortiz92/MicroEconomic-Theory-Programs
/Econ_programs/monopolies.py
1,209
4.09375
4
## Monopolies from sympy import * x1, x2, y, z, p = symbols('x1 x2 y z p') def monopoly(): cost = sympify(input("Enter the cost function c(y): ")) average_cost = simplify((cost/y)) #computes average cost marginal_cost = diff(cost,y) #computes marginal cost print("Average Cost, Ac(y)=",average_cost,'\n') pri...
1cb82527279ebb8b48a6abc6286138459e914a6f
TheoRobin76/Data_Engineering22
/DataEngineering22/OOP.py
4,523
4.03125
4
# # class Dog: # # # Class attribute # # species = "Canis familiaris" # # # # # Instance attributes # # def __init__(self, name, age, cuteness_factor): # # self.name = name # # self.age = age # # self.cuteness_factor = cuteness_factor # # # # # Instance method # # def __s...
1e15625e38c33569f7dd075723f30962fda50e21
AbhishekVasudevMahendrakar/ECE-3year-Code-Challenge
/BHARGAVI4AL17EC061.py
543
3.765625
4
''' Online Python Compiler. Code, Compile, Run and Debug python program online. Write your code in this editor and press "Run" button to execute it. ''' count=0 while count<3: user_name=input("Enter the username: ") password =input("Enter the password:") if user...
d618c107faa4bb7712b3222fb762b8c3041cc140
a-toro/Prueba_Tecnica
/Prueba1.py
5,042
4.0625
4
""" Enunciado Construya un objeto que reciba un arreglo o una matriz de dimensión N el cual contiene números de tipo entero. a. o.dimension -> Devuelve el número entero que define la dimensión del arreglo o matriz en su mayor profundidad. b. o.straight -> Devuelve true o false según el siguiente criterio: -T...
05ab88e763ea514aaa7f4a1532962ab335e9bd02
jonathabsilva/ProgISD20202
/Jonatha/Aula 03/Programas da aula e Exercícios/Exercicio02.py
490
3.828125
4
# EXERCÍCIO 02 - Índice de massa corporal (IMC) - Recebendo dados print('Programa usado para calcular o indice de massa corporal.') peso = float(input('Informe seu peso: ')) altura = float(input('Informe sua altura: ')) print(type(peso)) imc = peso/(altura ** 2) print('Muito abaixo do peso', imc < 17) print('Abaixo d...
242c4c2d7c81d637010ba93b332b0e2d512b9966
anixshi/CS-111-Python-PSETS
/ps01/debugNumsBuggy.py
1,038
3.6875
4
# *** DO NOT EDIT THIS FILE! *** # Bud Lojack's buggy debugNumsBuggy.py for CS111 PS01 Task 1 # Tests involving an integer intNum = raw_input('Enter a nonnegative integer intNum: ') print('The integer you entered is intNum') print 'Three times intNum is', intNum * 3 print intNum, 'concatenated copies of X is', intNum+...
8f2f945034b5c69c20707ce87b947b5db6c587e1
DanaAbbadi/data-structures-and-algorithms-python
/data_structures_and_algorithms/challenges/quick_sort/quick_sort_basic.py
983
4.25
4
def partition(arr,low,high): """ This function takes last element as the pivot, places the pivot element at its correct position where elements on the left are smaller, and all elemnts on the right are larger. """ i = ( low-1 ) pivot = arr[high] for j in range(lo...
0c32182782bd0f48275e3f88c1d775a0df4aa421
takapdayon/atcoder
/abc/AtCoderBeginnerContest069/B.py
178
3.625
4
def i18n(s): count = (len(s) - 2) return str(s[0]) + str(count) + str(s[-1]) def main(): s = str(input()) print(i18n(s)) if __name__ == '__main__': main()
8589758e33f6e4d5ed69313ce753724c65aafa95
chenxi0329/HassleFree
/frequency_sort.py
664
3.75
4
import Queue # import Queue, q = Queue.PriorityQueue() # q.put((a tuple)) q.qsize() q.get() class Solution: def frequencysrot(self, lst): dict = {} q = Queue.PriorityQueue() for str in lst: if str in dict: dict[str] += 1 else: ...
ac87cc0a11ace244bb35ef729f9015d312f485d2
ClaudenirFreitas/learning-python
/exercises/ex006.py
131
3.78125
4
input_number = input('Number: ') number = int(input_number) print(f"Number: {number}. {number * 2}. {number * 3}. {number ** 2} ")
30c94a09e177201634aae76e5c7e032dea9f9865
AP-Skill-Development-Corporation/PythonWorkshop-PaceCollege-Batch-3
/strings.py
1,579
4.375
4
# Strings """ -->Collection of charatcter is called string --->Group of chararcters is called a string -->in python string representation is '' or "" or """""" ---> In python string immutable ---> in python string is indexed value based --->string supports slicing operator--->':' """ #a=''' ''' #print(type(a)) '''...
5b0ce9a43a1c6e2cd2b51b2ac03ee4854dc3389d
alexwang19930101/PythonBase
/基础类型/while和for遍历列表.py
142
3.65625
4
#-*- coding:utf-8 -*- nums = [10,11,12,13,14,15] ''' i = 0 while i<len(nums): print nums[i]; i+=1 ''' for num in nums: print num
677df796c8ea53676715c640b7b0c262a12b1f61
thom145/exercism
/python/acronym/acronym.py
365
4.125
4
import re def abbreviate(words): """ :param words: the word you want the abbreviation of :return: returns the abbreviate as a string """ list_abbreviate = re.split("[, \-!?:]+", words) # split on all given chars abbreviate = [word[0].upper() for word in list_abbreviate] # take the first letter...
9721ce443d54ed1ccf38d56cb88a218972b4d474
xenron/sandbox-github-clone
/qiwsir/algorithm/int_divide.py
417
3.515625
4
#! /usr/bin/env python #encoding:utf-8 """ 将一个整数,分拆为若干整数的和。例如实现: 4=3+1 4=2+2 4=2+1+1 4=1+1+1+1 """ def divide(m,r,out): if(r==0): return True m1=r while m1>0: if(m1<=m): out.append(m1) if(divide(m1,r-m1,out)): print out out.pop() ...
40a6322f8da33d83ddbdad53e54c9ad5d52d243a
saurabhv1/QuesAnsBot
/athenabot/athenabot/utils.py
185
3.765625
4
def is_number(string): if '%' in string: string = string.split('%')[0].strip() try: float(string) return True except ValueError: return False
e9a8b408b2c45417f5fc545b332a09a1ba701915
yesitsreallyme/Robotics
/lab_code/lab10.py
1,823
3.53125
4
import lab10_map import math class Run: def __init__(self, factory): """Constructor. Args: factory (factory.FactoryCreate) """ self.create = factory.create_create() self.time = factory.create_time_helper() self.servo = factory.create_servo() sel...
c30dfd8de5ecd8153fdbcca2ec7183e74c92a1ab
claraj/web-autograder
/grading_module/example_assignments/example_python_assignment/lab_questions/Loop2fun.py
2,015
4.21875
4
""" NOTE Chapter 3 lab (Lab 6) & Homework assignments are redesigns of previous programs, to follow the new IPO structure.​ Use the code from the Loop-2 program from last time You will create functions called main(), inputNumbers(), processing(), and outputAnswer(). The old program and new program will have a simila...
4f760adb3f1077898fb24db99666b49f36e77bc5
NasimKh/Frauenloop_intro_python
/week2/leap_year.py
384
4.03125
4
# leap year def is_leap(year): leap = False if (year % 4 == 0) and (year % 100 != 0): # Note that in your code the condition will be true if it is not.. leap = True elif (year % 100 == 0) and (year % 400 != 0): leap = False elif (year % 400 == 0): # For some reason here you had False tw...
2cd8043da45ae96602bc28770224003f7f656f10
Datrisa/AulasPython
/calculos.py
716
4.03125
4
#calcular duas notas e ter a média nome = input('Qual o seu nome? ') n1 = float(input('Sua nota na Prova 1 foi: ')) n2 = float(input('Coloque também a nota da Prova 2: ')) m = (n1+n2)/2 print(f'{nome}, Sua média na matéria foi: {m}') print('Muito bem!') # ***************** #Dobro, Triplo e raiz quadrada n=int(input...
412f57ee6068181c06e301d01a3d6e5e8915b657
Don-Burns/CMEECourseWork
/Week2/Code/scope.py
2,643
4.375
4
#!/usr/bin/env python3 """ A script looking at how global and local funtions are handled inside and outside functions.""" __author__ = 'Donal Burns (db319@ic.ac.uk)' __version__ = '0.0.1' #PART 1 _a_global = 10 # a global variable if _a_global >= 5: _b_global = _a_global + 5 # alsoa global variable def a_funct...
bf55521618e904356413a4ba8c3619ff0100b9aa
matheusms/python-pro-mentorama
/seq_fibonacci/modulo2_fibonacci.py
908
3.75
4
#Crie um objeto que gere a seq de Fibonacci import pytest class Fibonacci: def __init__(self, interacao): self.anterior = 0 self.proximo = 1 self.interacao = interacao def __iter__(self): return self def __next__(self): if self.interacao == 0: ...
b8c23cbb93832c67d9b093160a46620a22f7f31d
MonikaLaur/SmartNinja
/Class8/Homework_8.3.py
85
3.65625
4
# Make a string lower case string = "Today Is A BeautiFul DAY" print string.lower()
66af9839631b0d1f875ecee8ad07596f22a6b509
MaayanLab/clustergrammer-web
/clustergrammer/upload_pages/clustergrammer_py_v112_vect_post_fix/__init__.py
6,202
3.5
4
# define a class for networks class Network(object): ''' Networks have two states: 1) the data state, where they are stored as a matrix and nodes 2) the viz state where they are stored as viz.links, viz.row_nodes, and viz.col_nodes. The goal is to start in a data-state and produce a viz-state of the ne...
4504eb1fc912373aa244e0d891b6ac199607387e
shakib0/BasicPattterns
/pattern6.py
176
3.6875
4
for r in range(5): for c in range(r+1): if c<1 : print((5-r)*' ',r,end = '') else: print('',r,end = '') print()
d48d59ba512d46f1da62d8ca9334959c9c0da9d5
reud/AtCoderPython
/Python/ABC126B.py
275
3.671875
4
S=input() mae=int(S[0]+S[1]) usiro=int(S[2]+S[3]) maeMM = True if 0< mae and mae<13 else False usiroMM =True if 0< usiro and usiro<13 else False if maeMM and usiroMM: print('AMBIGUOUS') elif maeMM: print('MMYY') elif usiroMM: print('YYMM') else: print('NA')
11fef3c419dd3102d413e27494bb47b18d81e4c1
christinegithub/oop_cat
/cat.py
1,694
4.46875
4
# Create a class called Cat class Cat: # Every cat should have three attributes when they're created: name, preferred_food and meal_time def __init__(self, name, preferred_food, meal_time): self.name = name self.preferred_food = preferred_food self.meal_time = meal_time # Create two insta...
b1c51433733553cb528b4c3e1a4dfbf9ece3d694
nv29arh/hw2
/variables.py
423
3.875
4
country = 'Russia' capital = 'Moscow' rank = 1 print(country) print(country, 'is', 'a', 'country') print (capital, 'is', 'the', 'biggest', 'city', 'of', country) print ('Cremlin', 'is', 'in', capital) print ('Square', 'is', rank, 'place') # str country = 'Russia' print (type(country)) #int rank = 1 print (type(rank)...
076d4bddfac1ee507fe0528a444729cb7be8c236
ming-log/NetworkProgramming
/06 tcp客户端.py
1,829
3.9375
4
# !/usr/bin/python3 # -*- coding:utf-8 -*- # author: Ming Luo # time: 2020/9/3 11:40 # tcp客户端 # tcp客户端,并不是像之前一个段子一个顾客去吃饭,这个顾客要点菜,就问服务员咱们饭店有客户端么, # 然后这个服务器非常客气的说道:先生 我们饭店不用客户端,我们直接送到您的餐桌上 # 如果,不学习网络的知识是不是说不定也会发生那样的笑话 # 所谓的服务器端:就是提供服务的一方,而客户端,就是需要被服务的一方 # tcp客户端构建流程 # tcp 的客户端要比服务器端简单很多,如果说服务器端是需要自己买手机、插手机卡、设置铃声、等待别人 #...
89462ac39995eb1d6d6a777ad50c6dc5a4fa3148
newagequanta/MITx_6.00.1x
/Week 3/biggest.py
643
4.03125
4
def biggest(aDict): ''' aDict: A dictionary, where all the values are lists. returns: The key with the largest number of values associated with it ''' list_biggest = [] biggest_len = 0 for element in aDict: if isinstance(aDict[element], (dict, list, tuple)): current_len...
d933cfea18035e77ed23a3eda38440abc84f87cf
AaronLack/C200
/Assignment3/qc1.py
1,152
3.53125
4
#Consult At Office Hours, I am Cofused. import math def f(x): return 3*(x**2) + 4*x + 2 x = -2/3 + math.sqrt(2)/3j y = -2/3 - math.sqrt(2)/3j print(f(x)) print(f(y)) ### import numpy as np import math import numpy as np import matplotlib.pyplot as plt def q(a,b,c): #figure out how to define x discrima...
07d2bf8acfe0301ec2e1dab36d2bdd39396197a1
evshary/leetcode
/0137.Single_Number_II/solution.py
439
3.53125
4
from typing import List class Solution: def singleNumber(self, nums: List[int]) -> int: hash_table = {} for i in nums: try: hash_table[i] += 1 if hash_table[i] == 3: del hash_table[i] except: hash_table[i] =...
1b65f24773f1f9b1d3dd71d2dbe7887b155d82fd
phlalx/algorithms
/leetcode/360.sort-transformed-array.py
1,090
3.609375
4
# # @lc app=leetcode id=360 lang=python3 # # [360] Sort Transformed Array # # https://leetcode.com/problems/sort-transformed-array/description/ # # algorithms # Medium (47.27%) # Likes: 242 # Dislikes: 70 # Total Accepted: 29.1K # Total Submissions: 61.5K # Testcase Example: '[-4,-2,2,4]\n1\n3\n5' # # Given a so...
b37ec6b5bacd45c435ac427a5af9e1a30137cb41
euleoterio/Python
/input.py
144
3.984375
4
numero = input("Digite um numero: ") print("O numero digitado eh:") print(numero) nome = input("Digite seu nome: ") print("Bem vindo, " + nome)
6dd61080292e46cdf29ff36a2c02b8f374a98fa1
WinterBlue16/Coding_Test
/input/01_basic_input.py
553
3.921875
4
# 가장 보편적인 입력(input) 코드 # 문자열(str) 1개 입력 x = input() print(x) # 정수형(int) 1개 입력 n = int(input()) print(n) # 실수형(float) 1개 입력 f = float(input()) print(f) # 공백을 기준으로 다수 입력 # 문자열 x, y, z = input().split() print(x, y, z) # 정수형, 실수형 x, y, z = map(int, input().split()) # print(x, y, z) x, y, z = map(float, input().split())...
bcedeba1696765d26b93fff57747eb1dcd3946d2
hmgans/DataMiningHW
/AS01.py
6,289
3.859375
4
#This is the python file for AS01 from random import random from random import randint import numpy as np import matplotlib.pyplot as plt import time #Part 1A # n - int that is the max of the domain 1-n def randomIntCollision(n): trialNumber = 0; dictionary = dict(); while(True): trialNumber+=1...
f5f20d2ceb28f0f4df70d2edc10283a0b87ab380
Stitch-wk/learngit
/001.py
603
3.765625
4
# -*- coding: utf-8 -*- #sorted函数排序方法 list1 = [] for i in range(5): num1 = int (input('请输入整数:')) list1.append(num1) list2=sorted(list1) print(list1) print(list2) input('press any key to...') #增加了冒泡排序法 list3 = [] print ('请输入十个整数:') for i in range(10): print ('输入第%d个整数:'%i) num2 = int input() list3.a...
5225e7d2d72d4958e593f6c33ba79d872d7bb48a
helen5haha/pylee
/game/PascalsTriangle.py
724
4.0625
4
''' Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] ''' def generate(numRows): rows = [] if numRows <= 0: return rows if numRows >= 1: rows.append([1]) if numRows >= 2: ...
7a679597672833f9c9332b3f7084a3f1d7d5d66e
FemkeAsma/afvinkopdrachten
/(7)miles-per-gallon.py
197
3.84375
4
miles_driven= input("Number of miles that have been driven: ") gallons_gas= input("Number of gallons of gas that have been used: ") MPG= int(miles_driven) / int(gallons_gas) print("MPG:", MPG)
360629627ca569be476cc4fe08f48269e12a1c78
alrijleh/chess
/bots/odd_bot/odd_bot.py
1,834
3.9375
4
from board import Board from collections import defaultdict import random def look_for_moves_to_odd(pieces: list, board): moves_to_make = [] for piece in pieces: piece_moves = piece.get_moves(board) for move in piece_moves: if move.target[0] % 2 == 1: moves_to_make.a...
b9393d851a29737a5f64c4f22567cf1b503cec1b
Antoine-Darfeuil/Python-Training
/Python Formation Exercices/library.py
2,996
3.703125
4
class Document(): def __init__(self, code, title): self.code = code self.title = title def __str__(self): return self.title class Book(Document): _compter = 0 def __init__(self, isbn, title, author, genre): super().__init__(isbn, title) ...
9be4a2dfb8235be3e9b24e7e72ec398129357b59
dbzahariev/Python-Basic
/pythonbasic/Basic/EXAM_1_dec_2018/solution/05_trekking_mania.py
855
3.796875
4
count_groups = int(input()) all_people = 0 count_musala = 0 count_montblanc = 0 count_kilimanjaro = 0 count_k2 = 0 count_everest = 0 for i in range(0, count_groups): count_people = int(input()) all_people += count_people if count_people <= 5: count_musala += count_people elif 6 <= ...
9ff40c8b3707c1d92eedbb3a198c3cda5e505696
davidrotari19/FinalProject
/Position.py
1,152
3.5
4
import math from time import sleep import gopigo3 robot = gopigo3.GoPiGo3() from Firebase import add,retreive #Comment one out when u are on that MAC_ADRESS_LEADER="leaderraspber123a" MAC_ADRESS_FOLLOWER=["follower2468","follower13579"] Last_Left=0 Last_Right=0 x=0 y=0 WHEEL_CIRCUMFERENCE = 0.20892 # w...
242919e1f1ede298157ff32f1d40c2f172070379
baviamu/set8-10.py
/VOV.PY
219
3.890625
4
B = input(" ") if B in ('a', 'e', 'i', 'o', 'u','A','E','I','O','U'): print("%s vowel." % B) elif B == 'y': print("Sometimes letter y stand for vowel, sometimes stand for constant.") else: print("%s constant." % B)
35c01ea84977ba69cf47706f300c56e8eceb4539
BartlomiejRasztabiga/PIPR
/lab6-zaliczenie1/zad1.py
359
4.15625
4
def get_indices_of_given_chars(text, chars_list): result = [] for char in text: if char not in chars_list: result.append(-1) else: result.append(chars_list.index(char)) return result sample_text = 'Ala ma kota' sample_list = ['a', 'A', ' ', 'k'] print(get_indices_of...
a43631f167aad81ca9b558e7081f3c53cb6f0658
cailinanne/python_examples
/generators.py
737
4.34375
4
# Create a list, iterate around it (twice) print "list" my_list = [1, 2, 3] for i in my_list : print(i) for i in my_list : print(i) # Create a list using a list comprehension, iterate around it (twice) print "list comprehension" my_list = [x*x for x in range(1,5)] for i in my_list : print(i) for i in my...
6c21d272efa5d0cfda2fe74ae8948123fa884a5b
AngelSosaGonzalez/IntroduccionMachineLearning
/Machine Learning/IntroduccionML/Modulos/IntroPandas/IntroPandas_2.py
5,452
4.25
4
""" Introduccion a Pandas: este proyecto veremos sobre el modulo de Pandas, veremos sobre el manejo de datos antes de comenzar veremos el concpeto de Pandas: Pandas es una herramienta de manipulación de datos de alto nivel desarrollada por Wes McKinney. Es construido con el paquete Numpy y su estructura de datos cla...
5f01dfb8ff7c33f5f004171ecef3d2383b4c0ba9
igortereshchenko/amis_python
/km73/Mirniy_Nickolay/3/task4.py
300
3.75
4
N = int(input('Количество студентов : ')) K = int(input('Количество яблок : ')) apples = K//N rest = K%N if (N > 0) & (K>0) : print('Количество яблок у студента : ' , apples, '\nОстаток яблок : ' , rest) else : print('Error')
8c07ee6325ab6c1dea782153338429c914e9bf64
MrHamdulay/csc3-capstone
/examples/data/Assignment_7/clxqui001/question1.py
702
4.03125
4
"""this program removes any duplicated string within a list while still keeping the orignal order quincy cele 27 april 2014""" #convert the input into a list and continuously add more strings into the list until the word "done" has been supplied. create an additional empty list. strings=input("Enter strings (end wi...
7a0d7870b83861dcec82ddec383c02f43a77ab55
chathula777/mycode
/listmethods/day1challenge02.py
565
3.921875
4
#!/usr/bin/env python3 import random icecream = ["flavors", "salty"] tlgclass = ["Adrian","Bikash","Chas","Chathula","Chris","Hongyi","Jauric","Joe L.","Joe V.","Josh","Justin","Karlo","Kerri-Leigh","Jason","Nicholas","Peng","Philippe","Pierre","Stephen","Yun"] icecream.append(99) print(icecream) random_student...
82da68d2b7f124dbc231ed4eabe4985f57a3e613
sharmakajal0/codechef_problems
/EASY/LUCKY5.sol.py
387
3.875
4
#!/usr/bin/env python '''Module for lucky 5''' ## # Question URL: https://www.codechef.com/problems/LUCKY5 ## def unlucky_digits(str_value): '''Function for Unlucky digits''' count = 0 for i in str_value: if i != '4' and i != '7': count += 1 return count T = int(input()) for _...
e0e4db55b09d9c1027e47cb49f09b42f0edbe131
hyunjun/practice
/python/problem-O-of-n/peak_index_in_a_mountain_array.py
878
3.5625
4
# https://leetcode.com/problems/peak-index-in-a-mountain-array # https://leetcode.com/problems/peak-index-in-a-mountain-array/solution class Solution: # 1.23% def peakIndexInMountainArray(self, A): peakIdx, maxVal = None, max(A) for i, a in enumerate(A): if maxVal == a: ...
68385143af943f8276bad9b81dd4e2584a01ac79
James-Damewood/Leetcode_Solutions
/BinaryTreeLevelOrder.py
1,038
3.875
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution(object): def levelOrder(self, root): """ :type root: TreeNode :rtype: List[Li...
2ce510956ce354a0f01725fd5647ea2b8d3230fd
Tarun-Sharma9168/Python-Programming-Tutorial
/gfgpy1.py
251
4.0625
4
''' Author name : Tarun Sharma Problem Statement:Python program to add two numbers ''' num1=input("first number") num2=input("second number") result=float(num1)+float(num2) print("the sum of {0} and {1} is {2}".format(num1,num2,result))
91d0e99762217d718ba256b5883c3d01d27c34a8
domspad/hackerrank
/apple_disambiguation/which_apple.py
1,613
4.3125
4
#!/usr/bin/env python """ (Basic explanation) """ def whichApple(text) : """ Predicts whether text refers to apple - the fruit or Apple - the company. Right now only based on last appearance of word "apple" in the text Requires: 'apple' to appear in text (with or without capitals) Returns: 'fruit' or 'computer-c...
93e9763efc8ebf3a8be6748070aa0d36ef9e8adb
vinaybisht/python_tuts
/PythonDictionary.py
813
4.03125
4
# Python dictionary example class PhoneBook: def __init__(self): pass def _contacts_book(self): return {"John": "+91 1234567890", "Ron": "+91 0235687900", "Xian": "+91 2035689782"} phone_book = PhoneBook() local_contacts = phone_book._contacts_book() print(l...
63110de931af7b0e5c65ac9218248c7fd6bf8d91
YasminMuhammad/python_Calender
/comparisons.py
578
4.03125
4
#three number to find the max number def max_num(number1 , number2 ,number3) : if number1>=number2 and number1>=number3 : return number1 elif number2>=number3 and number2>=number1 : return number2 else : return number3 #هي فانكشن جاهزه اصلا بس هي مرقعه و خلاص print(max_num(20,15,9))...
e30e57fca4fb72154ce1c990da08ca29ce0527c0
aliakseik1993/skillbox_python_basic
/module1_13/module2_hw/task_8.py
1,024
4.21875
4
print('Задача 8. Обмен значений двух переменных') # Что нужно сделать # Дана программа, которая запрашивает у пользователя два слова, а затем выводит их на экран два раза. a = input('Введите первое слово: ') b = input('Введите второе слово: ') print(a,b) a, b = b, a print(a,b) # Задача: поменять значения переменных...
59144d643f806628e1237ab1b1bf2e3909db1a6f
brennanhunt16/Monty-Hall-Code
/montyhall!.py
1,620
3.921875
4
import random def thegame(numberoftests): switch = 0 stay = 0 doors = {1: "ZONK!", 2: "ZONK!", 3: "ZONK!"} for i in range(numberoftests): #creating random car door car = random.randint(1,3) doors[car]= "car!" original = {} original.update(doors) ...
6b9d35b39d28a277854b4aec7b1cb84a0e57fb72
gloomysun/pythonLearning
/18-异步IO/3_async_await.py
747
3.640625
4
''' 用asyncio提供的@asyncio.coroutine可以把一个generator标记为coroutine类型,然后在coroutine内部用yield from调用另一个coroutine 实现异步操作 请注意,async和await是针对coroutine的新语法,要使用新的语法,只需要做两步简单的替换: 把@asyncio.coroutine替换为async; 把yield from替换为await。 ''' import asyncio @asyncio.coroutine def test(): n = 1 for i in range(50000000): n = n + ...
80dac5b56b8458172f432080ae7f9d46c6918b98
parlad/PythonExe
/DirectorySt.py
197
3.828125
4
tel = {'jack': 4098, 'sape': 4139} tel['guido'] = 4127 print(tel) tel['jack'] del tel['sape'] tel['irv'] = 4127 print(tel) list(tel) print(sorted(tel)) 'guido' in tel print('jack' not in tel)
5273bd131681ccf4ba341e85c866ee594d0e2ae9
jadeaxon/hello
/Python 3/lp3thw/ex07/ex7.py
1,077
4.3125
4
#!/usr/bin/env python3 # Prints a string literal. print("Mary had a little lamb.") # Uses format() method to replace {} placeholder. print("Its fleece was white as {} {}.".format('yellow', 'snow')) # Prints a string literal. print("And everywhere that Mary went.") # Use * overload to print a string multiple times. pri...
5b398119ebc498b556d39c43503904a6bb97389b
jd-shah/Portfolio
/GitHub_Classroom_Issue_Creator/issue_creator.py
1,699
3.859375
4
# -*- coding: utf-8 -*- """ Created on Sat Aug 22 18:04:17 2020 @author: shahj Github Classroom is used to share assignments with students. If class is programming based, one might need to share "issues" with each student as a part of the assignment. This feature isn't available in Github Classroom yet. Till they r...
922aad079cd705e62e289f05562e1db5d35f3a6c
IvanBasOff/python
/ex06_files/ex06.py
547
3.734375
4
import os import csv print(os.path.join("Users", "bob", "st.txt")) # st = open("st.txt", "w") st.write("Test string") st.close() # with open("st.txt", "w") as f: f.write("test string number 2") # with open("st.txt", "r") as f: print(f.read()) #CSV with open("st2.csv", "w") as f: w = csv.writer(f, ...
7502ac73fd14234ce87c5e8928eea4cd6652cabf
FabioMenacho/backend
/semana1/dia3/practica.py
867
3.765625
4
# f = open('alumnos.csv','a') # print("REGISTRO ALUMNO: ") # nombre = input("NOMBRE: ") # email = input("EMAIL: ") # celular = input("CELULAR: ") # f.write(nombre + "," + email + "," + celular + '\n') # f.close() # fr = open('alumnos.csv','r') # alumno = fr.read() # print(alumno) # fr.close() fr = open('alumnos.csv'...
7e3a30f50c02e52b5fe56e2df210365f150979d2
josemariap/python
/practica_exception.py
921
4.0625
4
# exceptions def suma(num1, num2): return num1+num2 def resta(num1, num2): return num1-num2 def multiplica(num1, num2): return num1*num2 def divide(num1,num2): try: return num1/num2 except ZeroDivisionError: print("No esta permitido la division por 0") return "Error en la operación" while True: t...
7b76d03d498d056c60a9e61343ba5ba4a8b35da6
ChrisJaunes/generating_test_paper
/Generator/genProgramming/p12.py
1,662
3.59375
4
import numpy.random as random from sample import ProgrammingProblemDesc, ProgrammingProblemSTD def generatorProblemDesc() -> ProgrammingProblemDesc: return ProgrammingProblemDesc("拿硬币", """ 桌上有 n 堆力扣币,每堆的数量保存在数组 coins 中。 我们每次可以选择任意一堆,拿走其中的一枚或者两枚,求拿完所有力扣币的最少次数。 示例 1: 输入:3 4 2 1 输出:4 解释:第一堆力扣币最少需要拿 2 次,第二堆最少...
d3bc2dd31d895fc04140e85544d7814fb4f5dbb2
ashinzekene/public-apis-py
/app/utils/scrap.py
811
3.625
4
from bs4 import BeautifulSoup import requests def fetch_url_text(url): """ Fetch for a url and return the response """ return requests.get(url).text def scrap(html, selector, attr): """ Scrap for text in an html text """ soup = BeautifulSoup(html, "html.parser") sels = soup.select(...
45e36c4cd57248ab08165fd76de646c6ce1e1442
yakovitskiyv/algoritms
/unlike_deal_test.py
1,044
3.984375
4
class Node: def __init__(self, value=None, next=None): self.value = value self.next = next def print_linked_list(vertex): while vertex: print(vertex.value, end=" -> ") vertex = vertex.next print("None") def get_node_by_index(node, index): while index: node = n...
61dd4e65ea1affca9a0ec3ccecea12605245f743
Skya-neko/DataMining
/ch4_class-1-1.py
1,957
3.8125
4
# -*- coding: utf-8 -*- """ Created on Fri Apr 9 15:07:13 2021 @author: Vivian """ '''語法錯誤 Syntax error''' '''在寫程式的時候寫出電腦看不懂的腳本(script)。''' # NameError ================================================================= # 第一種:未命名的function(函式) pritn('Hello World!') # >>> NameError: name 'pritn' is not defined # 第二種:...
7bb14517bb66afc2697c7696a6ca89e451a54eea
perrinod/hacker-rank-solutions
/Algorithms/Strings/Caesar Cipher/solution.py
666
3.875
4
# https://www.hackerrank.com/challenges/caesar-cipher-1/problem #!/bin/python3 import math import os import random import re import sys def caesarCipher(s, k): encryptedString = "" for i in range (0, len(s)): if(s[i].isalpha()): a = 'A' if s[i].isupper() else 'a' encryptedStri...
1768fdda8b973b3f88d45f9383c11afd51de3be3
teclivre/Python
/Desafios- Python/Desafio-10.py
456
3.859375
4
# Conversão de real para dolar. print('\n \n Agora vamos ver quantos dolares você pode comprar com os Reais que está em sua carteira. \n \n ') name = input('Primeiro me diga seu nome: ') d = float (input('Dite o valor do dolar no dia de hoje: $')) r= float (input('\n \n Agora me diga quanto você tem em sua carteira? ...
014888e15f15be2d8c3c05a774d573b095d73fff
krishnasree45/Practice-Codes
/array_in_pendulum/my_method.py
986
3.734375
4
# code """ The minimum element out of the list of integers, must come in center position of array. If there are even elements, then minimum element should be moved to (n-1)/2 index (considering that indexes start from 0) The next number (next to minimum) in the ascending order, goes to the right, the next to next numb...
4edb28de7c66ecb8c16b4b5ece613a568287d639
leandrovianna/programming_contests
/URI/OBI2013Fase1Replay/175_1.py
305
3.703125
4
def check(a, b, c, d): return (a * d == b * c) a, b, c, d = raw_input().split(); a = int(a) b = int(b) c = int(c) d = int(d) if (check(a, b, c, d) or check(a, d, c, b) or check(c, b, a, d) or check(b, a, c, d) or check(a, b, d, c)): print "S" else: print "N"
d96aedcb01aad344e044c2accf5f1ec88c598d52
altareen/csp
/09Tuples/tupleoperations.py
873
4.375
4
# initializing a tuple drinks = ("tea", "coffee", "juice") print(drinks) print(type(drinks)) # initializing a tuple with a single element soda = ("cola",) print(type(soda)) # retrieving an element with square bracket notation chai = drinks[0] print(chai) # using slicing to get a new tuple result = drinks[:2] print(r...
355c8d82baf73e81ff64c656175316f5e07f9ec1
michalgar/Attendance
/extensive_main.py
1,466
4.15625
4
""" This file will include the main functionality of the program. It should display a menu of actions to the user and invoke the relevant function """ import Logic # Display a menu to the user print("\nWhat would you like to do?") print("1- Add employee") print("2- Delete employee") print("3- Mark attendance") print("...
188b4605acd90546e36dc98f886468ad9d2246a0
TheCyberian/Hacking-Secret-Ciphers---Implementations
/simple_substitution_cipher.py
3,095
4.125
4
import sys, random """ To implement the simple substitution cipher, choose a random letter to encrypt each letter of the alphabet. Use each letter once and only once. The key will end up being a string of 26 letters of the alphabet in random order. There are 26! possible keys, which is equal to 26*25*24*.....*2*1 = 40...
ff7ac260d818478f3e7cd9006571a3079ddf1e7e
Yobretaw/AlgorithmProblems
/EPI/Python/LinkedList/8_2_reverseSingleLinkedList.py
698
3.890625
4
import sys import os import math from linkedlist import * """ ============================================================================================ Given a linear nonrecursive function that reverses a singly linked list. The function should use no more than constant storge beyond that needed for th...
01c170576f8bd2361a372a8091430a239551d184
sankeerth/Algorithms
/Graph/python/common/detect_cycle_directed.py
833
3.734375
4
from Graph.python.common.graph_adj_list import Graph def detect_cycle(graph): visited = {node: False for node in graph.adj_list} cycle_list = list() def detect_cycle_util(s): visited[s] = True stack[s] = True cycle_list.append(s) for v in graph.adj_list[s]: if...