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 |
|---|---|---|---|---|---|---|
fa07f290de617d2db79e96029da007f8e1f94ed4 | ambroseCole/cli_poker | /poker.py | 351 | 3.59375 | 4 | starting_amt = 100
ante = 5
num_players = input("How many players?")
print("Enter players in order")
players = {input():starting_amt for _ in range(num_players)}
dealer = 0
while len(players) > 1:
pot = 0
small_blind = (dealer + 1) % num_players
big_blind = (dealer + 2) % num_players
dealer = sma... |
fb8966009b2e09c64df08fdee9cc21251fb1910b | SahanaBharadwaj/Assignment1Python | /problem1.py | 208 | 3.984375 | 4 |
def rev_word(sentence):
words = sentence.split(' ')
rev_sentence = ' '.join(reversed(words))
return rev_sentence
if __name__ == "__main__":
word = 'Hello World'[::-1]
print (rev_word(word)) |
b2c0f4d56af52930fb94356d565dc2a7822acd3b | KennethTBarrett/cs-module-project-iterative-sorting | /src/iterative_sorting/iterative_sorting.py | 2,050 | 4.40625 | 4 | # TO-DO: Complete the selection_sort() function below
def selection_sort(arr):
# loop through n elements
for i in range(0, len(arr) - 1):
cur_index = i
smallest_index = cur_index
# TO-DO: find next smallest element
# For loop, in range of untouched indexes.
for index in r... |
ad2ca961ccb3dc5fc36fc958a7bdfa1d797b59c2 | Cbkhare/Challenges | /TopCoder_Min_coins.py | 981 | 3.96875 | 4 | import math
print ('Give the denominations.(space delimited)')
box = list(map(int,input().split(' ')))
print ('Target Value, You can also give more than values. (space delimited)')
contents = list(map(int,input().split(' ')))
for item in contents:
summ = item
coins = 0
boom = [i for i i... |
e8ca51cc2ec589c50b304d5e8b25d04fc9670cc8 | Cbkhare/Challenges | /Fb_beautiful_strings.py | 2,140 | 4.15625 | 4 | #In case data is passed as a parameter
from sys import argv
import string
from operator import itemgetter
file_name = argv[1]
fp = open(file_name,'r+')
contents = [line.strip('\n') for line in fp]
#print (contents)
alphas = list(string.ascii_lowercase) #Else use this list(map(chr, range(97, 123)))
#print ... |
fd331cd98a5383c06c45605f4a736462cfd78502 | Cbkhare/Challenges | /remove_char_crct.py | 1,073 | 4.21875 | 4 |
#In case data is passed as a parameter
from sys import argv, getsizeof
#from operator import itemgetter
#import re
#import math
#from itertools import permutations
#from string import ascii_uppercase
file_name = argv[1]
fp = open(file_name,'r+')
contents = [line.strip('\n').split(', ') for line in fp]
for item i... |
8a4d50a0c008157298bfbd1c818f8192a48b9d5f | Cbkhare/Challenges | /swap_case.py | 878 | 4.15625 | 4 |
#In case data is passed as a parameter
from sys import argv, getsizeof
#from operator import itemgetter
#import re
#import math
#from itertools import permutations
#from string import ascii_uppercase
file_name = argv[1]
fp = open(file_name,'r+')
contents = [line.strip('\n') for line in fp]
for item in contents:
... |
64f1847bb5a5af4c42b1102ee1f43048b772b548 | Cbkhare/Challenges | /Decorator_Directory.py | 1,586 | 3.96875 | 4 | from operator import itemgetter
def bazinga(fun):
def wrap_fun(d_list,k):
new_d_list = fun(d_list,k)
for i in new_d_list:
if i[3] == 'M':
print('Mr.'+' '+str(i[0])+' '+str(i[1]))
else:
print('Ms.'+' '+str(i[0])+' '+str(i[1]))
return wrap_f... |
33644190c754944d40a75d1dbd8556ae8c3f7ece | Cbkhare/Challenges | /InterviewBit_Single2_BitManipulation.py | 885 | 3.5625 | 4 | class Solution:
# @param A : tuple of integers
# @return an integer
def singleNumber(self, A):
one, two = 0, 0
for i in range(0, len(A)) :
one, two = (one ^ A[i]) & ~two , (one & A[i]) | (two & ~A[i])
#print (one, two)
return one
if __name__=='__ma... |
f55a19df5633d7a50927f86387ae36d6c997c6f2 | Cbkhare/Challenges | /HackerRank_Beautiful_Binary_String.py | 1,504 | 3.90625 | 4 | from sys import stdin as Si, maxsize as m
#import numpy as np
class Solution:
pass
if __name__=='__main__':
n = int(Si.readline())
S = Si.readline().strip('\n')
count = 0
while '010' in S:
i = S.index('010')
S = S[:i+2]+'1'+S[i+3:]
count+=1
print(count)
'''
Al... |
d3f9affdfe72bc65b3e1eb1f84ebd823427837fa | Cbkhare/Challenges | /InterviewBit_DP_Stocks1.py | 765 | 3.703125 | 4 | class Solution:
def maxProfit(self, A):
n = len(A)
r = 0
if n>1:
mn = A[0]
for i in range(1,n):
mn = min(A[i],mn)
r = max(r,A[i]-mn)
return r
if __name__=='__main__':
S = Solution()
n = int(input... |
43260b50100729ab9098a85cbf15f3d91e3e6513 | Cbkhare/Challenges | /InterviewBit_Trees_InOrder.py | 538 | 4.03125 | 4 | class Solution:
# @param A : root node of tree
# @return a list of integers
def inOrder(self, A):
if A.left: self.inOrder(A.left)
self.List.append(A.val)
if A.right: self.inOrder(A.right)
def inorderTraversal(self, A):
self.List = []
self.inOrder(A)
re... |
9d62e237013cafc5eca81aba6e466767b2010a04 | Cbkhare/Challenges | /CodeForces_342_C_K_Tables.py | 2,176 | 3.515625 | 4 | if __name__=='__main__':
n,k = map(int,input().split(' '))
Sum = 0
t,s =(),pow(n,2)
for i in range(n):
tmpt = ()
for j in range(n-k+1):
tmpt +=(s,)
s -=1
t += (tmpt,)
Sum+=s
print (Sum+n)
#table
s = 1
for i in range(n):
tn =... |
928c8c3e87e17e93a29ba2ee1fdfb80f498ea447 | Cbkhare/Challenges | /Trailing_word.py | 1,557 | 3.96875 | 4 | from sys import argv
from re import search
file_name = argv[1]
fp = open(file_name,'r+')
contents = [line.strip('\n').split(',') for line in fp if len(line)>1] #to avoid blank lines
#print (contents)
for track in contents:
if '' in track:
continue
word = str(track[1])+'$'
#print (word,track)
... |
e486a889838843a3a37155d999b0ba888c46c929 | Cbkhare/Challenges | /CodeForces_682_B_AlyonaAndMex.py | 2,231 | 3.6875 | 4 | from sys import stdin as Si,maxsize as m
from math import floor as F
from collections import defaultdict as dt,Counter as Co
from operator import itemgetter as ig
from math import pi
from itertools import product as P
if __name__== '__main__':
n = int(Si.readline())
L = sorted(list(map(int,Si.readline().split... |
1af0558b9bcc658294d6942c0a232d4fc19e9055 | Cbkhare/Challenges | /InterviewBit_Maths_PowerOfTwoIntegers.py | 776 | 3.796875 | 4 | from sys import stdin as si
from math import sqrt; from itertools import count, islice
from sys import maxsize as m
class Solution(object):
def isPower(self, A):
if A==1: return True
for i in range(2,100000):
j=i
while j<m/i:
j*=i
if j... |
920d2ff4b74ff86352851e8435f0a9761c649392 | Cbkhare/Challenges | /multiply_list.py | 1,233 | 4.15625 | 4 | #In case data is passed as a parameter
from sys import argv
#from string import ascii_uppercase
file_name = argv[1]
fp = open(file_name,'r+')
contents = [ line.strip('\n').split('|') for line in fp]
#print (contents)
for item in contents:
part1 = list(item[0].split(' '))
part1.remove('')
part2 = list(... |
d0e2001bdf1d7803709faa17e25f057bbf2860b6 | Cbkhare/Challenges | /double_trouble.py | 2,251 | 3.890625 | 4 |
#In case data is passed as a parameter
from sys import argv, getsizeof
#from operator import itemgetter
#import re
#import math
#from itertools import permutations
#from string import ascii_uppercase
file_name = argv[1]
fp = open(file_name,'r+')
contents = [line.strip('\n') for line in fp]
for item in contents:
... |
6f5924c4f0cc6f8de6c0bc68c50e4ad8c8eef468 | Cbkhare/Challenges | /LCP.py | 1,233 | 3.859375 | 4 | class Solution:
# @param A : list of strings
# @return a strings
def longestCommonPrefix(self, A):
A.sort(key = lambda s: len(s))
tm = ''
if len(A)==1: return A[0]
for i in range(len(A[0])):
for x in range(i,len(A[0])):
t = A[0][i:x+1]
... |
0ea75af0aeb9c2bea86f5c8e95f9ca942344e8a9 | Cbkhare/Challenges | /HackerRank_Numpy_Transpose_Flatten.py | 1,424 | 4.125 | 4 | from sys import stdin as Si, maxsize as m
import numpy as np
class Solution:
pass
if __name__=='__main__':
n,m = map(int,Si.readline().split())
N = np.array([],int)
for i in range(n):
N = np.append(N,list(map(int,Si.readline().split())),axis=0)
N.shape = (n,m)
#Note:-
#To appe... |
1fcc97a5b12e9d96139117018640c18505f15823 | Cbkhare/Challenges | /InterviewBit_LinkedList_Partition.py | 1,402 | 3.78125 | 4 | class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
# @param A : head node of linked list
# @param B : integer
# @return the head node in the linked list
def partition(self, A, B):
h1 = ListNode(-1)
p1 = h1
h2 = ListNode(-1)
... |
0c747667e925a98008c91f87dedbd34c2ab10e83 | Cbkhare/Challenges | /str_permutations.py | 1,087 | 4.3125 | 4 | #In case data is passed as a parameter
from sys import argv
from itertools import permutations
#from string import ascii_uppercase
file_name = argv[1]
fp = open(file_name,'r+')
contents = [line.strip('\n') for line in fp]
#print (contents)
for item in contents:
#print (item)
p_tups= sorted(permutations(i... |
9741d6be03fdf9005b64b0e8c87d29011bf8a7f0 | Cbkhare/Challenges | /Time_pal.py | 1,811 | 3.984375 | 4 | class Solution:
# @param A : string
# @return string
def findways(self, s1,s2):
if s1==s2=='': return 0
c = 0
if s2=='':
if s1==s1[::-1]:
return 1
for i in range(0,len(s1)+1):
string = s1[:i]+s2+s1[i:]
if string==string[::-1... |
401ad91075ea23478cd759b63117807aa9a2720b | Cbkhare/Challenges | /hidden_digits.py | 1,530 | 3.8125 | 4 | #In case data is passed as a parameter
from sys import argv
#from string import ascii_uppercase
file_name = argv[1]
fp = open(file_name,'r+')
contents = [ line.strip('\n') for line in fp]
#print (contents)
alpha = list(map(chr, range(97, 107))) #from i to j
for item in contents:
stack = []
for c in i... |
b6f9b2c907d00c4262b675859a0a7431005af3de | Cbkhare/Challenges | /number_pair_sums_replace.py | 1,335 | 3.703125 | 4 | import sys
from itertools import chain, combinations
file_name = sys.argv[1]
fp = open(file_name, 'r+')
contents = [line.strip('\n').split(';') for line in fp]
#print (contents)
for item in contents:
s= int(item[1])
data = list(map(int,item[0].split(',')))
tup = list(combinations(data,2))
stack ... |
7b9ea2a73c9cdc6e1b9cb0f11ddac7626b3a3f07 | Cbkhare/Challenges | /InterviewBit_BackTracking_Permutations2.py | 1,321 | 3.625 | 4 | class Solution:
# @param A : list of integers
# @return a list of list of integers
def swap (self,B,x,y):
temp = B[x]
B[x]=B[y]
B[y]=temp
return B
def permuteMe(self,A,c):
if c ==len(A)-1:
print (A)
if A not in self.S: self.S.append(A[:])
... |
a30834d30df6ba76c7eb4c1fab017ed49415b813 | Cbkhare/Challenges | /try_to_solve_it.py | 1,425 | 3.84375 | 4 | from sys import argv
file_name = argv[1]
file = open(file_name,'r+')
g= {'g': 'n', 'h': 'o','j': 'q', 'd': 'x',
'm': 't', 'b': 'v', 'c': 'w', 'a': 'u',
'i': 'p', 'e': 'y', 'f': 'z', 'k': 'r', 'l': 's',
's': 'l', 'q': 'j', 'p': 'i', 'w': 'c',
'y': 'e', 'x': 'd', 'n': 'g', 't': 'm',
'o': 'h', 'v': '... |
03c12d1dd9c19a382d0cacd0bc8ba28eab7582c0 | Cbkhare/Challenges | /LeetCode_Array_MissingNumber.py | 756 | 3.953125 | 4 | from sys import stdin as si
from math import sqrt; from itertools import count, islice
from sys import maxsize as m
class Solution(object):
def missingNumber(self, nums):
S = sum(nums)
return sum(range(0,len(nums)+1))-S
if __name__=="__main__":
n = int(si.readline())
for i in range... |
1fa238f5724e0215c1ff9832f2b76d25ad249f5d | Cbkhare/Challenges | /Largest_3_digit_Prime_Palandrome.py | 495 | 3.953125 | 4 | pal_num = []
for i in range(101,1000):
count = 0
for j in range(2,i):
if i%j ==0:
break
else:
count = j
if count == i-1:
if i//100 == i%10:
pal_num.append(i)
pal_num.reverse()
print (pal_num[0])
'''
Write a program which determines the larg... |
4ea1a0e7f8b49844a740aea05bf8297b9a63611c | Cbkhare/Challenges | /HackerEarth_Hash_PairSums.py | 1,220 | 3.609375 | 4 | from operator import itemgetter as ig
from sys import stdin as Si
if __name__=='__main__':
n,k = map(int,Si.readline().split())
A = list(map(int,Si.readline().split()))
h = {}
for i in A:
if i in h: print('Yes');break
h[k-i]=h.get(k-i,0)+1
else: print('No')
... |
96de75c1651f848394cf2744e9db09a1a4fc6f5e | Cbkhare/Challenges | /IntB_Que.py | 485 | 3.9375 | 4 | class Queue(object):
def __init__(self):
self.Q = []
def insert(self,value):
self.Q.append(value)
def delete(self):
self.Q.pop(0)
def genIt(self):
for value in self.Q: yield value
def _print(self):
return self.Q
myq = Queue()
nyq = Queue()
print (ty... |
00f5c0976f2c85f6020ec94b6e89531db083a49e | Cbkhare/Challenges | /Pascal_triangle.py | 1,146 | 3.53125 | 4 | class Solution:
# @param A : integer
# @return a list of integers
def getRow(self, A):
if A ==0: return [1]
if A==1: return [1,1]
elif A==2: return [1,2,1]
else:
old_stack = [1,2,1]
for i in range(3,A+1):
stack= [1,]
for... |
01c430769fe04145f479b54c51a5673bfa109098 | Cbkhare/Challenges | /Endian.py | 491 | 3.859375 | 4 | import sys
'''
file_name = sys.argv[1]
fp = open(file_name,'r+')
contents = [line.strip('\n') for line in fp]
content = [item.split(' ') for item in contents]
'''
if sys.byteorder=='little':
print ('LittleEndian')
else:
print ('BigEndian')
'''
Write a program which prints the endianness of the system... |
1eb659a8751d387401fb034ad9890657ad54c59f | Cbkhare/Challenges | /InterviewBit_Math_Excel.py | 796 | 3.765625 | 4 | chr_dict = {}
for i in range(1,27):
chr_dict[chr(64+i)]=i
class Solution:
# @param A : string
# @return an integer
def titleToNumber(self, A):
i = len(A)-1
c = 0
for j in range(len(A)):
c += pow(26,i)*chr_dict[A[j]]
i-=1
return c
if __name__=='__... |
999266d9a8e342a03465da5657c8f37b72039193 | Cbkhare/Challenges | /repeated_substr.py | 1,887 | 3.796875 | 4 | #In case data is passed as a parameter
from sys import argv
import re
file_name = argv[1]
fp = open(file_name,'r+')
contents = [line.strip('\n') for line in fp]
#print (contents)
for item in contents:
junk = list(item)
i =2
j =0
stack = []
s = 0
while (i-j)*2 <= len(item) and j < len(it... |
f90a60ab3d5764593f62e4c304bd2f14e8fc7382 | JAmesMoggJCU/Assignment_python | /ItemList.py | 424 | 3.546875 | 4 | from Items import Item
class Item_Lists:
def __init__(self, item_file):
self.item_list = []
self.file_reader(item_file)
def file_reader(self, item_file):
in_file = open(item_file, "r")
for line in in_file:
item_match = line.strip().replace(" ", "").split("... |
3717952831577ac18139e9fe16912629d673d5c1 | naveenreddy61/my_pythonleet | /0001_two_sum/0001_two_sums_2.py | 753 | 3.65625 | 4 | class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
'''
We want to use a dict method to solve this problem as dict uses hashing to search for the key value pair.
Search time is constant when averaged while using a appropriate hash function and propotionate alpha.
We are maki... |
4d3b4a636231b084a3361ff309e40fd57058ee11 | artemlen/3_Parallelism_PI20-3 | /multipy_matrix.py | 1,425 | 3.546875 | 4 | #import modules
from multiprocessing import Process, Pool
#opening matrixes
matrix1 = open('matrix1.txt', 'r')
matrix2 = open('matrix2.txt', 'r')
#reading matrix1
matrix1_list = []
for line in matrix1:
line = line.split()
matrix1_list.append(line)
#reading matrix2
matrix2_list = []
for line in matrix2:
l... |
777cbfda9ba6cf9639b5d6d7e175ab8c1d23d738 | ekiwi/awap | /tools/huffman/huffman.py | 8,642 | 3.5 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
# huffman.py
# Copyright (c) 2015, Kevin Laeufer <kevin.laeufer@rwth-aachen.de>
"""
"""
import string
def bitstring_to_int(string):
value = 0
for cc in string:
value = value << 1
if cc == '1':
value = value | 1
return value
class HuffmanTouple(object):
""" ... |
493c9dc9771ceb902006106a9661c4281a79bcf7 | sychen9584/Rosalind | /REVC/revc.py | 758 | 3.671875 | 4 | #In DNA strings, symbols 'A' and 'T' are complements of each other, as are 'C' and 'G'.
#The reverse complement of a DNA string ss is the string scsc formed by reversing the symbols of ss, then taking the complement of each symbol (e.g., the reverse complement of "GTCA" is "TGAC").
#Given: A DNA string ss of length... |
38970b97d992378a724b929a2e509ca06b60db41 | sychen9584/Rosalind | /LCSM/LCSM.py | 2,068 | 3.5625 | 4 | from Bio import SeqIO
import math
# binary search
# return first substring of given length that is found in all sequences
# add start parameter to avoid searching from zero everytime
def common_substr(seq_0, seqs, start, length):
# Look at all possible substrings of a given 'length'
for i in range(len(... |
b6e142f9993d67e2eb0976dd1ddb304315cf28a6 | RaelViana/Python_3 | /ex018.py | 460 | 4.1875 | 4 | import math #importação da biblioteca math
"""
Aplicação do Módulo Math
"""
num = int(input('digite um número par a raiz Quadrada: ')) #recebe num do usuário
rq = math.sqrt(num) #aplica a função square root(raiz quadrada) em num
print('A raiz quadrada de {} é {}'.format(num, math.ceil(rq)))
# a f... |
53226427b8e63b0da9aaab6adcdad2712bbc29dc | RaelViana/Python_3 | /ex020.py | 606 | 4.03125 | 4 | import math
"""
Programa que recebe valor de catetos e calcula a hipotenusa
"""
catetoOposto = float(input('digite um valor para o cateto oposto: ')) # recebe numero real do usuário
catetoAdjacente = float(input('digite um valor para o cateto adjacente: ')) # recebe numero real do usuário
hipotenusa = math.hy... |
ed7fccb8c5b758a7e8461d346a2637f4e380197a | RaelViana/Python_3 | /ex032.py | 613 | 4.25 | 4 |
"""
Estruturas condicionais simples e compostas.
"""
# estrutura simples
nome = str(input('Qual seu nome? '))
if nome == 'Maria': # execulta a ação caso valor seja igual
print('Que lindo nome..')
print('Bom dia "{}" !'.format(nome))
# estrutura composta
nota1 = float(input('Digite a primeira nota: '... |
2ddf4ad0c96280a9ea5b52cc941b0d762c7b4503 | RaelViana/Python_3 | /ex033.py | 939 | 4.09375 | 4 | from random import randint # importa a função randint
from time import sleep # Importa a função time
"""
Programa que faz o computador “pensar” em um número inteiro entre 0 e 5
e peça para o usuário tentar descobrir qual foi o número escolhido pelo computador.
"""
computador = ... |
2936f2e2b7d319129d4b5cfc2202e7ad33ec604c | super-iterator/puzzles-and-datastructures | /numer_permutations.py | 750 | 3.671875 | 4 | # you can write to stdout for debugging purposes, e.g.
# print "this is a debug message"
import re
def solution(S):
s = re.compile(" |-").split(S)
strNum = ''.join(s)
resultNum = ""
while strNum:
# resultNum += strNum[:3] + '-' if len(strNum) >=3 else s... |
ff2613b2e5184740dfba2047781493ff689aed03 | PutkisDude/Developing-Python-Applications | /week10-11/Exceptions/exceptions.py | 878 | 4.0625 | 4 | #Author Lauri Putkonen
# Use the file "countries.txt".
# Catch min 2 differenr exceptions when reading or writing to the file.
from datetime import datetime
try:
file = open("countries.txt", "r")
# file.write("error")
except FileNotFoundError:
print("No such file")
except ValueError:
print("You dont... |
ac2ffaa848aee4feacc96c124fa6ca0e6f4480e6 | PutkisDude/Developing-Python-Applications | /week3/3_2_nameDay.py | 490 | 4.25 | 4 | #Author Lauri Putkonen
#User enters a weekday number and the program tells the name of the day.
import calendar
day = int(input("Number of the day: ")) -1
print(calendar.day_name[day])
# Could also make a list and print from it but there is inbuilt module in python to do same thing
# weekdays = ["Monday", "Tuedsday... |
b43e0945a2e3e4841d22ea4255ac4e1918012479 | PutkisDude/Developing-Python-Applications | /week7/7_2_Clocks.py | 550 | 3.828125 | 4 | #Author Lauri Putkonen
#2. Create class Clock and it's subclass AlarmClock. Test clocks in main.
#There has to be ticking and alarming methods...
class Clock:
def tick(self):
print("tic tic tic..")
class AlarmClock(Clock):
def alarm(self):
print("Wakey wake")
print("BRRRRRRR")
... |
03ca4619d644725d3755674d279cb141ae1f972a | PutkisDude/Developing-Python-Applications | /week9/MathGame.py | 2,448 | 3.96875 | 4 | #Author Lauri Putkonen
#Video of the game: https://youtu.be/RJaPppaSP_4
#Audio is free from mixkit.co
#kids math game (add prize: pic, sound or something else (negative/positive))
#Two numbers are shown on labels
#User adds the sum to a textbox
#With a button sum is checked
#Then new values are generated to labels
#Ri... |
2d6ac4916750e794eac2fcae2a72f59e8beec9a3 | PutkisDude/Developing-Python-Applications | /week6/6_7_BiggestOfFive.py | 251 | 3.90625 | 4 | #AUTHOR Lauri Putkonen
#7. Function returns the biggest of 5 integers.
def theBiggest(*nums):
array = nums
return max(array)
print(theBiggest(3, 4, 5, 6, 8))
#OUTPUT: 8
# I use same answer than in task 5, since it takes unlimited amount arguments
|
cc9fc525ae1a0b9db527351f372004564c82ab96 | PutkisDude/Developing-Python-Applications | /week4/4_6_solve_equation.py | 479 | 3.90625 | 4 | #Author Lauri Putkonen
#Try to solve this equation (try find 1 of roots)
#3x^3 - 4x^2 + 9x +5 = 0
#Here ^ means exponent
x = -10000.0
increase = 999.0
result = 3 * x ** 3 - 4 * x ** 2 + 9 * x + 5
while result != 0.00:
temp_x = x + increase
result = 3 * temp_x ** 3 - 4 * temp_x ** 2 + 9 * temp_x + 5
if re... |
de71ba86ac2ddd6eee0fd85c4fa64658ee1bf14d | PutkisDude/Developing-Python-Applications | /week6/6_5_biggest_of_three.py | 163 | 3.703125 | 4 | #AUTHOR Lauri Putkonen
#5. Returns the biggest of 3 integers.
def theBiggest(*nums):
array = nums
return max(array)
print(theBiggest(3, 4, 5, 6, 8))
#OUTPUT: 8
|
858d7a2c502d68158e41e07f2c54733e3973916e | ShamReh/Python-learning-Practice | /utils.py | 147 | 3.65625 | 4 | def find_max(numbers):
maximum= numbers[0]
for number in numbers:
if number >maximum:
maximum=number
return maximum |
544e84da56dd48cfcc68e95ee74cccf53a245904 | ShamReh/Python-learning-Practice | /typeconversion.py | 219 | 3.953125 | 4 | birth_year = input ("Birth Year: ")
print(type(birth_year))
age= 2021 - int(birth_year)
print(type(age))
print(age)
weight_lbs = input("What is your weight(lbs)? ")
weight_kg = int(weight_lbs) * 0.45
print(weight_kg)
|
df51317594280435672782ebfda13e1f5c5a741f | alexander-bodunov/5_th_semester | /RIP/lab4_project/lab4_project/lab4_s/ex2.py | 1,374 | 3.734375 | 4 | __author__ = 'Work'
def print_result_sorted(data,ignore_case):
for i in find_sorts(data,ignore_case):
yield i
print('')
def upperToLower(el):
if type(el)==str:
if el.isupper:
el=el.lower()
# print(' ****',el)
return el
def my_sort(arr,ignore_case):
arr1=[... |
3dea1e6a8db653af80fa2877f1372bb9f43cd238 | NielsRisseeuw/PROG_Huiswerk | /Les 06/Opdracht BMI.py | 391 | 3.59375 | 4 | gewicht = eval(input('Wat is uw gewicht: '))
lengte = eval(input('Wat is uw lengte in centimeters: '))
bodymassindex = 0
bodymassindex = gewicht / (lengte**2)
if bodymassindex <= 18.5:
print('Ondergewicht')
elif bodymassindex > 18.5 and bodymassindex < 25:
print('Normaal')
else:
print('Overgewicht')
p... |
d121af4c15de80ac03a4a88fde6ba26d525d3bbc | NielsRisseeuw/PROG_Huiswerk | /Les 03/Oefening3_1.py | 190 | 3.65625 | 4 | naam = input('Wat is jou naam: ')
leeftijd = eval(input('Wat is je leeftijd: '))
if leeftijd < 18:
print(naam + ', Je mag niet stemmen')
else:
print(naam + ', Je mag wel stemmen') |
efcc13d8410e4c1131e16158c715fc53d3f97443 | NielsRisseeuw/PROG_Huiswerk | /Oefenopdrachten/OefenOpdracht7_2.py | 321 | 3.78125 | 4 | woord = ''
lengteWoord = 0
while lengteWoord != 4:
woord = input('Geef een string van 4 letters: ')
lengteWoord = len(woord)
if lengteWoord == 4:
print('Inlezen van correcte string: {} is geslaagd'.format(woord))
break
else:
print('{} heeft {} letters'.format(woord, lengteWoord)... |
83367fe4991047b195ad183561fce7f7d574b1fb | NielsRisseeuw/PROG_Huiswerk | /Les 02/Oefening2_5.py | 220 | 3.5 | 4 | leeftijd1 = eval(input('Geef de eerste leeftijd: '))
leeftijd2 = eval(input('Geef de tweede leeftijd: '))
leeftijden_opgeteld = leeftijd1 + leeftijd2
print('Leeftijden samen opgeteld zijn: ' + str(leeftijden_opgeteld)) |
a4156f4d9c49d4f1d7a591dc947a4be6c82cfc5f | NielsRisseeuw/PROG_Huiswerk | /Les 08/Oefening8_4.py | 223 | 3.765625 | 4 | invoer = input('Voer iets in: ')
if invoer == 'iets' or invoer == 'Iets':
print('Grapjas')
else:
for karakter in invoer:
asc = ord(karakter)
print('{} {} {:b} {:x}'.format(karakter, asc, asc, asc))
|
1e8382d9555ca4785323ac13c407411af6a742f9 | DFRLab/DataFestTbilisi | /download_data.py | 761 | 3.53125 | 4 | # -*- coding: utf-8 -*-
''' Download data from DFRLab's S3 bucket
This script will create a folder called data and store in it
the csv files.
'''
# import modules
import os
import urllib.request as req
# create data folder
if not os.path.exists('./data/'):
os.mkdir('./data/')
# download data from DFRLab's S3 b... |
f361d75c0d0b2f554e241f962d7b3b200bb24213 | asinghamgoodwin/optimization | /Genetic/knapsack.py | 2,098 | 3.671875 | 4 | # defining the knapsack problem, making some example data
# there are a bunch of items, each with a weight and a value
# we want to pack a knapsack of fixed weight capacity
# with the maximum combined values of items
import random
# GLOBAL VARIABLES
CAPACITY = 6404180
ITEMS = {0 : ( 382745 , 825594),
1 : ( 79... |
7a32efcdfaf7edef3e3ffaffabbeed9bed255bd3 | mkgmels73/Bertelsmann-Scholarship-Data-Track | /Python challenge/39_random_password.py | 1,389 | 4.40625 | 4 | #While generating a password by selecting random characters usually creates one that is relatively secure, it also generally gives a password that is difficult to memorize. As an alternative, some systems construct a password by taking two English words and concatenating them. While this password may not be as secure, ... |
386ace498e0bbd08ad70723a7752c3c974c730c4 | kimfucious/pythonic_algocasts | /tests/test_vowels.py | 775 | 3.578125 | 4 | import unittest
from exercises.vowels import vowels
@unittest.skip("skip vowels tests")
class VowelsTests(unittest.TestCase):
def test_function_is_callable(self):
# vowels function is_callable
self.assertTrue(callable(vowels))
def test_get_vowels_1(self):
self.assertEqual(
... |
12b45b29d942aec593b21161d8f6c4c6409722f2 | kimfucious/pythonic_algocasts | /solutions/matrix.py | 1,501 | 4.53125 | 5 | # --- Directions
# Write a function that accepts an integer, n, and returns a n x n spiral matrix.
# --- Examples
# matrix(2)
# [[1, 2],
# [4, 3]]
# matrix(3)
# [[1, 2, 3],
# [8, 9, 4],
# [7, 6, 5]]
# matrix(4)
# [[1, 2, 3, 4],
# [12, 13, 14, 5],
# [11, 16, 15, 6],
# [10, 9,... |
d8fe7f01e88380f8f50efe77415d6151592e269c | kimfucious/pythonic_algocasts | /exercises/maxchar.py | 227 | 3.953125 | 4 | # --- Directions
# Given a string, return the character that is most commonly used in the string.
# --- Examples
# max_char("abcccccccd") # returns "c"
# max_char("apple 1231111") # returns "1"
def max_char(string):
pass
|
789b0fd843d1966351934c7aa045dedd08d11dc6 | kimfucious/pythonic_algocasts | /exercises/levelwidth.py | 257 | 3.9375 | 4 | # --- Directions
# Given the root node of a tree, return a list where each element is the width
# of the tree at each level.
# --- Example
# Given:
# 0
# / | \
# 1 2 3
# | |
# 4 5
# Answer: [1, 3, 2]
def level_width(root):
pass
|
dca708d0b43e4adea6e69b7ec9611e919310a472 | kimfucious/pythonic_algocasts | /exercises/reversestring.py | 273 | 4.375 | 4 | # --- Directions
# Given a string, return a new string with the reversed order of characters
# --- Examples
# reverse('apple') # returns 'leppa'
# reverse('hello') # returns 'olleh'
# reverse('Greetings!') # returns '!sgniteerG'
def reverse(string):
pass
|
b93be8d587df03aa1ef86361067b3ae45c42e861 | kimfucious/pythonic_algocasts | /solutions/levelwidth.py | 510 | 4.15625 | 4 | # --- Directions
# Given the root node of a tree, return a list where each element is the width
# of the tree at each level.
# --- Example
# Given:
# 0
# / | \
# 1 2 3
# | |
# 4 5
# Answer: [1, 3, 2]
def level_width(root):
widths = [0]
l = [root, "end"]
while len(l) > 1:
nod... |
fdc8646c69a3c4eb44cd016b4d1708ca77acef07 | kimfucious/pythonic_algocasts | /solutions/palindrome.py | 410 | 4.40625 | 4 | # --- Directions
# Given a string, return True if the string is a palindrome or False if it is
# not. Palindromes are strings that form the same word if it is reversed. *Do*
# include spaces and punctuation in determining if the string is a palindrome.
# --- Examples:
# palindrome("abba") # returns True
# palindro... |
7484096aff7b568bf17f4bc683de3a538807ce52 | kimfucious/pythonic_algocasts | /solutions/capitalize.py | 1,010 | 4.4375 | 4 | # --- Directions
# Write a function that accepts a string. The function should capitalize the
# first letter of each word in the string then return the capitalized string.
# --- Examples
# capitalize('a short sentence') --> 'A Short Sentence'
# capitalize('a lazy fox') --> 'A Lazy Fox'
# capitalize('look, it is ... |
ab5b8976843bf756da297c682dbd75fc5306e057 | andygnewman/python-tutorial | /ex40a.py | 825 | 3.875 | 4 | class Song(object):
def __init__(self, lyrics):
self.lyrics = lyrics
def sing_me_a_song(self):
for line in self.lyrics:
print line
def how_many_lines(self):
print len(self.lyrics)
def sing_me_a_sorted_song(self):
for line in sorted(self.lyrics, reverse = T... |
6744b752c094cf71d347868859037e6256cdb4e8 | didomadresma/ebay_web_crawler | /ServiceTools/Switcher.py | 978 | 4.28125 | 4 | #!/usr/bin/env python3
__author__ = 'papermakkusu'
class Switch(object):
"""
Simple imitation of Switch case tool in Python. Used for visual simplification
"""
value = None
def __new__(class_, value):
"""
Assigns given value to class variable on class creation
:return: ... |
9df368cc12362e36c5e7c3fd5df1b9bd81031830 | marjana2019/python_problems | /calculate_speeding.py | 495 | 4 | 4 | # A program calculates the fine for speeding
# $50 plus $5 for each addtional mph over the limit and $200 penalty over 90mph
def main():
speed = eval(input("Enter the speed:"))
limit = eval(input("Enter the speed limit :"))
if speed < limit:
print (" Speed was legal")
else:
... |
ce28f1d8e7616592c9bfcefd37d54123091f1a46 | marjana2019/python_problems | /student_classification.py | 520 | 3.859375 | 4 | # A program that classifies students based on the credits earned,
# less than 7 credits is a Freshman, at least 7 credits to be a Sophomore
#16 to be a Junior and 26 for Senior
def main():
credit = eval(input("Enter the number of credits earned:"))
if credit <7 :
status = "Freshman"
elif ... |
950f41adc88bed86100bd3860b0efae56656a310 | Pooja5573/DS-Pragms | /std.py | 483 | 3.828125 | 4 | from Assignment1 import human
class student(human) :
def stu(self):
cls = input("enter class of the student")
eng = input("enter english marks")
sci = input("enter science marks")
mat = input("enter maths marks")
tot = int(eng)+int(sci)+int(mat)
print("Total :... |
21aa97d8eab6bb0f41c63d799ddb126be72a467f | Pooja5573/DS-Pragms | /table_fib_fact.py | 867 | 4.25 | 4 | #ASSIGNMENT : 1
#to find factorial of given num
n = int(input("enter the num"))
fact = 1
while n>=2 :
fact = fact*n
n-=1
print("factorial : ",fact)
##ASSIGNMENT : 2
#to find the fibonacci series
n = int(input("enter the num"))
a = 0
b = 1
c = a+b
while c <= n:
print("THE FIBONACCI serie... |
2c750c73abef21d0d1de92c0e564b290e7b6ac89 | peter517/PPUtils | /math/max_common_divisor.py | 258 | 3.5625 | 4 | def gcd(a, b):
if a < b:
a, b = b, a
while b != 0:
temp = a % b
a = b
b = temp
return a
(a, b) = (1280, 800)
(a, b) = (1920, 1200)
(a, b) = (1366, 768)
mcd = gcd(a, b)
print str(a / mcd) + " " + str(b / mcd)
|
ca5e6e904ab8fa597af6b5977a4b79e04a7bc791 | peter517/PPUtils | /net/tcp_attack.py | 1,036 | 3.515625 | 4 | #!/usr/bin/env python
# coding=utf8
import socket
import sys
import thread
import time
if __name__ == '__main__':
if len(sys.argv) != 3:
print "param len is not 3"
exit(0)
server_ip = sys.argv[1]
server_port = int(sys.argv[2])
print "server_ip=" + server_ip + ",server_port=" + str(s... |
ff983edef1aa0dcb6e5973057d65e675b9167358 | Maroonlk/untitled2 | /04.py | 469 | 3.953125 | 4 | class A(object):
def __init__(self, name, age):
self.__name = name
self.age = age
def say(self):
print("{0}, {1}".format(self.__name, self.age))
bob = A("bob", 22)
bob.say()
bob._A__name = "ad"
print(bob._A__name) #访问私有成员
print(dir(bob)) #访问私有成员
class MyObject(object):
def _... |
168ac1ee51f6a2ac405986b5450d07731a4c1a20 | Maroonlk/untitled2 | /2-高级-异常处理/else语句案例.py | 299 | 3.53125 | 4 | if __name__ == '__main__':
try:
num = int(input("input your num: "))
rst = 100 / num
print("计算结果是 {0}".format(rst))
except Exception as e:
print(e)
print(type(e))
else:
print("No Exception")
finally:
print("I am!")
|
15ff71372f240e9c09fb7da6ca61a12e7cf04e4e | ramalldf/informatics | /my_edx_cs600_fxns.py | 437 | 3.796875 | 4 | #The following are functions that I wrote during the coursework for edx 6.00.1x intro to cs and programming using python
def iterPower(base, exp):
'''
L5 Prob 1 (validated): Code calculates powers using a for loopbase: int or float.
exp: int >= 0
returns: int or float, base^exp
'''
tot= base... |
9ab523049f133c112ec7da49ff866728b2dde50a | chriseisbrown/tokenisation-poc | /head_csv.py | 1,054 | 3.6875 | 4 | # !/usr/bin/env python3
import os
from os import listdir
from os.path import isfile, join
import configparser
import argparse
import csv
from pprint import pprint
"""
"heads" a .csv file
"""
DEFAULT_NUMBER_ROWS = 10
def parse_args():
'''
Parse command line arguments
'''
# construct the argum... |
e7d5d7e1c7a2d766c49de8e0009482ad488a3a63 | Priktopic/python-dsa | /str_manipualtion/replace_string_"FOO"_"OOF".py | 1,052 | 4.3125 | 4 | """
If a string has "FOO", it will get replaced with "OOF". However, this might create new instances of "FOO". Write a program that goes through a string as many times
as required to replace each instances of "FOO" with "OOF". Eg - In "FOOOOOOPLE", 1st time it will become "OOFOOOOPLE". Again we have "FOO", so the 2nd ... |
57899dbcf24323514b453e3b1a9de5bc01379c8c | Priktopic/python-dsa | /linkedlist/largest_sum_of_ele.py | 1,149 | 4.4375 | 4 | '''
You have been given an array containg numbers. Find and return the largest sum in a contiguous subarray within the input array.
Example 1:
arr= [1, 2, 3, -4, 6]
The largest sum is 8, which is the sum of all elements of the array.
Example 2:
arr = [1, 2, -5, -4, 1, 6]
The largest sum is 7, which is the sum of th... |
17e30a414fdf6bf310fa229ddede6b7dd23551bc | Priktopic/python-dsa | /str_manipualtion/rmv_digits_replace_others_with_#.py | 350 | 4.25 | 4 | """
consider a string that will have digits in that, we need to remove all the not digits and replace the digits with #
"""
def replace_digits(s):
s1 = ""
for i in s:
if i.isdigit():
s1 += i
return(re.sub('[0-9]','#',s1)) # modified string which is after replacing the # with digits
re... |
5de81de0fb7f0a6d1c21fb5bd8612884301a1c93 | imsodin/academia_ai | /academia_ai/neural_network/cnn.py | 7,968 | 4.15625 | 4 | """Please add documentation here."""
import os.path
import numpy as np
import pickle
class ConvolutionalNeuralNet(object):
"""Convolutional neural network holds layers and methods to train and test.
It is built from several neural layers, as for example convolutional
layers, pooling layers or fully co... |
7e0c88d6af14f96cbf66ae2363600e83b4d821c1 | sarnaizgarcia/mi_mitap | /utils/breadcrumbs.py | 676 | 3.59375 | 4 | # Clase que permita el acceso a estuctura de pila
class BreadCrumbs(object):
def __init__(self, navigations):
self.navigations = list()
def stack_navigation(self, controller):
# controller se coloca en la primera posición de la lista
if not self.navigations:
self.navigatio... |
27e37cc586524f34a7be3942fee2b428915e45d1 | seyoung-solteq/Computational-Photography | /Code/image_transforms/warp_perspective.py | 681 | 3.515625 | 4 | """Image transforms: Warp using perspective transform"""
import cv2
import numpy as np
# Read image
img = cv2.imread('berlin-wall-03.png')
height, width = img.shape[:2]
cv2.imshow("Original", img)
# Perspective transform
pts1 = np.float32([[220, 85], [223, 414], [602, 190], [616, 323]])
pts2 = np.float32([[75, 75], ... |
3cb8e32ee18449fbd33065bd8816dc532462925b | mazuecos3/Python-Begginer | /Unidad5/ejercicio_II_u5.py | 264 | 3.578125 | 4 |
cantidadkw = float(input("Inserte el valor que ha consumido en Kw: "))
kw = 0.135
gasto = cantidadkw * kw
consumo_extra = 0
gasto_extra = consumo_extra * (kw + kw * 0.05)
if cantidadkw > 700:
print(gasto + gasto_extra)
else:
print(gasto) |
a4b9452af55bf63080d31e41febe9b6242221840 | mazuecos3/Python-Begginer | /Unidad5/ejemplo_1_u5.py | 617 | 3.625 | 4 | total_compra = float(input("Cuanto ha gastado el cliente: "))
importe_a_pagar = total_compra
if total_compra > 100:
tasa_descuento = 15
importe_descuento = total_compra * tasa_descuento / 100
importe_a_pagar = total_compra - importe_descuento
print(F'como has sobrepasado el gasto común recibes un ... |
f6b3d9fe9da9d26a8e8d61fc80e6a4090de07065 | mazuecos3/Python-Begginer | /Unidad6/ejercicio_IV_u6.py | 314 | 4.09375 | 4 | numero = int(input('Introduce un numero entero de el 0 al 9 '))
lista = [1, 3, 9]
while numero not in lista:
print("Numero ", numero ," no aparece en la lista prueba otro")
numero = int(input('Introduce un numero entero de el 0 al 9 '))
print("Numero ", numero, "correcto, si esta en la lista") |
28f2a84a957453f903ad0ef6b2cf81fe0f914de4 | mazuecos3/Python-Begginer | /Unidad9/cuenta_u9.py | 1,732 | 3.953125 | 4 | """
Desarrollar un programa que conste de una clase padre Cuenta y dos subclases PlazoFijo
y CajaAhorro.
Cuenta: Definir los atributos titular y cantidad y un método para imprimir los datos en la clase
CuentaAhorro: un método para heredar los datos y uno para mostrar la información.
PlazoFijo tendrá ... |
1717b36d317c14bcdcd5af8dcc6b42005b9f15bc | mazuecos3/Python-Begginer | /Unidad6/ejemplo1_Break.py | 200 | 3.671875 | 4 | password = ''
clave = 'Python3.7'
while True:
password = input('Contraseña: ')
if password == clave:
print('Estás dentro')
break
print('Contraseña incorrecta') |
6568d7983139753d61c654ea69f5ac588e826533 | filkinmaksim/labyrinth-solver | /src/Labyrinth.py | 502 | 3.5 | 4 | class Labyrinth:
"""Classe définissant un Labyrinthe défini par:
- une taille
- un début
- une fin
- une matrice contenant les cellules
- une matrice contenant les murs
- une dimension"""
def __init__(self, dimension, size):
self.Dimension = dimension
self.size = size
... |
6a620401105912e235aa8c012805767b97032d21 | dylanly/Python-Practice | /buffet.py | 273 | 3.5625 | 4 | buffet_food = ('steak', 'potatoes', 'eggs', 'fries', 'burgers')
print(buffet_food)
buffet_food = ('sausage', 'potatoes', 'eggs', 'hash browns', 'burgers')
print('The menu at the buffet has changed. View the new menu below:')
for food in buffet_food:
print(food)
|
153687f5a58296d127d14789c96ce8843eb236a0 | dylanly/Python-Practice | /best_friends.py | 386 | 4.25 | 4 | list_friends = ['Ken', 'Mikey', 'Mitchell', 'Micow']
print("Below you can see all my best friends!\n")
for friend in list_friends:
print(friend)
if 'Drew' not in list_friends:
print("\n:O \nDrew is not in my friends list!!\n")
list_friends.append('Drew')
for friend in list_friends:
print... |
ea74b7e3d4765ae4045ab2d745757be1a2258813 | dylanly/Python-Practice | /guest_list.py | 957 | 3.65625 | 4 | guest_list = ['Dylan']
guest_list.append('Micow')
guest_list.append('Ken')
guest_list.append('Mitchell')
guest_list.append('Mikey')
print(guest_list)
message = "Hey, " + guest_list[1] + " I'm having a party this friday, trying to come thruuu?"
print(message)
#Mikey couldn't come up to seattle :(
gu... |
3c14d358714801b4fb3118ddc18398b1b5e7d91e | allocator64/pzkl | /py/templates.py | 4,131 | 3.640625 | 4 |
def check_word(word, template):
# If it's string - then we need exact word
if type(template) == str:
if word.get('lex') == template:
return True
else:
return False
#If it's a list we need all list of attributes to be present in a word
elif type(template) == list:
definite_attributes = word.get("gr",... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.