blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
09e7598d58e01c75e13890667a18bf6a856405c2
hoainguyen1999/baithuchanh
/bai3.c9.py
846
3.953125
4
#chuong trình máy tính thực hiện các phép tính cộng, trừ, nhân , chia #phép cộng hai so def add(x,y): return x + y #phép trừ 2 so def subtract(x,y): return x - y #phép nhân 2 so def multiply(x,y): return x*y #phép chia 2 so def divide(x,y): return x/y print("1.Add") print("2.Subtract") pr...
ec21c76bddb291ae51f61d59c32cff7252ee31f6
myf-algorithm/Leetcode
/Huawei/40.输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数.py
432
3.78125
4
while True: try: a = input() char, space, number, other = 0, 0, 0, 0 for i in a: if i == " ": space += 1 elif i.isnumeric(): number += 1 elif i.isalpha(): char += 1 else: other += ...
ee1be409c13fd286cfae94e0890b48008329a387
ChristopherDaigle/Learning_and_Development
/Udemy/Learn_Python_Programming_Masterclass/ifChallenge/ifChallenge.py
645
4.21875
4
# Write a small program to ask for a name and an age. # When both values have been entered, check if the person # is the right age to on a 18-30 holiday (they must be # over 18 and under 31). # If they are, welcome them to the holiday, otherwise print # a (polite) message refusing them entry. name = input('Enter your ...
4434501a64212ab9c1255ca20ae1693a44a7f7ff
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_118/1960.py
766
3.59375
4
import math def palindrome(word): return word == word[::-1] def main(file): inputfile = open(file, 'r') howmany = int(inputfile.readline()) # how many test cases are there? stage = 0 outputfile = open('C-small-attempt1.out', 'wd') while stage < howmany: word = inputfile.readline().split() s,f = int(word[...
b60f9559461058da513fdf491df80bd8386b5953
RealDannyTM/Python-Assignments
/Functions.py
417
3.921875
4
"""Python is Easy - Assignment #2 - Functions Favorite Song""" # Functions def Artist(): ArtistName = "Duncan Lawrence" return ArtistName def Song(): SongName = "Arcade" return SongName def Awards(): AwardsName = "Album: Eurovision Song Contest Tel Aviv 2019" return AwardsName def Year...
a9fe4064f0aa9a13bc6afcfec7b666f3977ff9e9
mjdecker-teaching/mdecke-1300
/notes/python/while.py
1,958
4.28125
4
## # @file while.py # # While-statement in Python based on: https://docs.python.org/3/tutorial # # @author Michael John Decker, Ph.D. # #while condition : # (tabbed) statements # condition: C style boolean operators # tabbed: space is significant. # * Avoid mixing tabs and spaces, Python relies on correct positi...
bfc77f5f3600e9e0418ce31447e1f29e5f2b9352
b-douglas/ordergroove-to-cybersource-payment-migration-python
/misc/extractIdsNoCreditCards.py
7,037
3.640625
4
#!/usr/bin/python """ Created on Oct 08, 2020 extractIdsNoCreditCards.py Script runs and extracts the records WITHOUT decrypting the credit card numbers. @author: dougrob """ import configparser import csv # import os # import re import sys import base64 import time # ## Function to open a file as a csv # ## All...
88235f3f70c8ca46b98baebca9ac41645ea47010
vibhootiagrawal/python_course
/number_game.py
1,308
3.96875
4
# -*- coding: utf-8 -*- """ Created on Sun Jan 13 21:42:45 2019 @author: Education """ import random secret_number=random.randint(1,10) chance=0 def chancer(): n=6 if(n>0): chance=n-1 n=n-1 return chance def gamer(): guess_number=int(input("enter number")) if(guess_number>0): if(secret_...
fcd111e1188cef8074a98cb30353e8d63bdcaa8a
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_1/607.py
3,109
4.03125
4
#!/usr/bin/env python2.5 def solve_case(engines, queries): """ Problem The urban legend goes that if you go to the Google homepage and search for "Google", the universe will implode. We have a secret to share... It is true! Please don't try it, or tell anyone. All right, maybe not. We are just...
ae638a0615b4fa76f47658223ccc33baf0a59348
Sandeep1525/99005039
/assignment/count_less_mean.py
329
3.65625
4
def mean_cnt(l): index=0 if not l: print("Empty list") return 0 else: mean=sum(l)//len(l) l.append(mean) l.sort() print(l) for i in range(len(l)): if mean==l[i]: index=i print(index-1) return ...
1203dea80ff38f3957cd60ec055773133b32da28
IeuanOwen/LPTHW
/LPTHW/LPTHWEX18.py
1,552
4.5
4
# Learn Python the hard way EX18 # this is like your scripts with argv def print_two(*args): arg1, arg2 = args print "arg1: %r, arg2: %r" % (arg1, arg2) # ok, that *args is actually pointless, we can just do this def print_two_again(arg1, agr2): print "arg1: %r, arg2: %r" % (arg1, arg2) # this just takes...
bb82b1d8d24af2f9dff9d473436f9e7493887e6c
Anjytka/Project
/pythPlugins/Fiction/moving_average.py
2,035
3.90625
4
# -*- coding: utf-8 -*- """ data - усредняемые данные w - размер окна """ def moving_average(data, w): length = len(data) if (w > length): raise Exception("Окно должно быть меньше количества замеров") aver = [] for i in range(length - w + 1): aver.append(reduce(lambda x, y: x + y, data[i:i+w]) / w) for i in...
f51b0008d1d1c600c0eeda115fbc89aea5587abc
gsimon2/python_calculator
/calc_main.py
5,793
4.15625
4
#!/usr/bin/env python import sys from parser_calc import calc_parser from tkinter import Tk, Label, Button, Entry, END class calculator(): """ Calculator Class Creates a small gui for the calc_parser class """ def __init__(self, root_window): """ Init Initializing the root window for the gu...
281589add4daa5b404988edbb4a9e7284ac29cdc
dido18/il-pensiero-computazionale-unipi
/l01-Algoritmi/avanzati/code/problema_finanziario/cubico.py
1,206
4.09375
4
# Programma CUBICO in Python # Figura 4.2 del libro "Il Pensiero Computazionale: dagli algoritmi al coding" # Autori: Paolo Ferragina e Fabrizio Luccio # Edito da Il Mulino def cubico(d): """ Calcola la porzione d[a : v] avente somma massima provando tutti i possibili intervalli [i,j] in [1,n-1] estremi i...
ff4989543e1292bf695e35d8fd4ef9b28842dc64
benamoreira/PythonExerciciosCEV
/desafio077.py
333
3.9375
4
palavras = ('tudo', 'nada', 'estudar', 'carro', 'mercado', 'mesa', 'janela', 'livro', 'computador', 'lapis', 'caneta', 'celular') for pos in palavras: print(f'\nNa palavra {pos.upper()} temos as vogais: ', end='') for letra in pos: if letra.upper() in 'AEIOU': print(letra.upper...
163b98e92e2a44e42be3735e308a8706108b3915
PedroGoes16/Estudos
/Exercicios-Python/exercicios-curso-em-video/d099.py
420
3.859375
4
from time import sleep def maior(*lst): print(30*'-=') print('Analisandos os valores passados ...') for v in lst: print(v,end=' ') print(f'Foram informado {len(lst)} valores ao todo.') if len(lst) > 0: print(f'O maior valor informado foi {max(lst)}.') else: print('O maior...
d6a5b613995b62924c65591bad59ddd57981679d
AndersonRoberto25/Python-Studies
/Lista/Trabalhando com listas/lista2.py
1,426
4.59375
5
#Criando listas numéricas #A função range() de Python facilita gerar uma série de números. for value in range(1,6): print(value) #A função range() faz Python começar a contar no primeiro valor que você lhe fornecer e parar quando atingir o segundo valor especificado. Como ele para nesse segundo valor, a saída não ...
d69d012797b2661707f72db49694bd453fa368cf
lancelafontaine/coding-challenges
/hackerrank/algorithms/01-warmup/time-conversion/python3/time-conversion.py
505
4.0625
4
#!/bin/python3 import sys time = input().strip() def time_conversion(time): am_or_pm = time[-2:].lower() time = time[:-2] hour = time[:2] if am_or_pm == "am": if hour == "12": return "00" + time[2:] return time if am_or_pm == "pm": if hour == "12": ...
76fad5198bf1acd894ac4455654f6f33e90b7334
KojoAning/PYHTON_PRACTICE
/list.py
1,794
4
4
# grocery = ['deo','chicken','milk','eggs','sprouts','mug dal' , 199] # print(grocery[6]) # numbers = [2,5,1,67,9,1] # list_1 =['f','srinath'] # my_list = numbers[:] # this will ensure that my_list gets only the copy of the numbers # a = numbers.sort() # its unnecessry to write a function for sorting insted of using t...
73bbc14e4816c6df0db1039a8568109944a2d12a
shubhankar01/Python-Datastructures
/array/Equilibrium_point.py
772
3.671875
4
# Given an array A your task is to tell at which position the # equilibrium first occurs in the array. Equilibrium position # in an array is a position such that the sum of elements below # it is equal to the sum of elements after it. n = [int(x) for x in input().split(' ')] def equi(n): l = 0 r = len(n) - 1 ...
7ad2740f5ccaee4203267c1e59d7a01475125ae3
gharseldin/LeetCode-in-Python
/Cards/Arrays/1346_CheckIfNAndItsDoubleExist.py
679
3.546875
4
# could be solved more efficiently with binary search class Solution: def checkIfExist(self, arr: List[int]) -> bool: arr.sort() i = 0 j = len(arr) - 1 cache = {} return self.check(arr, i, j, cache) def check(self, arr: List[int], i: int, j: int, cache: {str, bool}) -> b...
782a99ad83b5563f411c6ce38509dacbe2e02808
franckeric96/exonan
/exo1.py
477
3.828125
4
prix = float(input("entrez le prix unitaire d'une heure :")) nbheures = int(input("combien d'heure suplémentaire avez vous réaliser? ")) montant = 0 if nbheures <= 39 : montant = 0 elif nbheures < 45 : montant = (nbheures -39)*(prix*1.5) elif nbheures < 50 : montant = (5*prix*1.5)+(nbheures ...
e60eae27b4e82cd94cd866eeb1ef4e5b5ffab9a3
Tifinity/LeetCodeOJ
/415.字符串相加.py
1,019
3.53125
4
import copy class Solution(object): def addStrings(self, num1, num2): """ :type num1: str :type num2: str :rtype: str """ l1 = [] l2 = [] for s in num1: l1.append(s) for s in num2: l2.append(s) if len(l1) > len(...
1277217ccc9278a4c1f920722c3c84d6edccc354
Johannyjm/c-pro
/AtCoder/abc/abc174/a.py
60
3.71875
4
x = int(input()) if(x >= 30): print("Yes") else: print("No")
64cddf845cae8dec54d9897351efd3a1323d8f1d
Yoatn/stepik.org
/programming_in_python/2.1.1.py
394
3.515625
4
#-------------------------------------------------- # Programm by Yoatn # # # Version Date Info # 1.0 04.10.2017 Initial Version # #-------------------------------------------------- a = int(input()) b = [] while a != 0: b.append(a) a = int(input()) b.append(a) ...
5a3f0b9fcd4e0bdcc3e5789f63e7de3698092d2d
fimh/dsa-py
/dp/322.py
1,463
3.8125
4
""" Question: Coin Change Difficulty: Medium Link: https://leetcode.com/problems/coin-change/ Ref: https://leetcode-cn.com/problems/coin-change/ You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewe...
f4702ca6544785f7c0b8210cdae8ae58293f80f4
JorgenStenshaugen/IN1000
/Oblig 1/beslutninger.py
525
3.640625
4
# Spør brukeren om den vil ha en brus print("Vil du ha en brus? (\"Ja\" eller \"nei\")") # Setter svaret i en variabel svar = input() if svar == "ja" : # Sjekker dersom verdien på svar variablen er lik "ja" og skriver ut en melding print("Her har du en brus!") elif svar == "nei" : # Sjekker dersom svaret e...
cfc18ff36d4d7e9fb8ce7e8856630f9a779267e6
maydhak/project-euler
/004.py
1,729
4.1875
4
""" Problem 4: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. """ # I wrote my own method for checking if a number is a palindrome. I thought the number shoul...
dbd602e41733cdd59373a520a3fe7dd996ead2e5
saki45/CodingTest
/py/backtrack/maze.py
1,759
3.984375
4
def solvemaze(maze, x, y): # This method is the classic way to find the route to the exit of a maze by backtrack # In this program by default the exit is in the upper right corner (maze(0,8)) # The elements in the maze: # 0 -- unvisited # 1 -- wall # 2 -- visited maze[x][y] = 2 # find one solution if x==0 a...
286afa82e4a950d53c77e46c012a9c23ffd1b9dc
Willianan/Algorithm_Book
/Chapter7/7.3.py
1,774
3.53125
4
# -*- coding:utf-8 -*- """ Author:Charles Van E-mail: williananjhon@hotmail.com Time:2019/3/19 10:45 Project:AlgorithmBook Filename:7.3.py """ """ 如何求正整数n所有可能的整数组合 题目描述:给定一个正整数n,求解出所有和为n的整数组合,要求组合安装递归方式展示,而且唯一。 """ ''' ******* 方法功能:求和为n的所有整数组合 ******* 输入参数:sums:正整数;result:存储组合结果;count:记录组合中数字的个数 '''...
f49527155bc5c9b9ede2d30ae774fb084e016776
Vladimirvp2/bunker
/Services/PasswordGenerator.py
10,921
3.875
4
''' Classes and data for random password generation according to the information provided by user ''' import string, random #defaults DEFAULT_PASSWORD_LENGTH = 8 #number of passwords generated to the user for choice DEFAULT_PASSWORD_RANGE = 10 LOOK_LIKE_SYMBOLS = 'l1O0|' class PasswordGeneratorException(Exception): ...
cd26a00a7f28078db66930a10967937c9e44a4dc
nguyend91/code-courses
/python/lpthw/ex42.py
1,835
4.21875
4
#!/usr/bin/env python2 # Animal is-a object class Animal(object): pass # Dog is-a Animal class Dog(Animal): # class Dog has-a __init__ that takes self and name parameters def __init__(self, name): # from self get the name attribute and set it to name self.name = name # create class named Cat is-a Anim...
f33e15b6c448f56806d8b6c3d3f7f6fe7b932511
yse33/exam_01_22
/main_consult.py
124
3.6875
4
from calculate import * days = int(input("How many days have you worked here?")) print("Your income: ", calculate(days))
a63743805488b55764b4e21f85ce9646d2ebb5a0
ntupenn/exercises
/medium/545.py
2,482
4.40625
4
""" Given a binary tree, return the values of its boundary in anti-clockwise direction starting from root. Boundary includes left boundary, leaves, and right boundary in order without duplicate nodes. Left boundary is defined as the path from root to the left-most node. Right boundary is defined as the path from root t...
c335bca4145748c1fd76cf3253dabea3afce9891
kyosukekita/ROSALIND
/Bioinformatics textbook track/implement_motifEnumeration.py
1,735
3.703125
4
"""問題の指示とは異なる方法の解法""" import itertools import collections def HammingDistance(seq1,seq2,d): """2つの配列が与えられ、ハミング距離がd以下であればTrue""" mismatch=0 for i in range(len(seq1)): if seq1[i]!=seq2[i]: mismatch+=1; return mismatch<=d def wordsWithmismatch(seq1,d): """配列が一つ与えられると、ハミング距離がd以下であ...
27908b97b09c6fbc68f3822e17798ba896000ec7
Python44/PythonStarter
/PythonStarter/1_Lesson/1_1.Geron.py
241
3.890625
4
a=input("Введите сторону а ") a= float(a) b=input("Введите сторону b ") b= float(b) c=input("Введите сторону c ") c= float(c) p =(a+b+c)/2 S=(p*(p-a)*(p-b)*(p-c))**0.5 print("Площадь = ", S)
751f4f187c70ce715ea2805ba0b9b11f3b94b5e0
OskarKozaczka/pp1-OskarKozaczka
/01-TypesAndVariables/Programs/1.29.py
200
3.640625
4
import random rzut=random.randint(1,6) guess=int(input("Zgadnij wyrzuconą liczbę oczek:")) if guess==rzut: print("Zgadłeś!") else: print("Komputer wyrzucił",rzut,"Spróbuj jeszcze raz!")
8f499262a7eb05bb032558e2ce19c195ef19b648
fraune/Chess-AI
/app/agent/Scorer.py
3,878
3.609375
4
from enum import Enum import chess from app.agent.scorer_weights_simplified_evaluation_function import white_pawn_weights, white_knight_weights, \ white_bishop_weights, white_rook_weights, white_queen_weights, white_king_weights_middle_game, \ white_king_weights_end_game, black_pawn_weights, black_knight_weig...
c5f091926da87eb453e4aba36b9984c693329b20
krishnamohan-seelam/pythonbeyond
/pythonbeyond/beyondcm/loggingcontext.py
1,178
3.984375
4
import sys ''' Simple example to understand context manager ''' class LoggingContext: def __enter__(self): LoggingContext.print_message(self, message=None) return self def __exit__(self, exc_type, exc_val, exc_tb): if exc_type is None: LoggingContext.print_message(self, mes...
7e367d81835a5feaaa895a58a905fb806bffa107
YMSPython/Degiskenler
/Lesson1/OperatorlerOrnekler.py
1,726
3.8125
4
# Örnek 1) Disaridan alinan # iki sayının toplamiyla farkinin birbirine bolumunden kalanin sonucu kactir? sayi1 = int(input("Lütfen birinci sayiyi giriniz : ")) sayi2 = int(input("Lütfen ikinci sayiyi giriniz : ")) toplam = sayi1 + sayi2 fark = sayi1 - sayi2 mod = toplam % fark print("Islem sonucu :", mod)...
3eb97503f86dd607a4411991921952bc6849e938
kylebrownshow/python-programming
/unit-3/dictionary.py
2,533
4.5
4
#a dictionary is a collection of key/value pairs # dictionaries use curly brackets { } . sets also use curlies, but we're not talking about that right now. student = {'name': 'emma', 'age': 25, 'address': 'Toronto'} #access elements in a dictionary print(student['name']) print(student['address']) print(student['a...
01fbb0052d65f72b9364a02d4433837ceaecc502
LuKuuu/python-study
/lk_02_test2.py
805
3.8125
4
words = ['cat', 'window', 'defenestrate'] for w in words[:]: # Loop over a slice copy of the entire list. if len(w) > 3: words.insert(0, w) print(words) print("-" * 40) def cheeseshop(kind, *arguments, **keywords): print("-- Do you have any", kind, "?") print("-- I'm sorry, we're all out of", kin...
71a764ce7795cb303405692b3f8d85d09bf834f0
orcinus42/python-script-testonly
/day3/mymod.py
301
3.890625
4
#!/usr/bin/env python # x = 30 def printInfo(): print x + 30 class MyClass(): data = 'hello MyClass' def __init__(self,who): self.name = who def printName(self): print self.data,self.name if __name__ == '__main__': printInfo() ins1 = MyClass('jerry') print ins1.data print ins1.name
bbf5ab1a0dc62feb269a610c97ab101a7988d197
arjun-19922107/sample
/python_day1/letter_G.py
472
3.859375
4
result_str=""; for row in range(0,7): for column in range(0,7): if ((0<row<6 and column == 0) or ((row == 0 or (column<5 and row ==6) or (column>2 and row ==3)) and (column >1 and column < 6)) or (row == 3 and 1<column <2 and column < 4)or ((0<row<2 or 3<=row<=5)and column==5)): ...
46061fa65a653a981e8081be7eb096d88c4568f2
huran111/python
/study_04/format.py
662
3.875
4
name = "胡冉" print("姓名是:" + name) age = 18 print("年龄是" + str(age)) print("年龄是:%s" % age) isMarry = False print("结婚否?回答:%s" % isMarry) print("年龄是:%d" % age) # %f 小数点后面的位数,而且是四舍五入 salary = 2323.2323 print("我的薪水:%.2f" % salary) ''' 皮卡丘 ''' message = "乔治说:我今年{}岁了,{}幼儿园".format(age, age) print(message) # input usernma...
d8636ce6b2414d2f22e88724928e38fe8dffb5e8
AnnaAwaria/pyselenium
/liczba.py
286
3.578125
4
class Number: def __init__(self, v): self.value = v def wyzeruj(self): self.value = 0; def ustaw(self, wartosc): self.value = wartosc number = Number(9) print(number.value) number.wyzeruj() print(number.value) number.ustaw(11) print(number.value)
a4ec967b66a363207b38ca2cf619acc2298de14a
ShenDeng75/LeetCode
/147 对链表进行插入排序.py
2,219
3.71875
4
# -*- coding: utf-8 -*- class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def insertionSortList(self, head: ListNode) -> ListNode: if not head: return None res = ListNode(head.val) root = head.next p1 = res ...
c17312a1f0a6859b3d93e1d09e622781be4a4410
jburgoon1/python-practice
/26_vowel_count/vowel_count.py
550
4.15625
4
def vowel_count(phrase): """Return frequency map of vowels, case-insensitive. >>> vowel_count('rithm school') {'i': 1, 'o': 2} >>> vowel_count('HOW ARE YOU? i am great!') {'o': 2, 'a': 3, 'e': 2, 'u': 1, 'i': 1} """ vowelCount = {} vowel = 'aeiou' for lette...
6776c6f6427f299909112697f9825b663dd97601
leofelix077/TGB---Paradigmas---Python
/wonder_woman.py
2,391
3.65625
4
#------------------------------------------------------------------------------ # Autores: Leonardo Felix, Gisela Miranda Difini, Karolina Pacheco, Tiago Costa #------------------------------------------------------------------------------ from numpy import random import random as rand def NUMBER_OF_TRIES(): retur...
da95e736306e3b348c064056f8d27239b9c3b809
erpost/python-beginnings
/tuples/tuple_return_sorted_sequence_reversed.py
186
3.96875
4
# Return sorted sequence (by value order) c = {'a': 10, 'c': 22, 'b': 1} tmp = list() for k, v in c.items(): tmp.append((v,k)) print(tmp) tmp = sorted(tmp, reverse=True) print(tmp)
b2cdff9ccbc173406f9b28ed5c86f56ac3614163
afieqhamieza/DataStructures
/python/type_time.py
972
4.0625
4
# Imagine you have a special keyboard with all keys in a single row. # The layout of characters on a keyboard is denoted by a string keyboard of length 26. # Initially your finger is at index 0. To type a character, you have to move your finger # to the index of the desired character. The time taken to move your fin...
4ee96b75d9a6551d566be63508137d972cf20b90
EgorMichel/2021_Michel_infa
/1st week/tort13.py
960
3.765625
4
import turtle as t t.shape('turtle') t.speed(0) def arc(r): for i in range(90): t.forward(2 * r * 0.01745) t.right(2) def circle(r): t.penup() t.forward(r) t.right(90) t.pendown() arc(r) arc(r) t.penup() t.left(90) t.backward(r) t....
f52b048228652eced1c4866f2a9791170aa9c773
Phobosmir/checkio-home
/the-most-frequent.py
960
4.21875
4
""" ZH-HANS RU JA English You have a sequence of strings, and you’d like to determine the most frequently occurring string in the sequence. Input: a list of strings. Output: a string. Example: most_frequent([ 'a', 'b', 'c', 'a', 'b', 'a' ]) == 'a' most_frequent(['a', 'a', 'bi', 'bi', 'bi']) == 'bi' """ ...
a0e1dc5b15091080d9cf23d8bbb2ea1093861766
dbaird1/pl
/dbaird1_hw1/pow_full.py
392
3.859375
4
#! /usr/bin/env python import sys def powF(n, p): if p == 0: return 1 else: return n * pow(n, p-1) def powI(n,p): if p == 0: return 1; s = 1 while p > 0: p-=1 s= s*n return s if len(sys.argv) != 3: print("%s usage: [NUMBER] [power]" % sys.argv[0]) exit() print(powF(int(sys.argv[...
958e1673473fad4442740dc969e65b67fec9dcfd
vavronet/python-for-beginners
/functions/daripa/pascal_triangle.py
953
4.21875
4
# Create a function that prints on the screen the Pascal triangle with n rows. # 1 # 1 1 # 1 2 1 # 1 3 3 1 # 1 4 6 4 1 #1 5 10 10 5 1 def get_unknown_content(row, previous_row): unknown = [] counter = 1 while counter <= (row - 2): item = previous_row[counter] + previous_row[counter - 1] ...
d2ea629e3747b8281ce6309e36bcdb131dc37dca
sbelectronics/nixiecalc
/calculator.py
4,967
3.53125
4
""" Calculator Engine Dr. Scott M Baker, 2014 http://www.smbaker.com/ smbaker@smbaker.com """ import math import sys class Calculator(object): def __init__(self): self.display = 0 self.memory = 0 self.accumulator = None self.inputBuffer = "" self.operators...
ba30c3dd71cc716dd0871cd216bd990c56673725
mrparkonline/python3_functions
/exercise1.py
1,960
4.21875
4
# U6E1 - Exercise Set 1 Solutions # Mr Park ''' note: - To use any of these functions, you can import the file and try calling the functions ''' def isEven(num): ''' isEven determines if the given argument is an even number --param num : integer --return boolean ''' return num % 2 == 0 ...
39aeb9d2bba1827ed0ce62a69ccf4894ba81841a
lronl/start01
/home_first.py
1,644
3.53125
4
#1 Создать список из N элементов (от 0 до n с шагом 1). В этом списке вывести все четные значения. lis = [i for i in range(50)] num = 1 out = [] while(num < len(lis)): if lis[num] % 2 == 0: out.append(lis[num]) num += 1 print(out) #2 Создать словарь, Страна:Столица. Capitals = dict() Capitals['Russia'] = 'Mo...
85ec69adfdaa5f913fcf0b94d3dc13b2ee8f76dc
oknelvapi/GitPython
/Coursera_online/week5/test5.3.4.py
339
3.625
4
# Переставьте соседние элементы списка (A[0] c A[1],A[2] c A[3] и т.д.). # Если элементов нечетное число, то последний элемент остается на своем месте. a = input().split() print(*([x for i in range(0, len(a), 2) for x in a[i:i+2][::-1]]))
2a861a372bee1234eded99f208ad0d7628bd1335
sheldonzhao/LeetCodeFighting
/25. Reverse Nodes in k-Group.py
1,859
4
4
''' Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is. You may not alter the values in...
7e3980d18c785ceab36c979ea8ea646e48f1bb38
superorakul/while
/vsearch.py
472
3.578125
4
def search4vowels(phrase: str) -> set: """Здесь есть описание которое мне влом писать так что извините""" vowels = set('aeiou') return vowels.intersection(set(phrase)) def search4letters(phrase: str, letters: str='aeiou') -> set: """Возвращает множество букв из 'letters' найденных в указанной форме ""...
c17e88935491cb67e4f8a8751b5bbf6bb66c54e4
justinzh/python
/nester.py
446
3.625
4
'nested class in function' X = 1 def nester(): X = 2 print(X) class C: 'docstring for class C' X = 3 print(X) def method1(self): print(X) print(self.X) def method2(self): X = 4 print(X) self.X = 5 ...
ad1cc1968545006d11cd2241bb4dc61f2196fc42
jordan78906/CSCI-161_projects
/HernandezAlmache_Jordan_11.py
2,119
4.40625
4
#Jordan Hernandez-Alamche #CSci 161 L03 #Assignment 11 #Merge sort ''' -Merge Sort: 1:Find Mid point to divide the array into two halves 2:Call Merge Sort for first half 3:Call Merge Sort for second half 4:Base Case: if array size is 1 or smaller, return. 5:Merge the divided arrays sorted until the complete array is m...
619ae3498b34d7f95f825887527837d32b80e11e
mradityagoyal/python
/NextPermutation.py
1,469
3.625
4
class NextPermutation: def nextPermutation(self, nums): """ :type nums: List[int] :rtype: void Do not return anything, modify nums in-place instead. """ if len(nums) < 2: return for i in range(len(nums)-1, 0, -1): prev = i -1 if nums[i] > nums...
f19496470f2555a77a3aa855f980dc62e6a64d00
henriavo/learning_python_5e
/part_2/ch6.py
490
3.875
4
#!/usr/bin/python3 import copy print("mutable objects \n") print("shared references and equality \n") lista = [23, 41, 66, 11] listb = lista if lista == listb: print("both lista and listb are variables with same value!\n") if lista is listb: print("both lista and listb are variables pointing to the same object!\n...
ec5738f3915590b61a8eb2daa039e411e1266cd6
rtmoffat/pylearn
/fac.py
106
3.53125
4
def fac(n): if (n<=1): return 1 else: return (n * fac(n-1)) x=input("Enter number:") print(fac(x))
85404073ff30cda662e2dbed2c4522453ab6edb8
parkjeongmi/jamie_study
/0626test/0625_1.py
508
3.8125
4
#백준 #최소 스패닝 트리 #모든 정점 연결 + 가중치의 합 최소 #Kruskal Algorithm #1. 간선 정렬 #2. 간선이 잇는 두 정점의 root를 찾음 #3. 다르다면 하나의 root를 바꾸어 연결 def find_parent(parent, x) : if parent[x] != x : parent[x] = find_parent(parent, parent[x]) return parent[x] def make_union(parent, a, b) : a = find_parent(parent,a) b = find_...
2a9aa37463169109695215d2bf44c9052c1069e0
tancheng/CacheSim
/cachesimulator/word_addr.py
316
3.765625
4
#!/usr/bin/env python3 class WordAddress(int): # Retrieves all consecutive words for the given word address (including # itself) def get_consecutive_words(self, num_words_per_block): offset = self % num_words_per_block return [(self - offset + i) for i in range(num_words_per_block)]
810de4170334c19eb7c20f5e501c92f54a573882
vaibhavg12/Problem-Solving-in-Data-Structures-Algorithms-using-Python3
/Algorithms/2 Sorting/MInAbsDiffPair.py
923
3.96875
4
""" Given an array of integers, find minimum absoulute difference pair of all the possible pairs. first approach is to find each pair by runnning two loop and finding minimum among them. O(n2) """ """ Using sorting munimum diff pairs will be adjacent to each other. """ import sys def MinAbsPairDifferences(arr): si...
98b745b499fe4aed5644a5e76e357d88d182b5ed
raultm/Enero-String-Calculator
/amaneiro/stringcalculator.py
1,417
3.859375
4
#!/usr/bin/python #my own exceptions class NegativesNotAllowed(Exception): pass class StringCalculator: def add(self, values=""): if (len(values) == 0): return 0 adapter = EntryValuesAdapter(values) if (adapter.getNumberOfValues() == 0): return 0 if (not...
65d3bfdac89d6ae2d6b35bd96e44618de8ed5707
xfsala/Cool-ideas-python
/Collatz conjecture/Collatz con-3n+1 prob.py
495
3.8125
4
def checknum(num): iterations=1 while(num!=1): if num%2==0: num=num//2 else: num=3*num+1 iterations+=1 print(num,iterations) for i in range(20,31): checknum(i) /* when n is even set n as n/2.else set n as 3n+1. Repeat process till num become...
dbe8ca2c595afb3f97fbd6de685322a48f3cf6db
CaosMx/100-Days-of-Code_Python-Bootcamp-2021
/d001_e001.py
1,105
4.71875
5
# Day 001 # Exercise 001 # CaosMx # Dic 2020 """ Printing to the Console Instructions Write a program in main.py that prints the some notes from the previous lesson using what you have learnt about the Python print function. Warning: The output in your program should match the example output shown below exact...
e9cd859f53d0caf62a96f60e06e5a19ecb8bed1b
LopesAbigail/intro-ciencia-computacao
/Step-01/SEM7-EX02-PerimetroRetangulo.py
324
4
4
# Retângulo largura = int(input("digite a largura: ")) altura = int(input("digite a altura: ")) for i in range(0, altura): for j in range(0, largura): if (i == 0 or i == altura-1 or j == 0 or j == largura-1): print("#", end = "") else: print(" ", end = "") print("") ...
a19b1e11014ecb6c6c8c121df273dfb80e85e717
jiajiabin/python_study
/day11-20/day11/03_拷贝构造函数.py
2,198
4.09375
4
class Rect: def __init__(self, length, width): self.__length, self.__width = length, width # 在其他语言中,这个就是构造函数,构造函数不是构造对象的函数,而是初始化的函数。 # 在C++当中构造函数和类名相同的,在Python不认为这个函数是构造函数,构造函数是new。init就是初始化函数 def set_length_width(self, l, w): self.__length, self.__width = l, w def __repr__(self): ...
9fd56f29d142953aa363e79ad801b2eb62353ff3
DiptiGupte/Automate-the-Boring-Stuff-with-Python-projects
/inverter.py
553
3.6875
4
import openpyxl #invert the row and colum of the cells in spreadsheet def invert(spreadsheet): newWb = openpyxl.Workbook() newSheet = wb.active givenWb = openpyxl.load_workbook(spreadsheet) givenSheet = read.active for rowNum in range(1, givenSheet.max_row + 1): for colNum in range(1, given...
7894adf619c48a61cec7f861d0efb4212055f8fa
JunctionChao/LeetCode
/next_bigger_number.py
1,463
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Date : 2020-11-05 # Author : Yuanbo Zhao (chaojunction@gmail.com) """ get the next bigger number using the same digits of a number ex: 123 -> 132 """ def next_bigger(number): # 将数字转化为list number_to_list = [] while number: number, mod = divmod(num...
1d345e04ac551d260cfb34fd6aa8e5c64fea76b5
frankobe/lintcode
/16_permutations-ii/permutations-ii.py
1,155
3.765625
4
# coding:utf-8 ''' @Copyright:LintCode @Author: frankobe @Problem: http://www.lintcode.com/problem/permutations-ii @Language: Python @Datetime: 15-06-23 18:34 ''' class Solution: """ @param nums: A list of integers. @return: A list of unique permutations. """ def permuteHelper(self, nums, r...
a77e3d67abb3552e8e87ea95b73228ed8edff977
Ran-Dou/Python-for-Data-Scientist
/9 Manipulating DataFrames with pandas.py
8,812
3.578125
4
import os os.chdir('/Users/randou/Esther/Coding/Python/Data Scientist with Python/Python-for-Data-Scientist') # ============================================================================= # EXTRACTING AND TRANSFORMING DATA # ============================================================================= import pandas...
9582adc414a0635f4b72e5a7ab9ef75e405ababe
chronosvv/algorithm
/4longestsubstring.py
1,433
4.09375
4
# 题目: # # Given a string, find the length of the longest substring without repeating characters. # # Examples: # Given "abcabcbb", the answer is "abc", which the length is 3. # Given "bbbbb", the answer is "b", with the length of 1. # Given "pwwkew", the answer is "wke", with the length of 3. # Note that the answer ...
db94542c073c5085f14377f01330ecc31150214d
AlfredFranciss/C0804768_Week2_ClassEX
/revname.py
245
4.40625
4
# Function which accepts the user's first and last name and prints them in reverse def getname(): fname = input('Enter your First Name:') lname = input('Enter your Last Name:') print(f'Reversed Name is {lname [::-1]} {fname[::-1]}')
454eefc85682af10b1d2baf564a8154b22c0c642
Gaffey911/Gaffey
/file_practice.py
1,412
3.640625
4
''' 1.B E:\test.txt 2.默认打开模式是 r 只读 3.二进制形式 4.dump() 5.load() 6.以二进制在末尾追加写入读取 7.不关闭会占用资源并且不会保存内容 8.tell()方法 ''' #9 filename=input('请输入文件名:') print('请输入内容,【单独输入‘w’保存并退出】') f=open(filename,'w') while True: filecontent=input() if filecontent!='w': f.write(filecontent) else: break f.close() #1...
a193ecb1135a2441d21801c51e621e88bb6e43b8
amoahisrael/Global-code-P
/week2file/fold.py
175
3.671875
4
#from function import even #num=[2,6,8,12] def is_even(x): return x % 2 ==0; numbers = [1,56,234,87,4,76,24,69,90,135] a = (list(filter (is_even, numbers))) print(a)
da04feddf1bfdfdb3bff24e6b94896e877e7842c
okkays/advent_2020
/twentyone/solve.py
1,415
3.5
4
import collections import itertools import re inputmatcher = re.compile(r'^([\w\s]+)\(contains ([\w\s,]+)\)$') def readinput(filename): with open(filename, 'r') as f: raw = [l.strip() for l in f.readlines()] pairs = [] for line in raw: match = inputmatcher.fullmatch(line) ingredients = match[1].str...
d9b646304d9dec4b64acdda810a08e27d315b470
liviode/my_python
/edu/list_filter.py
188
3.640625
4
my_list = [123, 'artus', 'zürich', 22.476] print('my_list', my_list) filtered_list = [e for e in my_list if e != 123] print('...after filtering') print(my_list) print(filtered_list)
f36322a0c8096f236567f993ec77cc76d7d0a9b0
Fabaladibbasey/MITX_6.00.1
/longestSubstring
1,092
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Feb 4 23:48:24 2021 @author: suspect-0 """ # Assume s is a string of lower case characters. # Write a program that prints the longest substring of s in which the letters occur in # alphabetical order. For example, if s = 'azcbobobegghakl', then your ...
2bc80e66a5f6137243421a68686234a44ab2e882
MarkJParry/MyGMITwork
/Week03/absolute.py
257
4.125
4
#Filename: absolute.py #Author: Mark Parry #Created: 03/02/2021 #Purpose: Program to take in a number and give its absolute value inNum = float(input("Please enter a negative number: ")) print("the absolute value of {} is: {}".format(inNum,abs(inNum)))
c705c14d336bbbfa8dde80dae09dc22726b9f90c
hafizadit/Muhammad-Hafiz-Aditya_I0320064_AbyanNaufal_Tugas5
/I0320064_Soal1_Tugas5.py
481
3.6875
4
# Header print("") print("="*50) end = "Program Sapa" endCenter = end.center(50) print(endCenter) print("="*50) print("") # Program nama = input("Masukkan nama anda :") LK = input("Masukkan jenis kelamin anda (l/p) :") print("") if LK == "l" or "L": print("Selamat datang, Tuan",nama) elif LK == "p" or "P": pr...
2438f745c3c93d677bec9767d491e319f6210c85
Everlone/ProjectEuler
/euler_001.py
770
4.03125
4
''' euler_001.py First problem of the Euler Project ------------------------------------------------------------------------------ If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. -...
d794a7444e45815af026bea3a9ce108cf3b430af
boreesych/SQLwebinar
/from_azure2python.py
425
3.53125
4
import psycopg2 conn = psycopg2.connect( "dbname='' user='' host='' password=''" ) cursor = conn.cursor() cursor.execute("SELECT * FROM students") # cursor.execute("SELECT id, nickname FROM students") for i in cursor.fetchall(): print(i) # [print(row) for row in cursor.fetchall()] # for id, ni...
ddb05d8f840b293d8e621770bb566fbde22243e9
ataabi/pythonteste
/Desafios/ex013.py
234
3.671875
4
# Faça um algoritmo que leia o salario de um funcionario e mostre seu novo salario, com 15% de aumento. s = float(input('Qual o salário do funcionario ? \n: ')) print(f'Com 15% de aumento o salário sera de R${(s+(s*0.15)):.2f} .')
15aa426bfefaac2d48d133607b94b53a135f904b
DAVIDnHANG/TL-PythonAllProject-CS
/LSC%--Data-structure/names/JoshuaNames.py
2,139
4.0625
4
""" Binary search trees are a data structure that enforce an ordering over the data they store. That ordering in turn makes it a lot more efficient at searching for a particular piece of data in the tree. This part of the project comprises two days: 1. Implement the methods `insert`, `contains`, `get_max`, and `fo...
fa254d0f0ec78aa0df1e00c40e6fd979ac16a118
stldavids/03-Text-Adventure
/gameEngine.py
8,084
3.578125
4
#!/usr/bin/env python3 import sys, logging, os, json version = (3,7) assert sys.version_info >= version, "This script requires at least Python {0}.{1}".format(version[0],version[1]) logging.basicConfig(format='[%(filename)s:%(lineno)d] %(message)s', level=logging.INFO) logger = logging.getLogger(__name__) #Players ...
37872c8564377735354d9c6a1f5d6783044205d3
jeffersonjpr/maratona
/codewars/python/Smallest unused ID.py
736
3.609375
4
# https://www.codewars.com/kata/55eea63119278d571d00006a # referencia # https://stackoverflow.com/questions/53513/how-do-i-check-if-a-list-is-empty # https://stackoverflow.com/questions/3654830/why-are-there-no-and-operators-in-python # https://www.geeksforgeeks.org/max-min-python/ # http://excript.com/python/operador...
e77812de3414766abf9ef1331a69ad9ee911ef8d
EmiCohenSoft/eCohenAdimra
/semana6/7ºEJ_ingresos_diarios_2020.py
3,965
3.609375
4
""" Cálculos sobre ingresos: Se dispone de un reporte de ingreso diario del año 2020, en archivo de texto con formato CSV (valores separados por coma), ver adjunto. 1. Cargar el paquete de reportes en una lista. 2. Calcular el promedio diario de ingresos del 1er semestre. 3. Calcular el promedio diario de ingresos de...
2521f72b09553909ebe0ad5a81abcadc63ba54b6
AdamZhouSE/pythonHomework
/Code/CodeRecords/2526/50263/263886.py
234
3.609375
4
str1 = input() str2 = input() if 'null' in str1 or 'null' in str2: str1 = str1.replace(',null','') str2 = str2.replace(',null','') list1 = eval(str1) list2 = eval(str2) list3 = [] list3 = list1 + list2 print(sorted(list3))
122cb10128d81a4e89a7ed8f420c93e8ea69ddbe
albertyfwu/project_euler
/56.py
187
3.546875
4
max_digit_sum = 0 for a in range(2, 100): for b in range(2, 100): n = a**b sum = 0 for c in str(n): sum += int(c) max_digit_sum = max(max_digit_sum, sum) print max_digit_sum
927b58db1a7dad055906aa2cb0ec640adb3aa3bb
Morgassa/Code_Wars
/4 kyu/(4 kyu) Range Extraction.py
1,870
3.515625
4
def generator(args): len_arsgs = len(args) i = 0 while i < len_arsgs: low = args[i] # Enquanto o contador 'i' for um caracter menor que o tamanho da lista e # o valor do argumento atual +1 for igual ao proximo. # Soma-se 1 ao contador 'i'. while i < len_arsgs-1 and ...
afacfd880ad32ff86076130e0ffae15978c68654
galenwilkerson/Coursework
/Kaggle_Titanic_Machine_Learning_2016/kaggle_titanic_1.py
21,336
3.703125
4
''' Basic Titanic Competition submission for kaggle https://www.kaggle.com/c/titanic Much of this comes originally from: https://www.dataquest.io/mission/74/getting-started-with-kaggle The point of this is to go through all of the steps from reading data to submitting to kaggle Functions are written as generally as ...
94d62711656f57424cb987fc879c9b0db3335b81
mike-jolliffe/Learning
/PDX_Code_Guild/DarkRealm/Creature.py
4,698
3.859375
4
from Room import * class Creature(object): '''Used for creating a creature, giving it stats, and making it fight''' def __init__(self, name, health, weapon, location): self.name = name self.health = health self.weapon = weapon self.location = location def move(self, dir, R...
52a8a100a21eafae3c521ad83b64e6b2de36f9ea
incidunt/py.standard.lib.practice
/re_simple_match.py
481
3.609375
4
import re pattern = 'this' text = 'does this text match the pattern ?' match = re.search(pattern, text) s = match.start() e = match.end() print 'found "%s"\nin "%s"\nfrom %d to %d ("%s")' % \ (match.re.pattern, match.string, s, e, text[s:e]) regexes = [ re.compile(p) for p in [ 'this', 'that' ] ] print rege...