blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
36ad44fdab61c80f92847790e6010fb67f478e2f
DEVESHKUMAR97/Turtle_patterns
/Turtle_pattern2.py
518
3.65625
4
import turtle turtle.bgcolor("black") turtle.speed(0) turtle.penup() turtle.goto(-50,-50) turtle.pendown() turtle.left(36) turtle.color("blue","skyblue") turtle.begin_fill() def multiple_stars(turtle,size): if size >=10: for i in range(5): turtle.forward(size) multiple_stars(turtle,...
847a49fdb7708f3580206e41d99621f0b4eebbf6
zgarzella/CS1
/Programs/count_to_twenty.py
172
3.890625
4
# Zack Garzella # This program will count to 20 counter = 0 while counter <= 20: print(counter, end = " ") counter += 1 input("\n\nPress enter key to exit")
46f1e807005af6cd55a29077000f541ed2737231
salviolorenzo/python105
/de_dup.py
722
3.8125
4
#list1 = [] #list2 = [] #element_count = int(input("How many elements in the list? ")) #counter = 0 #while counter < element_count: # elem = input("Enter an element to add to the list: ") # for i in range(len(list1)): # if list1[i] != (list1[i]-1) # list2.append(elem) # counter +=1 # list1 = ['h...
41e3bec8b049fed024ec87b80e62e77c64d8aed2
Prashant-Bharaj/A-December-of-Algorithms
/December-01/py_ajaykrishnan23.py
440
3.8125
4
import random def binary_search( x, start, end): mid = int((start + end)/2) if(x>mid): print('Higher') binary_search(x,mid+1,end) elif (x<mid): print('Lower') binary_search(x,start,mid-1) else: print(mid,' is right. Your guess is spot on!') exit(0) def main(): player_a_ch...
a0e2a73cbf88f8ad6d3a7511482471b28b3aeb58
Qiong/ycyc
/learnstreet/2.py
1,192
4.3125
4
#string defs project def revers(str): # Accept an input string, str, and reverse its characters in order "REPLACE THIS CODE WITH YOUR CONVERSION METHOD" return str[::-1] def uppercase(str): # Convert all the characters of the input string, str, to upper # case. Reurn the uppercased string. "REP...
457a0e97e76a70d6033e99274a7d48413ff10949
luismoax/Competitive-Programming---luismo
/RPC/Competencia 05 RPC 2020/D.py
457
3.765625
4
n = int(input()) for i in range(n): k = int(input()) name = str(input()) pancakes = 0 peaSup = 0 # reading restorant names for j in range(k): plate = str(input()) if plate == "pea soup": peaSup = 1 if plate == "pancakes": pancakes = 1 ...
52b5024f6473aac7a3259aed3716e211eefe96bf
SurakshaRV/python-lab-1BM17CS108
/db8.py
1,025
3.9375
4
import sqlite3 con=sqlite3.connect("mydb7.db") p=con.cursor() con.execute("CREATE TABLE STUDENT (roll int primary key not null, name charvar not null, sem int not null, dept charvar)") details=[[1,'abc',5,'cse'],[2,'def',5,'cse'],[3,'xyz', 5, 'cse']] con.executemany("INSERT INTO STUDENT VALUES(?,?,?,?)",details) st_lis...
ad66b634ef338efc5611b85e7ca11ae919ee8e93
edu-athensoft/ceit4101python
/stem1400_modules/module_9_datetime/s91_datetime/s5_timedelta/datetime_8_timedelta_nextndays.py
411
4.03125
4
""" datetime module timedelta class 1.5.6 Time duration in seconds You can also find sum of two dates and times using + operator. Also, you can multiply and divide a timedelta object by integers and floats. """ from datetime import datetime, timedelta now = datetime.now() print(now.strftime('%Y-%m-%d %H:%M:%S')) ...
3fcb15eb6a254f019f429bfcd3bac5dab1b5c32c
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_201/1415.py
2,680
3.640625
4
import heapq class PrioritySet(object): def __init__(self): self.heap = [] self.set = set() def add(self, d): if d not in self.set: heapq.heappush(self.heap, -d) self.set.add(d) def get(self): d = -heapq.heappop(self.heap) self.set.remove(d...
eacf41de93ff8422d1fd7fa415ee2090b31638d8
Ana-Vi/Homework
/Pythons/l7q5.py
268
3.75
4
def listaret(palavra,letra): l=[] for x in range(len(palavra)): if letra==palavra[x]: l.append(x) return l texto= str(input("insira a palavra e o caractere: ")) lista= texto.split(" ") palavra= lista[0] letra= lista[1] print(listaret(palavra,letra))
5be6431ab724a8d1a488b94748c9ff26ba2e567c
leonardokiyota/Python-Training
/LivroPythonInt/Exercises/Chapter 04/4.2.py
530
4.0625
4
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- ''' Escreva um programa que pergunte a velocidade do carro. Caso ultrapasse 80 Km/h, exiba uma mensagem dizendo que o condutor foi multado. Nesse caso, exiba p valor da multa, cobrando R$5,00 por km excedido. ''' vel = float(input("Digite a velocidade: ")) i...
0accdcc95ba84009e18f357bd014336b0ac84190
mukeshv483/python_demo_programs
/Python-programs/Python-Training/python_programs2/python22.py
440
3.984375
4
import math x=input("Enter the value of x: ") y=input("Enter the value of y: ") print "acos(x) : ", math.acos(x) print "asin(x) : ", math.asin(x) print "atan(x) : ", math.atan(x) print "atan2(x,y) : ", math.atan2(x,y) print "cos(x) : ", math.cos(y) print "sin(x) : ", math.sin(x) print "tan(x) : ", math.tan(x) pr...
3686332172991106b001b954a53ef44ff6a5ec09
ZhangNANPy/LeetCode
/97_InterleavingString.py
1,662
3.5
4
# -*- coding: utf-8 -*- # @File : 97_InterleavingString.py # @Author: ZRN # @Date : 2019/5/24 """ 给定三个字符串 s1, s2, s3, 验证 s3 是否是由 s1 和 s2 交错组成的。 输入: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac" 输出: true """ class Solution: def isInterleave(self, s1: str, s2: str, s3: str) -> bool: if len(s1) + len(s2) !...
6aad564d5c63e16f79ec1191960cd6f0a8d09ae4
figarrido/Algorithms
/Sort/RandomizedSelection.py
1,242
3.8125
4
# -*- coding: utf-8 -*- from random import randint __author__ = "figarrido" """ RSelection: Recibe un arreglo de números en desorden y el número del i-ésimo número más pequeño, elige un número (pivote) aleatoriamente y lo intercambia con el primer elemento del arreglo luego se ordenan los elementos menores al pivote i...
5bd6355d7d074ed775d43e13bd94fb0ff1902a05
xiang-daode/Python3_codes
/7_list元素之遍历.py
212
3.921875
4
a = [3,2,7,6,8] for m in a: print(m) for i in range(len(a)): print(i, a[i]) b = ['I', 'have', 'a', 'little', 'cat'] for m in b: print(m) for i in range(len(b)): print(i, b[i])
fe19779ee76bf578db8cc587ea1baebf8c2abdc8
markrgrant/robot
/robot/balance.py
1,180
3.953125
4
from container import Container class Balance(Container): """ A Balance Weighs a single container. A Balance can weigh containers of any type. """ _default_weight = 1.0 def __init__(self): self._contents = None def to_dict(self): return dict( contents=self._c...
4a6306b0f537524c6057391a6c865c0050bc0c29
Murilo-ZC/FATEC-MECATRONICA-MURILO
/LTP2-2020-2/Pratica06/prog06.py
543
3.875
4
#O programa deve ler o codigo do produto e consultar seu valor em uma #tabela de precos pre-definida. Exibir o total do pedido para o usuario def pegarPreco(codigo): #Indice == código do produto e conteúdo é igual ao seu valor lista_de_precos = [10, 15, 200, 50, 40, 80, 200] if codigo >= 0 and codigo < len(lista...
f4b81f561c369b88c418cafce81615e658f597bc
joreakshay/python
/SimplePrograms/File/longestAndSmalestLine.py
668
4.125
4
#Write a program to accept name of a file from user & display longest & smallest line from the same. def LongestAndSmallest(fd): line = fd.readline() smallest=line longest=line while line != "": if len(longest)<len(line) : longest=line if len(smallest)>len(line) : ...
9b417c9b7f1b52eef8192a0c4b1cd867b4cc4836
SaiSivaNow/MyPlayRoom
/myfiles/heapsort.py
823
3.71875
4
def maxHeapify(mylist,i,n): l= 2*i+1 r=l+1 largest=i if l<n and mylist[l]>mylist[largest]: largest=l if r<n and mylist[r]>mylist[largest]: largest=r if largest != i: mylist[largest],mylist[i]=mylist[i],mylist[largest] maxHeapify(mylist,largest,n) ...
011f3d62b6d5debd688cb81f230920c32a05ee54
kartrio/learnPython
/com/ex16.py
968
4.1875
4
from sys import argv script = argv filename = raw_input("file:") print "We're going to erase %r." % filename print "If you don't want that,hit CTRL-C (^c)." print "If you do want that,hit RETURN" # readline ȡıļһ # write(stuff)-stuffдļ raw_input("?") print "Opening the file..." # r:wдa:Ӳb:ƴȡ ȱʡr # 'w+' ...
72cb55cb3cc55af964284c4365b3cd7671ef8124
thbeca-30/Computational_Mathematics
/LabWork2/SolvingLinearEquations.py
3,431
3.578125
4
import numpy as np eps = 0.001 def GaussMethod(): print('Метод Гаусса:') a = np.array([ [3.11, -1.66, -0.60, -0.92], [-1.65, 3.51, -0.78, 2.57], [0.60, 0.78, -1.87, 1.65] ]) a[1] = a[1] - np.round(a[0] * (-0.53), 2) # из второй строчки вычитаем первую, умноженную на -0.53 ...
311b8de01e6bbf1da3529db053fd47fcf60e3da1
ssardanah/FYDP
/firmware/arduino_fw/arduino_fw.py
832
3.578125
4
################################################################### ## Script listens to serial port and writes contents into a file ## ################################################################### ##Install pySerialL # sudo easy_install pyserial ##Change the port address: ##On termial list all ports: # ls /d...
604ed6241f30bdcb83b685ce63b74992a0b7f4b0
June-fu/python365
/2020/01january/31.py
596
4.21875
4
#!/usr/bin/python # -*- coding: UTF-8 -*- # Author: june-fu # Date : 2020/2/2 """ Problem 27: Write a function triplets that takes a number n as argument and returns a list of triplets such that sum of first two elements of the triplet equals the third element using numbers below n. Please note that (a, b, c) and (b,...
5f8cfcd2107a5fb2eeb4661f33626c55fd01ff55
Kateryna-hub/study
/Lesson_3/homework_lesson_3.py
3,031
3.96875
4
class Stack: def __init__(self): self.items = [] def clear(self): self.items.clear() def push(self, item): self.items.append(item) def pop(self): if len(self.items) == 0: print('Stack is already empty') else: return self.items.pop() ...
a79b4b3e76fd6598b9850604e50d344d82d5539d
gjwei/leetcode-python
/medium/Construct BinaryTreefromPreorderandInorderTraversal.py
885
4
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ created by gjwei on 3/25/17 """ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None from TreeNode import * class Solution(object): def build...
0c279ad3bbbb3bf4b7cf780247df2f506939164c
mosest/11th-Python
/6.2 - 5 and 7.py
625
4.40625
4
#Tara Moses #Assignment 6.2: All Except 5 and 7 #January 29, 2013 #1. Program prints out all numbers between 0 and a user-specified max. #2. Program omits all multiples of 5 and 7. print("I'm going to print out all the numbers between zero and another number.") print("Except I won't print any multiples of 5 or 7. I h...
1dcb3c646ac822a2e05268ea13608416a137c610
akshatthirani/comparing-cloud-storage
/mkaccount.py
1,369
3.59375
4
""" Script to generate jQuery commands for account creation """ import argparse from random import randint def main(): # Parse arguments parser = argparse.ArgumentParser(description='Service type') parser.add_argument('service', type=str, nargs=1) parser.add_argument('account_name', type=str, na...
a3a3594edc24202f4f1466d2aa68cf5063ba5cbc
AlecFaye/Coding-Practice
/August 2020/August 11/Trik.py
692
3.875
4
def a_move(_position): if _position == 1: _position = 2 elif _position == 2: _position = 1 return _position def b_move(_position): if _position == 2: _position = 3 elif _position == 3: _position = 2 return _position def c_move(_position): if _position == 1...
9db0ea8b3c9facb9cc2338ec81018f7a2ad88e16
YanhongSha/Hello
/hello.py
117
3.765625
4
height = input('height:') weight = input ('weight:') print('hello, you height is',height, 'your weight is', weight)
09a8c83666a3710acbfb03bc1ab5fc59c3d3d4eb
SantiagoJSG/Trabajo_Final_30_Abril
/Ejercicio5.py
355
4.09375
4
# Ejercicio 5 import math print("El programa está orientado a leer un número decimal e imprimir su parte entera y decimal por aparte.") numero = float(input("Digite un número decimal: ")) parte_decimal, parte_entera = math.modf(numero) print(f"La parte entera del número digitado es: {parte_entera} y su parte d...
30c399a35d625485e83f42018b52b7f8065a6df8
RickyHuo/leetcode
/python/python3/kth-largest-element-in-an-array.py
876
3.609375
4
class Solution: def findKthLargest(self, nums: [int], k: int) -> int: nums = nums.sort() return nums[-k] def quick_sort(self, nums): if len(nums) <= 1: return nums before = [] after = [] flag = nums[0] for i in range(len(nums) - 1): ...
3a178b02902da024d7c3224ffd9bbf12d39fbbda
etsuura/AI_practice
/ex3_4.py
4,944
3.734375
4
import copy from queue import PriorityQueue def AStarSearch(graph, start, goal): openlist = [start] closedlist = [] queue = PriorityQueue() queue.put((0, start)) allcost = cost_class() now_cost = 0 print("start") while openlist != 0: #step2 print(openlist, close...
ea41dce75f4572c89e572eef246a5737d3f11ff9
KickItAndCode/Algorithms
/Trees/Traversal.py
1,861
3.796875
4
from collections import deque # Root -> Left -> Right def PreOrder(tree): if tree: print(tree.getRootVal()) PreOrder(tree.getLeftChild()) PreOrder(tree.getRightChild()) def IterativePreOrder(tree): if tree: stack = deque() stack.append(tree) while stack.coun...
78a6e0c1b3f5baf1fad52f393cbc3b5492e2b494
wzb1005/leetcode
/Python/q22.py
554
3.609375
4
# 22. Generate Parentheses from typing import List class Solution: def generateParenthesis(self, n: int) -> List[str]: self.output = [] def seekpar(str, left, right): if left == right ==0: self.output.append(str) return if left != 0: ...
468575841bc8ae8ad81ccdd43291da4001caa0bb
TheWritter/ProjectEuler
/problem2.py
1,330
4.0625
4
""" Even Fibonacci numbers Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million,...
84c739567b47af208fb1f25ff81b1c3aeb202611
cohenne/google-project
/try_without_files.py
1,262
4
4
# This file is intended to check the correctness of the function logic without integrating the whole system import string sentences = ["hello", "nechama", "bracha"] def replace_char(word): word = word[::-1] for index, char in enumerate(word): for i in string.ascii_lowercase: if word.repl...
c0380f9a74753bfcf66c769b9d62d0c0ff431f32
Shovon588/Programming
/Codeforces with Python/1407A. Ahahahahahahahaha.py
558
3.5
4
for I in range(int(input())): n = int(input()) a = list(map(int,input().split())) ones = 0 zeros = 0 for num in a: if num==1:ones+=1 else:zeros+=1 half = n//2 if zeros>=half: print(half) for i in range(half): print(0,end=' ') elif ones>=half...
5d81f0e7dbd59337cb0ee129ce2f9df8c68269d2
statistics-exercises/central-limit-theorem-2
/main.py
423
3.828125
4
import matplotlib.pyplot as plt import numpy as np def normal( mu, sigma2 ) : # Your code to generate the normal random variable goes here # This part draws the graph indices, samples = 100*[0], 100*[0] for i in range(100) : indices[i] = i+1 samples[i] = normal( 5, 9 ) plt.plot( indices, samples, 'ko...
50824e944e7d054066a5d8ad9ed9672833e1a595
weihaoclarencehuang/python
/Exam Prep.py
5,353
4.0625
4
############################################################################################# # String and list slicing ############################################################################################# s = "The number is 42." print(s[4:-7]) print(s[-7:-1]) print(s[-6:len(s)]) >>>number >>> is 42 >>>is 42....
29c23ea4fe2e89726c246c52dd9f02e28ba68a18
LizbethOD/poo_1719110401
/semana_2/banco.py
1,134
3.75
4
class Banco: '''Atributos''' cajeros= "5" escritorios= "10" ventanillas= "8" color= "azul y blanco" gerentes= "7" oficinas= "5" vigilancia= "policias" horario= "8am-8pm" pantallas= "2" computadoras= "40" '''Metodos''' def prestar_dinero(self): print("Prestar dinero") def brindar_se...
004c19740a122ddec7d3a9ef8ac6861deba32c32
Shiva-Kandagatla/python-scripts
/Leaning _Tower_of_Pisa.py
375
3.8125
4
n = int(input("Enter Height : ")) sp,st=" ","*" if n==1: print(st) else: # For Line 1 print(sp*(n-1) , end="") print(st*n) # For All inbetween Lines x=n-2 for i in range(n-2): print(sp*x,end="") print(st,end="") print(sp*(n-2) , end="") print(st) x=x-1...
8078d07e76ecfa5f6273597a9c58d00a832b467b
jnjnslab/python-sample
/01_bisic/henkan.py
194
3.921875
4
#数値を文字列に変換する print(str(29)) print(str(3.14)) #整数に変換する print(int('123')) print(int(3.14)) #浮動小数点に変換する print(float('3.14')) print(float(10))
5d4de7f69df1ba845f296176c33b0d3e79f010ae
yankuang608/Algorithm
/D&C/maximum_array_linear.py
566
3.671875
4
#maximum subarray linear-time def Find_Maximum_Subarray(A): n=len(A) sum=0 max=-10000000 for i in range(0,n): sum+=A[i] if sum>max: max=sum high=i sum=0 max=-10000000 for j in range(n-1,-1,-1): sum+=A[j] if sum>max: max=sum ...
651d501207d91776ef13864939883210e8f64a4f
vprusso/6-Weeks-to-Interview-Ready
/quickstart_guides/recursion/python/binary_search.py
1,571
4.1875
4
""" Title: Binary search Problem: Binary search is a search algorithm that finds the position of a target value within a sorted array. Binary search compares the target value to the middle element of the array. If they are not equal, the half in which the target cannot lie is eliminated and the se...
8fd59bde5646be13df8f47d9bcc44d34aa1b3688
Berteun/adventofcode2019
/day14/part01_02.py
1,814
3.515625
4
import math from collections import namedtuple, defaultdict Element = namedtuple('Element','quantity name') Reaction = namedtuple('Reaction', 'inputs outputs') produced_by = defaultdict(list) produced_of = {} def to_element(s): qty, name = s.strip().split() return Element(int(qty), name) def parse_reaction(l...
04becd5d4c95d08e95b316690e12ed9bd80df6a8
swesadiqul/python-gui-widgets
/PanedWindow.py
358
3.5625
4
from tkinter import* def exit_page(): exit() root = Tk() root.title("PanedWindow") pw = PanedWindow(root, bg="green", width=300, height=200) b = Button(pw, text="Close", bg="yellow", activebackground="yellow", font=("arial", 12, "bold"), command=exit_page) pw.place(x=200, y=50) b.place(x=120, y=10) roo...
07da14d1b3117b47a5216f551d6e772212b4b79f
cathuan/LeetCode-Questions
/python/q204.py
816
3.796875
4
import sys class Solution(object): def remove(self, nums, flags, index): num = nums[index] local_index = index + num while local_index < len(nums): flags[local_index] = False local_index += num new_index = index + 1 while new_index < len(nums) and...
f3566a22373f4336989f57d177443632b87e4a57
3than0ls/Imperial
/utils/proper.py
539
4.03125
4
def proper(list): """turns a list of items into a string, but it has the "and" at the end, meaning we can't just use .join()""" string = "" for i, item in enumerate(list): item = str(item) if i == 0: string += item elif i != len(list) - 1: string += f", {item...
5d162288264666de5ba7fe0613024e34ef806caa
VVKot/coding-competitions
/leetcode/python/21_merge_two_sorted_list.py
459
3.765625
4
class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode: temp = head = ListNode(-1) while l1 and l2: if l1.val < l2.val: head.next, l1 = l1, l1.next ...
697865c8d41c12d74cb2b7a6e860d59543b23c16
jessyefuster/ft_linear_regression
/train.py
2,109
3.71875
4
#!/usr/bin/python3 import math import sys import matplotlib.pyplot as plt from parse import parseDataset, storeValues from linearFunction import hypothesis plt.ion() fig = plt.figure() ax = fig.add_subplot(1,1,1) def showGraph(t0, t1, clear=False): if clear: ax.clear() ax.plot(dataset['km'], dataset['price'], ...
da82392e90352a6b7524963975ce1ed9cb455b4f
N0l1Na/Algorithms_Python
/PIL008/PIL008.py
407
4.09375
4
""" PIL - The exercise is taken from the Pilshchikov's Pascal problem book Task 9.2 page 48 Regular types: matrix Specify the variable types A, A[3], A[9][18], A[1][1], B, B[15], B[3], B[10][16] """ n = 10 first_matrix = [[0 for i in range(n)] for i in range(n)] n = 10 matrix1 = [[0 for i in range(n)] for i in ran...
4438f6e72a8d7c26695d31716a1399ebc1f52d67
attacker2001/Algorithmic-practice
/Codewars/[6]persistent-bugger.py
2,058
3.84375
4
#!/usr/bin/env python # coding:utf-8 """ @author: attacker2001 @file: [6]persistent-bugger.py @time: 2018/12/05 @project: Algorithm-Exercise @software: PyCharm """ """ https://www.codewars.com/kata/persistent-bugger/train/python Write a function, persistence, that takes in a positive parameter num and returns...
fea5f99c27b0c07240f918b0de700fe89148af65
spiderbeg/python-ins
/rectangle.py
260
3.75
4
import random def rectangle(w=5, l=5, i="*"): for wide in range(w): for leng in range(l): if leng < l-1: print(i, end='') else: print(i) rectangle(4,5, "#") rectangle(4,9, "#") rectangle(8,3)
a040cf5420313ba9b949df593bdc9db23a6b8b7b
hugotuesta/python_apps
/arcade/almost_increasing_sequence.py
547
3.921875
4
def almost_increasing_sequence(sequence): removed_one = False prev_maxval = None maxval = None for s in sequence: if not maxval or s > maxval: prev_maxval = maxval maxval = s elif not prev_maxval or s > prev_maxval: if removed_one: retu...
93baa979c1928e547e03e6d68e5547a962b1763e
mohammedjasam/Competitive-Programming
/Solved/Python/QuickBrownFox.py
410
3.609375
4
N = int(input()) for x in range(N): Letters = [] for x in range(97,123,1): Letters.append(chr(x)) s = input() s = s.lower() for letter in s: if letter in Letters: Letters.remove(letter) if len(Letters) == 0: print('pangram') else: print('missing'...
22f1bfecdeeaf630f57088297e90f8196a93add9
oaao/advent-of-code
/python/2021/06/06.py
737
3.609375
4
""" EXERCISE PROMPT: http://adventofcode.com/2021/day/6 """ INPUT = [int(x) for x in open('input', mode='r', encoding='utf-8').read().strip('\n').split(',')] def spawn(initial_state, days=0): # use a register of 0-8 (possible age states) spawn_state = [0] * 9 # initialise spawn state with starting fish ages for...
0edfa318ce2384646820d78db9b35872d713ff59
michaelkutuzov/lambda_brain
/z0ec/z0ec.py
239
3.5625
4
def squirrel(N): def factorial(N): counter = 1 result = 1 while counter <= N: result = result * counter counter += 1 return result f = factorial(N) return int(str(f)[0])
f87c198b9a70672476da01b051068c3913375edf
adamorhenner/Fundamentos-programacao
/vp2/objeto.py
848
3.5
4
#pessoa1 = ["adamor","065-054-343-21", "adamorhenner2@outlook.com"] #pessoa2 = ["adam", "123456894", "ada_candido@hotmail.com"] #print(pessoa1[0], pessoa1[1], pessoa1[2]) p1 = {'nome': 'Adamor', 'cpf': '06505434321', 'email': 'adamorhenner2@outlook.com'} p2 = {'nome': 'Adamor1', 'cpf': '06505434321', 'email': 'adamo...
785f7e75651661407737600cb709cfd411a65cd0
tlaehdtlr/Go-Algorithm
/삼성/주사위 굴리기.py
1,307
3.515625
4
def move(command, r,c): if command==1: c+=1 if c>=M: return None dice[0] = dice[0][1:] + [dice[0][0]] dice[1][0] = dice[0][0] dice[1][2] = dice[0][2] elif command==2: c-=1 if c<0: return None dice[0] = [dice[0][-1]] + dice[0][:-1] dice[1][0...
a1dcd16a8de7591640ac2ca3868d7cc051b06302
PierreBeylard/jeu_du_pendu
/code/pendu.py
2,208
3.75
4
###Régles du jeu### """l'ordinateur choisit un mot au hasard dans une liste, un mot de huit lettres maximum. Le joueur tente de trouver les lettres composant le mot. À chaque coup, il saisit une lettre. Si la lettre figure dans le mot, l'ordinateur affiche le mot avec les lettres déjà trouvées. Celles qui ne le s...
6aea488ab45998317d8a8d5e180d539e5721873e
ariModlin/IdTech-Summer
/MAC.py
518
4.125
4
# finds the MAC of a message using two different keys and a prime number message = "blah blahs" key1 = 15 key2 = 20 prime_num = 19 def find_mac(): message_num = 0 for i in range(len(message)): # takes each letter of the message and finds its ASCII counterpart num = ord(message[i]) # adds each ASCII nu...
aef1e8864d462368f9b6639dfedbf068976a34d7
gun-1986/watchguard
/lib/web/webtable.py
1,485
3.671875
4
""" This module solves the problem of getting table element data of web """ __author__ = 'jin.qian' class WebTable(object): """ Getting table element data of web according to row number """ web = None xpath = None def __init__(self, web,xpath): self.web = web self.xpath ...
7a9898acb3b78ef7c10b47cbcfc8221363d0aff9
DuvanSGF/Python3x
/col.py
108
3.96875
4
num=7 if num>3: print("3") if num <5: print("5") if num ==7: print("7")
d550955821136eea13a312a0b74bf38683102b04
chefirchy/Python
/l2/12.py
220
3.703125
4
print("Умова: Вивести вартість цукерок.") a, b = map(float, input("Значення「A」(цiна за кг), 「B」(маса): ").split()) print("【Цiна】(грн) => {0}".format(a*b))
29e10ea7101ed7590927b858ea32d546480efbb0
YoungGaLee/Python-Study
/Hackerrank/[1] Iterables and Iterators/Iterables and Iterators_nayoung.py
441
3.84375
4
# Enter your code here. Read input from STDIN. Print output to STDOUT from itertools import combinations def calculate(n, q, k): score = 0 num = 0 a = list(combinations(q,k)) total = len(a) for i in a: if 'a' in i: num +=1 score = num/total print(round(score, 3)) ...
d7055bd59d669bf5aee34bf3f2faadcf05b4cefd
Cica013/Exercicios-Python-CursoEmVideo
/Pacote_Python/Ex_python_CEV/exe044.py
1,410
3.9375
4
# Elabore um programa que calcule o valor a ser pago por um produto, considerando o seu preço normal e condição # de pagamento: - À vista dinheiro/cheque: 10% de desconto - À vista no cartão: 5% de desconto # - Em até duas vezes no cartão: preço normal. - 3 vezes ou mais no cartão 20% de juros. produto = float(input('D...
a7e8cff5d23f616e05325401dcf35b3a688d808a
seanchen513/leetcode
/greedy/0134_gas_station.py
5,506
4.21875
4
""" 134. Gas Station Medium There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to its next station (i+1). You begin the journey with an empty tank at one of the gas stations. R...
e3fdbbae595a8b86d095df20be00b678e8d48c58
foureyes/csci-ua.0479-spring2021-001
/_includes/classes/17/space.py
336
4.0625
4
def insert_spaces(word): """inserts spaces after every letter in word""" new_word = "" for c in word: new_word += c + " " return new_word assert "f i s h " == insert_spaces("fish"), "inserts spaces after every letter" assert "" == insert_spaces(""), "empty string if word is empty" print(insert_...
f9ce46d6a99c4040d19f6915f670132ecc4870bd
EmilieMarieCH/fonctions-exercices
/steps.py
329
4.15625
4
def converter_meter(x): results=x*1000 return results def count_steps(): a=int(input("How much Km did you walk today?:")) a=converter_meter(a) b=int(input("What is the size of your average step(in meters)?:")) results = a/b return results print("you have made:" +str(count_steps()) +"steps...
b7fbd5f109cf940c3969fde6d0cdb939c4bb03f7
JotaMGomes/Python-Problems-Solutions
/HackerRank/left-rotation.py
510
3.875
4
# https://www.hackerrank.com/challenges/array-left-rotation/problem # Jose Luiz Mattos Gomes from typing import List class Solution: def rotate(self, nums: List[int], k: int) -> None: # guarantee that k is between 0 and nums.length k = k % len(nums) # if k is zero than no rotation is needed if(k==0)...
93aabae0bdfe63fa3d9e4b6051d9f54551a59e96
iahvector/door2door_gis_challenge
/door2door/utils/gis.py
494
3.75
4
"""GIS utilities""" from __future__ import division import math def meters_to_degrees(distance_in_meters, radius): try: float(distance_in_meters) float(radius) if distance_in_meters < 0: raise ValueError("distance_in_meters must be a positive number") if radius <= 0: ...
fc187d644073b6b3c2064ceb86dd1c39c44658e9
ifmylove2011/student
/exercise/ex15.py
317
3.8125
4
# 利用条件运算符的嵌套来完成此题:学习成绩>=90分的同学用A表示,60-89分之间的用B表示,60分以下的用C表示。 def grade_show(score): if score >= 90: grade = 'A' elif score >= 60: grade = 'B' else: grade = 'C' print(grade) grade_show(88)
30cbd22f976fe6ef96b2bf2057f478835318a1c9
Ruyuz/python_hw
/final-proj-Registration-System/registration.py
10,123
3.84375
4
import pandas import pickle as pk from pathlib import Path from registrar import * institution_name = input('Welcome to the Registration System\nPlease enter the name of your institution: ') institution = Institution(institution_name) # create an instance of Institution path = Path('./data/{}.pkl'.format(institution_n...
5315e68a06067a3ab9a99178ab86ce613dc163fb
corridda/Studies
/CS/Programming_Languages/Python/Python_Documentation/The_Python_Standard_Library/Built-in Functions/c-d/divmod__test.py
816
4.21875
4
"""divmod(a, b)""" # https://www.programiz.com/python-programming/methods/built-in/divmod """Take two (non complex) numbers as arguments and return a pair of numbers consisting of their quotient and remainder when using integer division. With mixed operand types, the rules for binary arithmetic operators apply. For in...
77c16024dfbb825e19fc39ef5cf385235cdc038c
rodumani1012/PythonStudy
/Python/Python09_Method/MTest03_gugu.py
788
3.921875
4
# -*- coding: utf-8 -*- # 1. for문을 사용하여 구구단을 출력하는 gugu() 함수를 만들자. def gugu(): for i in range(2, 10): print('< ' + str(i) + '단 >') for j in range(1,10): print(i, 'X', j, '=', i*j) # 2. while문을 사용하여 구구단 중, 입력된 단을 출력하는 gugudan(x) 함수를 만들자. def gugudan(x): i = 1 print('< ', x, '단 >'...
615ed7a78a48f3c13b82b66c84f17fa25f91baff
chenjiahui1991/LeetCode
/P0885.py
760
3.546875
4
class Solution: def spiralMatrixIII(self, R, C, r0, c0): """ :type n: int :rtype: List[List[int]] """ step = [(0, 1), (1, 0), (0, -1), (-1, 0)] result = [[r0, c0]] x = r0 y = c0 direction = 0 count = 1 base = 0 while cou...
5ecec8b1b5d43c96dffa298fdda11eeb8f92a24d
xxxhol1c/PTA-python
/programming/3-19.py
99
3.640625
4
n = int(input()) lst = [input() for _ in range(n)] print(f'The longest is: {max(lst, key = len)}')
f7d62028257da0b12df660e6bfe009715d79db03
lukbor2/learning
/Python/OOP and Inheritance/bound_unbound_methods.py
958
3.78125
4
class Spam: def doit(self, message): print(message) obj1 = Spam() obj1.doit('Hello World') x = obj1.doit # bound method object: instance + function x('Hello World') t = Spam.doit # unbound method object (a function in 3.x) t(obj1, 'howdy') class Selfless: def __init__(self, data): self.data ...
bb24984d076bb44bcb554827c28391b32f3e1bd4
IGDEXE/Automate-the-Boring-Stuff-Udemy
/CombinarPDFs.py
679
3.53125
4
#! python3 # Combina todos os PDFs de um diretorio import PyPDF2, os # Pega todos os nomes pdfFiles = [] for filename in os.listdir('.'): if filename.endswith('.pdf'): pdfFiles.append(filename) pdfFiles.sort() pdfWriter = PyPDF2.PdfFileWriter() # Verifica todos os arquivos for filename in pdfFiles: ...
068e28beb933dea1767c8fdfce687b575634571d
PoisonRain/rtfgrgtgsrtghyk-
/Elf.py
16,627
3.515625
4
from elf_kingdom import * from math import sqrt import flanking from newMath import get_alpha_from_points, get_point_by_alpha class Elf: """ elf class is used to remember previous elf state and have complex moving methods """ def __init__(self, game, elf): self.game = game self.elf = ...
939165d220f5bcbb7d5ccbea0adfe982b4022e59
code4happylife/Python-100-Days
/Day01_15/code/Day11/example10_7.py
1,372
4.125
4
# encoding: utf-8 ''' @author: developer @software: python @file: example10_7.py @time: 2019/12/25 22:07 @desc: ''' while True: print("Please input two numbers to calculate the sum of them.") first_num = input("Please input the first number:") second_num = input("Please input the second number:") if fi...
43caa844a31989e1d89939639a2441164f33fcfc
MatteovonBraun/summerwork2017
/0.0.1 (PRE SUMMER WORK)/WATSON ET AL INTERACTIVE.py
2,266
3.671875
4
import matplotlib.pyplot as plt import numpy as np import math Dh = 4283 tH = 4.408*10**17 #in seconds #what is an afermative response affirmative = ["yes", "y", "yeah", "yee", "affirmative", "si", "certainly", "quite so", "definetly", "yaeh", "yeha" "yay"] #what is a negative response negative = ["no", "n", "nay",...
7d415381cac892eae0cff391fa671197bb9271a7
as3379/Python_programming
/String_manipulation/replace_chr_num.py
454
3.984375
4
"""string problem to remove numbers from a mix of numbers and characters""" def string_replace(s,n): S =[] N =[] #To remove numbers and return characters for i in s: if i.isalpha(): S.append(i) print(S) print(''.join(S)) #To remove characters and returnn numbers ...
dc412505faa6f3fbbd55b22d62e4d69d21acb6c0
Brandon-Hernandez-T/curso-python
/Condiciones.py
891
4.09375
4
tema_curso = "== Condiciones ==" print(tema_curso) #Condicional IF - ELSE numeroIngresado = int(input("Introduce un numero: ")) if numeroIngresado >= 10 : print("El numero es mayor o igual a 10") else : print("El numero es menor a 10") print("Fin") #Condicional elif calificacionQuimica = int(input("Ingresa ca...
7a8e43a7f15594287a336fc3b2a8e16746cc94e6
whitis01/psychic-octo-waffle
/feed.py
356
3.875
4
import feedparser print("Enter your name:") x = input() print("Hello, " + x) # For now we will hard code an RSS feed into the Feed parser. NewsFeed = feedparser.parse(x) # entry = NewsFeed.entries[0] print(len(NewsFeed.entries)) for post in NewsFeed.entries: print(post.title + " : " + post.link) #print(NewsFee...
1822b8c4b481b01e0c856ea1bb6fae70544f511b
UrbanMaasai/test-tyme
/OOP/test_Noteapplication.py
1,190
3.953125
4
import unittest import Note_it #from Note_it import Noteapplication class NoteapplicationTest(unittest.TestCase): """Testing the Noteapplication class""" """ """ def successfully_created_list_as_required(self): """test if the note_list is properly created """ testcase = NotesApplication("") self.assertListE...
e6d10a24e95cd72022ad0621f4cf413084975f94
TusharDimri/Python
/Args & Kwargs In Python.py
1,742
4.125
4
def func_print(a,b,c): #simple function to print arguments passed print(a,b,c) func_print(1,2,3) # *args def arg_func(normal,*args): #writing args is just a covntion,the argument can have an name but * is mandatory print(type(args)) #this tells as that args are stored in the form of a tuple inside the functio...
9fd2142e06198d94ba05cfff5f0f5393f223b3e8
mnuman/my-python-learnings
/aoc-2017/day15.py
4,512
3.78125
4
import day15_generator """ --- Day 15: Dueling Generators --- Here, you encounter a pair of dueling generators. The generators, called generator A and generator B, are trying to agree on a sequence of numbers. However, one of them is malfunctioning, and so the sequences don't always match. As they do this, a judge wai...
5d016013b17a6f5718e0d32ad9ec177e88881b53
rogerroxbr/Treinamento-Analytics
/Trabalhos/Arthur/1309-1709/1409/Estruturas_Controle/2.py
285
3.84375
4
velocidade = int(input("Informe a velocidade do carro: ")) limite = 80 if velocidade > limite: print("MULTADO!") velocidade_acima_limite = velocidade - limite valor_km_acima = velocidade_acima_limite * 5 print(f"O usuário recebeu uma multa de R${valor_km_acima}.00!")
b3fc5513538f424d59562501c1bcf5ecb95e0d3a
zangyifan2001/1805
/06.day/7取款机.py
506
3.6875
4
import time print("          欢迎使用取款机") a = input("输入您的姓名:") print("欢迎%s先生"%a) int(input("输入您的账号(可支持qq用户):")) int(input("输入您的账号密码:")) print("           正在登录") time.sleep(1) c = 8000 print("%s先生,您卡上余额为:%d"%(a,c)) d = int(input("请输入您的取款金额:")) print("           取款成功") e = (c-d) print("卡剩余额:%d元"%e)
1856d70dd9f0f0a4ffcd91086bb04ea3c94cabb6
qamine-test/codewars
/kyu_4/next_bigger_number_with_the_same_digits/next_bigger.py
563
3.90625
4
# Created by Egor Kostan. # GitHub: https://github.com/ikostan # LinkedIn: https://www.linkedin.com/in/egor-kostan/ import itertools def next_bigger(n: int) -> int: """ A function that takes a positive integer number and returns the next bigger number formed by the same digits. If no bigger numb...
8235e6dac69d262be9be872600b6f69c602d60f7
edgeworthZ/first_year_log
/Lab_Quiz/nPrime.py
451
3.953125
4
n = int(input('n: ')) number_range = [True for _ in range(10**n)] count=0 for number in range(10**n): #Isn't Prime or less than 2 if number_range[number]==False or number < 2: number_range[number]=False continue #Number we want if number>=(1+10**(n-1)): count+=1 ...
66b4761f44db900dded2127d3022fd16c6616700
narchio/Rutgers-CS
/CS_352/DNS_UDP/ts.py
1,385
3.71875
4
''' *** Authors: Nicolas Carchio and Oliver Gilan *** Top-Level DNS server (TS) - maintains a DNS_table of three fields: - Hostname - IP address - Flag (A or NS) 1. reads in DNS records from a file - dictionary to maintain the table 2. client sends queried hostname as a string to TS 3. The TS program...
a973d1e953cd439a78b9fa72424d54fde111cce9
amaurymedeiros/desktop-file-search
/colecao/primeiro.py
465
3.625
4
# CIENCIA DA COMPUTACAO - UFCG # PERIODO 2010.1 # LABORATORIO DE PROGRAMACAO I # PROFESSORES: DALTON E JORGE # MONITOR: PAULO # TURMA: 3 # ALUNO: EMERSON BORGES MAT.:20911030 # LISTA I, QUESTAO 1 # Escreva um programa que leia da entrada o valor de uma conta de restaurante # e imprima na saIia o valor total a ser pag...
b43683cf28cef06ed33243bcdba4e6f8f69a23eb
luckydimdim/bobel-algo
/python/bubble_sort/index.py
206
3.984375
4
def bubble_sort(array): length = len(array) for bypass in range(1, length): for k in range(0, length-bypass): if array[k] > array[k+1]: array[k], array[k+1] = array[k+1], array[k] return array
f9388f9f6911b67c3c0a5e99464890da05062b20
MaximillianDark/Hackathon-Game
/src/sprite.py
6,003
3.625
4
"""Sprite module for the project.""" from src.util import * class Sprite: """Base sprite class for onscreen objects.""" def __init__(self, src, dest, groups=None): self.src = src self.dest = dest self.groups = [] if groups: for g in groups: g.add...
dc7cac55a5e6355c2336a175c945b35ff48fc292
lfbessegato/Python_Avancado
/permutacoes.py
95
3.71875
4
import itertools for p in itertools.permutations([1,2,3]): print(''.join(str(x)for x in p))
9b8ff7bd8b5995d3bd3cb628f29816a5e01c27e8
dnath/RamseyCoin
/etc/py_tabu_search/json_formatter.py
1,314
3.578125
4
#!/usr/bin/python import json # Import json module ''' Counter Example class We have 2 constructors either with data and size or with json objects We have also a function to return the corresponding json with this object ''' class CounterExample: def __init__(self, data, size=None): if size != None: ...
e31c87092277eb5cb62b7290601745935a835e60
shankar7791/MI-10-DevOps
/Personel/Avdhoot/Python/Feb 17/random.py
172
3.828125
4
''' import random n = random.random() print(n) ''' import random2 a = int(input("Enter first number ")) b = int(input("Enter second number ")) print(random2.randint(a,b))
f044f534d29c67440d141d5f23f1daedaa6a4649
gzroger/CheckioEx
/sciex/digit-stack.py
1,009
3.890625
4
class Stack: def __init__(self): self.s = [] self.sum = 0 def command(self, command: str): cmdpar = command.split() if cmdpar[0] == "PUSH": self.s += [int(cmdpar[1])] elif cmdpar[0] == "POP": if self.s: self.sum += self.s.pop() ...