blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
f71966aabae8b8ce84cb666670509098c3948eb5 | Anusri29/MIT_6.00x | /is_list_permutation.py | 1,264 | 3.890625 | 4 | def getMaxElement(L1):
d = {L1.count(x):x for x in L1}
countMax = max(d.keys())
countMax_element = d[max(d.keys())]
typeOfElement = type(countMax_element)
A = []
A.append(countMax_element)
A.append(countMax)
A.append(typeOfElement)
return tuple(A)
def listArg(L, element):
'''
... |
be69b6917670b21664dd33b85670ba8ddd9fac78 | AndreLovo/Python | /Desafio040.py | 529 | 3.84375 | 4 | n1= float(input('Entre com a nota 1: '))
n2= float(input('Entre com a nota 2: '))
m= float((n1+n2)/2)
print('A nota 1 é:{:.1f}'.format(n1))
print('A nota 2 é:{:.1f}'.format(n2))
print('A media é:{:.1f}'.format(m))
if m<5.0:
print('A média é de {:.1f}, e o aluno está REPROVADO!'.format(m))
elif 6.9> m >=5:
... |
b005f3cf3de139390b2fe1032f917fbd2f15f226 | AndreLovo/Python | /Desafio017a.py | 265 | 4.03125 | 4 | # Python3 program for hypot() function
# Import the math module
import math
# Use of hypot fucntion
print("hypot(3, 4) : ", math.hypot(3,4))
# Neglects the negative sign
print("hypot(-3, 4) : ", math.hypot(-3,4))
print("hypot(6, 6) : ", math.hypot(6,6)) |
301e2f05845d63e1510e35d5eb219b6e42b2481b | AndreLovo/Python | /Desafio024.py | 235 | 3.96875 | 4 | cid= str(input('Entre com a cidade que você nasceu: ')).strip()
print(cid[0:5].upper() =='SANTO')
#strip elimina os espaços que o usuário colocar
# upper eu transformo toda digitação do usuário em maiúsculo e depois comparo
|
2bcf69759cfc30d1741ef2d3f618195942aabeb9 | AndreLovo/Python | /Desafio011.py | 237 | 3.796875 | 4 | c= float(input('Entre com o valor do comprimento (m) da parede: '))
h= float(input('Entre com o valor da altura (m) da parede: '))
print('A área da parede é de: {} m² e serão necessários {} litros de tinta!'.format((c*h),(c*h)/2)) |
3b207ab29dee4196a42557b443e051320873849a | AndreLovo/Python | /Desafio054a.py | 397 | 3.8125 | 4 | from datetime import date
atual= date.today().year
totmaior=0
totmenor=0
for pess in range(1,8):
nasc= int(input('Em que ano a {}º pessoa nasceu? '.format(pess)))
idade = atual -nasc
if idade>=21:
totmaior+=1
else:
totmenor+=1
print('Tivemos {} pessoas maiores de idade!'.forma... |
a9f945408a4b6d3088528e294952c35a6a8abb9c | AndreLovo/Python | /Desafio007.py | 105 | 3.828125 | 4 | n1= float(input('n1: '))
n2= float(input('n2: '))
print ('A média das notas é: {}'.format((n1+n2)/2)) |
34de1e239bfad09570cf8302c245fa8b981860d5 | AndreLovo/Python | /Desafio054.py | 370 | 3.75 | 4 | #Análise de Dados
s=0
m=0
from datetime import date
atual= date.today().year
for c in range(0,3,1):
a= int(input('Entre com o ano de nascimento:'.format(c)))
if (atual-a>=21):
s+=c
print('Temos {} pessoas maiores de idade'.format(s))
elif(atual-a<21):
m+=c
print('... |
81905224310e6c47a9d9f8b84eefadef619d8b1e | AndreLovo/Python | /Desafio049.py | 134 | 3.828125 | 4 | num= int(input('Digite eum número para ver a sua tabuada: '))
for c in range(1,11):
print('{} X {:2} = {}'.format(num,c,num*c)) |
447c1e35ad0e435e736af2d8c14f6581b129ab2d | AndreLovo/Python | /Desafio035.py | 256 | 3.875 | 4 | a=float(input('Entre com a reta A:'))
b=float(input('Entre com a reta B:'))
c=float(input('Entre com a reta C:'))
if(a+b>c and b+c>a and c+a>b):
print('O triângulo PODE ser formado')
else:
print('O triângulo, NÃO PODE ser formado')
|
136df7871ace6be897e56098d0d9b886941b0a88 | AndreLovo/Python | /aula06b.py | 181 | 3.90625 | 4 | print('==Desafio 003==')
n1 = float(input('Entre com o valor n1: '))
n2 = float(input('Entre com o valor n2: '))
s= n1 +n2
print('A soma entre {} e {} é {}' .format(n1,n2,s))
|
68ba1f4ae70573115a8278dfa7077a978fb45f71 | AndreLovo/Python | /Desafio60a.py | 156 | 4.0625 | 4 | from math import factorial
num=int(input('Entre com um número inteiro qualquer: '))
fat=factorial(num)
print('O fatorial de {}! é: {}'.format(num,fat)) |
713e8dbbde5fcd443cd4d8e5349d71b8db193817 | AndreLovo/Python | /aula013b.py | 136 | 3.859375 | 4 | s=0
for c in range(0, 4):
n= int(input('Digite um valor: '))
s+=n
print('O somatório de todos os valores foi {}'.format(s)) |
e383712f9fe4b7a7340c370667601f8fc8e87abb | andlon93/Euler | /24.py | 1,779 | 4.03125 | 4 | '''
A permutation is an ordered arrangement of objects.
For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4.
If all of the permutations are listed numerically or alphabetically,
we call it lexicographic order.
The lexicographic permutations of 0, 1 and 2 are:
012 021 102 120 201 210... |
f6bb00cedcdbc1d80386f04de62abb0934bbd9a9 | andlon93/Euler | /6.py | 143 | 3.640625 | 4 | def sum_of_squares(i):
n = 0
b = 0
for k in xrange(1,i+1):
n += k**2
b += k
b = b**2
print b
print n
print b-n
sum_of_squares(100)
|
fda91b38907f4802fc8dd1fafcdb2183846c00dc | djphan/c275-Project-2-pyGame_Attempt | /helperfunctions.py~ | 681 | 3.984375 | 4 | import random
def randomizer_output(items):
"""
randomizer_output takes in a list of tuples (items) of the following format: (item, weight)
and returns the item at a given probability. For this assignment this will be
[(-1, 0.2), (0, 0.5), (1, 0.2), (2, 0.2)]
To call final damage we will need to... |
99aef3c4746dfa0c2c4621e6bd6ee13635428077 | scootermcgavin686/C950-DSA-II | /main.py | 10,118 | 3.734375 | 4 | from csvreader import LoadTruck, loadPackageData
from hashtable import myHash
loadPackageData("WGUPS Package File.csv")
miles = LoadTruck()
userInput = ''
print('\n\nWGU Delivery Project')
print('Scott Moore Student ID# 0001070276', '\n')
# This loop is the command line interface for my program. A while loop will ... |
74d68b9c7b35c0c0df7b8d11da423b810289564e | noveee/Programming-Handbook | /Pg 85.py | 782 | 3.890625 | 4 | # Challenge 1
favmusi = ["5SOS", "Coda", "Kamiyada", "Scarlxrd"]
# Challenge 2, adjusted
places = ("School", "Grandma's house", "My friend's house")
# Challenge 3
am = {"height" : "5'10",
"favorite color", "purple",
"favorite song", "dreams of you",
"favorite instrument", "guitar"
}
... |
af44a1352e34f66e6346505eafebb321348d4b6e | Odegaard11/test1 | /test37.py | 1,055 | 3.65625 | 4 | # 정렬된 k개의 리스트가 있다.
# k개의 리스트 중 적어도 한개의 숫자를 포함하는 구간 간격이 가장 작은 숫자의 범위를 구하시오.
def existance(min, max, numbers):
for number in numbers:
if min <= number and number <= max:
return True
return False
list1 = [4, 10, 15, 24, 26]
list2 = [0, 9, 12, 20]
list3 = [5, 18, 22, 30]
length =... |
0256a59adbf0485a632bc844164f8632c5d6b984 | Odegaard11/test1 | /test12.py | 828 | 3.96875 | 4 | # Bubble Sort
def bubble(list1):
swap = 0
loop = 0
needSort = True
while needSort:
swapInLoop = 0
for i in range(len(list1)-1):
if list1[i] > list1[i+1]:
temp = list1[i]
list1[i] = list1[i+1]
list1[i+1] = temp
... |
0878cfffbece73ae333f17d0c9c9a9bea67d18fd | Odegaard11/test1 | /test34.py | 1,015 | 3.59375 | 4 | # 수직선 위에서 정수 x에서 정수 y로 이동하는 과정을 생각해보자.
# 각 단계의 길이는 음이 아니어야 하며 이전 단계의 길이보다 1이 작거나, 같거나, 1이 커야 한다.
# x에서 y로 가는 데 필요한 최소 단계의 수는 얼마인가? 첫번째와 마지막 단계의 길이는 모두 1이어야 한다.
def steps(diff):
count = 1
while count**2 <= diff:
count += 1
count -= 1
loss = diff - count**2
if count < loss:
... |
261e56d35a2324ba0815120ba56d332476d44470 | Koemyy/Projetos-Python | /PYTHON/Python Exercícios/3 lista de exercicios/1114.py | 116 | 3.796875 | 4 | x=int(input())
z=2002
while(x!=z):
print("Senha Invalida")
x=int(input())
print("Acesso Permitido") |
83e7fd504560c1669d9ea8fc1bbab237858f6c7c | Koemyy/Projetos-Python | /PYTHON/Python Exercícios/1 lista de exercícios/ex18.py | 506 | 3.75 | 4 | valor = int(input())
print(f"{valor}")
x = valor//100
print(f"{x} nota(s) de R$ 100,00")
valor-=x*100
x = valor//50
print(f"{x} nota(s) de R$ 50,00")
valor-=x*50
x = valor//20
print(f"{x} nota(s) de R$ 20,00")
valor-=x*20
x = valor//10
print(f"{x} nota(s) de R$ 10,00")
valor-=x*10... |
4326e8da1c32e07197cf7cec167b52b6aab5e706 | Koemyy/Projetos-Python | /PYTHON/Python Exercícios/2 lista de exercicios/ex45.py | 88 | 3.828125 | 4 | n=2
c = int(input())
while(n<=c):
z=n**2
print(f"{n}^{2} = {z}")
n+=2 |
74928d1fef25c7ace77867de559101ef071e2f0e | lxj19681972/MITx-6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python | /PS2-3.py | 1,397 | 4.09375 | 4 | """
Now write a program that calculates the minimum fixed monthly payment
needed in order pay off a credit card balance within 12 months. By a
fixed monthly payment, we mean a single number which does not change
each month, but instead is a constant amount that will be paid each
month.
In this problem, we will ... |
9c1d42db7098367ed97a11251ff99f2279da9e8f | jirvin16/CryptoFun | /BabyStepGiantStep.py | 2,482 | 3.625 | 4 | import math
import random
import time
#2=3**x mod 2**31+2**30+7=3221225479
def BabyGiant(y,g,p):
S=[]
T=[]
m = int(math.ceil(math.sqrt(p)))
for i in range(m + 1):
S.append( (i,pow(g,i*m,p) ) )
T.append( (i,(y*pow(g,i, p))%p) )
start = time.time()
for i in range(m + 1):
sta... |
349cc5aaf3b9d8f62ea07a3b6b330bfe0ba6beec | shuxton/Scripts | /spam.py | 307 | 3.5 | 4 | from pynput.keyboard import Key, Controller
import time
message="Hello world"
keyboard= Controller();
time.sleep(5);
for num in range(100):
for letter in message:
keyboard.press(letter)
keyboard.release(letter)
keyboard.press(Key.enter)
keyboard.release(Key.enter)
time.sleep(0.1) |
8eaee12e76185566bcf00367dbfe72ae0b7d12da | bstrellis/Sorting | /project/iterative_sorting.py | 1,001 | 4.1875 | 4 | # Complete the selection_sort() function below in class with your instructor
def selection_sort( arr ):
# loop through n-1 elements
for i in range(0, len(arr) - 1):
index_of_min = i
for j in range(i+1, len(arr)):
if arr[index_of_min] > arr[j]:
index_of_min = j
... |
98ddf606dd1563c78473894ec1e519d1729efe9e | EliRuan/ifpi-ads-algoritmos2020 | /LISTA Fábio 01_Parte 01/f1_q16.py | 207 | 3.71875 | 4 | #entrada
lado_do_quadrado = float(input('Digite o valor do lado do quadrado: '))
#processamento
area_do_quadrado = lado_do_quadrado * 2
#saída
print('A área do quadrado é:', area_do_quadrado)
|
ab5df570e750934bc803c5affc9b2025a71d0f01 | EliRuan/ifpi-ads-algoritmos2020 | /Exercícios Iteração WHILE/f3_q21.py | 349 | 3.78125 | 4 | print('-' * 60)
print('Para a expressão: S = (1/1 + 3/2 + 5/3 + 7/4 + ... + 99/50): ')
print('-' * 60)
contador = 1
numerador = 1
soma = 0
print('O valor de S é ', end= '')
while contador <= 50 and numerador <= 99:
soma = soma + (numerador/contador)
contador += 1
numerador = numerador + ... |
71f44226149dddd686a3e47805fca8e2257b0528 | EliRuan/ifpi-ads-algoritmos2020 | /Exercícios Iteração WHILE/f3_q08.py | 350 | 3.890625 | 4 | def programa():
n = int(input('Número: '))
lim_inferior = int(input('Limite inferior: '))
lim_superior = int(input('Limite superior: '))
while lim_inferior <= lim_superior:
if lim_inferior % n ==0:
print(lim_inferior,'→', end=' ')
lim_inferior += 1
p... |
6d186f6a5789f2b6d68ab6406f88ed751a331cc9 | EliRuan/ifpi-ads-algoritmos2020 | /LISTA Fábio 01_Parte 01/f1_q15.py | 309 | 3.828125 | 4 | #entrada
base_do_triangulo = float(input('Digite a base do triângulo: '))
altura_do_triangulo = float(input('Digite a altura do triângulo: '))
#processamento
area_do_triangulo = (base_do_triangulo * altura_do_triangulo) / 2
#saída
print('A área do triângulo é igual a:', area_do_triangulo)
|
1ef002776370fddb6e824bbd033e9d4e4de2b7b1 | EliRuan/ifpi-ads-algoritmos2020 | /LISTA Fábio 01_Parte 01/f1_q10.py | 348 | 4.125 | 4 | #entrada
num1 = input('Digite o primeiro número: ')
num2 = input('Digite o segundo número: ')
#processamento
quociente = (int(num1)) / (int(num2))
resto = (int(num1)) % (int(num2))
#saída
print('O quociente da divisão entre', num1, 'e', num2, 'é: ', quociente)
print('O resto da divisão entre', num1, 'e', nu... |
a6592db6f24652e515907f1a59c243a20e7d4b46 | EliRuan/ifpi-ads-algoritmos2020 | /LISTA Fábio 01_Parte 01/f1_q6.py | 192 | 3.78125 | 4 | # entrada
velocidade_km_h = int(input('digite uma velocidade em km/h: '))
# processamento
velocidade_ms = velocidade_km_h / 3.6
#saída
print(f'A velocidade é {velocidade_ms} m/s')
|
6de17a34ece5fa966589cdf40d96ff1f0d09ebf5 | EliRuan/ifpi-ads-algoritmos2020 | /Exercícios Iteração WHILE/f3_q14.py | 299 | 3.984375 | 4 | def maior_quadrado():
n = int(input('Digite um número: '))
quadrado = n * n
atual = 1
while atual **2 <= n:
quadrado = atual * atual
atual = atual + 1
print(f'O maior quadrado até {n} é {quadrado} (quadrado de {atual-1}).')
maior_quadrado()
|
0de66541a110eae04dfd107744f85fe4d4ec5f5e | EliRuan/ifpi-ads-algoritmos2020 | /LISTA Fábio 01_Parte 01/f1_q19.py | 194 | 3.828125 | 4 | #entrada
raio_esfera = float(input('Digite o raio da esfera: '))
#processamento
volume_esfera = (4 * 3.14 * raio_esfera * 3) / 3
#saída
print('O volume da esfera é:', volume_esfera)
|
720fb779c8dc049ccbf09d732232f5e3587b3cae | ishpreetknanda/Code-Academy-Pro | /Python/Ex3_List_Less_Than_Ten_Solutions/run.py | 229 | 4 | 4 | a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
num = int(input("Enter number to compare with: "))
myList = []
def cal(list,num):
for val in list:
if val<num:
myList.append(val)
print myList
cal(a,num) |
084b048a40bf446dc8518bca67cdd265c35024ae | guiconti/workout | /leetcode/250.countUnivalueSubtrees/250.countUnivalueSubtrees.py | 1,006 | 3.9375 | 4 | # Given a binary tree, count the number of uni-value subtrees.
# A Uni-value subtree means all nodes of the subtree have the same value.
# Example :
# Input: root = [5,1,5,5,5,null,5]
# 5
# / \
# 1 5
# / \ \
# 5 5 5
# Output: 4
# Definition for ... |
cfe6aedb89cfb8c02e8f8c85d8dd1749624216ce | guiconti/workout | /leetcode/2.add-two-numbers/test.py | 1,397 | 3.71875 | 4 |
from .solution import Solution
import ast
import os
unknown_answer_token = '?'
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
def test():
with open(os.path.join(os.path.dirname(__file__), 'input.txt'), 'r') as file:
while True:
a = file.readline()
if not a:
... |
48f3b1ede9534097782c6ab88dec72f5e582422c | guiconti/workout | /leetcode/409.longestPalindrome/409.longestPalindrome.py | 897 | 3.796875 | 4 | # 409. Longest Palindrome
# Easy
# 724
# 69
# Add to List
# Share
# Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.
# This is case sensitive, for example "Aa" is not considered a palindrome here.
# Note:
# Assume the... |
18bbc5ffe6d249a6db0c3ad2d6451244a9b2a4bf | guiconti/workout | /crackingthecodeinterview/linkedlist/2-2.py | 1,013 | 3.8125 | 4 | # Implement an algorithm to find the kth to last element of a singly linked list.
class Node:
def __init__(self, data):
self.data = data
self.next = None
# Solution 1 Create two pointers to run the array. Run the first point k time
# Then start running each pointer together. When the first pointer reach th... |
312ff7986118aa251b91844bc0bf68dceffe4db2 | guiconti/workout | /hackerrank/arrays/hourglassSum.py | 1,057 | 3.609375 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
HOURGLASS_WIDTH = 3
HOURGLASS_HEIGHT = 3
# Complete the hourglassSum function below.
def hourglassSum(arr):
biggestHourglassSum = -10000
for i in range(len(arr) - HOURGLASS_HEIGHT + 1):
for j in range(len(arr[i]) - HOURGLASS_WIDT... |
5b4fa6a066e12d1cadbcdae791c8513c403fd449 | guiconti/workout | /crackingthecodeinterview/arrays/1-8.py | 953 | 3.890625 | 4 | # Write an algorithm such that if an element in a matrix MXN is 0, its entire row and column will be 0
# If the result is bigger than the original string return the original string
# Solution 1 Iterate through each element, if a 0 is found add its row and column to two
# support arrays. After everything is checked use... |
31555963a86030a986db6362e6d18d4830cc1947 | guiconti/workout | /leetcode/36.valid-sudoku/36.valid-sudoku.py | 1,083 | 3.546875 | 4 | class Solution:
def isValidSudoku(self, board: List[List[str]]) -> bool:
sudokuSize = 9
subBoxSize = 3
for i in range(sudokuSize):
# Validate row
hashmap = collections.defaultdict(bool)
for cell in board[i]:
if cell != '.':
if cell in hashmap:
return False
... |
3f6f3e7187462f8146706027d739af4dc0addf9c | guiconti/workout | /crackingthecodeinterview/treeAndGraphs/4-3.py | 929 | 3.859375 | 4 | # Given a graph find if there is a route between two nodes
import queue
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def createSubTree(root, sortedArray):
if len(sortedArray) == 0:
return None
median = len(sortedArray) // 2
root = Node(sortedArray[... |
af500e64eec3eac1d10d1fb2eed0b445ea56d2cf | guiconti/workout | /leetcode/58.length-of-last-word/58.length-of-last-word.py | 112 | 3.546875 | 4 | class Solution:
def lengthOfLastWord(self, s: str):
s = s.strip().split(' ')
return len(s[len(s) - 1]) |
0a25dd8c7435b90f89fc6d87334b78a0bc5d34d0 | guiconti/workout | /crackingthecodeinterview/treeAndGraphs/4-2.py | 807 | 3.9375 | 4 | # Given a graph find if there is a route between two nodes
import queue
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def createSubTree(root, sortedArray):
if len(sortedArray) == 0:
return None
median = len(sortedArray) // 2
root = Node(sortedArray[... |
31316797a123ad7bedf90e48df5b82f47d46b413 | guiconti/workout | /utils/oop/class.py | 624 | 3.765625 | 4 | from functools import cmp_to_key
class Player:
def __init__(self, name, score):
self.name = name
self.score = score
def comparator(a, b):
if (a.score > b.score):
return -1
elif (a.score < b.score):
return 1
elif (a.name > b.name):
return -1
elif (a.name < b.name):
... |
038210f90a4725c2ba447c0056e444ca68f319bb | guiconti/workout | /leetcode/86.partition-list/86.partition-list.py | 1,277 | 3.71875 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def partition(self, head: ListNode, x: int) -> ListNode:
rightHead = None
currentRight = None
current = head
leftTail... |
ffdb2fbeab19b5c6055c843715efabf72c202192 | guiconti/workout | /hackerrank/strings/sherlockAndValidString.py | 1,413 | 3.890625 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
CHARS = 26
# Complete the isValid function below.
def isValid(s):
my_list = list(s)
my_freq = {}
for item in my_list:
if (item in my_freq):
my_freq[item] += 1
else:
my_freq[item] = 1
... |
a0acf3fd422849352dcd06676691311889c52511 | dh00023/TIL | /algorithm/code/python_code/sort/20210406_updown.py | 785 | 3.515625 | 4 | """
하나의 수열에 다양한 수가 존재.
이때 수는 크기에 상관없이 나열되어 있다. 이 수를 큰 수부터 작은 수의 순서로 정렬해야한다. 수열을 내림차순으로 정렬하는 프로그램을 만들어라.
입력조건
- 첫째 줄에 수열에 속해 있는 수의 개수 N이 주어진다.(1<=N<=500)
- 둘째 줄부터 N+1 번째 줄까지 N개의 수가 입력된다. 수의 범위는 1이상 100,000 이하의 자연수이다.
입력으로 주어진 수열이 내림차순으로 정렬된 결과르 공백으로 구분해 출력한다. 동일한 수의 순서는 자유롭게 출력해도 좋다.
"""
n = int(input())
arr = []
fo... |
c4b5b33a22b63f21d3ef278769d0a462d8114e45 | hemanth-kotagiri/python-beginner-projects | /Password Generator/main.py | 1,468 | 3.890625 | 4 | import sys
import string
import random
import os
class Password:
def __init__(self):
""" A class to generate, manipulate random Passwords"""
try:
a = list(map(lambda a : True if a == 'y' else False, [input("Include upper-case(y/n): "), input("Include lower-case(y/n): "), input("Include ... |
cb303aded21370808e8bb5780735ba9d16376b25 | TogrulAga/Coffee-Machine | /Coffee Machine/task/machine/coffee_machine.py | 3,199 | 4.28125 | 4 | # Write your code here
class Coffee:
def __init__(self, water: int = 0, milk: int = 0, beans: int = 0, price: int = 0):
self.water = water
self.milk = milk
self.beans = beans
self.price = price
class CoffeeMachine:
espresso = Coffee(water=250, beans=16, price=4)
latte = Cof... |
b4e7d8beead80b4d1f98cbf73b4374267baa0960 | savitadevi/function | /average.py | 207 | 3.796875 | 4 | def fun (a,b,c):
sum=a+b+c
average=sum/3
print(average)
user1=int(input("enter the number"))
user2=int(input("enter the number"))
user3=int(input("enter the number"))
fun(user1,user2,user3)
|
dd9060e08d6fe3b2bb2e7db7dcc1e10dead5cbde | savitadevi/function | /prime number.py | 600 | 3.78125 | 4 | # def number(isprime):
# i=0
# a=[]
# while i<len(isprime):
# j=1
# count=0
# while j<=(isprime[i]):
# if isprime[i]%j==0:
# count=count+1
# j=j+1
# if count==2:
# a.append(isprime[i])
# i=i+1
# print(a)
# number... |
015ad6b80b8f346e06be582e55da5ca482bf5ea7 | savitadevi/function | /nav_gurukul.py | 572 | 3.921875 | 4 | # 1st method
def number(a):
i=1
while i<(a):
if i%3==0:
print("nav")
elif i%7==0:
print("gurukul")
elif i%7==0 and i%3==0:
print("navgurukul")
else:
print(i,"savuta")
i=i+1
n = int(input("enter the number="))
number(n) ... |
58da01fae9b7ea292cb15a70259e1c7728457dca | sreedom/rabbit-pipeline | /component.py | 1,745 | 3.640625 | 4 | # component defenition
# author Sreeraj
#
'''Defines an abstract class for components
'''
import abc
class Component(object):
''' abstract Baseclass for all components
'''
__metaclass__ = abc.ABCMeta
def __init__(self, **kwargs):
''' Optional init args:
conf : dictionary of confs
... |
a8a8d4f3ba102f5fa469faeb10de9d78d44433c2 | hema59/Technical-Interview | /100-Days-Coding-Challenge/6_Doubly_Linked_Palindrome/solution6.py | 1,406 | 3.875 | 4 | class Node:
def __init__(self, val):
self.value = val
self.next = None
self.prev = None
class doubly_linked:
def __init__(self):
self.head = None
self.size = 0
def create_doubly_linked(self, string):
if len(string) == 0 : return False
string = list... |
d50cc1b5a7363248619bd5baa2cabb2e82ddcc74 | hema59/Technical-Interview | /100-Days-Coding-Challenge/9_Highest_product/solution.py | 644 | 3.921875 | 4 | test_cases = {'1': [0, -1, 3, 100, -70, -5],
'2' : [1, 3, 5, 2, 8, 0, -1, 3]}
answers = {'1':300, '2':720}
#assuming without repetition
def find_highest_prod( array):
if len(array) == 0 : return []
if len(array) <= n : return array
array = sorted(array)
cur_max = max_so_far = 1
for item... |
ff9dd5a1e175a640010d7690fb62caff41695326 | hema59/Technical-Interview | /100-Days-Coding-Challenge/10_Find_Two_Missing_Numbers/solution.py | 784 | 3.796875 | 4 | test_cases = { '1' :[1,2,1,2,4,3,2,3,2,1] ,
'2' :[3,3,3,3,4,3,3,1,1,1],
'3' :[],
'4': [1],
'5':[5,5,5,5] }
answers = { '1' : [1,4],
'2' :[1,4],
'3' :[],
'4' : [1],
'5' :[]}
def find_odd_count... |
1f3d56ef4b234ba0126195a54b81410c6d38272f | Vishnu-prathap/Python3003 | /Activity_14.py | 746 | 4.09375 | 4 | def input_dimensions():
num = input("Enter the values of length, breadth and Height of tromboloid: ")
x = num.split()
l,b,h = [float(ele) for ele in x]#An element is to be converted into float, it searches for element in x(old list) with list unpacking
return l,b,h
def valk(l,b,h):
k = l... |
0c71fff273c7f7a862fec1552754fa74eac56cee | Vishnu-prathap/Python3003 | /maclaurenseriesofsinx.py | 489 | 4.0625 | 4 | def input_theta():
theta = float(input("Enter the angle for whose sin is to be calculated (in radians)\n"))
return theta
def factorial(n):
fac = 1
for i in range(1,n+1):
fac=fac*i
return fac
def sinxvalue(n,theta,sum):
sum = 0
sign = 1
for i in range(1,n):
sum = sum + sign*(theta**(2*i-1)/fac... |
9af6d4e349a0cc163ead6098b0fad712b28326b5 | Vishnu-prathap/Python3003 | /Activity_03.py | 173 | 3.890625 | 4 | a = input("Enter string 1\n")
b = input("Enter string 2\n")
print(a+b)
c = a+b
print(c+c+c+c+c)
print(c+" "+c+" "+c+" "+c+" "+c)
print(c+"\n"+c+"\n"+c+"\n"+c+"\n"+c)
|
4db83ad4c142ab237526c1c5c9623910f94f9aaa | bparker12/python_function_practice | /chickenMonkey.py | 312 | 3.8125 | 4 |
def num():
zero_hundred = range(1, 100)
for num in zero_hundred:
if (num) % 5 == 0 and num % 7 == 0:
print("ChickMonkey")
elif (num) % 5 == 0:
print("Chicken")
elif (num) % 7 == 0:
print("Monkey")
else:
print(num)
num() |
48713ab463446fb9574153240edbf5742cc192b9 | crisbodnar/DeepTacToe | /policy_gradient_against_itself.py | 1,552 | 3.796875 | 4 | """
Builds and trains a neural network that uses policy gradients to learn to play Tic-Tac-Toe.
Returns a probabilitity over the action space expressing the confidence that that action is the best
The opponent is playing using the trained function learned previously by playing against a random player
"""
import functo... |
bfd9e2cec64d393cfc797aa4ce50eb0987dd5d89 | henokemp/think-python-exercises | /chapter4.py | 616 | 3.890625 | 4 | import turtle
import math
bob = turtle.Turtle()
t = turtle.Turtle()
print(bob)
print(t)
def square(name, length): # look how the syntax for defining the function and calling the function is similar
for i in range(4):
name.fd(length)
name.lt(90)
def polygon(name, length, n):
for i in range(n):
name.fd(length... |
d285cdfed3cc957cdc9b5e6ca95d44cf7f2bc31b | henokemp/think-python-exercises | /recurse_test.py | 263 | 3.84375 | 4 | x = 9
def find_x(n):
if not isinstance(n, int): # Lines 4 and 5 are a guardian to make sure that the given value is an integer.
print ('n has to be a whole number.')
return None
elif n != x:
print (n)
n = n + 1
find_x(n)
else:
print(n)
find_x(1)
|
7dd8dc336a7a0fb56d82ef641bcb3e73d83d7302 | henokemp/think-python-exercises | /chapter6_2.py | 375 | 3.640625 | 4 | """def ack (m, n):
if m == 0:
n = n + 1
print (m, n)
if n == 0:
m = m - 1
n = 1
ack (m, n)
print (m, n)
if m > 0 and n > 0:
return ack(m-1, ackermann(m,n-1))
ack(3, 4)"""
def ackermann (m, n):
if m == 0:
print (m, n)
return n + 1
if n == 0:
return ackermann(m-1, 1)
print (m, n)
return ac... |
0874b69bc17a0549fd7d163a47e49b1ad3fc220f | fmcc/StylometricAnalyser | /structures/trie.py | 1,931 | 3.671875 | 4 | class Trie():
def __init__(self):
self.root = dict()
def __iter__(self):
for i in self.__traverse():
yield i
def __contains__(self, key):
return self.find(key)
def __getitem__(self, key):
if self.find(key):
return self.find(key)
else:
... |
b9a9518761bfbdfb48190891b5dbbff01f079849 | almoglev/Machine-Learning | /Ex3- Image Recognition- Neural Network/ex3.py | 7,074 | 3.71875 | 4 | import numpy as np
import scipy
"""
defines
"""
IMAGE_SIZE = 784
FIRST_LAYER_SIZE = 150
LAST_LAYER_SIZE = 10
ETA = 0.005
EPOCH = 50
MAX_COLOR = 255
TRAIN_PERCENT = 0.8
"""
activation function- relu (if the value<=0 returns 0, otherwise returns the value)
"""
def relu(x):
return np.maximum(np.z... |
d87931eff55b89a241ccc1bb156a8f5d136055ce | cckn/python-algorithm | /14_dict.py | 277 | 3.796875 | 4 | def findSameName(names):
nameCount = dict()
for name in names:
if name not in nameCount:
nameCount[name] = 1
else:
nameCount[name] = nameCount[name]+1
return nameCount
print(findSameName(['Tom','jessy', 'Tom','seddle'])) |
2190254d1f23a5d0151137c3d4218b223c7212eb | cckn/python-algorithm | /05.py | 553 | 3.71875 | 4 | def gcd(a, b):
minNumber = min(a, b)
for n in range(minNumber, 0, -1):
if (a % n == 0) & (b % n == 0):
return n
def gcd_recursive(a, b):
minValue = min(a, b)
maxValue = max(a, b)
if minValue == 0:
return maxValue
return gcd_recursive(minValue, maxValue % minValue)... |
321f97442a9838aa2f46796e4426fbab6c9291f8 | KelvinChi/LeetcodeBank | /101_symmetric_tree待研究.py | 348 | 3.6875 | 4 | #!/usr/bin/env python3
# _*_ coding:utf-8 _*_
def add_2(n):
a = [1] * n
a.reverse()
print(list(reversed(a)))
for i in range(1, 2 ** n):
a[0] += 1
for i in range(1, n):
if a[i - 1] > 2:
a[i] += 1
a[i - 1] = 1
print(list(r... |
32d2453d651310db892cf6409b92cbaea2e4dbea | KelvinChi/LeetcodeBank | /020_valid_parentheses.py | 934 | 3.890625 | 4 | #!/usr/bin/env python3
# _*_ coding:utf-8 _*_
def pair(a, b):
if a == '(' and b == ')':
return True
elif a == '[' and b == ']':
return True
elif a == '{' and b == '}':
return True
else:
return False
def la(string):
if string == '':
return 'True'
else:
... |
fb5033a63666120d0c680c379152bd1fe0fb52c9 | KelvinChi/LeetcodeBank | /234_palindrome_linked_list.py | 395 | 4.09375 | 4 | #!/usr/bin/env python3
# _*_ coding:utf-8 _*_
def palindrome_linked_list(string):
lis = list(string)
count = 0
for i in range(len(lis) // 2):
if lis[i] == lis[-1 - i]:
count += 1
else:
print("False")
break
if count == len(lis) // 2:
print('Tr... |
25f9c137d5cc29cbb792d0b9f61ca03087a9047b | KelvinChi/LeetcodeBank | /414_third_maximum_number.py | 207 | 3.875 | 4 | #!/usr/bin/env python3
# -*- coding:utf-8 -*-
# Created by CK 2019-05-11 04:20:27
def tmn(lis):
a = sorted(list(set(lis)))
return a[-1] if len(a) < 3 else a[0]
lis = [2, 2, 3, 1]
print(tmn(lis))
|
94697cc2de59e30969937ee3d4dcef785580eedf | KelvinChi/LeetcodeBank | /520_detect_capital.py | 371 | 3.703125 | 4 | #!/usr/bin/env python3
# -*- coding:utf-8 -*-
# Created by CK 2019-05-21 02:05:47
def dc(string):
if string.lower() == string \
or string.upper() == string \
or string.lower().title() == string:
return True
else:
return False
s1 = 'USA'
s2 = 'China'
s3 = 'HaHa'
print(... |
8d6ce3baf9020214d20e6e3e4746a02b19393038 | KelvinChi/LeetcodeBank | /594_longest_harmonious_subsequence.py | 409 | 3.515625 | 4 | #!/usr/bin/env python3
# -*- coding:utf-8 -*-
# Created by CK 2019-05-29 06:24:06
def lhs(lis):
temp = list(sorted(set(lis)))
count = []
result = 0
for i in temp:
count.append(lis.count(i))
for i in range(len(count) - 1):
if result < count[i] + count[i + 1]:
result = co... |
4dae88117129bc48e026b785e53d14210db88b35 | KelvinChi/LeetcodeBank | /628_maximum_product_of_three_numbers.py | 233 | 3.859375 | 4 | #!/usr/bin/env python3
# -*- coding:utf-8 -*-
# Created by CK 2019-05-31 03:31:02
def mpotn(lis):
lis.sort()
result = 1
for i in lis[-3:]:
result *= i
return result
lis = [1, 3, 2, 5, 8]
print(mpotn(lis))
|
e3ec34b78f4dfe45e6b81b9ce16c5ceb79a47a61 | KelvinChi/LeetcodeBank | /231_power_of_two.py | 569 | 4 | 4 | #!/usr/bin/env python3
# _*_ coding:utf-8 _*_
def power_of_two(num):
a = []
r = 30
for i in range(r):
a.append(2**i)
if num in a:
print('True')
elif r_2(num, r) in a:
print('True')
elif r_2(r_2(num, r), r) in a:
print('True')
else:
two(r_2(r_2(num, r... |
513d484e9186324e8a71ddcea381f0798b88b8f1 | KelvinChi/LeetcodeBank | /217_contains_duplicate.py | 253 | 4 | 4 | #!/usr/bin/env python3
# _*_ coding:utf-8 _*_
def contains_duplicate(lis):
temp = set(lis)
print('True') if len(temp) != len(lis) else print('False')
a = [1, 1, 5, 6]
b = [1, 3, 5, 6]
contains_duplicate(a)
contains_duplicate(b)
|
0a3c98536da2c2a3e314bd164f56c02da9148180 | KelvinChi/LeetcodeBank | /125_valid_palindrome.py | 569 | 4.21875 | 4 | #!/usr/bin/env python3
# _*_ coding:utf-8 _*_
def valid_palindrome(string):
temp = str_judge(string)
num = len(temp) // 2
if temp[:num] == ''.join(list(reversed(temp[-num:]))):
print('Yes, it is.')
else:
print("No, it isn't.")
def str_judge(string):
temp = []
f... |
c8adf4d092c10a92d73775c47c59ddc37b035798 | KelvinChi/LeetcodeBank | /680_valid_palindrome_II.py | 1,014 | 3.5625 | 4 | #!/usr/bin/env python3
# encoding: utf-8
def judge(string):
lis = list(string)
count = 0
for i in range(len(lis) // 2):
if lis[i] == lis[-1 - i]:
count += 1
else:
return False
if count == len(lis) // 2:
return True
def get_index_list(li... |
f5074cd465e027884ad8d294dd012f3edc41eda0 | KelvinChi/LeetcodeBank | /558_quad_tree_intersection.py | 4,881 | 3.5 | 4 | #!/usr/bin/env python3
# -*- coding:utf-8 -*-
# Created by CK
class Node:
def __init__(self, value=None, topLeft=None, topRight=None,
bottomLeft=None, bottomRight=None, isLeaf=None, level=None):
self.value = value
self.topLeft = topLeft
self.topRight = topRight
... |
e8942e2c606010a560385900a0eadb8a217eae3d | alex-xia/leetcode-python | /lib/bitwise_and_of_numbers_range.py | 1,337 | 3.59375 | 4 | __author__ = 'axia'
'''
Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.
For example, given the range [5, 7], you should return 4.
'''
import math
def bformat(num):
return '{0:b}'.format(num)
class Solution(object):
def rangeBitwiseAnd(s... |
eed7b31e31d9f5c724971c93acab64b6b8343e4e | alex-xia/leetcode-python | /lib/tree_traverse.py | 4,222 | 3.5 | 4 | __author__ = 'axia'
class TreeNode:
def __init__(self, val=None):
self.val = val
self.left = None
self.right = None
class BinaryTree:
def __init__(self, root=None):
self.root = root if root else None
def from_list(self, arr):
if len(arr) == 0:
return No... |
a26b74d6dc59c10e3d432ab10cba6e32dfd99bf8 | alex-xia/leetcode-python | /lib/generate_random_point.py | 2,042 | 4.40625 | 4 | '''
Given the radius and x-y positions of the center of a circle, write a function randPoint which generates a uniform random point in the circle.
Note:
input and output values are in floating-point.
radius and x-y position of the center of the circle is passed into the class constructor.
a point on the circumference... |
6892d5dda6ab1baace238fe4e310210717dd835e | alex-xia/leetcode-python | /lib/number_of_digit_one.py | 1,226 | 3.859375 | 4 | __author__ = 'axia'
'''
Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.
For example:
Given n = 13,
Return 6, because digit 1 occurred in the following numbers: 1, 10, 11, 12, 13.
'''
class Solution(object):
def countDigitOne(self, n):
"... |
dbafe12500a0c8cc15bbd4d372ae15e12af5ea10 | alex-xia/leetcode-python | /lib/happy_number.py | 1,333 | 4.1875 | 4 | __author__ = 'axia'
'''
Write an algorithm to determine if a number is "happy".
A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loop... |
e9b347464c809d2a92264baba986092643dc871a | alex-xia/leetcode-python | /lib/count_horses.py | 2,088 | 4.15625 | 4 | '''
There are a lot of horses in the yard, and we want to count how many there are. Unfortunately, we've only got a recording of the sounds from the yard. All the horses say "neigh". The problem is they can "neigh" many times. The recording from the yard is sadly all mixed together. So, we need to figure out from ... |
d5d7ddc0c919887969008b76a0269d5aeed7bcf0 | alex-xia/leetcode-python | /lib/add_and_search_word.py | 2,914 | 3.90625 | 4 | __author__ = 'axia'
'''
Design a data structure that supports the following two operations:
void addWord(word)
bool search(word)
search(word) can search a literal word or a regular expression string containing only letters a-z or .. A . means it can represent any one letter.
For example:
addWord("bad")
addWord("d... |
f249dff42d817d3f014dc61ae3adae2e27b3e5e0 | majek/codejam-practice | /32001/A.py | 1,349 | 3.625 | 4 | import sys
GATE_AND=-1
GATE_OR=-2
def plus(a,b):
if a is Ellipsis or b is Ellipsis:
return Ellipsis
return a + b
for case_no in xrange(1, input() + 1):
print >> sys.stderr, "Case #%s:" % (case_no,)
print "Case #%s:" % (case_no,),
M, V = map(int, raw_input().split())
CH = [None] * M... |
51486757ddddb0566b3da38b3c225ec6ce55be11 | akhmanchi/GCC-Patch-1.0.2 | /python/Question4.py | 767 | 3.515625 | 4 | # modify this function, and create other functions below as you wish
def question04(v, c, mc):
if len(v) == 0 or len(c) == 0:
return 0
if len(v) != len(c):
return 0
answer = 0
maxc = max(c)
minc = min(c)
# print(maxc)
while mc >= minc:
if maxc <= mc:
index... |
73e99071544e1be9ab6adbf54f87dfddd45beb8a | tarakdavis/currency_converter | /currency_converter.py | 605 | 3.53125 | 4 | from currency import Currency
class CurrencyConverter:
def __init__(self, rates):
self.rates = rates
def convert(self, currency, convert_to_code):
if currency.currency_code == convert_to_code:
return currency
else:
if convert_to_code in self.rates:
... |
7c4b501c444a42cb4609073c5702dadd8fbb35ee | Gopika1/Python | /Python package/Student.py | 537 | 3.90625 | 4 | class Student:
def __init__(self, Name, Mark, Branch):
self.Name = Name
self.Mark = Mark
self.Branch = Branch
def display(self):
print(" My Name is " + self.Name, "and my mark is " + self.Mark, "and my branch is " + self.Branch)
n = input("Enter a name")
m = input("Enter a mark"... |
cc80b7100a234c5d12e2ffae18a4500c500c6245 | Gopika1/Python | /Python package/sample inheritanc.py | 377 | 3.59375 | 4 | class Employer:
def __init__(self):
print("Calling parent constructor")
def EmployerMethod(self):
print("Hi,I am an Employer")
class Employee(Employer):
def __init__(self):
print("Calling Child constructor")
def EmployeeMethod(self):
print("Hi,I am an employee from CS dept")
E... |
a796636fef28ec1db5f711dec63513f485a59160 | nk915/study_exam_code | /02-python/test.py | 430 | 4.1875 | 4 | #!/usr/bin/python
if(1 or 0 or (0 and 0)):
print '1'
if((1 or 0 or 0) and 0):
print '2'
if(1 or 0 or 0 and 0):
print '3'
if((1 or 0) or (0 and 0)):
print '4'
if(1 or (0 or (0 and 0))):
print '5'
print '================================'
if(0 or 1 or (0 and 0)):
print '1'
if((0 or 1 or 0) and 0):
print '2'
... |
eb741bcfde0ee5379519d766af4db859334f7a8c | ListFranz/peoplemangagertwo | /main/vin.py | 710 | 3.546875 | 4 | from Tkinter import *
import sqlite3
import sys
def pconn():
conn=sqlite3.connect("people.db")
cu=conn.cursor()
return conn,cu
def pinsert(pid,pna,pinf):
conn,cu=pconn()
sinsert="insert into people values('%s','%s','%s');"%(pid,pna,pinf)
cu.execute(sinsert)
conn.commit()
def now_in():
one=e_id.get()
two=e_nam... |
eba6f031fc4f37d5830f954858cbb813c4b2c273 | alieus/Sales | /Sales_assesment.py | 6,438 | 4.375 | 4 | # A program to help a company assess its monthly sales
# Alieu Sanneh
#the main function controls the sequence in which the code is run.
#it accepts inputs from the user and then prints
def main():
all_monthly_sales =[]
value=True
while value==True:
monthly_sales = float(input('Please enter mon... |
72ce8c95d71d8c430296a7ea7441feb89e18ca3c | wesenu/cs699-Software_lab | /Lab9/Demos/setoperations.py | 565 | 3.875 | 4 | s = set (['a','b','c','d'])
u = set (['b','c','d','e'])
print "s", s
print "u", u
intersectionset =s&u
print "intersection", intersectionset
unionset =s|u
print "union", unionset
differenceset1 =s-u
print "s-u", differenceset1
differenceset2 =u-s
print "u-s", differenceset2
uniqueelements = u^s
print "uniqu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.