blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
8388b6b5205a2dd9d7273f98d864d77a8b0da7c7 | RealMrRabbit/python_workbook | /exercise_13.py | 3,058 | 4.46875 | 4 | #Exercise 13: Making Change
#(Solved—33 Lines)
#Consider the software that runs on a self-checkout machine. One task that it must be
#able to perform is to determine how much change to provide when the shopper pays
#for a purchase with cash.
#Write a program that begins by reading a number of cents from the user as an
... |
a0b6a8921da7aa3562a1441fbe826bf528aa5ed6 | RealMrRabbit/python_workbook | /exercise_3.py | 2,794 | 4.5 | 4 | #Exercise 3: Area of a Room
#(Solved—13 Lines)
#Write a program that asks the user to enter the width and length of a room. Once
#the values have been read, your program should compute and display the area of the
#room. The length and the width will be entered as floating point numbers. Include
#units in your prompt an... |
0631db793b7e3e9a551576b4e1cf680e0ef7f026 | davidwilemski/aoc18 | /day02/1/checksum.py | 669 | 3.640625 | 4 | import collections
import sys
def score_word(id_):
counter = collections.Counter(id_)
top_two = counter.most_common(2)
result = 0
first = top_two[0][1]
second = top_two[1][1]
has_three = False
has_two = False
if first >= 3:
has_three = True
if second >= 2:
... |
2b667eb9f7bc2446cc7a41e4b5cfeb4ee03cc25e | Light07/Mobile_FrameWork | /EvcMobile/axis20/interfaces/etown/datastruct.py | 7,014 | 3.78125 | 4 | """
This module is created to make the verification for UI data easier.
The structs in this module are the abstractions for UI data and database.
"""
from copy import copy
# all datetime should use DateTime module
from DateTime import DateTime as DateTime
class Week:
DAYS_OF_A_WEEK = 7
def __init__(self, w... |
6a003911cc1f0f89c481611305ffc7b7d8359f53 | Vikramjitsingh0001/assingnments | /assingnment_4.py | 2,482 | 4.15625 | 4 | #Q1
a=(1,2,3,4,5,'car','bike') #take tupil which contains different types of data type
print(len(a)) #print the lenth of tupil eg number of varriable
#Q2
v=(1,5,3,7,33,9) #take a tupil which contain n number
print(max(v)) #from n numbers find the largest one from tupi... |
8bb67a212452b55817e8e4b33ab5500e943a15d4 | Vikramjitsingh0001/assingnments | /assinginment 7 on function .py | 3,713 | 3.90625 | 4 | # Q1 to find the area of cicle using function
a = 3.14 #take vale of pi=3.14
r = int(input("enter the radius of circle")) #take value of radius from user
def area(a, r): #create a function of area
r... |
3e55fa6d87c20d2440b491666f958f9509d3374a | jdravi/DataStructureAndAlgorithm | /Code/PythonCode/LinkedList/LinkedList.py | 1,088 | 3.90625 | 4 | from PythonCode.LinkedList.node import Node
class LinkedList():
def __init__(self):
self.head = None
self.k = 0
def add_beg(self, data):
node = Node(data)
if self.head == None:
self.head = node
else:
node.next = self.head.next
self.h... |
43b547b8743987f29b8624086ba624b56348ae67 | shiny13/leetcode-problems | /NRepeatingElementSize2NArray/nrepeating_element_2narray.py | 522 | 3.609375 | 4 | import sys
from queue import PriorityQueue
if __name__ == '__main__':
input = sys.stdin.read()
A = list(map(int, input.split()))
n = len(A) // 2
elements = {}
answer = -1
for i in A:
item = 1
if i not in elements:
elements[i] = item
else:
item =... |
86c278e4ad8adb1976c9ed187549a1aaafc0d130 | shiny13/leetcode-problems | /HIndex2/h-index-2.py | 751 | 3.640625 | 4 | import sys
from typing import List
class Solution:
def hIndex(self, citations: List[int]) -> int:
if citations is None or len(citations) == 0:
return 0
n, res = len(citations), 0
mid, start, end = 0, 0, len(citations) - 1
while start <= end:
mid = start + ... |
40294469a53a964b57c884c723467eb174f539c5 | shiny13/leetcode-problems | /FindTheDuplicateNumber/find_the_duplciate_number.py | 397 | 3.734375 | 4 | import sys
from typing import List
class Solution:
def findDuplicate(self, nums: List[int]) -> int:
seen = set()
for num in nums:
if num in seen:
return num
seen.add(num)
if __name__ == '__main__':
input = sys.stdin.read().strip()
nums = list(map(i... |
d535cbcf92ec7630de135f12275312faba18a20b | shiny13/leetcode-problems | /SearchInsertPosition/search_insert_position.py | 561 | 3.953125 | 4 | import sys
from typing import List
class Solution:
def searchInsert(self, nums: List[int], target: int) -> int:
beg, end = 0, len(nums)
while beg < end:
mid = (beg + end)//2
if nums[mid] >= target:
end = mid
else:
beg = mid + 1
... |
6697d609f2d2512fb5e07bfc46b4f60c9c06cdc6 | shiny13/leetcode-problems | /QueueReconstructionByHeight/queue_reconstruction_by_height.py | 552 | 3.515625 | 4 | import sys
from typing import List
class Solution:
def reconstructQueue(self, people: List[List[int]]) -> List[List[int]]:
length = len(people)
if length == 0:
return []
people = sorted(people, key = lambda x: (-x[0], x[1]))
#print(people)
lis = []
for p... |
cbc6294d5ffb12a127804bd903ae651aa32b8b54 | sriniharika/jenkins-py | /decoratordemo.py | 297 | 3.515625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Apr 5 16:26:46 2021
@author: NiharikaSrivastava
"""
def escape_unicode(f):
def wrap(*args,**kwargs):
x=f(*args,**kwargs)
return ascii(x)
return wrap
@escape_unicode()
def my_Func():
return '@$%%#$%#@mnk'
print(my_Func()) |
ad060056fb45d250683cf24300c69c5fc5527dbb | Nubstein/Python-exercises | /Condicionais e Loop/Ex6.py | 512 | 4.125 | 4 | #Faça um programa que pergunte o preço de três produtos e informe qual produto você deve comprar,
#sabendo que a decisão é sempre pelo mais barato.
p1=float(input("Insira o preco do produto 1: R$ "))
p2=float(input("Insira o preco do produto 2: R$ "))
p3=float(input("Insira o preco do produto 3: R$ "))
if p1<p... |
cf35e65f5ed0def55723e846fea1366d42d61a5b | Nubstein/Python-exercises | /Strings/Ex8_strings.py | 490 | 4.25 | 4 | #Verificação de CPF.
# Desenvolva um programa que solicite a digitação de um número de CPF
# no formato xxx.xxx.xxx-xx e indique se é um número válido ou inválido
# através da validação dos dígitos verificadores edos caracteres de formatação.
cpf=input(" Insira o numero de cpf no formato xxx.xxx.xxx-xx ")
if (cp... |
8ef207bbeb6c3056ab20b3e3fd952bdd9037be4b | Nubstein/Python-exercises | /Classes/Ex 2 classe bola.py | 581 | 3.640625 | 4 | #Classe Bola: Crie uma classe que modele uma bola:
#Atributos: Cor, circunferência, material
#Métodos: trocaCor e mostraCor
class Bola():
def __init__(self, cor, circunferencia, material):
self.cor=cor
self.circunferencia=circunferencia
self.material=material
print("Objeto ... |
beee854515c5d50c7c7169f4402ce2852a55e4d0 | Nubstein/Python-exercises | /Funcoes/Ex2_funcao.py | 190 | 3.71875 | 4 | #Faça um programa, com uma função que necessite de três argumentos,
# e que forneça a soma desses três argumentos.
def funcao_3(n1,n2,n3):
return (n1+n2+n3)
funcao_3(2,3,4)
|
91be40cb62c28dc236b72ffbcc967239531c4eec | Nubstein/Python-exercises | /Repeticao/Ex1_repet.py | 326 | 4.25 | 4 | #Faça um programa que peça uma nota, entre zero e dez.
# Mostre uma mensagem caso o valor seja inválido
# e continue pedindo até que o usuário informe um valor válido.
nota=float(input("Insira uma nota entre 0 e 10: "))
while nota<0 or nota>10:
nota=float(input("Valor incorreto! A nota deve ser de 0 á 10 ")) |
30662d0583dadaa50deee3108a56dd03b6f6624f | Nubstein/Python-exercises | /Condicionais e Loop/Ex16.py | 316 | 3.84375 | 4 | # Exercício 6 - Crie uma variável chamada contador = 0. Enquanto counter for menor que 100, imprima os valores na tela,
# mas quando for encontrado o valor 23, interrompa a execução do programa
contador = 0
while contador < 100:
if contador == 23:
break
print(contador)
contador += 1 |
e2fcaedd0a0ac22274ada8167ad5c6050f78bc9e | Nubstein/Python-exercises | /Funcoes/Ex11_funcao.py | 436 | 4.34375 | 4 | # Exercício 3 - Crie uma função que receba como parâmetro uma lista de 4 elementos, adicione 2 elementos a lista e
# imprima a lista
def funcaoex3 (lista): #defina a função
print(lista.append (5)) # insira os elementos que quer adicionar
print(lista.append (6))
lista1=[1,2,3,4] #ide... |
4a8edfb293d82ec4d0acaba0a450f9cc7c1db5de | Master-sniffer/Algorithms | /Python/Linear Search/File.py | 169 | 3.796875 | 4 | def search(arr, x):
for i in range(len(arr)):
if arr[i] == x:
return i
return -1
arr=[1,2,3,4,5,6,7,8,9,10]
print(search(arr,5))
|
49e793a8aafda472980ac6d462187cbb39f7ffe2 | CaoLocBK/CaoXuanLoc-fundamental-C4E23 | /ses02/serious2.py | 102 | 3.546875 | 4 | n = int(input("Nhap so n: "))
tich = 1
for i in range(1,n+1,1):
tich = tich*i
print("n! = ", tich) |
2081b9a55f746ed077ef718c7558594a8a881d4b | ankitandel/dictionary.py | /14.py | 309 | 3.625 | 4 | dict = {
'a':50,
'b':58,
'c': 56,
'd':40,
'e':100,
'f':20
}
c=[]
for i in dict.values():
c.append (i)
print(c)
b=0
for i in range(3):
for k in range (len(c)-i-1):
if c[k]>c[k+1]:
b=c[k]
c[k]=c[k+1]
c[k+1]=b
print(b) |
6ad2ce72f785faa1af8b818eecb1791c89abb31e | ankitandel/dictionary.py | /18.py | 94 | 3.75 | 4 | m=int(input("enter the number"))
i=0
a={}
while i<=m:
a.update ({i:i*i})
i+=1
print(a) |
428490b3f59293a90c29d1931a058ca58a48b044 | one-degree-north/mate-2021-worlds-rnd | /controls_pygame/controls.py | 3,650 | 3.765625 | 4 | # controls.py
# Takes keyboard input and sends info to Communications
import sys
import time
import pygame
class Controls:
def __init__(self,
comms: Communications,
exit_program: ExitProgram,
screen_color: (int, int, int) = (0, 0, 0),
screen_dim... |
aae70338741315e45fa346e17b416d667a011da2 | etmorefish/leetcode | /LinkList/SingleCycleLinkList.py | 4,640 | 3.625 | 4 | # -*- coding: utf-8 -*-
# @Time : 19-12-4 下午5:55
# @Author : MaoLei
# @Email : maolei025@qq.com
# @File : LinkList1.py
# @Software: PyCharm
class Node(object):
"""链表的结点"""
def __init__(self, item):
# item存放数据元素
self.item = item
# next是下一个节点的标识
self.next = None
class ... |
f0c6287ba150619cd54cf53f41834d6f28f65e8f | etmorefish/leetcode | /剑指offer/16_ 数值的整数次方.py | 563 | 3.84375 | 4 | """
实现函数double Power(double base, int exponent),求base的exponent次方。不得使用库函数,同时不需要考虑大数问题。
"""
class Solution:
def myPow(self, x: float, n: int) -> float:
if x == 0:
return 0
res = 1
if n < 0:
x, n = 1/x, -n
# for i in range(n):
# res *= x
wh... |
c39a17a8da7be6651c4adaaebeb5d107aa7aeac9 | etmorefish/leetcode | /剑指offer/29_矩阵的边界.py | 1,377 | 3.84375 | 4 | """
根据题目示例 matrix = [[1,2,3],[4,5,6],[7,8,9]] 的
对应输出 [1,2,3,6,9,8,7,4,5] 可以发现,
顺时针打印矩阵的顺序是 “从左向右、从上向下、从右向左、从下向上” 循环。
(模拟、设定边界,清晰图解)
"""
class Solution:
# def spiralOrder(self, matrix):
# res = []
# while matrix:
# res += matrix.pop(0)
# matrix = list(zip(*matrix))[::-1] ... |
0bcde4506b97f57a45ceb6dc263609f843a80e92 | etmorefish/leetcode | /剑指offer/24_反转链表.py | 1,785 | 3.9375 | 4 | # -*- coding:utf-8 -*-
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
# 返回ListNode
def ReverseList(self, pHead):
# write code here
pReverseHead = None
pNode = pHead
pPrev = None
while pNode:
pN... |
2227d7d89a8da5c58dfb7ed6c712a848ca4a05e9 | etmorefish/leetcode | /剑指offer/18_删除链表中的节点.py | 946 | 3.671875 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
"""
特例处理: 当应删除头节点 head 时,直接返回 head.next 即可。
初始化: pre = head , cur = head.next 。
定位节点: 当 cur 为空 或 cur 节点值等于 val 时跳出。
保存当前节点索引,即 pre = cur 。
遍历下一节点,即 cur = cur.next 。
删除节点: 若 cur 指向某节点,则执行... |
c5d857d74c65df404c4eb424848aef47be6215ae | etmorefish/leetcode | /LinkList/141.py | 642 | 3.703125 | 4 | # -*- coding: utf-8 -*-
# @Time : 19-12-7 下午9:56
# @Author : MaoLei
# @Email : maolei025@qq.com
# @File : #141.py
# @Software: PyCharm
# 哈希表
'''
给定一个排序链表,删除所有重复的元素,使得每个元素只出现一次。
示例 1:
输入: 1->1->2
输出: 1->2
示例 2:
输入: 1->1->2->3->3
输出: 1->2->3
'''
class Solution(object):
def hasCycle(self, head):
"... |
34faaf103b19d05dccdb0e094e9d000bac4122f7 | etmorefish/leetcode | /test.py | 2,915 | 3.5625 | 4 | import random
import time
def running_time(func):
def inner(*args, **kwargs):
t1 = time.time()
res = func(*args, **kwargs)
t2 = time.time()
print('%s running time: %s secs.' % (func.__name__, t2 - t1))
return res
return inner
@running_time
def bubble_sort(li):
fo... |
1db08250175bf0c987c74bc9a54e454f20bd6e62 | etmorefish/leetcode | /剑指offer/删除链表中重复的节点.py | 1,142 | 3.90625 | 4 | '''
给定一个排序链表,删除所有含有重复数字的节点,只保留原始链表中 没有重复出现 的数字。
示例 1:
输入: 1->2->3->3->4->4->5
输出: 1->2->5
'''
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def deleteDuplicates(self, head):
dummyHead = ListNode(0)
... |
53c5bdae2b269874d077df20d259ef3338ad9049 | etmorefish/leetcode | /剑指offer/15_二进制中1的个数.py | 836 | 3.734375 | 4 | """
请实现一个函数,输入一个整数,输出该数二进制表示中 1 的个数。
例如,把 9 表示成二进制是 1001,有 2 位是 1。因此,如果输入 9,则该函数输出 2。
输入:00000000000000000000000000001011
输出:3
解释:输入的二进制串 00000000000000000000000000001011 中,共有三位为 '1'。
"""
class Solution:
def hammingWeight(self, n: int) -> int:
# return bin(n).count('1')
# 2.取余
# count=0
... |
6593dd6daf5421e935923fe5cdcad22f71399131 | etmorefish/leetcode | /init_new.py | 280 | 3.671875 | 4 | class A:
def __init__(self):
print('this is init method', self)
def __new__(cls):
print('this is cls`s id', id(cls))
print('this is new method', object.__new__(cls))
return object.__new__(cls)
a = A()
print('this is Class A of id', id(A)) |
9b5e2a840da29c6e4310b58a0c3857c9eb3b7cdc | etmorefish/leetcode | /7.py | 600 | 3.71875 | 4 | # -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
class Solution(object):
def reverse(self,x):
"""
:type x: int
:rtype: int
"""
a = 0
if x > 0 :
a = 1
else:
... |
cc08695c2bf255234785db23020045a10d476adf | vinay-vemuri/python-basics | /conditional/isodd.py | 131 | 4.1875 | 4 | a= int(input("enter a number:"))
if(a%2)!=0:
print("{} is odd number".format(a))
else:
print("{} is even number".format(a)) |
3d0eeb3f24782dd28300e1ac80a41ae06d3daf15 | gbravo5/m-dulo_2-carrera_tortugas | /2311_Turtle_Race_v1.py | 1,670 | 3.53125 | 4 | import turtle
class Route():
listofparticipants = []
def __init__(self, length, width, fillcolor, nb_participants):
# screen setup:
# create
self.__screen = turtle.Screen() # method of turtle: Screen()
# customize
self.__s... |
ac577f356c2844b5fadc99e681e53b3fa246e32d | Bentley0928/NbaScoringBot | /nba.py | 4,614 | 3.5625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# This program is dedicated to the public domain under the CC0 license.
"""
Simple Bot to reply to Telegram messages.
First, a few handler functions are defined. Then, those functions are passed to
the Dispatcher and registered at their respective places.
Then, the bot is... |
ded1eab0d4581df253330552e248a8b920a7dbf1 | cpe202fall2019/lab1-ZachLofquist | /lab1_test_cases.py | 3,667 | 3.984375 | 4 | import unittest
from lab1 import *
class TestLab1(unittest.TestCase):
def test_max_list_iter(self):
"""add description here"""
tlist = None
with self.assertRaises(ValueError): # used to check for exception
max_list_iter(tlist)
#Tests for the max being at the end of the... |
e75cd86f53d855b6e6414d263f9399e470a6f3db | yangyamei/LZ | /myself/phonedirectory.py | 2,216 | 3.953125 | 4 | '''
插入联系人
print('|---欢迎进入通讯录程序---|')
print('|---1.查询联系人资料---|')
print('|---2.插入新的联系人---|')
print('|---3.删除已有联系人---|')
print('|---4.退出通讯录程序---|')
contacts={}
while 1:
selectnum=(int)(input("请输入相关的指令代码:"))
if selectnum==1:
for k,v in contacts.items():
print(k+':'+v)
elif selectnum==2:
... |
6c84d15a727e6f711369d327b2de374fce4a5dea | yangyamei/LZ | /myself/全局变量.py | 187 | 3.65625 | 4 | var ='hi'
def fun1():
global var
var='Baby'
return fun2(var)
def fun2(var):
var+='I love you'
fun3(var)
return var
def fun3(var):
var='小甲鱼'
print(fun1()) |
ecf72a95adb14fc34432f0459f6856919649c05f | Matheus-A-Leme/Atividades-Python- | /Atividades de Aula/buscaprimeirocomdelay.py | 4,412 | 3.546875 | 4 | import time
vetorA = [1, 70, 3, 4, 5, 90, 7, 8, 9, 10, 11]
vetorB = [1, 74, 3, 4, 5, 6, 7, 8, 9, 10, 67, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]
vetorC = [1, 78, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 92, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41... |
a678a03ed9f7d5c46837ba8ce353eb2ffb811573 | Matheus-A-Leme/Atividades-Python- | /Atividades de Aula/buscalinear.py | 500 | 3.65625 | 4 | #Busca Linear
def busca(lista, x):
for i in range(len(lista)):
if lista[i] == x:
return i
return None
lista_linear = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 28, 29, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 30]
numero = 30
indice = busca(lista_linear, numero)
if indice is not None:
print("O ind... |
ede5131f297bc7650a230737a49f41ed67390824 | z0k/CSC108 | /lab3/booleans.py | 363 | 3.6875 | 4 | def marathon_time(half_time, hilly):
''' (num, bool) -> num
>>> marathon_time(10, False)
30
>>> marathon_time(10, True)
50
Return half_time * 2 + 10 if hilly == True
Return half_time * 2 + 30 if hilly == False
'''
if hilly == False:
return half_time * 2 + 10
if hilly ==... |
12853d4c6fbd6325541bce74c1307871c28bf8f9 | z0k/CSC108 | /Exercises/e2.py | 1,960 | 4.1875 | 4 | # String constants representing morning, noon, afternoon, and evening.
MORNING = 'morning'
NOON = 'noon'
AFTERNOON = 'afternoon'
EVENING = 'evening'
def is_a_digit(s):
''' (str) -> bool
Precondition: len(s) == 1
Return True iff s is a string containing a single digit character (between
'0' and '9' i... |
8872da12b952c791195bf27d8d424a712cdd4b91 | cuttonsea/lotto | /skdus.py | 141 | 3.8125 | 4 |
list = []
while (True):
qustn = input("이름을 말해봐 ")
if (qustn == "end"): break;
list.append(qustn)
print(list)
|
7e586e771f71ed3073d01d43e162302ce587dc51 | btab2273/57_exercises | /13_compound_interest.py | 460 | 3.828125 | 4 | principal = float(input('What is the principal amount? '))
rate = float(input('What is the rate? '))
time = int(input('What is the number of years? '))
compounded = int(input('What is the number of times the interest is compounded per year? '))
#Calculations
roi = principal*(1 + ((rate/100)/compounded))*... |
003747497c42c7efe471343843b9bf6a1f4cf5d3 | btab2273/57_exercises | /03_printing_quotes.py | 178 | 3.59375 | 4 | # Input for the quote: quote
quote = input('What is the quote? ')
# Input for crediting the quote: author
author = input('Who said it? ')
print(author + ' says,' + quote) |
8acc1e3f0854ad0a5e26a94c7d23fc975c40e306 | btab2273/57_exercises | /26_months_to_cc_payoff.py | 657 | 4.0625 | 4 | import math
# Exercise 26 - Months to Pay Off a Credit Card
# Assign variables: num_months, daily_rate(APR/365), bal, payment
bal = float(input('What is your balance (USD)?'))
apr = float(input('What is the APR on the card (as a percent)? '))
payment = float(input('What is the monthly payment you can make... |
239c97c9291ac1d0932a4d064789966ed24802fa | hchsujimmy37/X-Village-2018-Exercise | /1-1.py | 393 | 4.0625 | 4 | a=float(input('Input the power of second:'))
b=float(input('Input the power of single:'))
c=float(input('Input the power of zero:'))
print(a,'X^2+',b,'X+',c)
d=((-b)+pow(pow(b,2)-4*a*c,0.5))/(2*a)
e=((-b)-pow(pow(b,2)-4*a*c,0.5))/(2*a)
if d==e:
print('The answer is ',d,'.')
elif (pow(b,2)-4*a*c)<0:
print('Do no... |
89ccaa585120ee00f3c7b5ef929359a7bf953108 | brettonw/ubuntu-python | /intro/lesson28.py | 164 | 4.09375 | 4 | #! /usr/bin/env python3.8
# Strings
def main ():
s1 = "You said '{}'."
prompt = input ("What do you want to say? ")
print (s1.format (prompt))
return
main()
|
621d99b30398065a90e2891f77413b17bc89ea8d | AngeloCastro9/LabyrinthIA | /Labyrinth.py | 582 | 3.78125 | 4 | graph = {
'A' : ['B','C'],
'B' : ['D', 'E'],
'C' : ['F'],
'D' : ['A', 'B'],
'E' : ['F'],
'F' : ['F', 'C'],
'G' : ['C', 'E'],
'H' : ['A', 'F']
}
def dfs(graph, vertex):
visited = set()
def dfs_recursive(graph, vertex):
visited.add(vertex)
print("visitando: " + vertex)
fo... |
8033594f41b3043a80c607327271b7b9d3596691 | itsaMeMario1532/test_repo | /test.py | 67 | 3.703125 | 4 | # for loop
my_list = [1,2,3,4]
for num in my_list:
print(num)
|
e26618124fea71a6f6d43e3a3a9bdc734733e96f | ValentinChernyaev/practice | /Паук.py | 290 | 3.984375 | 4 |
from turtle import *
n=int(input("Ввведите количество ног паука"))
shape ('circle')
color('black', 'black')
pensize(5)
begin_fill()
for i in range(1,n+1) :
forward (200)
stamp()
backward(200)
left(360/n)
end_fill()
done() |
534b770c98a017c9d97616ee7877c5f846f273e3 | quandb/atc | /flags/flags_example.py | 1,543 | 3.8125 | 4 | """
Examples of using Flags:
1. Error with required flag not set.
$ python py/tenpoint7/flags/flags_example.py
>> FATAL Flags parsing error: flag --name=None: Flag --name must be specified.
2. Only required flags.
$ python py/tenpoint7/flags/flags_example.py --name=Chocolate
>> Hello Chocolate
3. Required & op... |
60091d41e766a80d04c07a76602eaba534ee8d38 | FarMcKon/dandies | /80headers.py | 1,116 | 3.796875 | 4 | #!/usr/bin/python
# Simple program which opens a file of urls, retrives their headers and prints them to tty and writes to a file
import urllib2
import sys
usage = '''
Port 80 Headers - Multiple site list
Author: bostonlink
Usage: ./80headers.py url_list'
Notes: Use a custom list of urls, each url should be on a ne... |
566131b69d4ba1d15fb87f274c01f8be634b238d | RavenelMaelys/Calculatrice_python | /Calculatrice.py | 566 | 4.03125 | 4 | #On demande a l'utilisateur de rentrer une opération simple.
nombre1=int(input('Entrer le premier nombre: '))
signe=str(input('Entrer le signe du calcul: '))
nombre2=int(input('Entrer le deuxieme nombre: '))
# addition
if (signe == "+"):
resultat = nombre1+nombre2
# soustraction
elif (signe == "-"):
... |
23bc316d2f5782844e8fd926d577bcb85ceec17d | APope-UCB/w205Exercise2 | /finalresults.py | 2,183 | 3.6875 | 4 | # finalresults.py
# Andrea Pope
#w205
# Display results (1) of streaming tweets into postgres dB
# Gets word as an argument and returns the total number of word occurences in the stream
# standard python library tools
import sys # command line arguments
import string # string ascii
import psycopg2
# general... |
489794a944d4f63f719631d9d5040f775ae80861 | vignesh-26/vicky | /permutation_hunter.py | 103 | 3.53125 | 4 | from itertools import permutations
n=input()
m=permutations(n)
for i in list(m):
print("".join(i))
|
18b034dd7929251c34a219ee1123d5953b2c20a0 | vignesh-26/vicky | /largest_3_number.py | 277 | 4.0625 | 4 | num1=float(input("enter the first number:"))
num2=float(input("enter the second number:"))
num3=float(input("enter the third number:"))
if (num1>num2) and (num1>num3):
print(num1)
elif (num2>num1) and (num2>num3):
print(num2)
elif(num3>num1) and (num3>num2):
print(num3)
|
95313695cd10e7f06cd85d2057dd706649c66dc7 | andrewzwicky/puzzles | /icpc/icpc_2017/e_speed.py | 2,487 | 3.9375 | 4 | """
Problem E
Need for Speed
Time limit: 1 second
Sheila is a student and she drives a typical student car: it is old, slow, rusty, and falling apart. Recently, the
needle on the speedometer fell off. She glued it back on, but she might have placed it at the wrong angle. Thus, when
the speedometer reads s, her true ... |
f43b75197e2f5c49c7995cfabbc92fb320014dc0 | andrewzwicky/puzzles | /CodeEval/challenge_19.py | 439 | 3.625 | 4 | import sys
from unittest import TestCase
def challenge(input_string):
num, i, j = map(int, input_string.strip().split(','))
num_string = '{:b}'.format(num)
if num_string[::-1][i - 1] == num_string[::-1][j - 1]:
return 'true'
else:
return 'false'
if __name__ == "__main__"... |
bd7d9b1ddff421e9bd0896d076f675f14fbeab2e | MinalSadani/Digit-Recognition-using-KNN | /digit_recognition_KNN.py | 1,963 | 3.671875 | 4 | from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
from sklearn.metrics import confusion_matrix
from sklearn.metrics import classification_report
from sklearn import datasets
import numpy as np
# pip install opencv-python used for image recognition
import c... |
00666a0ef19e39ada6eefd84e2b175984643118f | omerasif-itu/tarteel-ml | /generate_vocabulary.py | 1,202 | 3.625 | 4 | """Create a text file with all ayahs line by line."""
import argparse
import logging
import os
from tqdm import tqdm
from tqdm import trange
from utils import quran_helper
DESCRIPTION = 'Create a text file with all unique ayahs in the Quran.'
VOCABULARY_FILENAME = 'vocabulary.txt'
parser = argparse.ArgumentParser(d... |
97b9851bbf3bad0be9569858c0217ba551fdc50d | pythonkila/learning-python | /Python.py | 1,002 | 3.75 | 4 | None
if type(varA) == str or type(varB) == str:
print ('string involved')
elif varA > varB:
print ('bigger')
elif varA == varB:
print ('equal')
else:
print ('smaller')
n = 2
while n <= 10 :
print (n)
n = n + 2
print ('Goodbye!')
t= 12
while t > 11 :
print ('He... |
fdc37bdec8269fd5a2a7929275c328bf3e24c512 | sahilb2/pong | /pong_two_agents_env.py | 4,326 | 3.6875 | 4 | from abc import ABC, abstractmethod
import numpy as np
from numpy.random import randint
import random
PADDLE_HEIGHT = 0.2
class SimpleState:
def __init__(self, ball_x, ball_y, velocity_x, velocity_y, paddle_y, hit, game_over):
self.ball_x = ball_x
self.ball_y = ball_y
self.velocity_x = vel... |
3b95d76b3a9cc27d4b7e88f3c877d186be2e4497 | mariah9875/Binp37-15-credit-project | /bin/gene_name.py | 2,264 | 3.546875 | 4 | #!/usr/bin/env python3
import argparse
usage = "This program extracts gene type, gene name and gene id from GTF annotation file"
parser = argparse.ArgumentParser(description=usage)
parser.add_argument('-i',metavar='InFile',help='A GTF input file',type=argparse.FileType('r'),required=1)
parser.add_argument('-t',metav... |
f23776b0ea7d95b86dc0ab31d15f208657050d50 | Tavheeda/python-programs | /lists.py | 1,882 | 4.25 | 4 | # fruits = ['apple','orange','mango','apple','grapes']
# print(fruits)
# print(fruits[1])
# import math
# for fruit in fruits:
# print(fruit)
# numbers = [1,2,3,4,5,8,9,10]
# print(numbers[2:5])
# print(numbers[3:])
# for number in numbers:
# print(number)
# i = 0
# while i < len(numbers):
# print(numbers[i])
# ... |
1c8e95a0016a54d4afcedf51c97fadec782ea5da | perellonieto/deep_calibration | /calibration_methods.py | 1,936 | 3.515625 | 4 | import numpy as np
from sklearn.isotonic import IsotonicRegression
from sklearn.linear_model import LogisticRegression
# TODO implement a MLP calibration method
#from sklearn.neural_network import MLPClassifier
from presentationtier import PresentationTier
import matplotlib.pyplot as plt
plt.ion()
plt.rcParams['image... |
05ba7b120fe15b9657b2d6cdb14599315d60f6ca | GeinerGV/1720869 | /Pregunta03.py | 860 | 3.625 | 4 | from os import system
system("cls")
n = 0
while n<=0:
try:
n = int(input("Ingrese el orden N de la matriz (N x N) a operar: >> "))
except Exception:
pass
finally:
system("cls")
print("Matriz generada ("+str(n)+" x "+str(n)+"):\n")
from random import random
from math import pow
def... |
95ee0082c38d579bc90e9191b2945daa744ac774 | manu34414/CLRS | /Chapter8/sortCounting.py | 1,011 | 3.828125 | 4 | class CountSort:
def __init__(self, input):
self.array = input
def printarray(self):
print(self.array)
def countsort(self, kvalue):
"""
kvalue is the maximum value of A, which is to say, all elements in A is
within the range of [0, kvalue]
"""
length... |
2f855c3e384c9ad7f1f0c1e3fa6241e84fba7bf9 | Muhammad-Siddiq/Chap2 | /Practice chap 2.py | 8,069 | 4 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Muhammad Siddiq 19B-071-SE
# Pracrice problem 2.1
# In[5]:
n = 5
sum_num = (n * (n + 1)) / 2
print(sum_num)
# In[15]:
def Average(lst):
return sum(lst) / len(lst)
lst = [23, 19, 21]
average = Average(lst)
print("Average of the list =",round(average, 2))
# In[1... |
97a5ff0dc2aecd96042e34191edad234e13f89e7 | The-Totti/marvin | /fase04/ex07/acharNumero.py | 197 | 3.6875 | 4 | def acharNumero(num1):
if num1 < 5:
return ("a")
elif num1 <= 10:
return ("b")
elif num1 <= 100:
return ("c")
elif num1 > 100:
return ("d")
|
20cee6ce3878408e6bb7dcde91cafa2771780064 | schorrm/CompilationTests | /hw3-parents/make_submission.py | 780 | 3.671875 | 4 | #!/usr/bin/python3
import os
from zipfile import ZipFile
import glob
import sys
if len(sys.argv) == 3:
tz1 = sys.argv[1]
tz2 = sys.argv[2]
else:
tz1 = input("Enter the first Teudat Zehut: ")
tz2 = input("Enter the second Teudat Zehut: ")
code_files = glob.glob('*.c') + glob.glob('*.cpp') + glob.glob... |
70e7efe384fe294632ef7e598b5e65d1f42a7072 | jay841224/python-gwo | /try.py | 250 | 3.78125 | 4 | class abc():
def __init__(self, a):
self._a = a
self._b = 0
@property
def a(self):
return self._a
@a.setter
def a(self, a):
self._a = a
self._b = self._a * 5
c = abc(3)
c._a = 5
print(c._a) |
371d8da7ee5de56abae237c68d5ec1bd192bd750 | nicvw/codewars | /doubles.py | 1,745 | 3.875 | 4 | """
https://www.codewars.com/kata/56c04261c3fcf33f2d000534/train/python
Professor Chambouliard hast just discovered a new type of magnet material. He put particles of this material in a box made of small boxes arranged in K rows and N columns as a kind of 2D matrix K x N where K and N are postive integers. He thinks t... |
fa768fedfaaced231280505c2c89989e443414de | digital-work/python-tutorials | /cmd-line.py | 813 | 3.71875 | 4 | '''
Created on 3. feb. 2020
@author: me294
'''
import argparse
def pupsi():
# positional arguments
parser = argparse.ArgumentParser("A simple command line script example.")
parser.add_argument("first", help="First required argument.")
parser.add_argument("second", help="Second required argument."... |
1900035fea24672551527d46a2314fa0e234f915 | tokado/Algo1 | /sort_algorithm/insertion_sort.py | 667 | 3.890625 | 4 | from help_instrument import counters
def insertionSort(zoos):
for i in range(1, len(zoos)):
key_atribute = zoos[i].number_of_passengers
key = zoos[i]
j = i - 1
while j >= 0 and compare_element_from_insertsort(key_atribute, zoos[j].number_of_passengers):
zoos[j + 1] = ... |
5cb043b1f2e075ca5574af8a5fb3a42d6e615137 | mehryar-m/AoC2020 | /day1/day1.py | 1,042 | 3.734375 | 4 | # https://adventofcode.com/2020/day/1
def soln1(list_of_expenses, value):
for index in range(0, len(list_of_expenses)):
remainder = value - list_of_expenses[index]
if remainder <= value:
if remainder in list_of_expenses[index + 1:]:
print("Found: " + str(list_of_expense... |
bf647ea23765206540a48baf7609da87c19d58c4 | ifann/Python | /a/c9.py | 107 | 3.6875 | 4 | a = [1,2,3,4,5,6,7,8]
# for x in range(1,len(a),2):
# print(x, end=' | ')
b = a[::2]
print(b) |
837328223c46c0b000efeba0af8f060e94a887d9 | quay/quay | /util/canonicaljson.py | 908 | 3.6875 | 4 | import collections
import collections.abc
def canonicalize(json_obj, preserve_sequence_order=True):
"""
This function canonicalizes a Python object that will be serialized as JSON.
Example usage: json.dumps(canonicalize(my_obj))
Args:
json_obj (object): the Python object that will later be seri... |
e01ad33d1480014c8f5d3712ec4c5cd375e4dd82 | gpestana/coding_exercises | /cracking/sorting/MergeSort.py | 772 | 3.84375 | 4 | class MergeSort:
#O(n) extra space for arrays [O(nlogn) if linked lists]
#O(nlogn) time
def sort(self, arr):
if len(arr) <= 1:
return arr
mid = len(arr) // 2
left = arr[:mid]
right = arr[mid:]
self.sort(left)
self.sort(right)
return list(self.merge(left, right))
def me... |
eb6660f7c92db4c8cccea392deba6212cf95ae05 | gpestana/coding_exercises | /hackerrank/similarPair.py | 1,362 | 3.765625 | 4 | class Node:
def __init__(self, val):
self.children = []
self.val = val
def addChild(self, child):
self.children.append(child)
def getChildren(self):
return self.children
class Tree:
def __init__(self):
self.root = None
def addPair(self... |
d27191e0deb45f61b13c839b44c6084bcf2f5320 | Qu3d45/ZeroToMasterPython | /ex122_polymorphism.py | 779 | 3.59375 | 4 | class User():
def sign_in(self):
print("Logged in")
def attack(self):
print(" do nothing")
class Wizard(User):
def __init__(self, name, power):
self.name = name
self.power = power
def attack(self):
User.attack(self)
print(f"attacking with power of {s... |
affe75c992acc0810076af78dac563336a6c422a | graceolivia/cs50 | /pset6/credit/credit.py | 1,229 | 3.984375 | 4 | from cs50 import get_int
creditCard = get_int("Enter credit card number:\n")
stringCC = str(creditCard)
creditCardLength = len(stringCC)
sumDigits = 0
doubledSumDigits = 0
firstSet = stringCC[creditCardLength - 2::-2]
# meaning of this [::] is: slice, [starting at second to last digit : until end of string : every ... |
c76af246d2320fa84bb288f550b981001ac70b3e | ZuluSomeone/Bob | /prov2.py | 171 | 3.5 | 4 | minfil=open('Desktop/prov.txt','r') #This line opens the text document
print minfil.read() #This line reads the file and print it out
minfil.close() #This line closes it
|
c136bfa49fdd1bac286eaca4c4e1735b6dce9f3e | MOysolova/Python | /is_increasing.py | 312 | 3.84375 | 4 | def is_increasing(seq):
index = 0
result = True
for number in seq:
if index < len(seq) - 1:
next_number = seq[index + 1]
if number > next_number:
result = False
break
index += 1
return result
print(is_increasing([5,6,-10])) |
eb68861dc2affd83c27af1477fe56b05f2e070d2 | MOysolova/Python | /week_1/2.If_Elif_Else_Simple_Problems/evenodd.py | 128 | 4.21875 | 4 | a = input("Enter a number: ")
a = int(a)
if a % 2 == 0:
print("{} is even".format(a))
else:
print("{} is odd".format(a)) |
569409fabb8b6ac8ae793eadc9bf5d7a009c9670 | MOysolova/Python | /is_decreasing.py | 309 | 3.8125 | 4 | def is_decreasing(seq):
index = 0
result = True
for number in seq:
if index < len(seq) - 1:
next_number = seq[index + 1]
if number < next_number:
result = False
break
index += 1
return result
print(is_decreasing([1,2,3])) |
17bc30abd4a4aa2ec5f28b9f4320cdbb988fdb5e | MOysolova/Python | /week_1/1.IO_simple_Problems/n_dice.py | 154 | 3.875 | 4 | from random import randint
n = input("Enter sides: ")
n = int(n)
def random_dice(n):
result = randint(1, n)
return result
print (random_dice(n))
|
5eca4aecbfd3329f91b8647398b58fb7c07f08ec | MOysolova/Python | /week_1/5.Saturday_tasks/1_to_n_by_2.py | 104 | 3.703125 | 4 | n = input("Write N: ")
n = int(n)
start = 1
add = 2
while start <= n:
print(start)
start += add
|
e3b2259f632bcb98dccfb6c5a02342684a772fd6 | MOysolova/Python | /week_1/5.Saturday_tasks/reverse_int.py | 187 | 3.9375 | 4 | n = input("Enter N: ")
n = int(n)
rev_number = 0
while n != 0:
digit = n % 10
rev_number = rev_number * 10 + digit
n = n // 10
print("Reversed number: {}" .format(rev_number)) |
42457827d12df00b4f3e7e0e3825e6092ce9aad7 | MOysolova/Python | /week_1/4.While_loop_problems/60k.py | 118 | 3.546875 | 4 | start = 0
end = 60000
while True:
if start == end:
break
start += 1
print(start)
print("The End.") |
c103852a72228c59d6ee57814c3c0369a7889d84 | MOysolova/Python | /week_1/5.Saturday_tasks/largest_3_digits.py | 792 | 3.84375 | 4 | n = input("Enter a 3-digit number: ")
n = int(n)
a = n % 10
n = n // 10
b = n % 10
n = n // 10
c = n % 10
n = n // 10
largest = c
if b >= largest and b >= a:
largest = b
if a >= largest and a >= b:
largest = a
smallest = c
if b <= smallest and b <= a:
smallest = b
if a <= smallest and a <= b:
smalles... |
ac3954b8a853b65eed53e26e24a16e6a6c06b7aa | huyngopt1994/python-Algorithm | /bigo/day-4-queue-and-stack/stpar-Street-Parade.py | 786 | 3.890625 | 4 | # https://www.spoj.com/problems/STPAR/fbclid=IwAR3DNOqkth79CD9rurn55e5Gf8Ph_3oV6ZztxDi9qG4pBYfsAljL4TnWSCE
while int(input()) != 0:
main_queue = list(map(int, input().split()))
# first in first out
count = 1
side_road = [] # stack # first in last out
while len(main_queue) > 0:
if main_queue... |
2a609274e048483b4da0868cca9f3bb1eeadf55d | huyngopt1994/python-Algorithm | /green/green-09-recursive/exponent.py | 208 | 3.65625 | 4 | # apply a,b : a**b using (a*a*a*a (b times))
def get_exponent(a,b):
#base case
if b ==0:
return 1
#recursive case
return a*get_exponent(a,b-1)
result = get_exponent(4,5)
print(result) |
0c5b17efb0a1646429381cbc1fb3b8f2aef2c10f | huyngopt1994/python-Algorithm | /leet-code/lru-cache/lru-cache.py | 2,572 | 3.734375 | 4 | class Node:
def __init__(self, key, value, prev=None, next=None):
self.value = value
self.key = key
self.prev = prev
self.next = next
class DoubleLinkedList:
def __init__(self):
self.size = 0
self.head = Node(key=0, value=0)
self.tail = Node(key=0, value... |
5a7f7ada1ecefd3d6c9c2a5d0d92f34ade735cfe | huyngopt1994/python-Algorithm | /green/green-05-array/tour.py | 415 | 3.78125 | 4 | number = int(input())
array_student = map(int, input().split())
# ouput : print "YES" if the number of man == number of woman
# solution : we just loop per student and count the number of man and number of woman and compare them
number_man = 0
number_woman = 0
for student in array_student:
if student:
number_man ... |
41cdbd237bb42ba8c58e5c96c0ff408e03fcf3af | huyngopt1994/python-Algorithm | /leet-code/30-day-leet-coding-challenge/__init__.py | 866 | 3.65625 | 4 | from queue import Queue
from collections import OrderedDict
class FirstUnique:
def __init__(self, nums):
self.my_queue = Queue()
self.hash_count = {}
self.unique_items = OrderedDict()
self.order_item = []
for num in nums:
self.add(num)
self.prev_first_u... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.