blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
2ecb0e95eb31e781d66400341dde9555326c5562 | screamcha/address-book-python | /main.py | 777 | 3.84375 | 4 | from book import AddressBook
print('!!!Welcome to the Address Book CLI!!!')
book = AddressBook()
while True:
print('Possible actions:')
print('1 - list all stored addresses;')
print('2 - add new address;')
print('3 - modify an existing address;')
print('4 - delete an address from the book.', end='\n\n')
... |
a2a25f4d4de5b9878858780972a595a9a05b6b30 | RadhaGarapati/EulerProgram1 | /Euler25.py | 466 | 4.0625 | 4 | import itertools
def Fibanocci_Thousand_Digits():
DIGITS = 1000
prev = 1
cur = 0
for i in itertools.count():
# At this point, prev = fibonacci(i - 1) and cur = fibonacci(i)
if len(str(cur)) > DIGITS:
raise RuntimeError("Not found")
elif len(str(cur)) == D... |
246790b7c2c5f1e4a0f900601fdbba8e2790abe7 | Mounika1705/job_analysis | /json_parser.py | 370 | 3.828125 | 4 | import json
"""
This method is used to parse json files
Arguments:
filename: Name of the json file
"""
def parser(filename):
with open(filename, 'r') as f:
return json.load(f);
"""
if __name__ == "__main__":
# Testing the parser function
data = parser('./roles.json')
print(data)
data =... |
290cc0763e0732bf2ef13a2936a47570b1c3255f | Sharonbosire4/hacker-rank | /Python/Python/Introduction/Loops/__main__.py | 235 | 3.828125 | 4 | from __future__ import print_function
import sys
def loops(num):
return [ x**2 for x in range(num) ]
def main():
result = loops(int(input()))
for line in result:
print(line)
if __name__ == '__main__':
main()
|
88f637733a9a059fda6f0130f8bc00d99e129d96 | yunieyuna/Solutions-for-Leetcode-Problems | /python_solutions/160-intersection-of-two-linked-lists.py | 1,837 | 3.609375 | 4 | # https://leetcode.com/problems/intersection-of-two-linked-lists/
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode:
# 原地址:https:/... |
76749249d9a11adffcec7e5fc3db2f7b242d99d1 | majkelmichel/euler_pc | /2.py | 309 | 3.515625 | 4 | liczby_fib = []
def fibonacci(zakres,lista):
num1=0
num2=1
while num1<zakres:
num1+=num2
num2+=num1
lista.append(num1)
lista.append(num2)
return lista
fibonacci(4000000,liczby_fib)
wynik = 0
for i in liczby_fib:
if i % 2 == 0:
wynik+=i
print(wynik) |
f5703f84e731bd1afcf2ae757e208b3cbd8fa3ef | Kamil22/gitrepo1 | /python/sort_przez wstaw_.py | 753 | 3.609375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# sort_przez wstaw_.py
def sort_przez_wstaw(lista):
for i in range(1, len(lista)):
el = lista[i]
k = i - 1
while k >= 0 and lista[k] > el:
lista[k+1] = lista[k]
k -= 1
lista [k + 1] = el
return lista
def ... |
8e07310bc910efce743da727a376944c17e2eb80 | mark-andrews/pyin01 | /notebooks/analysispkg/analysis.py | 809 | 3.90625 | 4 | """
This modules provides a number of important functions.
This code is free and open source software, distributed by the
GNU Public Licence (GPL 3.0).
Copyright: Mark Andrews, 2020
"""
x = [1, 2, 3, 4, 5]
y = dict(a = 1, b = 2, c = 3)
whoami = 'Mark Andrews'
class Person:
"""
This class is a person objec... |
2a5453761f048b7e7d0334e0d51cc19d0f599b6a | camichael007/python-scripts | /scripts/threading_3.py | 375 | 3.609375 | 4 | #!/usr/bin/env python
import threading
import time
class MyThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.name = 'new_' + self.name
def run(self):
print 'my name is %s' %self.name
if __name__ == '__main__':
for i in range(10):
t = MyThr... |
5864191ad0f72f790d2aec13f0659387b9198102 | edberthans123/Assignment-1-Driving-Simulation | /Assignment 2/KMP.py | 182 | 3.8125 | 4 | #Program that will transform long variations into short
def name():
w = input().split('-')
u = []
for y in w:
u.append(y[0])
print(''.join(u).upper())
name()
|
6f1920164e6cd447bc0497237e558747c73ed98d | mathewmilan/programming_problems | /random-problems-python/make_anagrams.py | 1,312 | 3.609375 | 4 |
import logging
from collections import Counter
logging.basicConfig(filename = 'MakeAnagrams_log.txt',
level = logging.DEBUG,
format = '%(asctime)s-%(levelname)s-%(message)s')
#Find the number needed to make anagrams from two input strings
def no_needed(a, b):
a_map = cre... |
60e1509095c24464e3c7fa564d9aa32beff21b97 | AMProduction/Python-HW2 | /task_2.py | 359 | 3.859375 | 4 | """ Task 2
Author: Andrii Malchyk
v.1.0
"""
print("Please, enter the number 100<=n<=999: ")
input_number = input()
if 100 <= int(input_number) <= 999:
output_number = [int(x) for x in str(input_number)]
output_number.sort(reverse=True)
else:
print("The input number is out of range!")
exit()
... |
a50367e8f23e0b980e31245b36e5f571c5f61d39 | Redouanelh/Oefening | /pe4_1.py | 189 | 3.53125 | 4 | Uren = eval(input('Hoeveel uur heb je gewerkt: '))
Uurloon = eval(input('Wat is je uurloon: '))
Salaris =Uren*Uurloon
print(str(Uren)+' uur werken levert je ' + str(Salaris)+' euro op.')
|
368c824232df3a22372704d7bd8fc23b923c1435 | prakharpande/mlwoc1 | /model2.py | 4,061 | 3.53125 | 4 | import numpy as np
from loader import MNIST
import pandas as pd
#sigmoid function
def sigmoid(z):
return 1/(1+np.exp(-z))
#sigmoid gradient function
def sigmoidgradient(z):
sig = sigmoid(z)*(1-sigmoid(z))
return sig
#forwardpropagation
def forwardprop(Theta1,Theta2,X,Y):
a1 = np.hstack([np.ones((len(X),... |
705f621ad992afcca1bb7f759f73f4e1a8efebcd | codrinleonte/python_labs | /LabII/Ex5.py | 1,175 | 3.5 | 4 | # Sa se scrie o functie care primeste ca parametru o lista x, si un numar k.
# Sa se returneze o lista cu tuple care sa reprezinte combinari de len(x)
# luate cate k din lista x. Exemplu: pentru lista x = [1,2,3,4] si k = 3 se va returna
# [(1, 2, 3), (1, 2, 4), (1, 3, 4), (2, 3, 4)].
def generic_combinations(i, n, ... |
1c7e486d53f3c8f28cdb08299fee1893728ec509 | rubbalpreetsingh/Python-Tkinter | /28th.py | 771 | 3.71875 | 4 | #Searching Software
from tkinter import *
import wikipedia
def getData():
enteredValue=entry.get()
text.delete(1.0,END)
try:
answerValue=wikipedia.summary(enteredValue)
text.insert(INSERT,answerValue)
except:
text.insert(INSERT,"Check what you input or internet connection")
roo... |
96e52a931f8e625e845953229ca8e6580c784585 | fabzer0/python_exe | /generate_dict.py | 140 | 3.65625 | 4 | def generate_dict(n):
adict = {}
for i in range(1, n+1):
adict[i] = i**2
return adict
print(generate_dict(8))
|
f8c487af13b4ab04bf9746ecf015b2006fbae985 | AsapJay/GameAI | /AI.py | 7,513 | 4.03125 | 4 | '''
Created on Dec 27, 2016
@author: JR
'''
import random
#Needed for the minimax algorithm to store move positions and scores.
class Move(object):
def __init__(self, score , pos_tup = None ):
self.score = score
self.pos = pos_tup
class AI(object):
'''
The co... |
249d81ba2e73ad5b8c512adce4232c65ce8843ef | Aragroma/hello-world | /script 20.py | 1,182 | 4.5 | 4 | # The "if...elif...else"-statement
# If the numer is positive, we print an appropriate message
num = 3
if num > 0:
print(num, "is a positive number.")
print("This is always printed.")
num = -1
if num > 0:
print(num, "is a positive number.")
print("This also is always printed.")
# If else
num = ... |
3e41d6f87d77ebf9bd15c6a01c2c2702270407ab | Saifullahshaikh/-IPU-Intensive-Programming-Unit-01 | /4 Python Programming Examples on Strings/7 Calculate Length of string without using library functions.py | 128 | 3.90625 | 4 | def Length(string):
count=0
for i in string:
count+=1
return count
s= 'Hello Programming'
print(Length(s))
|
cddb0d2a56de749833e423af6bc8da602206a408 | kavithagowdabs/python-programs | /StudentMarks.py | 236 | 3.671875 | 4 | num1=int(input("enter marks of sub1"))
num2=int(input("enter marks of sub2"))
result=num1+num2
print(result)
if result>80:
print("distinctn")
elif result>=60 and result<80:
print("first class")
else:
print("pass")
|
b3bdea1c34ceaf72cfbdb7c5e8f09cb533ac6558 | guangyuyan/Sort | /Insert.py | 302 | 3.78125 | 4 | def insert_sort(l):
i = 0
while i < len(l):
for j in range(0, i):
if l[j] > l[i]:
l.insert(j, l.pop(i))
# break
i += 1
return l
print(insert_sort([3,2,1,4,2]))
#时间复杂度:O(n²)
#空间复杂度:O(1)
#稳定性:稳定 |
79d1cea442c73ee9cefddb0e8ba2f6e54ba3cdfd | MrStrory/Project_Github | /functions/PascalTriangle/PascalTriangle_cell.py | 911 | 3.5625 | 4 | from MyProjectForGithub.functions.PascalTriangle.PascalTriangle_mathOper import numberRank
def cell_ (baseIndC, numb):
rank = numberRank(numb)
findC = fIndC(baseIndC, rank)
lindC = lIndC(baseIndC, findC, rank)
find = fInd(findC)
lind = lInd(lindC)
cell = find + str(numb) + lind
return cell
... |
e3626b2fb396785bc142aed89b5ced627058cc61 | yujin0719/Problem-Solving | /프로그래머스/lv2.최솟값 만들기.py | 170 | 3.65625 | 4 | # Level2: 최솟값 만들기
def solution(A,B):
answer = 0
A.sort()
B.sort(reverse = True)
for a,b in zip(A,B):
answer += (a*b)
return answer |
f3a27ae69b4a805ab5d36b287290c944f47d9535 | MGasiewski/Euler | /problem14.py | 719 | 3.53125 | 4 | found = False
collatz_table = {}
highest = []
for i in range(1, 1000000):
val = i
current = []
while True:
if val == 1:
current.append(val)
collatz_table[i] = current
if len(current) > len(highest):
highest = current
break
elif... |
9aa7aced7692112897c14f493af1f3003aeb7e15 | joaramirezra/Can-You-Solve-a-Problem | /In-house/countWord.py | 512 | 4.15625 | 4 | def countSentence():
"""
countSentence() return the word count entered by the user.
Variables: sentence: str
"""
# take input from the user
sentence = input("Enter a sentence: ")
#removes space
sentence = sentence.strip()
#define a variable to count the sentence and set to zero
... |
57c308523c20a91ff11c43a16d81a3db05fadc82 | varun1729/Project-Euler | /26.py | 1,656 | 3.796875 | 4 | from decimal import *
import math
'''
def isPrime (num):
if (num <=1):
return False
if (num == 2 or num==3):
return True
elif (num%2 == 0):
return False
else:
ub = math.ceil(num**(1/2))
j = 3
while (j<=ub):
if (num%j == 0):
return False
j+=2
return Truen
'''
def RemainderApproach (num):
ar... |
b775c5edb590741f08097ec9b9b163cc93187ae8 | AFazzone/Python-Homework | /afazzone@bu.edu_hw_11_12.1.py | 2,185 | 3.734375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Apr 19 21:32:48 2019
@author: alf11
"""
import math
class GeometricObject():
def __init__(self, color = "green", filled = True):
self.__color = color
self.__filled = filled
def getColor(self):
return self.__color
... |
d63815357f294717ccd27cc76a001f53b2507f1a | jimibarra/cn_python_programming | /02_basic_datatypes/2_strings/02_07_replace.py | 572 | 4.3125 | 4 | '''
Write a script that takes a string of words and a symbol from the user.
Replace all occurrences of the first letter with the symbol. For example:
String input: more python programming please
Symbol input: #
Result: #ore python progra##ing please
'''
#Get sentence from user
sentence = input('Please provide a sent... |
911f5c1767976fd964a0f41ceab30c9bcc64a927 | TheCleanLove/Python | /test1.py | 158 | 3.875 | 4 | print('Hello World!')
print('What is your name')
myName = input()
print('Hello, ' + myName)
print('The length of your name is : ')
print(len(myName))
|
5f498781a69deb225a73bf3a91046a9dae503e04 | rkdtmddnjs97/algorithm | /BOJ/2020_12/1010.py | 233 | 3.625 | 4 | # 다리 놓기
def factorial(n):
return n*factorial(n-1) if n>1 else 1
t =int(input())
for i in range(t):
a,b = input().split(' ')
c = int(a)
d = int(b)
print(int(factorial(d)/(factorial(d-c)*factorial(c))))
|
af6768c271712b146977902a95d64c407e5a7323 | JohnRhaenys/escola_de_ferias | /DIA_01/introducao_python/aula/linguagem_python/04_comparadores/tipos_primitivos/string/string_02.py | 209 | 3.78125 | 4 |
# Tipo 'string'
a = 'Walter White'
b = 'WALTER WHITE'
print('Igual?', a == b)
print('Diferente?', a != b)
print('Maior?', a > b)
print('Menor?', a < b)
print('Maior ou igual?', a >= b)
print('Menor ou igual?', a <= b)
|
1dce79cd1c31159a2c4d19f90a000f4c2d1d515c | apurva13/assignment-3 | /List Solutions.py | 2,625 | 4.1875 | 4 | #Q1)Create a list with user defined inputs.
LIST=[]
n=int(input("enter total no. of value:"))
for x in range(n):
x=input("enter item:")
LIST.append(x)
print (LIST)
#Q2)Add the following list to above created list:
#[‘google’,’apple’,’facebook’,’microsoft’,’tesla’]
LIST2=['google','apple','facebook','microsoft... |
6d65cac91ad838ebfbe88cd7516baa4789aebaad | Darkxiete/leetcode_python | /60.py | 1,100 | 3.78125 | 4 | class Solution:
def getPermutation1(self, n: int, k: int) -> str:
def factorial(n):
result = 1
while n:
result *= n
n -= 1
return result
ans = ""
cands = [str(i) for i in range(1, n + 1)]
while n:
fact =... |
64170aaa6ea2227ac7a2af8d862df6b7734cf3ac | Luolingwei/LeetCode | /Stack/Q1673_Find the Most Competitive Subsequence.py | 642 | 3.703125 | 4 |
# 思路: 单调栈,每来一个小的数字,会替代掉已有的比它大的数字,从栈中pop所有比它大的数
# 但是需要check剩下的元素个数是否还够填满k个, 如果不够则不能继续pop
class Solution:
def mostCompetitive(self, nums, k):
res = []
L = len(nums)
for i,n in enumerate(nums):
while res and n<res[-1] and L-i>k-len(res):
res.pop()
if l... |
7ac25ebebbcbd1b51a7d80fab6f5bb1b7603adc4 | ash1kn1zar/luhn_algo | /Luhn Algo.py | 531 | 3.734375 | 4 | def luhn_algo(card_number):
num_digits = len(card_number)
n_sum = 0
second_digit = False
for i in range(num_digits - 1, -1, -1):
d = int(card_number[i])
if second_digit = True:
d = d * 2
n_sum += d // 10
n_sum += d % 10
second_digit =... |
3c0e228a4df397e555ceed6e30917970aa7447ef | ethanbar11/hashkal_16_3 | /lecture_7/homework_1_solution.py | 593 | 3.96875 | 4 | def get_words_amount(path):
counter = 0
with open(path, 'r') as f:
# Going over all the lines in the file, each one
# is one iteration.
for line in f:
# Splitting line into words and counting the amount
# of words in line.
words_in_line_amount = len(li... |
e2580cc19f413d06dbc5834f0148d34cc49f3e5f | syurskyi/Algorithms_and_Data_Structure | /_algorithms_challenges/exercism/exercism-python-master/hamming/hamming.py | 213 | 3.921875 | 4 | """Finds the hamming distance between two DNA sequences"""
def distance(strand_a, strand_b):
"""Counts the differences in two sequences of DNA"""
return sum(1 for a,b in zip(strand_a, strand_b) if a != b) |
80f834fc7c22a26b41f6186bf12e1e5ae0ec15c8 | FACaeres/WikiProg | /estruturas-condicionais/exercicio01.py | 378 | 4 | 4 | """Programa que calcula o consumo de um automovel"""
distancia = float(input("Qual a distancia percorrida (Km)? "))
litros = float(input("Qual a quantidade de combustivel consumida (l)? "))
consumo = distancia / litros
if consumo < 8:
print("Venda o carro!")
elif (consumo >= 8) and (consumo <= 14):
p... |
0bf14a4cc1a87381ad0880cecc9b1c39c169164e | thejanit/Fundamental-Projects | /Dice Rolling.py | 196 | 3.78125 | 4 | import random
dice_numbers = random.randint(1,6)
roll_the_dice = 'yes'
while roll_the_dice:
print('The dice is rolling...')
print('The value are: ', dice_numbers)
break
|
ce28e72029142fe029778943a368c3d49cea8f1a | shuaigegangNo1/MachineLearningDoubleColorBall | /MLDcb/com/sgg/mldcb/algorithm/ThirdNeutralNetworks.py | 1,881 | 3.578125 | 4 | import numpy as np
class ThirdNeutralNetworks(object):
def __init__(self, X, y):
self.X = X
self.y = y
pass
def nonlin(self, x, deriv=False):
if (deriv == True):
return x * (1 - x)
return 1 / (1 + np.exp(-x))
def get_synx(self):
np.random.seed... |
0d93cd6770a4ea6356803d2fa646e95b5f0ffa1a | AkshaykumarRode/LetsUpgrade-Python-Essentials | /Assignment_1_Day_6.py | 611 | 3.96875 | 4 | class bankacc:
def __init__(self,):
self.balance=0
print("Welcome to your bank account")
def deposit(self):
amount=float(input("Enter amount to be Deposite: "))
self.balance += amount
print("Amount Deposited:",amount)
def withdraw(self):
amount = float(input("Enter amount to be Withdrawn: ")... |
f3ffbac3be9aa657a6af85951233903aa100fd64 | kantdos/Selenium-Python | /Learning/loops.py | 516 | 3.625 | 4 | # if
greeting = "Good Morning"
a = 4
if a == 4:
print("Good Evening")
# print("Second Line")
else:
print(greeting)
# for loop
obj = [11, 12, 13, 14, 15]
for i in obj:
print(i)
print("************")
# sub of 5 natural numbers 1+2+3+4+5=15
summation = 0
for j in range(1, 6): # range(i,j) -> i to j-1
... |
86b7db763dff134fc43f4faf00ae7e7de7b4cc8d | dineshmk594/pdf_classify | /__init__.py | 926 | 3.609375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Mar 6 18:33:08 2020
@author: Dineshkumar M
"""
import PyPDF2
def pdf_classify(file):
if file.endswith('.pdf') or file.endswith('.PDF'):
opened_pdf = PyPDF2.PdfFileReader(file, 'rb')
if opened_pdf.isEncrypted:
opened_pdf.decryp... |
0d6d11c5d6605a54efedafbb88ffbe42f72257f0 | zsmoore/Advent-Of-Code-2017 | /day4.py | 745 | 3.96875 | 4 | import sys
def main():
in_file = open(sys.argv[1], 'r')
total = 0
for line in in_file.readlines():
if is_valid(line.strip()) and check_anagram(line.strip()):
total += 1
print(total)
def is_valid(passphrase):
if len(set(passphrase.split())) < len(passphrase.split()):
... |
4581361027f3816d5ef1de4faab67782b36b0c56 | yunosuke-naitoo/python_seminar | /02_list_tuple.py | 797 | 4.15625 | 4 | # リストの作成
x = [1, 2, 3, 'a', 'b', 'c']
# インデックスを使ってアクセス
print(x[0])
print(x[3])
# リストの末尾からアクセスしたい場合
print(x[-1])
print(x[-2])
# スライス
# x[i:j] i <= k < jをお取り出す
x[1:3]
x[1:4]
x[4:]
x[:4]
# 要素の追加
x.append('d')
print(x)
# 要素の削除
x.remove('a')
print(x)
# リストの長さ
len(x)
# リスト内の出現回数
d = [1, 1, 1, 2, 3, 4]
d.count(1)
# リストのソ... |
38b4d885e898bde62d86b8633ff4bdc57806016d | cwcr9029/cp2019 | /p02/q02_triangle.py | 283 | 4.25 | 4 | side1 = int(input("Enter side 1: "))
side2 = int(input("Enter side 2: "))
side3 = int(input("Enter side 3: "))
if side1 + side2 > side3 and side1 + side3 > side2 and side2 + side1 > side3:
print("Perimeter: {0}".format(side1 + side2 + side3))
else:
print("Invalid triangle") |
36f7c1ebeeee467ff9bf82d8c82e418b44474a5f | fruitfly/Muneebs_Portfolio | /Python_projects/programs/madlibs prgram.py | 897 | 4.28125 | 4 | name = input("please enter the name of your character ")
gender = input ("please input the gender of the character (must be male/female)")
noun1= input ("please input the first noun")
noun2 = input("please input the second noun")
noun3=input("please input the third noun")
if gender == 'male':
print (" Today," + na... |
4f8c8aecc6aaa857b1cd93583eeb13746f90a7c3 | svnavani/word_recommender | /word_recommender.py | 2,892 | 3.53125 | 4 | import sys, os, urllib.request
def initalize_english_dictionary():
# make a set of english vocab for fast lookup
english_vocab = set()
data = urllib.request.urlopen('https://raw.githubusercontent.com/first20hours/google-10000-english/master/google-10000-english-no-swears.txt')
for line in data:
english_vocab.a... |
a530dca1e47ae1d82ab95bf268947ae461243f67 | Jeyasuriya318/django-full-stack-bootcamp | /11_Python_Level_One/L099_Functions/lambda.py | 374 | 3.765625 | 4 | # Filter function
mylist = [1,2,3,4,5,6,7,8]
def even_bool(num):
return num%2 == 0
evens = filter(even_bool,mylist)
print(evens)
print(list(evens))
lambda num: num%2 == 0
evens = filter(lambda num: num%2 == 0,mylist)
print(evens)
print(list(evens))
tweet = 'Go Sports! #Sports'
result = tweet.split('#')
print(re... |
b6d2577284319f833803b347fa3a41b66cf749c5 | ahad-emu/python-code | /Coding/9_tuples.py | 226 | 3.9375 | 4 | t = (1,2,3)
print(t)
print(t[0])
t = ("a", "a", "a", "b", "c")
#item count
count = t.count("a")
print(f"the number of a is : {count}" )
#position of index
index = t.index("c")
print(f"The position Of \'c\' is : {index}")
|
79bd1fae6f4316f7c532975c66af0a68e71df6e0 | ShubhangiDabral13/Data_Structure | /Linked List/Linked_List_Delete_For_Given_Value.py | 2,080 | 4.1875 | 4 | """
Given a value, delete the first occurrence of this value in linked list.
To delete a node from linked list, we need to do following steps.
1) Find previous node of the node to be deleted.
2) Change the next of previous node to the next of given node .
3) Free memory for the node to be deleted.
"""
class N... |
81862bdff5b4c3304f0b165259a80bfb1837a1f8 | zombie1864/python_DSnA | /src/_03_strmatrix.py | 4,769 | 3.859375 | 4 | """ This class below is a simple string parser designed around a specific protocol. Parsing
strings/bytes from one format into another is a very common practice when using python for data
science or other backend work.
The detail of the protocol is specified below in the StrMatrix constructor. I have implemented th... |
86d71ec29e540b0187c6e777c63492e0882d028e | harshalms/python | /basics/alphaBeta.py | 1,508 | 3.859375 | 4 | ''' HackerRank All Women's Codesprint 2019 >> Alpha and Beta
Our friends Alpha and Beta found a magical treasure of Asgard. It consists of piles of gold coins. It is magical since if anyone tries to take a pile of coins, all the other piles of exactly coins (if they exist) disappear.
Alpha and Beta only have one tu... |
e220cc35e97967f63967983d190778852df1a994 | GyuReeKim/PycharmProjects | /190917/03.py | 401 | 3.59375 | 4 | # 재귀 호출을 통한 순열 생성
# 정렬된 순서가 아님
# 주어진 3개의 숫자로 만드는 순열
def perm(n, k):
if n == k: # n은 깊이, 바꿔줘야하는 고정 위치 # k는 바꿔줄 위치
print(p)
else:
for i in range(n, k):
p[n], p[i] = p[i], p[n]
perm(n+1, k)
p[n], p[i] = p[i], p[n]
p = [1, 2, 3]
perm(0, 3) |
82eb795b4dc505af6b2b18c1cf953e5fdd4e8b2d | xpessoles/Informatique | /P_02_AlgorithmiqueProgrammation/02_IntroductionAlgorithmique/Cours/images/ExempleCours.py | 3,231 | 3.921875 | 4 | # Exemple 1
n=input("Saisir un nombre : ")
n=int(n)
res=1
for i in range(1,n):
res = res*n
print(res)
# Exemple 1 - Corrigé
n = input("Saisir un nombre : ")
n = int(n)
res = 1
for i in range(1,n+1):
res = res*i
print(res)
# Courbe de de Bézier d'ordre 2 - Définition de la fonction
def f(u,x0,x1... |
ba946e73359521af3da77053eefee7b94fac51e9 | manuel-garcia-yuste/ICS3UR-3-06-Python | /guess.py | 697 | 4.1875 | 4 | #!/usr/bin/env python3
# Created by: Manuel Garcia Yuste
# Created on : October 2019
# This program gives more output whenever their is wrong input
import random
def main():
random_number = random.randint(1, 10)
# input
guess = input("Can you guess the number the computer chose from 0 to 10?:")
... |
82a7c29a9e4d0da895e10d379c40452e73fc11ec | SAWilding/cse210-student-team-challenges | /05-jumper/jumper/game/console.py | 1,996 | 4.28125 | 4 | class Console():
"""
Prints stuff to the screen.
Stereotype:
Displayer
Attributes:
user_guess_list: stores the letter guesses from the user.
user_guess: stores the letter guess for one round of play.
"""
def __init__(self):
self.user_guess_list = []
self.user_guess... |
c30c4ca699f137826efecdef12e24d3bf6d9ede8 | sunilsj99/sunil | /git.py | 101 | 3.671875 | 4 | a=raw_input("enter a no.")
b=raw_input("enter second no.")
c=int(a)+int(b)
print "the no. is %d" % c
|
2665c9b8511b4e420f1a6e46345263849ea9254d | Prakashchater/Daily-Practice-questions | /AlgoExpert/Caeser Encryption.py | 503 | 3.75 | 4 | # O(n) time and O(n) space
def caeserCypherEncryption(string,key):
new_letter=[]
new_key=key % 26
for letter in string:
new_letter.append(getnewLettercode(letter,new_key))
return "".join(new_letter)
def getnewLettercode(letter,key):
newLettercode=ord(letter)+key
return chr(newLettercode... |
258d3de96aea3ae0ce06559e946ea1f10f76ba43 | vishnu81/KLP-MIS | /klp/schools/management/commands/t1.py | 420 | 3.5625 | 4 | import sys
print sys.argv
class Class1(object):
k=7
def __init__(self,color="green"):
self.color=color
def H1(sefl):
print "HEKK CLASS!"
class Class2 (Class1):
def H2(self):
print "CLASS2"
print self.k, "is my color"
c1=Class1("blue")
c2=Class2("red")
c1.H1()
c2.H1()
c2... |
748c60f663a58dafaac7cbe740b771e3eeff30b6 | lanzhiwang/common_algorithm | /data_structures/03_linked_list/05_swap_nodes.py | 4,079 | 4.03125 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
def __str__(self):
if self.next is not None:
return 'data: %s, next: %s' % (self.data, self.next.data)
else:
return 'data: %s, next: %s' % (self.data, None)
class Link... |
9f18d6521c7920ff00fd11177f94872eb02a48d0 | bazy84/PythonLearning | /math.py | 148 | 3.5 | 4 | # Factorial math
import math
from math import factorial as fac
n = 5
k = 3
print(fac(n) / (fac(k) * fac(n-k)))
print(len(str(math.factorial(69))))
|
b00012979efd4eb33b514a4a35b025fc83d79602 | Clover0x29A/todo | /todo.py | 5,096 | 3.625 | 4 | from tkinter import *
class TodoItem:
def __init__(self, name, description):
self.name = name
self.description = description
class TodoList:
def __init__(self, root):
self.todo_file = 'todo_list.txt'
self.index = (-1,)
self.todo_items = []
self.rea... |
8e12e2aeea1032cf977cd257300755914d0ee248 | andresryes/EstructuraDatos | /Tarea12/Test.py | 909 | 3.78125 | 4 | import unittest
from HashTable import *
from HashFunction import *
class TestStringMethods(unittest.TestCase):
def test_insert(self):
hash_table = HashTable()
hash_table.insert(1,str(1))
self.assertEqual(len(hash_table.getHashTable()), 20)
'''
def test_getHashTable(self):
... |
66ddbde027ff7774e10009929ae7ed8d4e78f643 | ErickG123/miniProjetosPython | /aula3.py | 1,381 | 4.03125 | 4 | # a = int(input("Primeiro valor: "))
# b = int(input("Segundo valor: "))
# c = int(input("Terceiro valor: "))
#
# # Operações condicionais e operadores lógicos
# if a > b and a > c:
# print("A > B e A > C, valor de A: {}".format(a))
# elif b > a and b > c:
# print("B > A e B > C, valor de B: {}".format(b))
# el... |
714af0e2b79a00e3695afa37674c04c95d09b9fe | osantoslucas/PECIFPI | /questao02.py | 396 | 4.25 | 4 | #recebe nas variáveis os valores inteiros
numero1 = int(input('Insira um número: '))
numero2 = int(input('Insira outro número: '))
numero3 = int(input('Insira mais um número: '))
#variável com a média dos três valores inseridos acima
media = (numero1 + numero2 + numero3) / 3
#imprime na tela o resultado da va... |
510f6ea5a05c711530cfea039383dc35576fbf32 | simon-ritchie/python-novice-book | /src/str_format_map.py | 219 | 3.765625 | 4 | dict_value = {
'name': 'タマ',
'age': 5,
}
formatted_str = '飼っている猫の名前は{name}です。歳は{age}歳です。'
formatted_str = formatted_str.format_map(dict_value)
print(formatted_str) |
9dff7ab1940444bc96d4abf4c0ca5ce74deba346 | SRCinVA/rock_paper_scissors | /rock_paper_scissors.py | 1,303 | 4.375 | 4 | import random
user_wins = 0
computer_wins = 0
options = ["rock", "paper", "scissors"]
while True:
user_input = input("Type rock, paper, scissors, or q (to quit): ").lower()
if user_input == "q":
break # this will end the while loop and bring us down to "goodbye"
# clever: he set up all options ... |
cad6e5b53dd5a3f279f0236a5367d1cbea31df80 | snizzo/lucrezia | /src/grid/Entity.py | 526 | 3.5625 | 4 | """
Entities are objects that can be loaded in the game, be it Grids or Objects. They share some common methods, used by EntityManager.
The entity name is used to identify the entity uniquely in the game, across Grids, Objects
and any other kind of entity that will be implemented in the future.
"""
class Entity():
... |
6dfbed0ea07887facdd4e0f4144462d5a4331889 | silentpete/python-programming | /import-modules-example/01-custom-modules/package/custom_module.py | 132 | 3.84375 | 4 | def upPrint(value):
"""upPrint(string)
Will uppercase the string passed in and print it out.
"""
print(str(value).upper())
|
a509c863650beabcc96c8599820cde226c499187 | collinskoech11/RecursionQn | /a8q2.py | 950 | 4.09375 | 4 | # Noel Wafuko
# nww010 # 11308656
# For Instructor Jeff Long
Year = [2001,2002,2003,2004,2005,2006,2007,2008]
Population = [100,150,200,250,300,350,400,450]
import matplotlib.pyplot as plt
initial_population = int(input("Iinitial pupolation \n"))
n = int(input("No of years \n"))
r = float(input("Growth rate in th... |
ebea2b16d3247b35ceef830f5a9a61f467ef0d61 | abhinav0457/FSDP_2019 | /DAY_01/restart.py | 440 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Jun 3 18:40:43 2019
@author: user
"""
Code Challenge
Name:
Replacing of Characters
Filename:
restart.py
Problem Statement:
In a hardcoded string RESTART, replace all the R with $ except the first occurrence and print it.
Input:
RESTART
Output:
... |
e13d7b6c06df5906fc2d70a4b1240a9ed3c576eb | mildewyPrawn/IA | /Gustavo/Proyecto3/music_rec.py | 7,893 | 3.78125 | 4 | from tkinter import messagebox
from tkinter import *
from tkinter.ttk import *
import tkinter
class Music:
def __init__(self, gender, artist, name, ide, popularity, acousticness,
danceability, duration, energy, instrumentalness, key,
liveness, loudness, mode, speechiness, tempo, t... |
67a538b8a02da6b2b89fbf9cd1e044f35f9a055e | ngoyal16/ProjectEuler | /Project Euler #0022- Names scores/p0022.py | 352 | 3.78125 | 4 | # Enter your code here. Read input from STDIN. Print output to STDOUT
import sys
def count_word(word):
return sum(ord(c) - 64 for c in word)
name_string = raw_input().replace('"', '')
name_list = name_string.split(",")
name_list.sort()
res = 0
for i, val in enumerate(name_list):
res += (i+1) *... |
35486dc816944630df1013bb9735d9bc9662ec72 | yoshimura19/samples | /python/dataquest/quest/python_intro/1/func_words.py | 2,081 | 3.84375 | 4 | #coding:utf-8
f = open("dictionary.txt", "r")
vocabulary = f.read()
tokenized_vocabulary = vocabulary.split(" ")
#print(tokenized_vocabulary)
f2 = open("story.txt", "r")
story_string = f2.read()
# story_string = story_string.replace(".", "")
# story_string = story_string.replace(",", "")
# story_string = story_stri... |
7cdbd909e8f631e5cc9e0f16dc305ca4c6b5b36c | sudhap163/Coursera-machine-learning-Andrew-Ng-assignments | /ex2 (Week 3)/ex2.py | 2,388 | 3.546875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Dec 11 14:00:12 2017
@author: Sudha
"""
import pandas as pd
import numpy as np
import math as math
import matplotlib.pyplot as plt
data = pd.read_csv("ex2data1.csv")
Y = data["Admitted"]
del data["Admitted"]
X = np.array(data)
Y = np.array(Y)
# plotData
X_0 = []
X_1 = [... |
97483378324993d0327b48949b061e0eb1592f58 | teejdotme/cazton-solvers | /solvers/hadoop-hdfs/scripts/stage2Reducer.py | 605 | 3.78125 | 4 | #!/usr/bin/env python
import sys
def formatValue(value):
value = value / 10
fahrenheit = (value * 9/5) + 32
return round(fahrenheit, 1)
def main():
for line in iter(sys.stdin.readline, ''):
(key, entry) = line.strip().split('\t')
parts = entry.split(',')
state =... |
a63bbccbea8b14b172a526f41094b8a2e4909f9e | KevinWangTHU/LeetCode | /437.py | 1,360 | 3.640625 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def pathSum_MLE(self, root, sum):
"""
:type root: TreeNode
:type sum: int
:rtype: int
... |
81c7b86a54d954203979a8e47b09b3185311a9fb | handsomm/PythonLearn | /Chapter 4 (list & tuple)/04_tuples.py | 274 | 4.15625 | 4 | # Creating a tuple using ()
t = (1, 2, 3, 4)
t1 = () # Empty tuple
t2 = (1) # Wrong way to declar a tuple
t3 = (1,) # Tuple with single element
# Printing the element of tuple
print(t[0])
print(t1)
print(t2)
print(t3)
# Cannot update the values of a tuple
# t[0] = 34
|
de4fb985a8494a87f94c8023b4a3a2985edb5e0f | victorcunha94/curso_em_video_python | /exercícios/exe005.py | 144 | 4.0625 | 4 | n = int(input('Digite um número: '))
a = (n - 1)
s = (n +1)
print('O antecessor de {} vale {} e o seu sucessor é igual a {}'.format(n, a, s) ) |
0ff678d3e829186afb95b78afd55885d3404fa6e | PangXing/leetcode | /daily/month_202008/daily_20200803.py | 1,226 | 4.03125 | 4 | # coding:utf-8
'''
【415. 字符串相加】
给定两个字符串形式的非负整数 num1 和num2 ,计算它们的和。
注意:
num1 和num2 的长度都小于 5100.
num1 和num2 都只包含数字 0-9.
num1 和num2 都不包含任何前导零。
你不能使用任何內建 BigInteger 库, 也不能直接将输入的字符串转换为整数形式。
'''
class Solution(object):
def addStrings(self, num1, num2):
n1 = len(num1)
n2 = len(num2)
nxt = 0
... |
aeb4fa1dbd7beb99c9951bd022c182d297ab97b2 | Pugonfire/saymyname | /Listening.py | 1,207 | 3.625 | 4 | import speech_recognition as sr
r = sr.Recognizer()
m = sr.Microphone()
def removeLineBreak(lst):
lastWord = lst[-1]
removedWord = lastWord[:-1]
lst[-1] = removedWord
return lst
def callback(recognizer, audio):
try:
speech = recognizer.recognize_google(audio)
print(speec... |
4095b463f2063815b86ce3d1f0933e845807440a | Fyefee/PSIT-Ejudge | /34 Stepper II.py | 257 | 3.78125 | 4 | """Stepper II"""
def main(num, num2):
"""Stepper II"""
if num - num2 > 0:
for i in range(num, num2-1, -1):
print(i)
else:
for i in range(num, num2+1):
print(i)
main(int(input()), int(input()))
|
cd31a65b021872b4b083db9d1243f48f099ed018 | JakeWMueller/nothangman.py | /nothangman.py | 892 | 4 | 4 | import random
name = input("Welcome to pacifistwordgames.com. What's your name? ")
print("Good luck, " + name, ", not like anyone's life depends on it.")
fruits = ['apple', 'banana', 'pear', 'tomato', 'peach',
'watermelon', 'cantaloupe', 'grape', 'blueberry', 'raspberry']
word = random.choice(fruits)
print("... |
f8b05c8b22d2329b53c4c7231f73877323367795 | NThomas95/Math693A | /homework_1.py | 9,132 | 4 | 4 | '''
This is the code for the first homework assignment in M693A. The objective is to minimize the rosenbrock function,
described by:
f(x,y) = 100(y-x^2)^2 + (1-x)^2
We need to evaluate two methods: the steepest decent method and the newton direction method. We must use the
backtracking algorithm to determine ou... |
5cf789b1269c41e771d5b128757682dc779450cf | asperaa/back_to_grind | /Linked_List/linked_list_cycle.py | 1,017 | 3.890625 | 4 | """We are the captains of our ships, and we stay 'till the end. We see our stories through.
"""
"""[141. Linked List Cycle]
"""
class ListNode:
def __init__(self, val):
self.val = val
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def push(self,... |
a3fbeca7e99e07394d2c91fe6426143006d56dc7 | muhammad-masood-ur-rehman/Skillrack | /Python Programs/sum-of-even-odd-numbers.py | 1,077 | 4.09375 | 4 | Sum of Even & Odd Numbers
N numbers will be passed as input to the program. The program must print the sum of even numbers followed by the sum of odd numbers.
Input Format:
First line contains total number of test cases, denoted by T
Next 2*T lines, contain the test case values for T test cases. Each test case will ha... |
3b025cd99a6502d6446803cf55f29053d8002ed2 | kentxun/PythonBase | /ForOffer/67_StrToInt.py | 817 | 3.625 | 4 | # -*- coding:utf-8 -*-
'''
将一个字符串转换成一个整数(实现Integer.valueOf(string)的功能,但是string不符合数字要求时返回0),
要求不能使用字符串转换整数的库函数。 数值为0或者字符串不是一个合法的数值则返回0。
'''
class Solution:
def StrToInt(self, s):
# write code here
# 先排除异常特殊情况
if s in ['','-','+','+-','-+']:
return 0
count = 0
# 只要有... |
b29626f635b42c2ccfcd9e842ff0f793ef1849fb | Locke-Yuan/ctpython | /0321_Hw01.py | 405 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Mar 21 11:21:19 2021
@author: user
"""
"""
3/21 作業1
由系統亂數產生1~49之間六個不重複的整數,
請遞增排序印出
"""
import random
number = []
while True:
num = random.randint(1, 49)
if number.count(num) == 0:
number.append(num)
if len(number) == 6:
break... |
20a908651e8b18c44e4a207b8599a4a62aee6a13 | eiadshahtout/Python | /python3/fruit.py | 370 | 4.15625 | 4 | favouriteFruits = ["Bananas","Apples","Mangoes"]
if "Bananas" in favouriteFruits:
print("You like bananas")
else:
print("You don't like bananas")
if "Peacjes" in favouriteFruits:
print("You like peaches")
else:
print("You don't like peaches")
if "Apples"in favouriteFruits:
print("You really like ap... |
7bcf9016b8d747f2d5432e1fc4baefef741cafd9 | Arjun-Pinpoint/InfyTQ | /Programming Fundamentals using Python/Day 3/Assignment 25.py | 344 | 3.59375 | 4 | '''
The program provided in the starter code tab is written to display “*” as per the expected output given below. But the code is having logical errors, debug the program using Eclipse Debugger and correct it.
Expected Output:
*****
****
***
**
*
'''
for i in range(5,0,-1):
for j in range(i):
print("*",end... |
df2033bdb31f380eb9381ef4e8babebea41c8aeb | Nooh123-eng/Survay | /main.py | 353 | 3.875 | 4 | #prints survey
print("Survey:")
# QUESTION1:
q1 = input("What is you name?")
# QUESTION2:
q2 = input("What is you last name")
# QUESTION3:
q3 = input("What is you favorite number?")
# QUESTION4:
q4= input("How old are you?")
#prints you na,e,last name,favorite number,
print(f"Name: {q1} Last name:{q2} Favori... |
5fd0f90373985f29f93a0f24b181c7d27761f48d | GamaCatalin/Facultate | /An1_sem1/Python/Test 12.11/Services.py | 2,539 | 3.953125 | 4 | manufacturer=[]
model=[]
price=[]
def add_phone(phn):
'''
Adds a phone to the list if all requirements are met
'''
phone=phn.split()
t=1
if(len(phone)>3):
for i in range(1,len(phone)-2):
phone[1]=phone[1]+" "+phone[i+1]
phone[2]=phone[len(phone)-1]
for... |
685da757ecd8f355cea3b774ff35a973316f0790 | danielbrazz/SenaiProject | /SenaiPython/Logistica.py | 3,355 | 3.703125 | 4 | import ObjetoPedido
import os
clear = lambda: os.system('cls')
lista = ObjetoPedido.listaP
#sair da def lista()
#input incorreto simples
#loop lista
#fazer retirada de produto
gg = ObjetoPedido.Pedido('papel','100')
gg.aprovCom = '1'
lista.append(gg)
pp = ObjetoPedido.Pedido('caneta','10')
pp.aprovCom... |
c8035d2c8eb7fafb359215566ee9b2c42ab8be3f | rohithkumar282/LeetCode | /LeetCode917.py | 572 | 3.609375 | 4 | '''
Author: Rohith Kumar Punithavel
Email: rohithkumar@asu.edu
Problem Statement: https://leetcode.com/problems/reverse-only-letters/
'''
class Solution:
def reverseOnlyLetters(self, S: str) -> str:
index=[]
loc_index=0
rev = ""
for i in range(len(S)):
if S[i].i... |
b66752fd11f7a7bf74b0c905d05836bc52c8174f | EmmaOKeeffe/GOnline-Project | /game_final/GOnline/gonline.py | 6,077 | 3.515625 | 4 | import pygame
size = [1100, 800]
blue = (100, 149, 237)
black = (0, 0, 0)
brown = (165,42,42)
white = (255, 255, 255)
green =(0,100,0)
red = (255,0,0)
dark_red = (200,0,0)
grey = (100,100,100)
other_grey = (0,0,100)
background = 'Mahogany.jpg'
pass_count = 0
player = 1
clock = pygame.time.Clock()
cla... |
5197a3d9d7017c4c11cdf67915441c3624537d9c | ZacCui/cs2041_software-Construction | /ASS1/test01.py | 117 | 3.875 | 4 | #!/usr/bin/python3
x = 1
while x >= 1: break
while x < 10:
x = x+1
if x == 5:
continue
print(x)
|
c0d8e647f5ad71faa22d9ae3c12efaead844f0c2 | Charlie-Say/CS-161 | /notes/chaos-08.py | 692 | 4.40625 | 4 | """
A simple program to calculate a chaotic function.
This program will calculate the first ten values of a chaotic
function with the form k(x)(1-x) where k=3.9 and x is provided
by the user.
"""
def main():
"""
Calculate the values of the chaotic function.
"""
x = float(input("Enter a number between ... |
7ba1657f2f3853bebee801539f54027a42b97d2c | JamesChung821/python | /stanCode_Projects3/Assignment5 - Boggle Game Solver/anagram.py | 6,367 | 4.15625 | 4 | """
File: anagram.py
Name: James Chung
This program is to find the anagrams words for the word input by user
----------------------------------
This program recursively finds all the anagram(s)
for the word input by user and terminates when the
input string matches the EXIT constant defined
at line 19
If you correctly... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.