blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
57d8954fbba66252f63c2264b1f16c9f36adaa51
gabee1987/codewars
/CodeWars/stuff_test.py
161
3.734375
4
words = ['aabb', 'abcd', 'bbaa', 'dada'] sorted_words = [] for i in words: a = sorted(i) b = "".join(a) sorted_words.append(b) print(sorted_words)
0882864e7032f124d064fb5d5ab20f1b8c5308c3
brubribeiro/Python-EC
/movimentoObliquo.py
250
3.921875
4
#Bruna Ribeiro import math; theta = float(input()); velocidade = float(input()); gravidade = float(input()); radianos = math.radians(theta); h = (math.pow(velocidade, 2) * (math.sin(radianos))**2) denominador = (h/(2*gravidade)) print(denominador)
562048ef51c2f416afcbcc04c19a18564511a812
vishalvb/practice
/python_practice/slicing.py
414
4.125
4
#List slicing my_list = [0,1,2,3,4,5,6,7,8,9] print("list = ",my_list) print("my_list[0:]",my_list[0:]) print("my_list[:]",my_list[:]) print("my_list[:-1]",my_list[:-1]) print("my_list[1:5]",my_list[1:5]) #list(start:end:step) print("my_list[1::3]",my_list[1::3]) print("my_list[-1:1:-1]",my_list[-1:1:-1]) sample_ur...
2216c8bccf7af48fe03b888a3f82ed38c588792c
rereal7/Algoshiki_practice
/lecture_groups-13/Q1/Q1_5.py
129
3.578125
4
n = int(input()) ans = 0 # 後ろから見て貪欲法 while n > 0: if n%3 == 0: n //= 3 else: n -= 1 ans += 1 print(ans)
540cb2ffb66eac8c601ed844610cd0229a4f035f
maomao905/algo
/clone-n-ary-tree.py
738
3.53125
4
""" # Definition for a Node. class Node: def __init__(self, val=None, children=None): self.val = val self.children = children if children is not None else [] """ from collections import deque class Solution: def cloneTree(self, root: 'Node') -> 'Node': if not root: return Non...
8e4df277fa11f0b3e400f1c1c3bf012c25086b08
drettt/fattails
/fattails/metrics.py
2,404
3.703125
4
from copy import copy import numpy as np import pandas as pd def mad(x): """Calculate Mean Absolute Deviation Not to be confused with commonly found 'Median' Absolute Deviation. Parameters ---------- x : array_like Input array or object that can be converted to an array. ...
4be21200cbf9a7140a62c3addeac3e746a4f0b13
digjao/CursoEmVideo
/ExerciciosModulosPython/ex028.py
262
3.765625
4
velo = int(input('A velocidade do carro é: ')) if velo > 80: print('Você foi multado, pois a velocidade permitida é até 80Km/h') print('O valor da sua multa será de: R${:.2f} '.format((velo-80)*7)) print('Tenha um bom dia, dirija com segurança!')
c7732a8db8aedc7136b6e2453c2c18bce6d15bab
jluocc/jluo2018
/python/python/老师笔记/python/day17/day17/code/del_method.py
458
3.765625
4
# del_method.py # 此示例示意析构方法的定义和自动调用 class Car: def __init__(self, info): self.info = info print("汽车:", info, "对象被创建") def __del__(self): '''这是析构方法,形参只有一个self''' print("汽车", self.info, "被销毁") c1 = Car("BYD E6") c2 = c1 # c2绑定谁? del c1 # 删除变量c1 input("按回车键继续执行程序: ") print("程序...
3ca1a4be4318611edede3bba71da401b6ae9e014
rogeriosilva-ifpi/adsi-algoritmos-2016.1
/atividade_f/Atividade F - Kairo Emannoel - Leonardo Freitas/lista3questao16.py
364
4.125
4
def fibonacci(n,numero1 = 0, numero2 = 1): if n>0: atual=numero1+numero2 numero1=numero2 numero2=atual print atual, fibonacci(n-1,numero1,numero2) def main(): n=input("Insira numero de termos: ") n-=2 numero1=0 numero2=1 print numero1,numero2, fibonac...
6235af062f0b6607670939fe55b997691dc1d3b5
lethargilistic/MiscellaneousPython
/workClock.py
836
3.546875
4
import time import winsound SECONDS_IN_MIN = 60 DEFAULT_WORK = 10 DEFAULT_BREAK = 5 def wait(minutes): while minutes > 0: print(minutes, "minutes remaining...") time.sleep(SECONDS_IN_MIN) minutes -= 1 def main(): automatic = "q" while automatic != "y" and automatic != "n": ...
01c5662837c9a4f051c10e5d305b7fd00f0a41de
UalwaysKnow/-offer
/offer/栈和队列/包含min函数的栈(辅助栈).py
443
3.734375
4
class stack: def __init__(self): self.stack1 = [] self.stack2 = [] def pop(self): if len(self.stack1) == 0: return None if self.stack1[-1] == self.stack2[-1]: self.stack2.pop() self.stack1.pop() def push(self,data): self.stack1.append(data) if len(self.stack2) == 0 or data < self.stack2[-1]: ...
1303b4d4d625bf0bb46f647e0c10950b5ea1a696
macheart/Eight-Puzzle
/board.py
4,971
4.1875
4
class Board: """ A class for objects that represent an Eight Puzzle board. """ def __init__(self, digitstr): """ A constructor for a Board object whose configuration is specified by the input digitstr input: digitstr is a permutation of the digits 0-9 """ # c...
7674493f3b11d5cc7583c1e7309ed37f663138ee
soumiyajit/python
/python-basic/011-list3.py
152
3.6875
4
""" list of list for mutiplication table """ def multi_table(a): multi = [[a,b,a*b] for b in range(1,11)] return multi print multi_table(5)
c5783decee20671f5849ce7fe728622429945a27
liqingxuan/ECS165
/3c.py
1,331
3.625
4
import psycopg2 #open databse connection db = psycopg2.connect(database = "postgres") ###################------------3c------------#################### #Question 3c:Name and average grade of easiet and hardest instructor cursor3c = db.cursor() #find all instructors ans his assigned total GPA and total GPA*units cu...
e3ec2675e631c5a066482e2fee9c44ac2d7a8d14
Zahidsqldba07/sandbox
/codewars/swap-items-in-a-dictionary.py
752
4.34375
4
''' https://www.codewars.com/kata/swap-items-in-a-dictionary In this kata, you will take the keys and values of a dictionary and swap them around. You will be given a dictionary, and then you will want to return a dictionary with the old values as the keys, and list the old keys as values under their original keys. ...
b324c0eec8a263d56da84a608091a72325fb2457
Katarzyna-Bak/Coding-exercises
/Do I get a bonus.py
961
3.859375
4
""" It's bonus time in the big city! The fatcats are rubbing their paws in anticipation... but who is going to make the most money? Build a function that takes in two arguments (salary, bonus). Salary will be an integer, and bonus a boolean. If bonus is true, the salary should be multiplied by 10. If bonus i...
3f1e14d8aa71c9713a410d4876457229b189087c
salvador-dali/algorithms_general
/interview_bits/level_1/01_mathematics/00_example/03_prime_numbers.py
395
3.6875
4
# https://www.interviewbit.com/problems/prime-numbers/ def eratosthenes_sieve(n): prime, result, sqrt_n = [True] * n, [2], (int(n ** .5) + 1) | 1 append = result.append for p in xrange(3, sqrt_n, 2): if prime[p]: append(p) prime[p*p::p << 1] = [False] * ((n - p*p - 1) / (p <<...
5fad216dbc142984fda6aa2799962119dee0d36f
itzadi22/Basic-python
/difference_betweeen_two_dates.py
275
3.96875
4
# -*- coding: utf-8 -*- """ Created on Wed Mar 24 10:30:16 2021 Difference between any two dates @author: ASUS """ import datetime a=datetime.datetime(2000, 12, 22) b=datetime.datetime(2000, 12, 25) c=b-a print("The difference between two dates is :",c)
ed1532908486ac891ae639bda6aba78acd1aae24
Hassan8521/alx-higher_level_programming-1
/0x07-python-test_driven_development/2-matrix_divided.py
1,918
4.09375
4
#!/usr/bin/python3 """Define a matrix devision function""" def matrix_divided(matrix, div): """Divide all element of a matrix. Args: matrix(list): A list of lists of int/floats. div(int/float): The diviaor. Raises: TypeError:if the matrix contains non number, i...
c7ac685f28e29c023644364e3c4c5b945ef11825
unix2dos/pythonTest
/grammar/map_reduce.py
623
3.953125
4
# map()函数接收两个参数,一个是函数,一个是Iterable, # map将传入的函数依次作用到序列的每个元素,并把结果作为新的Iterator返回。 # python3 from functools import reduce a = list(map(str, [1, 2, 3, 4, 5])) print(a) # reduce把一个函数作用在一个序列[x1, x2, x3, ...]上, # 这个函数必须接收两个参数,reduce把结果继续和序列的下一个元素做累积计算,其效果就是: # reduce(f, [x1, x2, x3, x4]) = f(f(f(x1, x2), x3), x4) # reduce ...
85f681e19f46dc6a31cfdff400e05e603826aa58
lindo-zy/python-100
/python-009.py
225
3.609375
4
#!/usr/bin/python3 # -*- coding:utf-8 -*- ''' 题目:暂停一秒输出。 程序分析:使用 time 模块的 sleep() 函数。 ''' import time l = [1, 2, 3, 4] for i in range(len(l)): print(l[i]) time.sleep(1)
121ad3d14ece3ef9ab8d32ca8fa53d846563064d
moonlimb/interview_prep
/challenges/prod_of_other.py
1,099
3.75
4
from operator import mul def make_prod_ls(ls, zero_count, zero_index, prod_of_nums): if zero_count >= 1: # more than 1 zero: prod_ls contains all 0's prod_ls = [0] * len(ls) if zero_count == 1: # 1 zero: set element in prod_ls at zero_index to prod_of_nums prod_ls[zero_i...
2303927115fec377f10b103aec0cabd648c8d123
amarF117/forgit
/alfa5.py
510
3.703125
4
manushowProduc = 1 menubuyProduc = 2 productName =3 productPrice = 180 userBalanc = int (input("Enter ammout")) userCommand = int (input("Enter command")) if (userCommand ==1): print("Name " , productName ) print("Price ", productPrice) if (userCommand ==2 ): if (userCommand >= ...
60b5d34f34a4b0d06b4c263342c51d69086f51f2
eirikhoe/advent-of-code
/2015/20/sol.py
1,232
3.71875
4
def find_presents(house_number): divisible = [] i = 1 while i * i <= house_number: if (house_number % i) == 0: d = house_number // i divisible.append(i) if i != d: divisible.append(d) i += 1 return sum(divisible) * 10 def find_present...
74d03bfa34a54d54215d44a14864ac894b28e546
TheMiloAnderson/data-structures-and-algorithms
/Py401/array_binary_search/array_binary_search_test.py
638
3.671875
4
from array_binary_search import array_binary_search def test_binary_search_small(): """ test with small array """ arr = [1, 2, 3, 4] actual = array_binary_search(arr, 3) expected = 2 assert actual == expected def test_binary_search_large(): """ test with larger array """ arr = [i * 3 for...
d5a9b1768343444ee71f751d3e4d68f393e97e4a
vignesh787/PythonDevelopment
/Week11Lec6.py
407
3.890625
4
# -*- coding: utf-8 -*- """ Created on Mon Jul 19 08:31:50 2021 @author: Vignesh """ ''' def add(a,b): return a+b def sub(a,b): return a-b def multiply(a,b): return a*b def divide(a,b): return a/b ''' add = lambda x,y : x + y sub = lambda x,y : x - y multiply = lambda x,y : x * y divide = lambda...
de3918430a9e9852051714c4b6c5e6a1a2f7449b
HonniLin/leetcode
/neetcode150/875.koko-eating-bananas.py
1,964
3.515625
4
# # @lc app=leetcode id=875 lang=python3 # # [875] Koko Eating Bananas # # https://leetcode.com/problems/koko-eating-bananas/description/ # # algorithms # Medium (52.90%) # Likes: 5001 # Dislikes: 223 # Total Accepted: 221.5K # Total Submissions: 418.6K # Testcase Example: '[3,6,7,11]\n8' # # Koko loves to eat b...
a545f185d63749873d154f1fb422a6721b7da3e3
ccx210/git-tensorflow-test
/mnist/mnist_test.py
2,246
3.859375
4
#import tensorflow lib import tensorflow as tf #load data set (mnist for example) from tensorflow.examples.tutorials.mnist import input_data #read data from downloaded files, the parameter "one_hot=True" means the outputs are one-hot vectors. say as the form of [0,0,0,1,0,0,0,0,0,0]T mnist = input_data.read_data_sets...
29249afad2dc390b16e6e7f7cddd4cb3350a194c
Razoff/prepa_cahier
/half_move.py
1,676
3.671875
4
class HalfMove: """ Each member of this class hold half a move move_id: number of the full move the half move is part of (13) move_name: Name of the half move (Cxb2) white_move: True if it is a white move parent: parent half move children: list of all children half moves comment: Commen...
f94b01102016542c523af8604267d9a706f64683
Gafanhoto742/Python-3
/Python (3)/Ex_finalizados/ex030.py
270
3.90625
4
#Crie um programa que leia um número inteiro e mostre na tela se ele é PAR ou ÍMPAR. n = int(input('Me diga um numero qualquer: ')) resultado = n % 2 if resultado == 0: print ('O número {} é PAR'.format(n)) else : print ('O número {} é IMPAR!'.format(n))
6150e2b4d31e0e3a977c45238e5283096fd92f35
ravee-interview/DataStructures
/Week4/Design/155_minstack.py
1,483
4.0625
4
from collections import deque class MinStack(object): def __init__(self): """ initialize your data structure here. """ self.stack = deque() self.length = 0 def push(self, x): """ :type x: int :rtype: None """ #push on sta...
0f0ab6a5d3993d30460b6524ba5ec26aa1c1486d
Parvez6084/Easy-to-Python-Learning
/Variable.py
235
3.578125
4
name = "Parvez Ahmed" age = 24 GPA = 3.94 n,a,g = "Mukta",27,3.24 print("\n"+name) print(age) print(GPA,"\n") print("My name is "+name + ". i am ",age,". my GPA is ",GPA,"\n") print("My name is "+n + ". i am ",a,". my GPA is ",g,"\n")
e57b2a7e370f849ba15f0bd16c27639cdf209b04
nzsnapshot/MyTimeLine
/1-2 Months/tutorial/Files/remember_me2.py
455
4.09375
4
import json # Load username, if it has been stored previously, # Otherwise, prompt for the username and store it. filename = 'username2.txt' try: with open(filename) as f: username = json.load(f) except FileNotFoundError: username = input('What is your name? ') with open(filename,'w') as f: ...
ff62c60e8caa5eb16153d5824feb959193e061d4
kmintae/CITE301
/C_Motor/Car_Test.py
446
3.75
4
from Car import Car import time car = Car() while(1): time.sleep(1) test=input() if test=="w" : car.move_forward(300) elif (test=="s"): car.move_forward(-300) elif test=="d": car.move_right(300) elif(test=="a"): car.move_right(-300) elif(test=="e"): ...
8be06d5353d974cfed545bf0ef5cf4791bd129bb
davidzhusd/br-pdv
/portfolio.py
1,873
3.78125
4
import requests """ For the examples we are using 'requests' which is a popular minimalistic python library for making HTTP requests. Please use 'pip install requests' to add it to your python libraries. """ class Portfolio(): """docstring for Portfolio. Instance vars: params - passed into the API...
1a8857fd2d11c05383970b1afe4b00b2762a704c
FriggD/CursoPythonGGuanabara
/Mundo 1/Desafios/Desafio#24.py
248
3.859375
4
#Crie um programa que leia o nomne de umja cidade e diga se ela começa ou não com o nome SANTO cidade = input('Digite o nome da sua cidade: ').strip() cid = cidade.lower().split() print('Sua cidade é nome de santo? {}'.format('santo' == cid[0]))
0173373c8703c2b955002b1cba3411d479e1cd89
jay3ss/congenial-rotary-phone
/interfaces.py
1,876
4
4
"""Module that holds the interfaces that define different data structures""" import abc class ListInterface(abc.ABC): """Abstract base class that defines a list""" @abc.abstractmethod def clear(self): """Removes all entries from the list""" @abc.abstractmethod def entry(self, position): ...
4d8aff7bef6c9993b7473dda4117cff2f1b35387
peterschoice/python
/basic/06_loop.py
313
3.71875
4
menus = ["순남 시래기", "양자강", "20층", "23층"] for menu in menus: print(menu) for i in range(4): print(i) for i in range(4): print(menus[i]) for i in range(1,3): print(i) dict_nums = { "순남 시래기" : "02-6589-3652", "양자강" : "02-6589-3652" , "20" : "02-6589-3652" }
ba01ff43a4eec95489a4ce9adfd1053888910302
jerquinigo/Brooklyn-Steam-Center-lessons
/classActivities/dataTypeActivity/dataTypeStringActivity/stringActivity.py
681
3.59375
4
# please correct these errors by using proper syntax to get quotes and apostrophies to work along with any other string syntax errors present print("Hello Michael, that is Alex's math textbook, he asked me to "make sure no one takes it off his desk") print("Alex's textbook hasn't been removed from the desk. Mic...
b6cefaf4b110a387997c3f6a35574ed414fc662e
halmanza/pythonClass
/itemToPurchase.py
1,651
4.125
4
# Anthony Almanza # Chapter 9 class ItemToPurchase: item_name= str() item_price= float() item_quantity = int() def __init__(self,item_name="none",item_price= 0,item_quantity= 0): self.item_name= item_name self.item_price= item_price self.item_quantity=item_quantity return def print_item_...
183098bd293fa0d49bb4c79b744457255e42a1d2
mishag/euler
/src/prob35.py
742
3.609375
4
#!/usr/bin/python import primes import sys g_primes = set([]) circular_primes = set([]) def generate_cycles(n): cycles = [] num_str = str(n) for i in range(len(num_str)): num_str = num_str[1:] + num_str[0] m = int(num_str) cycles.append(m) return cycles def build_prime_s...
de6f1279543dbee3a45635da7bbe04950472a1be
sherrytp/bc_f19_econ
/ADEC7430 Big Data Econometrics/Lecture03/Pycode/Lecture03.py
4,238
3.703125
4
# -*- coding: utf-8 -*- """ Created on Wed Jan 30 22:53:39 2019 @author: RV """ #%% #%% Setup import os projFld = "C:/Users/RV/Documents/Teaching/2019_01_Spring/ADEC7430_Spring2019/Lecture03" codeFld = os.path.join(projFld, "PyCode") fnsFld = os.path.join(codeFld, "_Functions") outputFld = os.path.joi...
cc14fb5372ff90a818e3b22f6e4771d70f34f80b
Mateushrb/URI-Online-Judge
/Python/Iniciante/1176 - Fibonacci em Vetor.py
600
3.6875
4
# Lista da sequencia inicial de Fibonacci sequencia_fibo = [0, 1] valor_fibo = 0 # Estrutura de repetição para calcular a sequencia de Fibonacci for i in range(0, 60, 1): valor_fibo = sequencia_fibo[i] + sequencia_fibo[i+1] sequencia_fibo.append(valor_fibo) # Quantidade de testes T = int(input()) casos_testes =...
55ded99013a8784d05a4462a3dbbd2cd1db61e1c
kolpator/python
/not.py
189
4.0625
4
#!/usr/bin/python3 x = int(input("notunuz")) if x > 100 or x < 0: print("böyle bir not yok") elif x >=90 and x <=100: print("A aldınız") elif x >= 80 and x <= 89: print("B aldınız")
70ff0f19489988ed51caa350d921d5ffc72acb5c
smistro/stanford
/TripleKarel.py
2,153
4.125
4
from karel.stanfordkarel import * """ File: TripleKarel.py -------------------- When you finish writing this file, TripleKarel should be able to paint the exterior of three buildings in a given world, as described in the Assignment 1 handout. You should make sure that your program works for all of the Triple sample w...
ea5acf926f51adfd2116eef20d886ccf6a302489
grasingerm/PL
/cmu_hw_list_algorithms_and_invdict.py
5,539
3.65625
4
import copy import bisect def fast2(a): b = copy.copy(a) b.sort() for i in range(len(b)-1): if b[i] == b[i+1]: return False return True print(fast2([1, 2, 3]), " should be True") print(fast2([1, 2, 3, 4]), " should be True") print(fast2([1, 2, 3, -1, -14, 4, 7, 9, 11, 38]), " sho...
c4e55746ea83f0f05a2e0b50707165241f2586f7
sunnivmr/tdt4110
/oving9/sets.py
925
3.734375
4
print("\na)") my_set = set() print(my_set) print("\nb)") def oddetall(set, max): for i in range(max): if i % 2 != 0: set.add(i) oddetall(my_set, 20) print(my_set) print("\nc)") my_set2 = set() oddetall(my_set2, 10) print(my_set2) print("\nd)") my_set3 = set() my_set3 = my_set.differenc...
d5d06554d0f7d8c598d357732f8db83e0252d024
DMamrenko/Kattis-Problems
/autori.py
156
3.84375
4
#Autori inp = list(input()) answer = "" for letter in inp: if letter == letter.upper() and letter != "-": answer += letter print(answer)
379689ccc9e4cde26ae04b0a6b27387e7800f7a3
AlexandrSech/Z49-TMS
/students/Volodzko/Task_13/Task_13_1/func.py
760
3.578125
4
from exceptions import MyZeroException def my_sum(x, y): # Функция сложения двух чсел return "x + y = {}".format(x + y) def my_dif(x, y): # Функция вычитания двух чсел return "x - y = {}".format(x - y) def my_mul(x, y): # Функция умножения двух чсел return "x * y = {}".format(x * y) def my_divisi...
ee479d0c18e6efbc701454daf9c48bef11c63ed7
rnsdoodi/Programming-CookBook
/Back-End/Python/Basics/Part -4- OOP/02 - Polymorphism/04_hash_protocol.py
425
3.828125
4
class Person: def __init__(self, name): self._name = name @property def name(self): return self._name def __eq__(self, other): return isinstance(other, Person) and self.name == other.name def __hash__(self): return hash(self.name) p1 = Pe...
8928af60159aca65d2e8815d92cacbf621c75494
boksuh/Python_300
/061-080.py
1,200
3.75
4
""" 2021-07-05 Bokyung Suh Python 300 """ # 061 price = ['20180728', 100, 130, 140, 150, 160, 170] print(price[1:]) # 062 nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] print(nums[::2]) # 063 nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] print(nums[1::2]) # 064 nums = [1, 2, 3, 4, 5] print(nums[::-1]) # 065 interest ...
dbad2111915225b1119a682cac830155f5f56cd7
TheMcHammer/Magic-8-ball
/magic_8-ball/Magic8Ball.py
2,252
3.65625
4
import random class Fortune: #global fates fates = ['It is certain', 'It is decidedly so', 'Without a doubt', 'Yes - definitely', 'You may rely on it', 'As I see it, yes', 'Most likely', 'Outlook good', 'Yes', 'Signs point to yes', 'Reply hazy, try again', 'Ask again later', 'Better not tell you now', 'Cannot p...
30805bf258c0c6e75b5f2867ae0e8b2aab3df689
supazuko/Database-Exercises
/Python_DB_Connect/connect_insert.py
2,179
3.578125
4
import mysql.connector from mysql.connector import Error import stdiomask def connect_insert(): conn = None host = input('Enter Host for database: ') database = input('Enter database name: ') user = input('Enter user for database: ') password = stdiomask.getpass("Enter password: ") try: ...
9cdaa903a644b40b6b9029c304256ee913ed0382
dougaoyang/struct_code
/sort/quick_sort.py
998
3.859375
4
# 快速排序 import random # 获取分区点 def partition(arr, start, end): # i,j以此向后递推,i前面的都小于 下标p的值 i, j = start, start # 获取分区点 p = random.randint(start, end) while True: # 跳过下标p if i == p: i += 1 if j == p: j += 1 if j > end: break # 比较 j, p 将小于p的值交换到i的左侧 if arr...
e4cda589b8ea8e2b5992fff643c4669bedb3a5ff
roshstar1999/Art_Of-_Doing
/miles_per_hr_Conversion.py
365
4.4375
4
#MILES PER HOUR CONVERSION print("Welcome to miles per hour conversion app!") mph=input("\n enter the speed in miles per hour please =>") #for converting the miles into metres ===> miles*1609 mps=float(mph)*1609.34/(60*60) #using round function for upto 2 decimals precision mps=round(mps,2) print("the ente...
2e828befcc131412dbd396e02adc59eff7a6e20c
python2018wow/python_code
/p2-1.py
107
3.59375
4
name = input("請輸入您的姓名:") print("您好," + name + "!") print("大家一起學 Python!")
02c6e1e537ddc3ca4eab998374cea07b2bd58e07
lengyugo/Data-Structure-and-Algorithm
/12-sorts2/quick_sort.py
938
3.8125
4
""" quick_sort 快速排序 """ from typing import List import numpy as np def quick_sort(a:List[int]): quick_sort_c(a,0,len(a) - 1) ## def quick_sort_c(a:List[int],low:int,high:int): if low < high: #k = random.randint(low,high) #a[low],a[k] = a[k],a[low] q = partition(a,low,high) ...
5f246ef3eb4100549c48eb0f4832a833d1d6a4ed
batestin1/PYTHON
/CHALLENGES/100TASK/ex010.py
379
4.0625
4
#Crie um programa que leia quanto dinheiro uma pessoa tem na carteira e mostre quantos dólares ela pode comprar. import pandas print('-*-'*30) print('CONVERSAO DE DOLAR ') print('Desenvolvido por Maycon Cypriano') print('-*-'*30) real = float(input('Quanto você tem na carteira: ')) dolar = real*0.18 print(f'Se você t...
81056370079d3089494d28873cc57a01a752ebe8
greenfrog82/DailyCoding
/Codewars/6kyu/6kyu_multiple_3_or_5/src/main.py
277
3.515625
4
import unittest def mysolution(number): return sum(i for i in range(number) if not i % 3 or not i % 5) solution = mysolution class Test(unittest.TestCase): def test_1(self): self.assertEqual(solution(10), 23) if __name__ == '__main__': unittest.main()
5e293f3767b782aa3757044ad79dabc7551fc639
JeffHemmen/AoC-2019
/Day 4/day4.py
1,221
4.125
4
#!/usr/bin/env python3 from sys import argv def two_adjacent_digits_are_the_same(n): cs = str(n) left = None for c in cs: if c == left: return True left = c return False def two_adjacent_digits_are_the_same_v2(n): cs = str(n) left, num_repeat = '', 1 for c in c...
b1146e80e7891fd105a12ddc2374843068c066f1
developer0101/AVLtree
/avltree.py
3,325
3.546875
4
''' Reza Fathi AVL Tree in python3 ''' class Node: def __init__(self, val): self.val = val self.left = self.right = None self.height = 0 def updateHeight(self): lh = self.left.height if self.left else 0 rh = self.right.height if self.right else 0 self.height = 1 + max(lh, rh) def balance(self): lh = ...
970671fd7c1e9c625088512a3985f1e826913aff
AnshumanSharma05/Python
/StationaryShop.py
1,200
3.953125
4
''' A new stationary shop has been opened in the city. The owner asks his accountant to take the list of items sold in the store. The list should contain the details of the items and their costs. Help the accountant to generate the prince list by writing a Python program. Generate list with just 4 products - A4sheets...
4f993a22f064e488d21ed4f4572edac9cb675112
ErikArndt/GMTK-Jam-2020
/util.py
2,724
3.53125
4
"""This module is for general use functions that can be used by any module. """ import pygame def bevelled_rect(surface, colour, rect, border_radius): """pygame doesn't support rects with curved edges yet, so I had to write this myself. Args: surface (pygame.Surface): surface to draw the rect onto. ...
91508f2abde32f646dad83879e2aecc827a5ad42
CubeSugar/HeadFirstPython
/Day05/demo_class_define.py
651
3.671875
4
''' ''' ''' ''' #define function format time_string def sanitize(time_string): if '-' in time_string: splitter = '-' elif ':' in time_string: splitter = ':' else: return(time_string) (mins, secs) = time_string.split(splitter) return (mins + '.' + secs) #end def class Athlete: def __init__(self, a_name, a...
3f7837f57386fa1f85d6e6e4a6a30ff0f029b236
jfsolanilla/Python-Code
/Guess the Number.py
5,302
4.21875
4
# template for "Guess the number" mini-project # input will come from buttons and an input field # all output for the game will be printed in the console # Defining libraries import random import simplegui import math # Defining global variables Secret_Number = 0 # Number that will be guessed by the user Upper_Limit ...
f89d2d951dcad9eb2ca8d9fdd701313851d3dc3b
qmnguyenw/python_py4e
/geeksforgeeks/python/python_all/150_14.py
2,887
4.3125
4
Python | Delete elements with frequency atmost K There are many methods that can be employed to perform the deletion in the list. Be it remove function, pop function and many other functions. But most of the times, we usually don’t deal with the simple deletion, but with certain constraints. This article disc...
f35d5e60e919f240526e45a23acdbb3dbe4314b5
csungg/csung.github.io
/Folder2/chatbot.py
2,496
3.890625
4
class Personality(): hiResponse = "🤖 HELLO 🤖" whatsUpResponse = "🤖 🤖" howAreYouResponse = "🤖 🤖" otherResponse = "🤖 🤖" def processInput(self, response): if response == "Hi": print(self.hiResponse) elif response == "What's up?": print(self.whatsUpRes...
228a818aa19bd74ffe70e0c504a4031e54f26cf9
dionis-git/study
/practice_3.py
695
4.5
4
# Check if a number is positive, negative, or NULL. while True: user_input = (input('enter a number:\n')) if user_input == 'exit': break else: # Check user input can get converted to 'float' try: user_variable = float(user_input) # Check the sign of the number...
5799f4dd97217c61abb66c0775cd2568a48889ad
msanchez77/cs175_assignment2
/cs175/classifiers/softmax.py
4,674
3.84375
4
import numpy as np from random import shuffle from past.builtins import xrange def softmax_loss_naive(W, X, y, reg): """ Softmax loss function, naive implementation (with loops) Inputs have dimension D, there are C classes, and we operate on minibatches of N examples. Inputs: - W: A numpy arr...
7ab0d5898d27cd73589c22eb090a277b270763cd
igortemnikovd/MyPythonTest
/calculator.py
579
3.75
4
#простой калькулятор # from colorama import init from colorama import Fore, Back, Style #use Colorama to make Termcolor work on Windows too init() print( Back.WHITE ) what = input( "Что делаем? (+, -,): " ) a = float(input("Введите первое число: ")) b = float(input("Введите второй число: ")) if what == "+": c...
01bd422ae780515b8ad17df790aabec669890a6b
v1ctor/advent-of-code-2019
/day13/run.py
2,604
3.515625
4
import sys from computer import Computer class Game: sizeX = 0 sizeY = 0 score = 0 buf = None ball = None platform = None command = 0 def init(self, display): for i in range(0, len(display), 3): op = display[i:i + 3] if op[0] == -1: cont...
61608ce3e67bbc3c60732281ba06547759710913
3esawe/Hacking
/chapter1/passcracker.py
393
3.71875
4
import crypt def encrypt(word): return crypt.crypt(word,"AI") def passcracker(cryptedpass): words = open("words2") salt = cryptedpass[0:2] for word in words.readlines(): word = word.strip('\n') cryptword = crypt.crypt(word,salt) if cryptword == cryptedpass: return word return 'not found' if __...
aa90731b82c64f605cd100c31ee8c35b24f2eca6
radfordm-osu/homework-4
/hw4p3.py
179
3.578125
4
def NameGen(first, last): if (isinstance(first, str) and isinstance(last, str)): name = first + " " + last return name else: return "Error!"
d8a9ed2f36f52459cff0a0d05ba78f86478b4ed1
Luisdar0z/nonogrampy
/test.py
2,276
4.125
4
""" F = int(input("Numero de filas:\n")) C = int(input("Numero de Columnas:\n")) """ #ejemplo de ingreso de datos: 12 2 3 4 44, 123 3 32 2 323, 23 23 columna = input("ingrese columnas(solo separado por , sin espacio) \nR: ") col = columna.split(", ") print(col) #print("imprimiendo posicion valor 2 posicion 1: ", col[...
c715b2cfd2920467c20f8a1addbd6393d1d00155
Michaelnstrauss/Byte
/udemy/smileyface.py
153
3.53125
4
#!/usr/bin/env python3 smile = 1 while smile < 10: num = '\U0001f600' # for smiles in len(range(smile)): print(num*smile) smile += 1
10b520460c12d819116f8d80a87d8e6c8d81a715
romwil22/python-textbook-exercises
/chapter7/exercise3.py
1,415
4.65625
5
"""Sometimes when programmers get bored or want to have a bit of fun, they add a harmless Easter Egg to their program. Modify the program that prompts the user for the file name so that it prints a funny message when the user types in the exact file name “na na boo boo”. The program should behave normally for all other...
f253d412c5a55c7a11d3f76c302aab0b1a57a2c8
aserjunior/algoritmos-especial
/Atividade_Semana_5/uri1038_lanche.py
688
3.796875
4
def main(): #entrada lanche = int(input('Insira o código do pedido: ')) quantidade = int(input('Insira quantos pedidos vai querer: ')) #processamento validar = validar_lanche(lanche) valor_final = valor_lanche(validar, quantidade) #saída print(f'Total: R${valor_final: .2f}') ...
a9463183fdcd5d040a9dc15fbe3706403a8b2728
forbearing/mypython
/1_python/8.1_函数.py
3,736
4.125
4
函数的定义和调用 局部变量、全局变量 - 在函数中,不使用 global 声明全局变量时,不能修改全局变量的本质是因为,不能修改全局变量的 指向,即不能将全局变量指向新的数据 - 对于不可变类型的全局变量,因为其指向的数据不能修改,所以不使用 global 时无法修改全局变量 - 对于可变类型的全局变量,因为其指向的数据可以修改,所以不使用 global 时也可以修改全局变量 - 全局变量定义在调用函数之前,不是定义函数之前 = 可变类型:值可以修改(内存地址不变但所保存的值变化了)引用可以修改(变量的内存地址变化了) - 不可变类型:值不可以修改,可以修改变量的引用(= 赋值号) - 在函数里面修改...
8c524ff5d026ba497ee50ef57406d7b5326d92c9
Djamshed1/IS211_Assignment4
/sort_compare.py
4,825
4.1875
4
#!/usr/bin/env python # -*- coding utf-8 -*- """Week 4 Assignment 4 Part 2""" import time import random def insertion_sort(l): # l = list """ Args: l(list): List of numbers. Returns: l(list): Sorted List. Examples: >>> insertion_sort([1,2,3,4,5,6,7,8,9,10]) ([1, 2, 3,...
ae817d14984be079d38da264ee9cbb2e54dc221a
jz33/LeetCodeSolutions
/398 Random Pick Index.py
1,063
4.03125
4
''' 398. Random Pick Index https://leetcode.com/problems/random-pick-index/ Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array. Note: The array size can be very large. Solution that uses too much ...
9f043671f95d6bd1a0f8c00af426b49f465e467a
A-Alexander-code/150-Python-Challenges--Solutions
/Ejercicio_N058.py
1,375
3.84375
4
import random num1 = random.randint(1,10) num2 = random.randint(1,10) cont = 0 print("Inicia la prueba\nRealice las siguientes operaciones") oper1 = num1 + num2 oper2 = num1 - num2 oper3 = num1 * num2 oper4 = num1 / num2 oper5 = (num1 + num2) * num1 print("El primer número es: ",num1) print("El segundo número es: ",...
608a53882437a6522bbb96f10f2e57b94fb5500d
ToniCaimari/Codewars
/Python/kyu6/Count_char_in_string.py
271
3.71875
4
def count(string): character_list = [] character_number = [] for i in string: if i not in character_list: character_list.append(i) character_number.append(string.count(i)) return dict(zip(character_list, character_number))
b00598715a35f00055109b8c2828ee4c01ca5961
git-gagan/MywaysTrainee
/RoughExperiments/OpenCV/sizes.py
907
3.734375
4
import cv2 img = cv2.imread("C:/Users/Acer/Desktop/Nature.jpeg") #Changing size based on Aspect Ratio (measurement of relationship between height and width) #For Scaling up, use Inter_cubic or Inter_linear #For scaling down, use INTER_AREA or INTER_NEAREST #INTERPOLATION :- Mathematical procedure applied in or...
e3ec0d52b3f4deea078ced1f99d93e2cca91b004
tariqrahiman/pyComPro
/codeforces/contest/1087/test_B.py
1,271
3.515625
4
import unittest import B def valid(n, k, res): return (res / k) * (res % k) == n class test_class(unittest.TestCase): def test_basic(self): s = B.solve(6,3) self.assertEqual(s, 11) self.assertTrue(valid(6,3,int(s))) s = B.solve(1,2) self.assertEqual(s, 3) self.a...
2c56a3b04fc375ff2d78fdd163ad230f67cb55af
JFerRG/MySQL_Py
/GitHub/ComprobacionDeCuadrados.py
643
4
4
def validacion(): while True: try: num = int(input('Ingresa el valor: ')) if num > 0: return num break else: print('El número ha de ser mayor que cero') except Exception as e: print('Error al obtener el n...
b322c5e99b42aa50be960e4441fc737210996a0e
chars32/edx_python
/Weeks/Week9/4. gcd.py
338
4.15625
4
#Write a function named calculate_gcd that receives two positive integers a and b as parameter and returns #their greatest common divisor (GCD) using recursion. def calculate_gcd(a, b): if b == 0: return a else: print("antes", a,b, a%b) g cd = calculate_gcd(b, a%b) return gcd print(cal...
132ce94da67fd0260133132bbc41368d92518c2f
diegodukao/choraoipsum
/choraogenerator.py
707
3.65625
4
from random import shuffle WORDS = [ "vagabundo", "skate", "charlie", "brown", "santos", ] def generate(qt_words): words = WORDS.copy() sentence = "Chorao Ipsum vagabundo brown" for i in range(int(qt_words)): if not words: words = WORDS.copy() shuffle(words...
885fb68421f4c6511c598ae9ce9d458442fff2eb
selincifci/bby162
/uygulama04.py
1,273
3.625
4
__author__"Selin ÇİFCİ" kadin=input("isim giriniz:") erkek=input("isim giriniz") misra=input("mısra sayısı giriniz:") sec=int(misra) bosluk=" " i=["ilk görüşte","vapurdayken","okula giderken","arkadaşlarıyla gezerken","ağlarken","mesajlaştığında","sinirlendiğinde","ders çalışıyorken","saçmalarken"] k=["yanına gitti","...
392cb14a54315353e7ececc459d74af2212feabf
dg5921096/Books-solutions
/Python-For-Everyone-Horstmann/Chapter11-Recursion/split_recursive_list_sum.py
405
4.03125
4
# Recursively calculates the sum of a list's items by splitting the list in two. # FUNCTIONS def _sum_helper(given_list, start): if start == len(given_list): return 0 return given_list[start] + _sum_helper(given_list, start + 1) def split_recursive_sum(given_list): middle = len(given_list) // 2 ...
b9dfbd3ddc22c6988616a0c1bd852d34138df0c3
Wraient/Python-Progarams
/115.looping.in.dict.py
862
3.5625
4
user_info = { "Name" : "Rushikesh", "Age" : 18, "Fav_movie" : ["Robot", "Social Networks", "Twitter"], "Fav_tunes" : ["Tokyo Ghoul", "Weathering with you"] } # if "Fav_tunes" in user_info: # print("True") # else: # print("False") # if "Rushikesh" in user_info: # print("True") # else: # ...
4ceb4e2779293f46e180555640cc3ead0acbc68e
MrLW/algorithm
/leetcode/everyday/middle_781_numRabbits.py
901
3.578125
4
from typing import List from typing import Counter class Solution: def numRabbits(self, answers: List[int]) -> int: ''' 题目: 781. 森林中的兔子 ''' # 1. 利用规律实现 count = Counter(answers) res = sum([(x+y) // (y+1) * (y+1) for y, x in count.items()]) # 1. for + dic ...
a394acfe35134d1daea2959c250646762fbcb9bd
Wilsonilo/MIT-6.00.1x
/Mid-Term/problem7.py
913
3.875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jul 3 11:58:28 2017 @author: wilson """ import operator def dict_invert(d): ''' d: dict Returns an inverted dictionary according to the instructions above If d = {1:10, 2:20, 3:30} then dict_invert(d) returns {10: [1], 20: [2], 30: [3]...
7048aa85e18f6638cbf95dbe378412529162db47
mascarock/ADM-HW1
/scripts.py
31,734
4.21875
4
#### Problem 1 ### Introduction ## Ex 1 - Hello World # store the string "Hello, World!" in a variable hello = "Hello, World!" # print the variable print(hello) ## Ex 2 - If, Else #!/bin/python3 import math import os import random import re import sys #get the input if __name__ == '__main__': n = int(input(...
718f61d1c0b4f795438ad546414ee409d7a19bfb
cu-swe4s-fall-2019/version-control-jfgugel
/math_lib.py
146
3.703125
4
def div(a, b): if b==0: print ("Can't divide by 0") return 1 else: return a/b def add(a, b): return a+b
b471484f1199797dcf440c3181e6bee462ce23a1
thinkSharp/Interviews
/Calculater.py
3,351
4.09375
4
def calculator(expression): def calc(op, v1, v2): if op == '+': return v1 + v2 elif op == '-': return v1 - v2 elif op == '*': return v1 * v2 elif op == '/': return v1 / v2 return 0 def getValue(j): temp = '' ...
2dddbecbd937e254fc52c1fddc5e01eefac62344
h2hyun37/algostudy
/study-algorithm/src/nedaair/study/sort/bubbleSort1.py
542
3.796875
4
__author__ = 'nedaair' unsortList = [3, 31, 48, 73, 8, 11, 20, 29, 65, 15] def bubbleSort() : index = 1 while 1 : indexf = 0 for j in unsortList : if j > unsortList[indexf+1] : temp = unsortList[indexf+1] unsortList[indexf+1] = j ...
0ff62a729adbdbf680a862b7b50cd80f3cc814b9
Sakibapon/BRAC
/CSE/CSE 422/CSE422 AI LAB/Lab01/lab01task07.py
267
3.71875
4
# -*- coding: utf-8 -*- """ Created on Sun May 26 20:37:09 2019 @author: Musavvir """ import math c = int (input ("Please enter the year you were born in: ")) d = math.sqrt(1+4*c) x1= (d + 1)/2 print( "\nI will be ", int(x1), "years old in the year ", int(x1*x1))
68353cc2c1436b758bd852f8a00fa3f096bbad01
arthurffd/proj22_indice_reverso
/scripts/idx_reducer.py
792
3.5
4
#! /usr/bin/python3 # Python 3 Reducer script, for MapReduce jobs called by Hadoop Streaming jar # REVERSED (Inverted) Index # Expected Output: <word_id> /t <[doc_id] # Example: 1 [7, 22, 30] , 2 [31], 3 [1, 3, 4, 10, 23] from sys import stdin import re import os index = {} reverse = {} for line in st...
bdd549a566b450752355c5c8fa22b8b15301bcf7
alishahwee/houses
/roster.py
947
3.84375
4
from sys import argv, exit from cs50 import SQL # Check for correct usage if len(argv) == 1: print('roster.py missing command-line argument\nUsage: python roster.py example-house') exit(1) elif len(argv) > 2: print('roster.py only accepts one command-line argument\nUsage: python roster.py example-house') ...
44312385bfaaa836a04cf92ba5282546558fcaa1
tarunlnmiit/blackhatpython
/test1.py
215
3.90625
4
def sum(num1, num2): num1int = convert_integer(num1) num2int = convert_integer(num2) res = num1int + num2int return res def convert_integer(num): return int(num) ans = sum('1', '2')