blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
4533f070e5315f6af3d3e6e241cda08b35d8c627 | briamn/hangman | /hangman.py | 804 | 3.78125 | 4 | import random
#This gets a random word from a file i made
word = random.choice(open('randwords.txt').read().split())
rack = []
board = ['_'] * len(word)
for i in word:
rack.append(i)
print(rack)
print(board)
count = 0
while board != rack:
guess = input("Guess a letter: ")
for i in rack:
if gu... |
061f7fa4d8abf800003db7652e4f6e30231ec237 | soviedoa/Parcial-1 | /Punto9.py | 541 | 3.953125 | 4 | row = int(input("Ingrese la fila del dato a buscar: "))
column = int(input("Ingrese la columna del dato a buscar: "))
def pascal(row, column):
if row < 0 and column < 0:
return 0
elif row == 0 and column == 0:
return 1
else:
nuevaFila = [1]
ultimaFila = pascal(row-1... |
43f95a5826a369319a076f00fc5fc68a0824888d | profitlettuce/newboston-tutorials | /revshell/revshell_server_multi-client.py | 3,678 | 3.5625 | 4 | import socket
# import sys
import threading
from queue import Queue
import time
NUMBER_OF_THREADS = 2
JOB_NUMBER =[1, 2]
queue = Queue()
all_connections = []
all_addresses = []
# create socket
def socket_create():
try:
global host
global port
global s
host = ''
... |
0673e8e6f8288c64c4063e47d34fecaad49723a6 | Ghanshyam1296/Data-Structureand-Algorithm- | /Data_structure/Bi_search.py | 398 | 3.859375 | 4 | def Binarysearch(a,l,r,x):
if(r>=l):
mid = int((r+l)/2)
if a[mid]==x:
return a[mid]
elif a[mid]>x:
return Binarysearch(a,l,mid-1,x)
else:
return Binarysearch(a,mid+1,r,x)
else:
return -1
num=[1,2,3,4,5,6,7,8,9]
rn=in... |
0d1e57cfe85dc3a5710d1c340d3fc7fb89270e8f | abantikatonny/Statistics-Codes | /Assignment 1/Question number 3.py | 2,557 | 3.6875 | 4 | import numpy as np
import pandas as pd
import scipy.stats
# import the data file
data = pd.read_csv('C:/hmm/courses/3rd semester/Special topics/Assignment 1/data_master.csv', delimiter=',')
# creating a database for US because it has the highest date_reported data
States_database = data[data['Country'] == 'United Sta... |
9a14c11edcd7f0fffa672a5572ac5c1ae350aaff | rajivsimhadri/Fraud-Detection | /new_file.py | 140 | 3.703125 | 4 | print("new line of life is not a wife")
a=5
b=6
def sum(a,b):
c=a+b
return a
print("Added a new sum function which is not correct") |
c0bd299e764f4bef93de63d582e48450cf5e31bc | Ajsolanki/Python-Scripts | /knapsack.py | 1,100 | 4.03125 | 4 | v_list = input("enter a list of values(Please provide space between valuse) : ")
w_list = input("enter a list of weights (Please provide space between valuse): ")
W = int(input("Enter the Maximum weight :"))
import sys
def convertToList(string):
string = string.split(" ")
temp = [int(i) for i in string]
... |
21a2140f140ce42cbbc52996457327d8529bf253 | bapds/PyCharmEdu_CoffeMachine | /Problems/Fahrenheit/task.py | 245 | 3.921875 | 4 | '''
def fahrenheit_to_celsius(f):
return round(((f - 32) * 5 / 9), 3)
f = float(input())
print(fahrenheit_to_celsius(f))
'''
name = "John"
def change_name(new_name):
global name
name = new_name
change_name("Mary")
print(name)
|
8e063959842f645ca868bbc0aced8a66bb94d040 | nettijoe96/ai-asteroids | /datatools.py | 2,385 | 3.59375 | 4 | class DataFile:
def __init__(self, file_name):
self.file_name = file_name
"""
Writes data about pixels into a new text file.
Each frame is given an ID, and is given a pixel count for its
heading. Under each frame, a list of the counted pixels appears with
information about ... |
09caee80534bb7cb0923c7f5d128fe01086d76ff | nymoral/euler | /p17.py | 1,840 | 3.828125 | 4 | """
If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?
NOTE: Do not count spaces or hyphens.
For example, 342 (thre... |
57988e26cd73a8a6f1be62a08fc9e969ad76f0d2 | nymoral/euler | /p14.py | 1,263 | 4.09375 | 4 | """
The following iterative sequence is defined for the set of positive integers:
n → n/2 (n is even)
n → 3n + 1 (n is odd)
Using the rule above and starting with 13, we generate the following sequence:
13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
It can be seen that this sequence (starting at 13 and finishing at 1) cont... |
0cc737032d5e1bb00f19cc20b34aab1a7653dc32 | nymoral/euler | /p55.py | 516 | 3.625 | 4 | def reversed_int(n):
r = 0
while n != 0:
q, rem = divmod(n, 10)
r *= 10
r += rem
n = q
return r
def is_palindrome(n):
return n == reversed_int(n)
def is_lychrel(n):
for _ in range(50):
r = reversed_int(n)
n += r
if is_palindrome(n):
... |
4493a947b92dfedb71c70f73dce3336d7075ca9b | nymoral/euler | /p6.py | 730 | 3.921875 | 4 | """
* The sum of the squares of the first ten natural numbers is,
* 1^2 + 2^2 + ... + 10^2 = 385
* The square of the sum of the first ten natural numbers is,
* (1 + 2 + ... + 10)^2 = 552 = 3025
* Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385... |
b692dac5248f6da0bae71b5422f08e7b68b43cec | milosevich/My_first_exercises_in_Python | /cards.py | 329 | 3.609375 | 4 | class Card:
RANKS = ('Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King')
SUITS = ('Clubs', 'Diamonds', 'Hearts', 'Spades')
def __init__(self, suit, rank):
self.suit = suit
self.rank = rank
def __repr__(self):
return '{0} - {1}'.format(Card.SUITS[self.suit-1], Card.RANKS[self.r... |
135000f8c7d2d24e4fd064be6208e0e56a20773d | Fadzayi-commits/Python-Programming-Assignment1 | /Area of Triangle.py | 311 | 4.09375 | 4 | def triangleArea(x,y,z):
p = (x + y+ z)/2
return ((p*(p-x)*(p-y)*(p-y)) ** 0.5)
x = float(input('Enter first side of triangle:'))
y = float(input('Enter second side of triangle:'))
z = float(input('Enter third side of triangle:'))
print('Area of triangle is: {}'.format(triangleArea(x,y,z))) |
bb2c03a2046bd30f76ce013fb4c80bd0e158d3c4 | michelmassamiri/BlackHole-Routing-JS-App | /ExabgpServer/jsonCoder.py | 1,362 | 4.125 | 4 | '''
JsonCoder is used to encode/decode JSON string formatedself.
The class specializes The Json encoder/decoder methodology, and it is used essentially in the ExaBGP server class.
The Json file MUST be formated this way :
{
"command":"command-name",
"arg1":"your 1st argument",
"arg2": "your 2nd arg",
"arg3": "your ... |
09ea65c304d7d247882ed5d75934fcdb4b92b2a0 | fwfurtado/functional | /lambda_calculus/data_structure.py | 757 | 3.65625 | 4 | from lambda_calculus.arithmetic import four, three
from lambda_calculus.base import konstant
from lambda_calculus.logical import to_bool, true, false
from lambda_calculus.numbers import to_int, one, two
pair = lambda first: lambda second: lambda f: f(first)(second)
fst = lambda some_pair: some_pair(true)
snd = lambda... |
a2c6bcd10658ebe21351804ebca92c73ecf43954 | fwfurtado/functional | /lambda_calculus/arithmetic.py | 445 | 3.609375 | 4 | from lambda_calculus.numbers import two, one, to_int
add = lambda m: lambda n: lambda f: lambda x: m(f)(n(f)(x))
mul = lambda m: lambda n: lambda f: lambda x: m(n(f))(x)
power = lambda m: lambda n: lambda f: lambda x: m(n)(f)(x)
three = add(two)(one)
four = add(three)(one)
twelve = mul(three)(four)
six = add(four... |
94ba1fa8d1a23a1e0a311321ed24b7607c9bcdd6 | benjamin22-314/codewars | /Complementary DNA.py | 303 | 3.5625 | 4 | # https://www.codewars.com/kata/complementary-dna
# %%
def DNA_strand(dna):
transforms = {'A': 'T', 'T': 'A', 'G': 'C', 'C': 'G'}
return ''.join([transforms[t] for t in dna])
# %%
# tests
print(DNA_strand("AAAA"))
print(DNA_strand("AAAA") == "TTTT")
print(DNA_strand("ATTGC") == "TAACG")
|
48ae54a1eafa88e542dcaba3d75ff34fcb421249 | benjamin22-314/codewars | /counting-duplicates.py | 371 | 3.828125 | 4 | # Counting Duplicates
def duplicate_count(text):
return sum([1 for v in {i: text.lower().count(i) for i in text.lower()}.values() if v > 1])
# tests
print(duplicate_count('abcd'))
print(duplicate_count('abca'))
print(duplicate_count('abcabc'))
# other nice solutions
def duplicate_count(s):
return len([c ... |
58328a551645de8d85d5dcd824c55b124a03b6de | benjamin22-314/codewars | /format-a-string-of-names-like-bart-lisa-and-maggie.py | 422 | 3.96875 | 4 | # http://www.codewars.com/kata/format-a-string-of-names-like-bart-lisa-and-maggie
def namelist(names):
if len(names) == 1:
return names[0]['name']
else:
return ', '.join([n['name'] for n in names[:-1]]) + ' & ' + names[-1]['name']
# tests
our_names = [{'name': 'Bart'}, {'name': 'Lisa'}, {'na... |
a4408cec334b373d815b068220f9614f9a999811 | benjamin22-314/codewars | /build a pile of cubes.py | 1,309 | 3.875 | 4 | # https://www.codewars.com/kata/build-a-pile-of-cubes
# %%
def find_nb(m):
def calculate_m(n):
return sum([i**3 for i in range(n+1)])
for n in range(m):
if calculate_m(n) == m:
return n
if calculate_m(n) > m:
return -1
# The above is too inefficient
# %%
# ... |
0ef0cb25f5597a93a195ae90c9090d948456c747 | benjamin22-314/codewars | /lambdas-as-a-mechanism-for-open-slash-closed.py | 513 | 3.5625 | 4 | # https://www.codewars.com/kata/lambdas-as-a-mechanism-for-open-slash-closed
spoken = lambda greeting: greeting.capitalize()+'.'
shouted = lambda greeting: greeting.upper()+'!'
whispered = lambda greeting: greeting.lower()+'.'
greet = lambda style, msg: style(msg)
print(greet(style=shouted, msg='goodness gracio... |
874012a902bb360a6e36647c35f23c28ca7d6359 | RedheatWei/python-study | /python高级编程/2.2.2fibonacci.py | 277 | 3.65625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
@auther = 'Redheat'
@create = '2019/5/24 11:46'
@email = 'qjyyn@qq.com'
'''
def fibonacci():
a, b = 0, 1
while True:
yield b
a, b = b, a + b
fib = fibonacci()
for i in range(10):
print(fib.__next__()) |
03c75d34019fce60bba13b50cd4fe6461b9304e2 | RedheatWei/python-study | /实验/判断数值范围.py | 221 | 4.03125 | 4 | num = float(raw_input('Enter your number:'))
right = 'Your number is right !'
wrong = 'Wrong number !'
while False == (100 > num and num > 1):
print wrong
num = float(raw_input('Enter your number:'))
print right
|
28899b7dd442a30cac2620c76f963e9a2d1b8cbd | RedheatWei/python-study | /实验/输出字符串.py | 138 | 3.703125 | 4 | uni = raw_input('Enter a unicode:')
#pystr = uni
number = len(uni)
num = int(0)
while num < number:
print uni[num],
num = num + 1
|
a9c35acbded79af2d5c86a529c272d537494d283 | RedheatWei/python-study | /idle_instance/quick_sort.py | 513 | 3.5 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
@auther = 'Redheat'
@create = '2019/5/17 17:34'
@email = 'qjyyn@qq.com'
'''
'''
快速排序
'''
import random
def quick(l):
if len(l) < 2:
return l
left = []
right = []
mid = l[0]
for i in l[1:]:
if i < mid:
left.append(i)
... |
4f6f7b9c8092cc771f0e750a3465f4bbfc3b6eb5 | RedheatWei/python-study | /实验/5-2乘积.py | 152 | 3.734375 | 4 | #!/usr/bin/env python
A = float(raw_input('number A:\n>'))
B = float(raw_input('number B:\n>'))
def mul(A,B):
C = A * B
return C
print mul(A,B)
|
12d1dc6bca77b9c424f098d8facda464c8ca3bdc | RedheatWei/python-study | /实验/6章/例题/6-6.py | 213 | 3.8125 | 4 | #!/usr/bin/env python
aList = raw_input('Enter a string:\n')
L = len(aList)
for i in [None] + range(L-1):
if aList[i] == ' ':
aList = aList[:i] + aList[i+1:]
# L = len(aList)
print aList |
736830c9b434b4084f06db03f791caf909fb21e9 | RedheatWei/python-study | /实验/9章/例题/9-4文件访问.py | 414 | 3.546875 | 4 | #!/usr/bin/env python
#_*_ coding:utf-8 _*_
'''
Created on 2015��3��11��
@author: Redheat
'''
file_name = raw_input('Enter an absolute path:')
f = file(file_name)
aa = f.readlines()
f.close()
num = 0
while True:
for line in aa[num:num+25]:
print line,
go = raw_input('Enter (c) to continue,other to exi... |
f574889bab10ebcf27d85212a01af82b5d6f5864 | RedheatWei/python-study | /实验/19章/示例/tkhello3.py | 342 | 3.546875 | 4 | #!/usr/bin/env python
#_*_ coding:utf-8 _*_
'''
Created on 2015年6月29日
Email: weipeng@sinashow.com
@author: Redheat
'''
import Tkinter
top = Tkinter.Tk()
hello = Tkinter.Label(top,text='hello world')
hello.pack()
quit = Tkinter.Button(top,text='QUIT',command = top.quit,bg='black',fg='white')
quit.pack(fill=Tkinter.X,... |
c8e169b1191a105d7b4a7c5fcab3d947320617f8 | RedheatWei/python-study | /实验/实验/实验/sum.py | 430 | 3.625 | 4 | #!/usr/bin/env python
#_*_ coding:utf-8 _*_
'''
Created on 2015年6月25日
Email: weipeng@sinashow.com
@author: Redheat
'''
def check(num):
need = divmod(num, 2)[0]
num_list = []
for i in range(need):
if divmod(num,i)[-1] == 0:
num_list.append(i)
return sum(num_list)
large = 10**2
che... |
3980b8884b6b959207b0f4c89ee28a5cf87b0fd4 | Dawnlight181/learning_python | /h.py | 589 | 3.5 | 4 | musicians = ["Avicii", "Sia", "Labrinth",]
print(musicians)
locations = [(20.2334, 97.7888), (20.3200, 23.4829), (23.2342, 29.3293)]
print(locations)
traits = {"height": "170",
"color": "black",
"writer": "Horie",}
n = input("キーを入力してください")
if n in traits:
print(traits[n])
else:
print("別のキ... |
25f14294bc85a1102f3b96a11529d20d6bdf62d6 | anciaux/Cuttings | /basic_functions.py | 2,509 | 3.625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 5 11:34:31 2019
@author: DFSCHMIDT
"""
import numpy as np
# random_sample returns floats in the interval ]0.0;1.0]
from numpy.random import random_sample as rand
def create_ellipsoid(ellipsoid, npoints=1000):
"""
Create el... |
6208fe25c308a1bc3e7102c74e10afde4adef819 | dilansavar/numerical-methods | /polinom-butunkokler.py | 1,329 | 3.65625 | 4 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
def f(x):
return(1*x**5-7*x**4-3*x**3+79*x**2-46*x-120)
xi = float(input("bir başlangıç değeri girin: "))
def f(dizi,x):
toplam=0
a=0
for i in range(len(dizi)-1,-1,-1):
toplam=toplam+(dizi[a])*pow(x,i)
a+=1
return(toplam)
def fi(dizi,x):
... |
16c18eb253e2ef08ec6fc96beccbdfb4b58535d5 | Mperez5891/Learning-Python-With-Fantasy-Football | /Module 01/PracticeProblem_P04.py | 1,251 | 3.78125 | 4 | # Author: Manuel Perez
# Date: 09/12/2020
#
# Problem 4 (Medium)
# Using if statements, find whether or not Rashaad Penny is in the
# interquartile range for rushing yards (between 25th and 75th
# percentile), in the bottom 25th percentile, or in the top 75th
# percentile.
#
# Rashaad Penny Rushing Yards: 370 ya... |
edc925d3fcc1cbf733cee9096fbbed54e9af0ec1 | devedu-AI/YouTube_Tutorials | /Coloured_Console.py | 560 | 3.53125 | 4 | """
Tutorial Link:https://youtu.be/El0WJ38167A
"""
import colorama
from colorama import Back,Fore,Style
colorama.init(autoreset=True)
print(Fore.RED + "Savage Programmer")
print(Back.GREEN + "Savage Programmer")
text_fore = f'{Fore.MAGENTA}V{Fore.BLUE}I{Fore.LIGHTBLUE_EX}B{Fore.GREEN}G{Fore.YELLOW}Y{Fore.... |
724982deed7a73e32777053150dfd1691819b6dc | MattVillarrubia/project-euler | /smallestmultiple.py | 415 | 3.734375 | 4 | # Smallest multiple
# Problem 5
#
# 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 # without any remainder.
#
# What is the smallest positive number that is evenly divisible by all of the numbers from # 1 to 20?
smallMult = 1
for i in range(1, 21):
smallMult = smallMult * i
fo... |
217c6280c59507686fba9df11d2bd4dc56dc4542 | Tanvir1080/Leetcode | /Linked-List/addTwoNumbers.py | 891 | 3.75 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
number1 = []
number2 = []
head = current = ListNode(0)
... |
88835871f19c5dacc73cbd8a21ec222ea1875708 | Doktorishka86/Master | /Urok_1.py | 625 | 3.828125 | 4 | #time = int(input('Введите количество секунд: '))
#days, hours, minutes, seconds = time // 86400, time // 3600 % 24, time // 60 % 60, time % 60
#print(f'{days} дн {hours} час {minutes} мин {seconds} cек')
prime_list_01 = []
for x in range(101):
prime_list_01.append(x)
for element in prime_list_01:
if element... |
0d4739020183432a0c17484c85195ebe8a795134 | sakusss/leetcode | /118. Pascal's Triangle.py | 596 | 3.515625 | 4 | class Solution:
def generate(self, n):
"""
:type numRows: int
:rtype: List[List[int]]
"""
if n == 0: return []
if n == 1: return [[1]]
if n == 2: return [[1],[1,1]]
if n > 2:
list = [[] for i in range(n)]
for i in range(n):
... |
fb90cb80a426a25e39a782101fdde09ba02e1ae3 | sakusss/leetcode | /33. Search in Rotated Sorted Array.py | 1,727 | 3.890625 | 4 | ##这道题是二分查找Search Insert Position的变体,看似有点麻烦,其实理清一下还是比较简单的。因为rotate的缘故,当我们切取一半的时候可能会出现误区,所以我们要做进一步的判断。具体来说,假设数组是A,每次左边缘为l,右边缘为r,还有中间位置是m。在每次迭代中,分三种情况:
(1)如果target==A[m],那么m就是我们要的结果,直接返回;
(2)如果A[m]<A[r],那么说明从m到r一定是有序的(没有受到rotate的影响),那么我们只需要判断target是不是在m到r之间,如果是则把左边缘移到m+1,否则就target在另一半,即把右边缘移到m-1。
(3)如果A[m]>=A[r],那么说明从l到m一... |
e3b0563a3f5b62d759103bac9ad774f9e07a6d59 | Python-Boot-Camp/Trees-Code | /trees.py | 362 | 3.8125 | 4 | def make_tree(label, branches = []):
"""A (sub)tree with given LABEL at its root, whose children are KIDS."""
return (label, branches)
def label(tree):
"""The label on TREE."""
return tree[0]
def branches(tree):
"""The children of TREE (each a tree)."""
return tree[1]
def isleaf(tree):
"""True if TREE is a leaf ... |
7797f056b2156665874ec42dc1cd6e83c098f13d | pepelamah/MesRevisions | /TP_GE.py | 522 | 4.1875 | 4 | moy_int=0
while moy_int==0:
moy_str=input("Saisir votre note: ")
try:
moy_int=int(moy_str)
except:
print("Veuillez saisir une valeur numérique!!")
else:
if(20>=moy_int>=18):
print("Excellent!")
elif(18>moy_int>=14):
print("Très bien!!")
... |
82f76709a5f40cd73f1fe5d99fe529b617cbf1a5 | Yen-US/Introduccion-y-Taller-de-Programacion | /Recursion de Cola/MultiM.py | 610 | 3.640625 | 4 | def MultiM (MatA,MatB):
if isinstance (MatA,list) and (MatB,list):
return MultiM_aux (MatA, MatB, 0, 0, 0, 0, [],[])
else:
return "Por Favor ingrese dos matrices para su multiplicacion"
def MultiM_aux (MatA, MatB, IA, IB, IC, NV, NF, NM):
if IC == len(MatA):
return NM
elif IB !=len (MatB):
if IA != len(MatA... |
ca06d3fa6097afe95487de74b6b5d2e0187cad1d | Yen-US/Introduccion-y-Taller-de-Programacion | /Recursion de Pila/SumaDigitos.py | 293 | 3.515625 | 4 | #Martes
def Suma_Digitos (num):
if isinstance (num,int) and (num>0):
return Suma_Digitos_aux (abs(num))
else:
return "Error"
def Suma_Digitos_aux (num):
if num==0:
return 0
elif num>0:
return num%10 + Suma_Digitos_aux (num//10)
|
f4f5f07edf9343efd8935d46438f368e7ae697ef | Yen-US/Introduccion-y-Taller-de-Programacion | /Recursion de Cola/Ordenar Lista.py | 427 | 3.578125 | 4 | def Ordenar (L):
if isinstance (L,list):
return Ord (L,0,0)
else:
return "Error"
def Ord (L,I1,I2):
if I1==len(L)-1:
return L
elif I2==len(L)-1:
return Ord (L,I1+1,0)
elif L[I2]>L[I2+1]:
aux=L[I2]
L[I2]=L[I2+1]
L[I2+1]=aux
... |
ade91d8f9e867cf00b48de54289c55cbb7af345c | Yen-US/Introduccion-y-Taller-de-Programacion | /Recursion de Pila/Clasificar NumeroV.py | 558 | 3.765625 | 4 | #9/3/18
def clasificar_numero (num):
if isinstance (num,int):
return clasificar_numero_0y1 (abs(num))
else:
return "Error"
def clasificar_numero_0y1 (num):
if num==1 or num==0:
return "Número Especial"
else:
return clasificar_numero_primo(num,num-1)
... |
bfb181a0f09634f855530926ed571521fb2a0be8 | Yen-US/Introduccion-y-Taller-de-Programacion | /Recursion de Pila/Multiplicación Op 1M.py | 241 | 3.5 | 4 | #7/3/18
def s2(num):
if isinstance (num,int) and (num>0):
return s2_aux (abs(num))
else:
return "Error"
def s2_aux (num):
if num ==0:
return 1
else:
return (3*num-2) * s2_aux(num-1)
|
b934cd7aced852e87ea9c8cb7c5abed746dbd4f2 | mayaradg/loadsmart | /load/utils.py | 448 | 3.859375 | 4 | def calculate_carrier_price(shipper_price):
"""Calculates the carrier price based on the shipper price
The carrier price is the amount of money a carrier will receive if
they accept the load. It is the shipper price minus 5%.
:param float shipper_price: The price defined by the Shipper.
:return: T... |
9d3e69330c9df4b52127281f2b632c3a9550f72e | kazusa4418/PythonTraining | /dict-use.py | 398 | 4.25 | 4 | # 価格表のデータを変数priceに代入
prices = {"バナナ": 300, "リンゴ": 200, "マンゴー": 400}
# リンゴがあるか確認
exist = "リンゴ" in prices
if exist:
print(prices["リンゴ"])
else:
print("リンゴは存在しません")
exist = "マンゴー" in prices
if exist:
print(prices["マンゴー"])
else:
print("マンゴーは存在しません") |
636d227f9d6dc9b0e6c6d28ae4639d9d89d84840 | ThomasZumsteg/adventofcode2020 | /day05.py | 1,404 | 3.59375 | 4 | """Solution to day 5 of Advent of Code"""
from get_input import get_input, line_parser
import math
def binary_search(directions, start, stop):
for d in directions:
if d:
stop = math.floor((stop - start) / 2) + start
else:
start = math.ceil((stop - start) / 2) + start
... |
a3331f713682fc01f9c580192bbecf931e52d5f1 | ThomasZumsteg/adventofcode2020 | /day04.py | 2,135 | 3.71875 | 4 | """Solution to day 4 of Advent of Code"""
from get_input import get_input
from string import hexdigits, digits
def valid(passport, checks):
for field, check in checks.items():
if check is None: # Skip optional fields
continue
if field not in passport or not check(passport[field]):
... |
5286ca7dc181c0e9f01cdfde9568006b6c6df2e5 | ChangePlusPlusVandy/change-coding-challenge-maknight22 | /tweetGuess.py | 3,961 | 3.640625 | 4 | # Made by michael knight as part of application for Change++ 2020 Fall
# This is a simple python script that gives the users tweets from either kanye or elon and allows them to attempt to
# guess who wrote which tweet
import random
# we will use tweepy to make it easier to interact with the twitter api
import tweepy a... |
211c518faa64f59796dce1734e01b0b23438597d | ecamlioglu/Python-Study-Bootcamp | /Exercises/Exercise-2.py | 1,334 | 4.15625 | 4 | """
-------------------------------------------
This question is second week exercise in
Python Study Bootcamp in Kocaeli University
-------------------------------------------
QUESTION
Albert is studying in high school,
he wants to pass the Geometry Exam.
create an eligible formulas for him
Formulas contains regular... |
f4aa4cf840384aa629536d9c51d8ddaa56fec455 | pauloj626/Python | /math/matplotlib/graficos_aleatorios/test.py | 482 | 3.640625 | 4 | import numpy as np
from math import *
from matplotlib import pyplot as plt
def func1(x, E, m):
beta = 1/E
apha = (2*m*E - 1)/(2*E - 2*beta)
if x <= apha:
return beta*x
elif x < 2*m - apha:
return E*(x - apha) + beta*apha
else:
return beta*(x - (2*m - apha)) + (1 - beta*alpha)
def list_func(X, func, E, m... |
56543401f8fff6de82cf72f6710a4d11cd322f0f | Lz0224/Python-exercise | /lei练习/child.py | 686 | 3.625 | 4 | #!/usr/bin/python
#coding=utf-8
class ParentClass(object):
"""docstring for ParentClass."""
name = "老张"
# def __init__(self, arg):
# super(ParentClass, self).__init__()
# self.arg = arg
def fun(self):
print "老子有钱"
class ChildClass(ParentClass):
"""这是什么玩意。。。。"""
# def _... |
866f5f797731e3fb48d60df8f1a1f5e75a070dde | Lz0224/Python-exercise | /python老师/for.py | 353 | 3.828125 | 4 | #!/usr/bin/python
for i in [1,2,3,4,5]:
print i,
print ""
for i in (1,2,3,4,5):
print i,
print ""
for i in {1,2,3,4,5}:
print i,
print ""
for i in "hello world":
print i,
print ""
for i in {'a':1,'b':2,'c':3,'d':4}:
print i,
print ""
# for 1 in []:
# print "anything"
sum = 0
for i in rang... |
61ad153949468a1e222f68bb5f48c8c5603a5ea7 | Lz0224/Python-exercise | /jichu练习/3ci.py | 1,472 | 3.765625 | 4 | #!/usr/bin/python
#coding=utf-8
# a = 4
# n = 3
# if循环方法
# i = input('Please num:1~9 ')
# if i == a :
# print "very good"
# elif i != a:
# i = input('Please num:1~9 ')
# if i == a :
# print "very good"
# elif i != a:
# i = input('Please num:1~9 ')
# if i == a :
# ... |
a4d118f8dab2fb4b195e585619db1525fee4d63f | Lz0224/Python-exercise | /python老师/fun5.py | 323 | 3.5625 | 4 | #!/usr/bin/python
#coding=utf-8
#定义位置参数的函数
def fun(a,b):
print a,b
fun(1,2)
#设置参数默认值
def fun1(a,b = 100,c = 10):
print a,b
fun1(1)
# 定义收集参数的函数
def fun2(*a):
print a
fun2(1,2,3,4,5)
# 收集字典参数
def fun3(a):
print a
fun3(a = 1,b = 2,c = 3)
|
013dd27743ac6f14a139e25facda1f36cbd87ea7 | July523/Daily_Test | /wtf_python/test8.py | 815 | 3.78125 | 4 | # coding=utf-8
# @Time :2018/12/16 17:56
"""
A tic-tac-toe where X wins in the first attempt!/一蹴即至!
具体参考:
https://github.com/leisurelicht/wtfpython-cn?utm_source=
qq&utm_medium=social&utm_oi=950291290743590912#structure-of-the
-examples%E7%A4%BA%E4%BE%8B%E7%BB%93%E6%9E%84
"""
# 我们先初始化一个变量row
row = [''] * 3 # row ... |
693351302ccc83b5f86b4fa170a5ff013bcd4c5f | ray-dino/tensorflow_mnist_tutorials | /tutorial.py | 1,209 | 3.671875 | 4 | import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
# load example data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
# create placeholder
x = tf.placeholder(tf.float32, [None, 784])
# create Variables filled with zeros
W = tf.Variable(tf.zeros([784, 10]))
b = tf.Vari... |
ecca45b2aa3fa36f594deba0059a2c3be169b8f4 | usernameAdri/die-Dorfbewohner-REAL | /Kaptn.py | 2,228 | 3.640625 | 4 | import random
import time
print("arrrrrgghh ich bin Käptn Hook und denke an eine Zahl, wenn du sie errätst, kriegst du einen Schatz! du hast nur 6 Versuche.\n")
time.sleep(0.5)
Zahl=int(input("Wähle eine Zahl zwischen 1-100\n"))
if pirat==Zahl:
print("DU HAST DIE BEUTE ERLANGT!!! ARRRGGGGGHHH"),exit()
if... |
6e0ad60f5c4d08e58ec104beb3ac75e592a9d8cf | AparnaVivekanandan18/Distributed-DBMS | /5408Project/DBMS_Software/Serverless/GoogleFunction.py | 1,576 | 3.71875 | 4 | import math
import re
from collections import Counter
import csv
WORD = re.compile(r"\w+")
def get_cosine(vec1, vec2):
intersection = set(vec1.keys()) & set(vec2.keys())
numerator = sum([vec1[x] * vec2[x] for x in intersection])
sum1 = sum([vec1[x] ** 2 for x in list(vec1.keys())])
sum2 = sum([vec2[x... |
119d7b9f11e6e139b99cedce2df57c98098b3f35 | accountos/python- | /4.10.1逗号代码.py | 305 | 3.65625 | 4 | def tostring(param):
res = ''
for i in range(len(param)):
if i == 0:
res += str(param[i])
elif i == len(param)-1:
res += ', and ' + str(param[i])
else:
res += ', ' + str(param[i])
return res
print(tostring(['apple', 'pie', 0, 1]))
|
e5af1c34773ec420f456b39b0f98e616c3956bce | madrascode/basic-python-code | /Native-Datatypes/add_two_matrices.py | 787 | 3.78125 | 4 | X = [[12, 7, 3],
[4,5,6],
[7,8,9]]
Y = [[5,8,1],
[6,7,3],
[4,5,9]]
result = [[0,0,0],[0,0,0],[0,0,0]]
# print(len(X))
# print(len(X[0]))
for i in range(len(X)):
for j in range(len(X[0])):
result[i][j] = X[i][j] + Y[i][j]
for i in result:
print(i)
# comprehension_result = [[X[i][j]+Y[i... |
438cd1526f0a2b27cfd03abe5bca7cbba43683d9 | madrascode/basic-python-code | /binary_search_tree/running_sum.py | 192 | 3.6875 | 4 | def running_sum(nums):
result = []
sum = 0
for i in nums:
sum += i
result.append(sum)
print(result)
running_sum([1,2,3,4]) |
8f93ee5531893403094f157e8633d9cb449d6593 | madrascode/basic-python-code | /binary_search_tree/linear_search.py | 949 | 4.28125 | 4 | # linear search program using for loops
def traverse_cards(list_of_cards, target):
for i in range(len(list_of_cards)):
# print(list_of_cards[i])
if list_of_cards[i] == target:
return i
else:
return -1
# linear search program using while loops
def locate_cards(list_of_cards, ... |
d8114c060bc7b1a18d368f4390be96939e415463 | madrascode/basic-python-code | /loops&ifelse/prime_interval.py | 479 | 3.953125 | 4 | def prime_interval(lower, upper):
for num in range(lower, upper+1):
if num > 1:
for i in range(2, num):
if num % i == 0:
# print(str(i)+" times "+str(num//i)+" is"+ str(num))
# print("Not Prime")
break
else: ... |
4c6ac41aa41765f99a1a9930b1b0ebae3facaf27 | madrascode/basic-python-code | /loops&ifelse/leapyear.py | 403 | 4.28125 | 4 | def leap(num):
if num % 4 == 0: # Then its an LEAP Year
if num % 100 == 0: # if its an century then its not Leap Year
if num % 400 == 0: # if that century is 4th century then its leap year
print('Leap Year')
else:
print("Ordinary Year")
else:
... |
483410d4178f0592b6115280cebb242311d9b8d1 | hyewon0214/hyewon | /0628.py | 4,154 | 3.75 | 4 | def defangIPaddr(address):
a=""
for i in address:
if i == '.':
a+='[.]'
else:
a+=i
return a
#print(defangIPaddr('255.100.50.0'))
def numJewelISInStones(jewels,stones):
return sum(stones.count(j) for j in jewels)
#print(numJewelISInStones('aA','aAAbbbb... |
b2be84c7705e15eec5c0393890b462ef12572958 | hyewon0214/hyewon | /0626.py | 697 | 3.6875 | 4 | def twoSum(num, target):
dic={}
for i in range(len(num)):
value=target-num[i]
if value not in dic:
dic[num[i]]=i
elif value in dic:
return [dic[value],i]
#print(twoSum([3,2,4],6))
def moveZeroes(nums):
c=0
for i in range(len(nums)):
i... |
01aac5f6132dea0d8f756db0ad9baa7530d7367e | johnmorgan123/python_projects | /pythonDecsAndMore/generators.py | 406 | 3.90625 | 4 |
def create_cubes(n):
for x in range(n):
yield x**3
list(create_cubes(10))
def gen_fibon(n):
a = 1
b = 1
output = []
for i in range(n):
output.append(a)
a, b = b, a+b
return output
for number in gen_fibon(10):
print(number)
def simple_gen():
for x in range... |
b7d82cdab53c5eb61491f088052740d782c65b1c | skrulcik/MatrixModifier | /MatrixHelper.py | 8,051 | 4.59375 | 5 | #/bin/python
import string
from Matrix import *
alpha_index = 0 #Used in generating names for new matrices
def defaultName(length=1):
chars = string.ascii_uppercase
name = ''.join()
return random.choice(chars)
# TODO:add help text for other commands
help_texts = {"welcome":"\n\n Welcome to Matrix Helper \... |
786d8bbae5569ce430e4883c0cc07e188d8893e2 | JItinkumarIT/programing-questions | /p24 sum of natural number.py | 263 | 4.21875 | 4 | #wap to find the sum of natural number up to num
num=int(input("enter the natural number:"))
if num<0:
print("enter a positive number")
else:
sum=0
while(num>0):
sum+=num
num-=1
print("the sum is",sum)
|
ffa789b70d22da43a5db8691f36107a2d018afa0 | JItinkumarIT/programing-questions | /p9 string define.py | 322 | 3.890625 | 4 | #String is a collection of character
#string is an immutable datatype
#Character consist Alphabet , Digit ,and Special character.
fname='Jitin'
print(fname)
lname='Kumar'
print(lname)
fullname=fname +' '+ lname
print(fullname)
#for length
length=len(fullname)
print=('length',length)
fullname=fullname ... |
c92493295cb67bf001fdf16b5b1f74a2c14849b2 | jdblackstar/Sprint-Challenge--Algorithms | /recursive_count_th/count_th.py | 817 | 4.21875 | 4 | '''
Your function should take in a single parameter (a string `word`)
Your function should return a count of how many occurences of ***"th"*** occur within `word`. Case matters.
Your function must utilize recursion. It cannot contain any loops.
'''
def count_th(word):
# TBC - one base case is if len(word) < 2, ca... |
caab93ec70ca356e7617984eb4dc1568db50f8c9 | dhar174/scripts_for_rhyme_courses | /elu.py | 537 | 3.515625 | 4 | import numpy as np
import matplotlib.pyplot as plt
import sys
# ELU:
def ELU(x,a=.01):
x1=[]
for i in x:
if i<=0:
x1.append(float(np.exp(i)-1))
else:
x1.append(i)
return x1
# ELU derivative:
def ELU_deriv(x):
x1=[]
for i in x:
... |
4b59be29671cb940feeca8831467a605de1d2ac5 | dhar174/scripts_for_rhyme_courses | /gaussian.py | 336 | 3.53125 | 4 | import numpy as np
import matplotlib.pyplot as plt
import sys
def gaussian(x, Derivative=False):
if not Derivative:
return np.exp(-x**2)
else:
return -2 * x * np.exp(-x**2)
x = np.linspace(-10, 10)
plt.plot(x, gaussian(x))
plt.axis('tight')
plt.title('Activation Function :Gaussian... |
e00a28d78d8e115c7f9b9fc1bc3bd4d4a6c55534 | sergiohzlz/ReNeCiencias | /hopfield/discreto_mono.py | 1,389 | 3.578125 | 4 | #!/usr/env python
import numpy as np
from math import tanh
def crea_pesos(V, d, dbg=False):
M = np.zeros((d,d))
for s in range(len(V)):
print "vector ",s,": ",V[s]
v = V[s]
for i in range(len(v)):
for j in range(len(v)):
M[i,j] += (2*v[i]-1)*(2*v... |
0408e2c1a894abfef57949c11ee1f442dd4a1544 | ekeneakali/weekend-class | /day3/classvar_instance.py | 535 | 3.84375 | 4 | class Employee():
pay_rise = 0.05
#constructor method in class
def __init__(self, firstname, lastname, pay):
self.f = firstname
self.l = lastname
self.p = pay
#a class variable which object changes
print('this is a constructor')
#method in class
def details(self):
... |
b560d1a2f514e6bb4de48bb263ea80c9bb45c83b | ekeneakali/weekend-class | /day2/chapter3/ifelse.py | 122 | 3.921875 | 4 | a = 5
b = 10
if a > b:
print('a is greater b')
else:
print('a is not greater than b')
#else run one statement |
c20180d6bd542014f0891d429a8e3f7a349a5a73 | coder-dipesh/Basic_Python | /labwork2/leapyear.py | 257 | 4.0625 | 4 | year=int(input('Enter year to check :'))
if (year%4)==0:
if (year%100)==0:
if (year%400)==0:
print('Leap Year')
else:
print("Not Leap Year")
else:
print("Leap Year")
else:
print("Not Leap Year")
|
4f736eabc14e99df4b91f1786c1f2dc960650999 | coder-dipesh/Basic_Python | /labwork2/sumofthreedigit.py | 569 | 4.15625 | 4 | # '''
#
# Given a three-digit number. Find sum of its digit.
#
# '''
#
# total=0
# three_digit=input('Enter three digit number by seprating with space: ')
#
# digit=three_digit.split()
# print(digit)
#
# for i in range(0,len(digit)):
# digit[i]=int(digit[i])
#
#
# total= total + digit[i]
#
# print(total)
def getSum... |
609d207eb0012ee391961d5e1039e1d675b80af5 | coder-dipesh/Basic_Python | /labwork1/area_of_circle.py | 279 | 4.3125 | 4 | """
Write a Python program which accepts the radius of a circle from the user and compute the area.
(area of circle = PI * r2)
"""
radius = float(input("Enter the radius of circle: "))
area_of_circle = 22/7*(radius**2)
print(f'The total area of circle is {area_of_circle}cm2.')
|
1dd27fc76cff0c37695dea8fe8277a3ad0055bc1 | coder-dipesh/Basic_Python | /labwork2/fractional.py | 253 | 4.375 | 4 | '''
Que.7: Given a positive real number. print its fractional part.
'''
import math
number = float(input('Enter number to get its fractional part: '))
floatt,integerr = math.modf(number)
print(f'{floatt} is the fractional part of given number.')
|
87527a96711f630b76372c70a6055bb755ee1aa0 | ananyanitrr/ML | /First.py | 1,500 | 3.796875 | 4 | import matplotlib.pyplot as plt
import numpy as np
from sklearn import datasets, linear_model, metrics
# load the boston dataset
boston = datasets.load_boston(return_X_y=False)
# defining feature matrix(X) and response vector(y)
X = boston.data
y = boston.target
# splitting X and y into training and testi... |
29dd391323ca51429f3312f13a075a4a5144828d | 13661892653/workspace | /pyCode/oldboy_Oper_14/笔记/Python基础笔记16.py | 4,573 | 3.8125 | 4 | switch (){
case:ddddd:
console.log(ddd);
break;
case:ddddd:
console.log(ddd);
break;
default:
语句;
}
JavaScript
函数
普通函数
function func(arg){
}
匿名函数
没有名字的函数叫匿名函数
... |
9269f016efa70ff1d1b04ac36dbd8c7d242a9730 | gibbstp/project_euler | /Largest Prime Number.py | 676 | 4.03125 | 4 | '''The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?'''
def is_prime(n):
""""pre-condition: n is a nonnegative integer
post-condition: return True if n is prime and False otherwise."""
if n < 2:
return False;
if n % 2 == 0:
... |
c7d8094380179350048a6982a5f383e901e44f50 | cam673/Personal_Projects | /Python/longest_common_prefix.py | 1,180 | 4.125 | 4 | #Longest Common Prefix
#Check to see what the longest prefix within an array of words is
def longestPrefix(words):
result = ""
prefix = ""
accum = 0
base = words[0] #Selected word to grab prefixes from
#pick a word from the list and grab all possible prefixes from it
#Note: you do not have... |
1a386e42a3275f14998488a393e7ed43bb30ab28 | nimitpatel/python-practice | /s183b.py | 175 | 3.515625 | 4 | #s18-3b
myStr = "GTU is the best University"
print(myStr [15 : : 1])
print(myStr [-10 : -1 : 2])
#s18-3b-or
t = (1, 2, 3, (4, ), [ 5, 6] )
print(t[ 3 ])
t[4][0] = 7
print(t)
|
8ca6b2db9da3cb713a5850a7bcdb83abb7609771 | nimitpatel/python-practice | /3 Btn Bg Change.py | 664 | 4.40625 | 4 | '''
Write Python GUI program to create three push buttons using Tkinter.
Background color of a frame should be changed when different buttons
are clicked.
'''
from tkinter import *
tk = Tk()
def red():
f = Frame(tk, bg = "red", width = "100", height = "100")
f.pack()
def green():
f = Frame(tk, bg = ... |
779fde471c4b5e5446ca47257e95196e44b839d9 | OvsyannikovYuri/algoPython | /lesson1Part8.py | 465 | 4 | 4 | # Определить, является ли год, который ввел пользователем, високосным или невисокосным.
a = int(input("введите год в формате ГГГГ"))
if (a%4 == 0):
if (a%400==0) :
print ("високосный")
elif(a%100==0):
print ("невисокосный")
else:
print ("високосный")
else:
print ("НЕВИСОКОСНЫЙ... |
40903f5eebb97e30e3ceb7ef002db9b65a72a975 | Halimeda/Python_Pratice | /Exercices/Exo/ex_2_1.py | 229 | 3.75 | 4 | from random import choice
words = ['disorder', 'enemy', 'humanity', 'is', 'of', 'the', 'true']
message = ""
while len(words) > 0:
word = choice(words)
message = message + " " + word
words.remove(word)
print(message) |
1f659b94cab781130bdca56f9a17d4e24f0ce80e | Halimeda/Python_Pratice | /Exercices/Exo/class_vehicule.py | 1,891 | 3.703125 | 4 | class Vehicle():
def __init__(self, speed):
self.speed = speed
self.distance = 0
def ride(self, duration):
travel = duration * self.speed
self.distance += travel
class Bike(Vehicle):
def __init__(self):
super().__init__(15)
class Car(Vehicle):
def __init__(self)... |
a1c963976a6665f90e9b99ae1d4f1f90735f72f4 | Halimeda/Python_Pratice | /Exercices/Exo/plante_recursive.py | 209 | 3.640625 | 4 | def plant_height(year):
if year == 1:
return 0.8
else:
return plant_height(year - 1) * 1.5
print(plant_height(1))
print(plant_height(2))
print(plant_height(3))
print(plant_height(4)) |
86e8285da1726440a0f30feffeb2cb041ff718c1 | Halimeda/Python_Pratice | /Exercices/Exo/ex_1_1.py | 233 | 3.75 | 4 | from random import choice
characters = ["A", "B", "C", "D", "E", "F", "G"] # liste raccourcie de l'alphabet.
character = choice(characters)
entry = None
while(entry != character):
entry = input("Tapez " + character + ": ") |
5bf4814897b8db01daaf81fde177261673d85a0e | Halimeda/Python_Pratice | /ShiFuMi/main_pierrepapier.py | 1,275 | 3.96875 | 4 | from Player import *
number = int(input("How many players are you ? (1 or 2) : "))
restart = True
if (number%2 != 0):
player = Computer()
player1 = Player(input("Enter a player name : "))
else:
player = Player(input("Enter a player name : "))
player1 = Player(input("Enter a player name : "))
while ... |
ea7ef18c7bd87773511a9d278e56109d0ab64403 | Halimeda/Python_Pratice | /Exercices/Exo/homework_24_01.py | 541 | 3.859375 | 4 | number = int(input("Entrez un chiffre : "))
nbr_list = [number]
how_much = 1
result = number
while result < 20:
number = int(input("Entrez un chiffre : "))
nbr_list.append(number)
result = result + number
how_much += 1
if result >= 20:
for i in range(len(nbr_list) - 1):
big = max(nbr_list[i... |
2d993d4894053f5305a02fc4c5d9fc9005ddc0d7 | dcherry123/CDPythonWorkRepository | /Training/6 Dictionary/6-9_dictionary_favorite_places.py | 1,151 | 4.25 | 4 | # 6-9. Favorite Places: Make a dictionary called favorite_places. Think of three
# names to use as keys in the dictionary, and store one to three favorite places
# for each person. To make this exercise a bit more interesting, ask some friends
# to name a few of their favorite places. Loop through the dictionary, and p... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.