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 |
|---|---|---|---|---|---|---|
611a4cc9ce96fa0ac8639adb5831deeefcdfa78d | mhee4321/python_algorithm | /baekjoon/daily/11729.py | 283 | 3.8125 | 4 | # Hanoi's Top
# F(N) = 2 * F(N-1) + 1
def hanoi(st, ed, num):
if num == 1:
print(st, ed)
return
hanoi(st, 6 - ed - st, num-1) # 1단계
print(st, ed) # 2단계
hanoi(6 - ed - st, ed, num-1) # 3단계
N = int(input())
print(2**N-1)
hanoi(1, 3, N)
|
249fcb3cfb58e7e09469e67b689839aaf855e62a | mhee4321/python_algorithm | /programmers/Level1/pickTwoAndAdd.py | 639 | 3.6875 | 4 | from itertools import combinations
def solution(numbers):
answer = set()
for i in list(combinations(numbers, 2)):
answer.add(sum(i))
return sorted(answer)
a = [2,1,3,4,1]
print(solution(a))
# def solution(numbers):
# answer = list()
# for i in range(len(numbers)):
# for j in ran... |
87d5d26fcb0ca91b096212b7dd4d7f6bbf0bb7c8 | ludwigwittgenstein2/Algorithms-Python | /anagrams.py | 576 | 4.03125 | 4 | #anagrams
def verify_two_strings(str1,str2):
ana_table = {key:0 for key in string.ascii_lowercase}
for i in str1:
ana_table[i] += 1
for i in str2:
ana_table[i] -= 1
if len(set(ana_table.values())) <2:
return True
else:
return False
def test_verify_two_strings():
... |
8123ae338a8e4c11282dce6485f46456497347e3 | ludwigwittgenstein2/Algorithms-Python | /practiceInsSort.py | 449 | 3.96875 | 4 | # -*- coding: utf-8 -*-
"""
Author: Rick Sam
Book: Algorithms Python
Date: September 29, 2016
"""
def ins_sort(seq):
"""This is DocString –– Insertion sort function for file."""
for i in range(1, len(seq)):
j = i
while j > 0 and seq[j-1] > seq[j]:
seq[j-1], seq[j] = seq[j], seq[j-1... |
f064dfcc3a0fbb5a2aeab5205e1ac1a4ccd5d611 | ludwigwittgenstein2/Algorithms-Python | /debug1.py | 1,072 | 3.75 | 4 | import random
one = 0
two = 0
three = 0
four = 0
five = 0
six = 0
seven = 0
eight = 0
nine = 0
ten = 0
count = 0
while count < 10:
random_list = random.randint(1, 10)
print random_list
if random_list == 1:
one += 1
elif random_list == 2:
two += 1
elif random_list == 3:
thr... |
590d2a95134fe2f3d2962f4b7a4d8671f09fe759 | ludwigwittgenstein2/Algorithms-Python | /practiceBinarySearch.py | 1,719 | 3.890625 | 4 | # -*- coding: utf-8 -*-
"""
Author: Rick Sam
Date: September 27
Program: Binary Search
Comments: Frustrated on Algorithms -_- However, I was thinking of relying on God and not on myself,
sounds silly but think about this, What if tomorrow you don't wake up? I mean, we live our life as
if nothing... |
9f3a526f6f5f64a7e88c5378d84ab1e67309502a | ludwigwittgenstein2/Algorithms-Python | /segment2[total].py | 427 | 3.890625 | 4 | #Segment 2, Find out Revenue of store
# So, first, I go to the column 5, and then store it as a List
def total_revenue():
empty_list = []
with open('\Users\Rick\Desktop\sample_data.csv', 'r') as w:
next(w)
data = csv.reader(w, delimiter=',')
for row in data:
if row[5] not i... |
6fa8da3bb7546224f005b9ec464424679aa31dbc | ludwigwittgenstein2/Algorithms-Python | /programTower.py | 359 | 3.6875 | 4 | """ Author:Rick Sam
Comment: Tower of Hanoi """
def moveTower(height,fromPole, toPole, withPole):
if height >= 1:
moveTower(height-1, fromPole, withPole, toPole)
moveDisk(fromPole,toPole)
moveTower(height-1, withPole, toPole,fromPole)
def moveDisk(fp, tp):
print("moving disk from",... |
a60003858297af2148261cf7fbbfb3282c6c6f22 | ludwigwittgenstein2/Algorithms-Python | /programTestBubbleSort.py | 583 | 4.0625 | 4 | def bubble_Sort(item):
"""Bubble Sort is cool"""
print "The item before sorting:", item
for i in range(len(item)):
print "The first loop of i:", i
for j in range(len(item)-1-i):
print "The second loop of j:", j
if item[j] > item[j+1]:
print "The item ... |
42f2b0395e9eb10951a42b4bba6ea45a121f0a89 | ludwigwittgenstein2/Algorithms-Python | /VimPrograms/gnome_sort.py | 523 | 3.796875 | 4 | """
# Author: Rick
# Date: June 16, 2017
# Purpose: Gnome Sort in real world
# Name: Gnome Sort
[Pot7], [Pot1], [Pot2], [Pot5], [Pot4], [Pot 6], [Pot3]
Comparions - (n-1), so comparions = 6
Gnome Sort
"""
def Gnome_sort(seq):
i = 0
while i < len(seq):
if i == 0 or seq[i-1] < seq[i]:
i = i... |
22a659f5c8a04d92cc0571059fc255677b185d61 | ludwigwittgenstein2/Algorithms-Python | /practiceDictionary.py | 581 | 3.765625 | 4 | #Dictionary
import string
import sys
def count_unique_word():
words = {}
strip = string.whitespace + string.punctuation + string.digits + "\"'"
for filename in sys.argv[1:]:
with open('/Users/Rick/Desktop/checklist.yaml', 'r') as w:
for line in file:
for word in lin... |
86639d8b4616558b54fc4979b056d2bf5e0d544c | ludwigwittgenstein2/Algorithms-Python | /Quadratic-Practice:Algorithm.py | 766 | 3.921875 | 4 | #numpy
from random import randrange
seq = [randrange(10**10) for i in range(100)] # So this is creating a list with 100 random variables
# For example, [100,105,205, 2005... until 100]
dd = float("inf") # This is converting string to float, but what's the float value of inf? It shows inf?
for x in seq: # This is taking... |
dec3727194f0f991899fc2ac4dc890c7d52f086d | ludwigwittgenstein2/Algorithms-Python | /aiden.py | 138 | 3.75 | 4 | list_1=['David', 'Harold', 'Samuel', 'Ravi', 'Dan']
for value in list_1:
print value,' this is at ',list_1.index(value),'th position' |
6979073d91f2942ef8814001f8fa8c65424c6f9f | ludwigwittgenstein2/Algorithms-Python | /segment1.py | 624 | 3.515625 | 4 | #Segment 1
import csv
with open('/Users/Rick/Desktop/transaction_data.csv', 'rb') as f:
next(f) # Remember Rick, this is to skip headers
household_purchase = {}
household_list = []
data = csv.reader(f, delimiter=",")
for row in data:
if row[1] not in household_purchase:
household_purchase[row... |
4c1522a26bf3229bc112a37d81595a3321da1782 | ludwigwittgenstein2/Algorithms-Python | /ProgramBinarySearch.py | 506 | 3.859375 | 4 | """Author: Rick Sam
Date: Oct 10, 2016
Comments: Binary Search"""
def binarySearch(aList, item):
first = 0
last = len(aList)-1
found = False
while first <= last and not found:
mid = (first+last)//2
if aList[mid] == item:
found = True
else:
if it... |
fadad43d852a969082550097cf68f0ff23146689 | rivet9658/Rivet9658-Python-University-Works | /Python練習2/python練習2-例題4.py | 411 | 3.75 | 4 | #練習2-例題4
i=input("輸入16進位1~F的數字")
if i=="A":
print(i,"的十六進位值是10")
elif i=="B":
print(i,"的十六進位值是11")
elif i=="C":
print(i,"的十六進位值是12")
elif i=="D":
print(i,"的十六進位值是13")
elif i=="E":
print(i,"的十六進位值是14")
elif i=="F":
print(i,"的十六進位值是15")
else:
print(i,"的十六進位值是",i)
|
6626cc27b8cd0fb44aa658cf215aa65a33c003ad | rivet9658/Rivet9658-Python-University-Works | /Python Final Test/python final test 第三題.py | 226 | 4.125 | 4 | #python final test 第三題
print("輸入字串:")
str=input()
print("輸入要取代的字串:")
ch=input()
print("輸入取代的字串:")
bh=input()
if ch in str:
print(str.replace(ch,bh))
else:
print("not found")
|
0213f1e011b9c50e18abe072dfaec2e9ab33ffc0 | rivet9658/Rivet9658-Python-University-Works | /Python練習1/python練習1-例題5.py | 139 | 3.984375 | 4 | #練習1-例題5:
r,h=eval(input("please input r and h = "))
area=math.pi*(r**2)
volume=area*h
print("area=",area)
print("volume=",volume)
|
05fecaf976a0501368c62efad76e07f2f0472393 | rivet9658/Rivet9658-Python-University-Works | /找質數 二數最大公因數 三數最大公因數 完美數/找質數.py | 223 | 3.734375 | 4 | #找質數
i=eval(input("put a number:"))
e=eval(input("put a number:"))
for k in range(i,e+1):
for x in range(2,k+1):
if k%x ==0 and x!=k:
break
elif k%x ==0 and x==k:
print(k)
|
5b86e62faee5469ffceef20093c98ebe62d59e48 | rivet9658/Rivet9658-Python-University-Works | /階梯排列 二數最小公倍數 質數加總/二數最小公倍數.py | 300 | 3.59375 | 4 | #二數最小公倍數
u=eval(input("put a number:"))
x=eval(input("put a number:"))
great=0
lcm=0
if u>x:
great=u
else:
great=x
while(True):
if((great % u == 0) and (great % x == 0)):
lcm = great
break
great = great + 1
print(u,"和",x,"的最小公倍數是",great)
|
83d057e34a20b289778bbef3d96e73c2d9d7c915 | rivet9658/Rivet9658-Python-University-Works | /Python練習1/python練習1-例題2.py | 145 | 3.90625 | 4 | #練習1-例題2:
r=eval(input("please input a number:"))
import math
s=2*r*math.sin(math.pi/5)
area=((3*(3**0.5))/2)*s**2
print(s)
print(area)
|
cdeb86296556b7ae50cb9fe80868a542d2f79a92 | rivet9658/Rivet9658-Python-University-Works | /Python練習7/python練習7-例題2.py | 147 | 3.5 | 4 | #練習7-例題2
import random
number=[]
for i in range(0,10):
number.append(random.randint(1,100))
set1=set(number)
print(number)
print(set1)
|
901eac536672345c20822ba5524baca8ca57c5dc | mmuarc/AOC2019 | /day1/day1.py | 418 | 3.578125 | 4 | sum = 0
complexsum = 0
file = open("input.txt","r")
line = file.readline()
def complexfuel(fuel):
result = 0
while fuel > 0:
fuel = int((fuel / 3) - 2)
if (fuel < 0):
break
result = result+fuel
return result
while line:
sum = sum + int(int(line)/3) - 2
complexsu... |
92f338911d8c2a8130f3725e6c53ab8c3b5c438c | jeepchenup/LearnPython | /python/day1.py | 7,721 | 4.03125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 第一行注释是为了告诉Linux/OS X系统,这是一个Python可执行程序,Windows系统会忽略这个注释;
# 第二行注释是为了告诉Python解释器,按照UTF-8编码读取源代码,否则,你在源代码中写的中文输出可能会有乱码。
print('hello, python!')
# 遇到都到会输出一个空格
print('The quick brown fox', 'jumps over', 'the lazy dog')
# 输出表达式结果
print('100 + 200 = ', 100+200)
# 输入
name = ... |
d8ca838e737250e107433c0cd070aafcbdd74c56 | Muratozturknl/8.hafta_odevler-Fonksiyonlar | /week8_11_func_ozgunelaman.py | 424 | 4.125 | 4 | # Verilen bir listenin içindeki özgün elemanları ayırıp
# yeni bir liste olarak veren bir fonksiyon yazınız.
# Örnek Liste : [1,2,3,3,3,3,4,5,5]
# Özgün Liste : [1, 2, 3, 4, 5]
def ozgunlist(a):
list = []
for i in a:
if i not in list:
list.append(i)
return list
a = [1,2,2,4,1,4,1029,5,... |
4094daeae1f044f221d4a51c5db8ac56ae8b40d1 | crag-h4k/programming-cheatsheets | /python3_cheatsheet.py | 2,259 | 3.734375 | 4 | from pprint import pprint
#Lambda Functions
# use lambda anon functions as one time use funcs inside other funcs
cubed = lambda x : x * x * x
# Objects
class Dog:
# Constructor
def __init__(self, name = '', breed = '', weight = int(0)):
# Inner function()
def lbs_to_kilos(lbs):
kilos ... |
71a2001e4aa420393b39e2aeee6fa3b537a47019 | beardoll/Code-practice | /min_stack.py | 1,456 | 3.78125 | 4 | """ 题目
定义栈的数据结构,请在该类型中实现一个能够得到栈中所含最小元素的min函数(时间复杂度应为O(1))。
解法:建立一个辅助栈B
a) 当压入元素 <= top(B)时,将该元素压入;
b) 若从A中弹出的元素等于top(B),则将top(B)弹出
c) 若B为空,则往A压入元素时,把该元素也压入B中
"""
class Solution:
def __init__(self):
self.stackA = []
self.stackB = []
def push(self, node):
# write code here
self.... |
3d9dea748d1f933fb8738d5859861513b2c548c0 | beardoll/Code-practice | /max_value_in_window.py | 2,403 | 3.890625 | 4 | """ 题目
给定一个数组和滑动窗口的大小,找出所有滑动窗口里数值的最大值。例如,
如果输入数组{2,3,4,2,6,2,5,1}及滑动窗口的大小3,那么一共存在6个滑动窗口,他们的最大值分别为{4,4,6,6,6,5};
针对数组{2,3,4,2,6,2,5,1}的滑动窗口有以下6个:
{[2,3,4],2,6,2,5,1}, {2,[3,4,2],6,2,5,1}, {2,3,[4,2,6],2,5,1},
{2,3,4,[2,6,2],5,1}, {2,3,4,2,[6,2,5],1}, {2,3,4,2,6,[2,5,1]}。
思路:滑动窗口应当是队列,但为了得到滑动窗口的最大值,队列序可以从两端删除元素,因此使用双... |
ab69ccedd5c84cba9cb51b44289e1ee24b522151 | wzhang62/hello-world | /test_hw1.py | 586 | 4.03125 | 4 | def classify_triangle(a,b,c):
if a == b or a == c or b == c:
if a == b == c:
return print('equilateral triangle')
return print("isosceles triangle")
if a**2 + b**2 == c**2 or a**2 + c**2 == b**2 or b**2 + c**2 == a**2:
return print("right triangle")
if a != b != c:
... |
cb233a5991440de89e2221b596146f213b382630 | evgenii-eremeev/euler_project | /helpers/primes.py | 860 | 3.96875 | 4 | def make_primes(limit, sieve_len=2000000):
"""
Returns prime list up to the limit.
"""
sieve = [1] * sieve_len
primes = []
current_prime = 2
while len(primes) < limit:
if sieve[current_prime]:
primes.append(current_prime)
for multiple in range(current_prime**2... |
557c1eb5cbcc92e74519539d98187a5b1528d6dc | SmashAF/Random_Code_Storage | /weekly_challenges_completed.py | 26,637 | 4.0625 | 4 | '''
WCC: February 1st, 2021
'''
# def quad_solver(a ,b, c, x):
# return (a*x**2 + b*x + c)
# def mult_table(x):
# table = []
# for col in range(1, x+1):
# using = []
# for row in range (1, x+1):
# using.append(col * row)
# table.append(using)
# return... |
1d51c2453ea585443672286e5abc0b1e2b0d48cd | syqu22/python-turtle-geometry | /project/shapes/scalene.py | 558 | 3.53125 | 4 | from .shape import Shape
class Scalene(Shape):
def __init__(self, size, pos, color, fillcolor, pen_size, angle):
super().__init__(size, pos, color, fillcolor, pen_size)
self.angle = angle
#Get Bob from parent class
self = super().get_turtle()
print(f"Bob {Shape.id} on duty,... |
85447fce06bfb279be58d9e865fb4e006cb68bef | juanmarcoscabezas/holbertonschool-higher_level_programming | /0x03-python-data_structures/9-max_integer.py | 232 | 3.828125 | 4 | #!/usr/bin/python3
def max_integer(my_list=[]):
if len(my_list) == 0 or not my_list:
return None
max_val = my_list[0]
for item in my_list:
if item > max_val:
max_val = item
return max_val
|
e05b380f577208e1df340765ae6a0232b7c5b7f4 | Katezch/Python_Fundamentals | /python_fundamentals-master/02_basic_datatypes/2_strings/02_07_replace.py | 382 | 4.34375 | 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
'''
s = input(" please input words here: ")
symbol = input("please ... |
d2e10036bf49dcd494ca91b22389794a70060ac4 | Katezch/Python_Fundamentals | /python_fundamentals-master/03_more_datatypes/3_tuples/03_12_list_to_tuple.py | 132 | 3.625 | 4 | '''
Write a script that takes a list and turns it into a tuple.
'''
list_ = [5, 6, 8, 9, 0]
tuple_ = tuple(list_)
print(tuple_)
|
8b8af177b6a6b2af1f96d5d9c75d7b166f1e15ab | Katezch/Python_Fundamentals | /python_fundamentals-master/07_classes_objects_methods/07_01_car.py | 852 | 4.4375 | 4 | '''
Write a class to model a car. The class should:
1. Set the attributes model, year, and max_speed in the __init__() method.
2. Have a method that increases the max_speed of the car by 5 when called.
3. Have a method that prints the details of the car.
Create at least two different objects of this Car class and dem... |
2229e6351b717d196d6f56c19cdf8fe6a7821fe4 | bikashkarmokar/tdd_and_pytest | /arithmatic_function.py | 157 | 3.703125 | 4 | def is_multiple_of_five(num):
is_fact = False
if num > 0 and num % 5 == 0:
is_fact = True
return is_fact
def inc(x):
return x + 1
|
0e1f4a53457d5f74430972d5b6ca94bb9be95e67 | ai-se/leaner | /src/skiplist.py | 2,266 | 3.65625 | 4 | from random import randint, seed
class SkipNode:
"""A node from a skip list"""
def __init__(self, height = 0, elem = None):
self.elem = elem
self.next = [None]*height
class SkipList:
def __init__(self):
self.head = SkipNode()
self.len = 0
self.maxHeight = 0
... |
9ad5d79088608071553baff0f99640ef7f3f9f98 | ardyadipta/melek-for-member | /5. MFM_Python 1/dasar/whileloops.py | 76 | 3.59375 | 4 | a = 0
b = 10
while a < b:
print "a = %d" %(a)
a = a+1 #update a value
|
db52ecf9a1a51ba08d75dcfb51780dfb18190970 | quyentruong/InterviewQuestion_Python | /CheckPermutation/Solution.py | 816 | 4.03125 | 4 | # Quyen Truong
# 11/16/2016
# Given two strings, write a method to decide if one is a permutation of the other.
def check(a, b):
# Check if two strings have same length
if len(a) != len(b):
return False
# Create list ASCII
letter = [0] * 128
# Store each char of string a in the list ASCII... |
9ea3bc680f3f2dd1667d852aa974c8a95fb9858b | 161996gk/Practice | /CheckPrimality.py | 183 | 3.984375 | 4 | a=int(raw_input("Enter no.1: "))
b=0
for i in range(1,a+1):
if a%i==0:
b+=1
if b==2:
print "%d is a Prime Number" %(a)
else:
print "%d is not a Prime Number" %(a)
|
7743137a02672081bd72d706b1d25f24fbe5520d | Ravinderbaid/interviewbit | /Day25/MergeOverlapping.py | 843 | 3.703125 | 4 | # Definition for an interval.
# class Interval:
# def __init__(self, s=0, e=0):
# self.start = s
# self.end = e
class Solution:
# @param intervals, a list of Intervals
# @return a list of Interval
def merge(self, intervals):
intervals.sort(key=lambda x: x.start)
... |
e3f96b6194f11e0ea450fafe181c6e81356a290c | davidmdown/2017_Robot_Code | /rotate.py | 1,747 | 3.65625 | 4 | '''Note the Rotate method constructor takes the input degrees.
This is the amount that the robot is to rotate in dewgrees
counter clockwise. If the input value of degrees is negative then
the robot will rotate in a clockwise direction by an amount equal
to the absolute value of degrees.'''
from wpilib.command import ... |
1886ff0f957461299ec1cebabf14d69197aee750 | vadimadr/python-algorithms | /algorithms/graph/problems.py | 3,790 | 3.578125 | 4 | from collections import deque
from algorithms.graph import Graph
from algorithms.graph.searching import dfs_iter, restore_path
def find_cycle(g: Graph, v, p=None, c=None):
"""Find first cycle"""
if p is None:
p = [-1] * g.order()
c = [0] * g.order()
c[v] = 1
for u in g.successors(v,... |
6ba755b9b518ef5df74320d30852bc3a4b3ff1d3 | nietiadi/svm4r | /clauses.py | 3,080 | 3.84375 | 4 | #!/usr/bin/python3
# Generate all possible clauses
import sys
from pprint import pprint
import itertools
def generate_all_possible_clauses(num_of_prop=2):
"""
format:
p1's value,p2's value
0,0 => empty clause
1,2 => p1 v ~p2
return an object of itertools.product
"""
# return itertools... |
f6a0e67c717db0dfe0b30b76dd632fbbbd550670 | nietiadi/svm4r | /prime_numbers.py | 1,150 | 3.640625 | 4 | import math
prime_numbers_100 = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307,... |
14d06fa26fb51aecf4a59fa232e410742d8c0487 | nietiadi/svm4r | /old/proving.py | 1,023 | 4.125 | 4 | #!/usr/bin/python3
"""
using ctl-rp to prove all proofs and give the answer, which is either 'sat' or 'unsat'
"""
import itertools
import csv
def proving(num_of_propositions=2, with_empty_clause=False):
"""
create the csv file containing the results from ctl-rp
"""
if with_empty_clause:
fname = 'data/pro... |
5faebf21fd086852609d9db2f0b9271a90af5f4e | farhantjan/PRAKTIKUM4 | /code4.5.py | 304 | 3.5625 | 4 | buah=["Durian","Mangga","Rambutan"]
print(buah)
buah.append("Anggur")
print("Setelah ditambah :", buah)
buah.insert(0, "Pepaya")
print("Setelah ditambah :", buah)
buah.remove(buah[1])
print("Setelah dihapus [1] :", buah)
buah.remove("Anggur")
print("Setelah dihapus (Anggur) : ", buah)
|
a11c1a0f45c375a47979f736522c93bfe220397f | GrupoCinco/Paradigmas-y-Lenguajes | /Ejemplos-POO/Poligonos.py | 1,476 | 3.859375 | 4 | #!/usr/bin/env python
"""Poligonos.py: Un ejemplo sobre clases en Python."""
__author__ = "Flores Facundo"
__email__ = "flores.facundogabriel@exa.unsa.edu.ar"
__status__ = "Prototype"
import math
from random import randint
class Punto:
def __init__(self, x, y):
self.x = x
self.y ... |
f1960eabdebc92d2ffa2c21943a6c7c4a6cbdae3 | heriky/CS231n | /JianBo/assignment1/myQ1/numpyTest/numpyLearn.py | 970 | 4.09375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by wjbKimberly on 17-10-20
import numpy as np
#create normal array
a=np.array([1,2,3])
print(type(a))
print(a.shape)
print(a[0],a[1],a[2])
a[0]=5
print(a)
b=np.array([[1,2,3],[4,5,6]])
print(b.shape)
print(b)
#create special array
a=np.zeros((2,2))
print (a)
... |
ff7d9accd0778d062ad2bf27675662c62603c934 | j3camero/squad-league | /bradley_terry.py | 3,218 | 3.578125 | 4 | import csv
import random
# The classic Bradley-Terry model.
# a - the skill level of player A.
# b - the skill level of player B.
# Returns True if A wins, False if B wins. The random probability is based on
# a coin flip with probability p = a / (a + b). There are no draws allowed; one
# player or the other must ... |
d7863bb0898d25e12668124d5dd706e063d6aabf | msaadq/stackoverflow-site-scraper | /src/so_scraper.py | 3,026 | 3.53125 | 4 | import requests
from lxml import html
class so_scraper:
base_url = "https://stackoverflow.com" # Base URL for the SO website
login_url = base_url + "/users/login" # Login page URL
session_request = [] # Independent instance of a web session request
credentials = [] # Dictionary of login credential... |
4c047afe1081ccd63fd380f1e106cae07493c6b3 | ale-river/election-analysis | /PyPoll.py | 6,707 | 4.0625 | 4 | # Election_Analysis Project
"""PyPoll Homework Challenge Solution."""
# 1. Total number of votes cast
# 2. A complete list of candidates who received votes
# 3. Total number of votes each candidate received
# 4. Percentage of votes each candidate won
# 5. The winner of the election based on popular vote
# 6. The vote... |
2a53780d99bc1664c64a03aaa0ff8ae8eaf7ddf6 | rtejaswi/python | /pat2.py | 328 | 3.578125 | 4 | n=5
for i in range(1,n+1):
k=ord('A')
b=2
for j in range(1,n+1):
if i>=j:
if j%2==0:
print(b,end=' ')
b+=2
else:
print(chr(k),end=' ')
k+=2
else:
print(' ',end=' ')
print()
... |
caa45bf56cd1b83f43c9ee05ebd9c618b74f8527 | rtejaswi/python | /rev_str_loop.py | 794 | 4.34375 | 4 | '''str = "Python"
reversedString=[]
index = len(str) # calculate length of string and save in index
while index > 0:
reversedString += str[ index - 1 ] # save the value of str[index-1] in reverseString
index = index - 1 # decrement index
print(reversedString) # reversed string'''
'''str = 'Python' #initial s... |
28a83fae4e7ec13e26de638a2dae6d3de8638c01 | rtejaswi/python | /p2.py | 60 | 3.515625 | 4 | item = [1, 2, 3, 4, 5, 7]
for x in item:
print(x * "*")
|
f82fb1b4b61c6f2cdbd945fe80347bcbc830a6a8 | rtejaswi/python | /hello.py | 88 | 3.59375 | 4 | age = 22
name = "tej"
print('name is {a} and the age is {b}'.format(a = name, b = age))
|
4bc1ed3865cd2355558455189184717168c55296 | rtejaswi/python | /totalprac.py | 2,855 | 3.640625 | 4 | #Access specifiers
'''class A:
def __init__(self, a, b, c):
self.a = a
self._b = b
self.__c = c
def disp(self):
print('a is',self.a)
print('b is',self._b)
print('c is',self.c)
class B(A):
def disp(self):
print('a is',self.a)
print('b is',self._... |
e8117f04a269d2410701ab714d99f9717477f83a | nithish-kumar-t/Algorithms-Assignment | /change_dp.py | 975 | 4 | 4 | #Uses python3
'''
It decreases the complexity of changing problem by simply storing intermediate results and using them in the middile.
'''
import sys
from decimal import Decimal
def get_change(m):
#This returns the minimum number of coins required to convert m using [1,3,4] coins
#to change 5 our function re... |
850830934a1083b433e22a685a9e492fb035c183 | AjeetK/prog-lang-popularity-analysis | /tweets_score.py | 2,251 | 3.65625 | 4 | import json
import re
twitter_data_file = 'twitter_data.txt'
#tweets_file = open(twitter_data_file, "r")
with open(twitter_data_file) as tf:
tweets = [json.loads(line).get('text') for line in tf]
print len(tweets)
#### Function to classify the tweets by finding suitable keyword in the tweet
def tweets_related_to(w... |
4c46e1803fb19b102c0099904fca0120810b8f52 | ShreyaR13/CSV_Validator | /rules.py | 2,069 | 3.75 | 4 |
def validate_sales(column_key='total_purchases', **row):
""" This rule validates sale.
'The video must have over 200 sales.'
:rtype: boolean
"""
total_sales = row[column_key]
if total_sales:
if int(total_sales) > 200:
return True
return False
def validate_likes(column_... |
36fb72f8a75e857b634c49efa624c113ab320ffb | atharv21annika/chatbot1 | /main.py | 5,187 | 4.09375 | 4 | print("welcome to the departmental store")
print("please enter your name")
name=input()
print("welcome,",name)
print("which department would you like to visit")
print("1 grocery")
print("2 electronics")
print("3 household items")
choice=int(input())
if choice== 1:
print("welcome to the grocery department")
print("... |
2c68757a26d9817f50229e43e82f112fe5e387ba | valkata1220/Programming-Basics-Python | /05.Nested-Conditional-Statements-Lab/05.invalid_number.py | 101 | 3.546875 | 4 | number = int(input())
if not(number >= 100 and number <= 200) and number != 0:
print('invalid')
|
ef394934fe9866f16ae49c46e9849aaa4cd23636 | valkata1220/Programming-Basics-Python | /01.Simple-Operations-Calculations-Lab/05.trapezoid.py | 125 | 3.65625 | 4 | b1 = float(input())
b2 = float(input())
h = float(input())
trapezoid_area = (b1 + b2) * h / 2.0
print(f'{trapezoid_area}')
|
cffa519c21d744c94245ec8b5ed7ae305df74e27 | valkata1220/Programming-Basics-Python | /10.For-Loop-Exercise/03.odd_even_position.py | 1,155 | 3.953125 | 4 | numbers_count = int(input())
oddSum = 0
oddMin = 'No'
oddMax = 'No'
evenSum = 0
evenMin = 'No'
evenMax = 'No'
current_number = None
for i in range(numbers_count):
current_number = float(input())
if i % 2:
if evenMin == 'No':
evenMin = current_number
evenMax = current_number
... |
e615bc6ff7e40e79126bda673c2d458e96e2b703 | valkata1220/Programming-Basics-Python | /09.For-Loop-Lab/04.max_number.py | 238 | 3.90625 | 4 | numbers_count = int(input())
max_number = int(input())
current_number = None
for i in range(numbers_count - 1):
current_number = int(input())
if current_number > max_number:
max_number = current_number
print(max_number) |
9f13a422dad367a4c90239a537a329468933135c | valkata1220/Programming-Basics-Python | /01.Simple-Operations-Calculations-Lab/07.triangle_area.py | 144 | 3.8125 | 4 | triangle_side = float(input())
triangle_heigth = float(input())
area = triangle_side * triangle_heigth / 2
print(f'Triangle area = {area:.2f}') |
b0646208c655870622627b3713c33e2e5fef602b | valkata1220/Programming-Basics-Python | /07.While-Loop-Lab/02.graduation.py | 222 | 3.78125 | 4 | name = input()
grades = 1
sum = 0.0
while grades <= 12:
grade = float(input())
if grade >= 4:
sum += grade
grades += 1
average = sum / 12
print(f'{name} graduated. Average grade: {average:.2f}') |
f7a3cf0b0c49cbbc4f984ee59bc9da8229f66d2b | valkata1220/Programming-Basics-Python | /01.Simple-Operations-Calculations-Lab/02.inches_to_centimeters.py | 89 | 3.59375 | 4 | inches = float(input())
centimeters = inches * 2.54
print(f'Centimeters = {centimeters}') |
c9ed70cb0116df1175bfa58b700934beba33a073 | valkata1220/Programming-Basics-Python | /10.For-Loop-Exercise/02.half_sum_element.py | 399 | 3.78125 | 4 | numbers_count = int(input())
max_number = int(input())
sum = max_number
current_number = None
for i in range(1,numbers_count):
current_number = int(input())
if max_number < current_number:
max_number = current_number
sum += current_number
sum -= max_number
if sum == max_number:
print(f'Yes\nS... |
644d3db1f4e6cfd13758176f36081f03262bd197 | angie906/likelion_week4 | /quiz4.py | 623 | 3.96875 | 4 | def add(a,b):
print(f"{a}+{b}={a+b}")
def sub(a,b):
print(f"{a}-{b}={a-b}")
def mul(a,b):
print(f"{a}*{b}={a*b}")
def div(a,b):
print(f"{a}/{b}={a/b}")
while(1):
command=input("원하는 숫자를 입력하세요. 1. 더하기 2. 빼기 3. 곱하기 4. 나누기 종료")
if command=='5':
print("종료합니다.")
break
a=int(i... |
8734a5630ae1f5a5d5b20832ea99bda089fe6d89 | DiXionTeil/hw_by_me | /Matzo_python/in_work/sudoku.py | 1,374 | 3.53125 | 4 | import random
cell = 2
def create_line(cell_var):
return random.sample(range(1, cell_var ** 2 + 1), cell_var ** 2)
# print(create_line(cell))
# def mass_9_x_9():
# array = []
# for i in range(1, 10):
# new_line = create_line(cell)
# array.append(dict([('a' + str(i) + '1', int(new_line[0]... |
773e5f7655160283c123262638bd4563d7e8dd8e | DiXionTeil/hw_by_me | /Matzo_python/verified/Yur_Bra_hw09.py | 4,319 | 3.59375 | 4 | import random
# 1st task:
import time
limit_shots = 10
first_value_shots = limit_shots
ras = {'Player 1': '', 'Player 2': ''}
# ────────── * RULES * ────────────
print(f'''
Game:
Two players roll the dices.
The player is win, then who has more victory points from {limit_shots} rolls.
For roll, enter \'\033[1m+\03... |
f6eb1c469be3fc607b2fae6accffda9441392aad | saj1919/botathon_story_game | /syllables.py | 512 | 3.625 | 4 | from utils import possible_phones
import nltk
def syllables(word):
phones_list = possible_phones(word)
if not phones_list:
return []
phones = phones_list[0]
syllables = []
syllable = ""
for phone in phones:
if phone[-1].isdigit():
syllable += phone[:-1].lower()
... |
41461665902333516f96064ed537c8e66c2eab68 | IsaacMagno/python3_curso_em_video | /PythonExercicios/ex061.py | 293 | 3.828125 | 4 | a1 = int(input('Digite o primeiro termo: '))
r = int(input('Digite a razão: '))
c = 1
termo = a1
while c <= 10:
print('{}'.format(termo), end='')
print(' > ' if c < 10 else '', end=''),
termo += r
c += 1
print('\nEsses são os dez primeiros termos da PA solicitada.') |
2bf65e322deb4c7ab575e4b023931ea2f7d8f90e | IsaacMagno/python3_curso_em_video | /PythonExercicios/ex004.py | 310 | 3.75 | 4 | n = input ('Digite algo: ')
print("Isso é um numero:",(n.isnumeric()))
print("É um decimal?",(n.isdecimal()))
print("É uma letra?",(n.isalpha()))
print("Possui letras e números?",(n.isalnum()))
print("Está em maiusculo?",(n.isupper()))
print("Possivel imprimir?",(n.isprintable()))
print(type(n))
|
7fa8011b648d50ec35c8360b339de1edd63cd98c | IsaacMagno/python3_curso_em_video | /PythonExercicios/ex030.py | 159 | 4.0625 | 4 | n = int(input('Digite um número: '))
m = n % 2
if m == 0:
print('O numero {} é PAR!'.format(n))
else:
print('O numero {} é IMPAR!'.format(n))
|
4ec214f9f85bd27d5a9bbbec16928c58467edf35 | IsaacMagno/python3_curso_em_video | /PythonExercicios/ex064.py | 249 | 3.71875 | 4 | n = 0
c = 0
soma = 0
while n != 999:
n = int(input('Digite o numero [999 para parar] : '))
soma += n
c += 1
if n == 999:
soma = soma - 999
print('A soma de todos os {} números foi: {}'.format(c - 1, soma))
|
2580f0510bbb2557837b8872f73d543c7d0e4c98 | IsaacMagno/python3_curso_em_video | /PythonExercicios/ex101.py | 422 | 3.734375 | 4 | def voto(ano):
from datetime import date
atual = date.today().year
idade = atual - idd
if 65 > idade >= 18:
return f'Com {idade} anos: VOTO OBRIGATÓRIO'
elif 16 > idade < 18:
return f'Com {idade} anos: NÃO VOTA'
elif idade >= 65 or 16 <= idade <= 18:
return f'Com... |
1e118739dce7ef7ac75641368fe5513971321a8b | IsaacMagno/python3_curso_em_video | /PythonExercicios/ex068.py | 1,009 | 3.578125 | 4 | from random import randint
print('Vamos jogar PAR ou ÌMPAR?')
wins = 0
while True:
cpu = randint(0, 10)
player = int(input('Digite seu número: '))
ask = str(input('Par ou Ìmpar? [P / I]: ')).upper().strip()[0]
while ask != 'P' and ask != 'I':
ask = str(input('Par ou Impar? [P / I]: ')).u... |
f96605a3d6ac4c7ea26754514118ec17601229ee | IsaacMagno/python3_curso_em_video | /PythonExercicios/ex059.py | 2,058 | 4.0625 | 4 | from time import sleep
print('*' * 15, 'BEM VINDO', '*' * 15)
ask = 0
n1 = int(input('Digite um valor : '))
n2 = int(input('Digite um valor: '))
while ask != 5:
print('''O que você deseja fazer com os valores digitados?
[ 1 ] Somar
[ 2 ] Multiplicar
[ 3 ] Maior
[ 4 ] Digitar novos números
[ 5 ] Sair do p... |
e920e492cb3676f4f0235974554adb192af911bb | IsaacMagno/python3_curso_em_video | /PythonExercicios/ex026.py | 371 | 4 | 4 | text = str(input('Digite uma frase: ')).strip().lower()
print('A letra A aparece {} vezes na frase'.format(text.count('a')))
print('A primeira letra A apareceu na posição {}'.format(text.find('a')+1))
print('A ultima letra A apareceu na posição {}'.format(text.rfind('a')+1))
#igual ao metodo usado na aula, unica ... |
d137148c7b0c92fbd14c2124919e63d90f1b9411 | IsaacMagno/python3_curso_em_video | /PythonExercicios/ex055.py | 410 | 3.828125 | 4 | maior = 0
menor = 0
for kg in range(1, 6):
peso = float(input('Digite o peso da {}ª pessoa: '.format(kg)))
if kg == 1:
maior = peso
menor = peso
else:
if peso > maior:
maior = peso
if peso < menor:
menor = peso
print('O maior peso lido foi ... |
b634cf1c69ad96d653616ba7faa223636cbd1888 | IsaacMagno/python3_curso_em_video | /PythonTeste/aula17c.py | 86 | 3.734375 | 4 | a = [2, 3, 4, 7]
b = a[:]
b[2] = 8
print(f'Lista A: {a}')
print(f'Lista B: {b}')
|
909e65672ac779d00d5a1b204bb31f823beaeb5b | IsaacMagno/python3_curso_em_video | /PythonExercicios/ex089.py | 968 | 3.625 | 4 | alunos = list()
dados = list()
while True:
dados.append(str(input('Nome: ')).strip().title())
dados.append(float(input('Nota 1: ')))
dados.append(float(input('Nota 2: ')))
media = (dados[1] + dados[2]) / 2
dados.append(media)
alunos.append(dados[:])
dados.clear()
ask = ' '
... |
e44722944a0de9dde8cc58d519a55d80bb9d9547 | IsaacMagno/python3_curso_em_video | /PythonExercicios/ex012.py | 186 | 3.59375 | 4 | p = float(input('Digite o preço do produto: R$ '))
n = p*0.95
vd = p*0.05
print('O produdo agora custa: R$ {:.2f}'.format(n))
print('O desconto foi de: R$ {:.2f} '.format(vd))
|
1dd093287267b62b977599e0b32ffba7fad8a2b7 | IsaacMagno/python3_curso_em_video | /PythonExercicios/ex003.py | 177 | 3.875 | 4 | n1 = float(input("Digite um numero: "))
n2 = float(input("Digite um numero: "))
#n3 = float(input("Digite o frete: "))
s = n1+n2
print("O valor da soma é {}".format(s))
|
6cb3b59208e7ebe22969d071d11e9cf05b4d8b59 | IsaacMagno/python3_curso_em_video | /PythonExercicios/ex063a.py | 319 | 3.984375 | 4 | n = int(input('Quantos termos você quer mostrar? '))
t1 = 0
t2 = 1
print('{} > {} > '.format(t1, t2), end='')
cont = 3
while cont <= n:
t3 = t1 + t2
print('{} > '.format(t3), end='')
t1 = t2
t2 = t3
cont += 1
print('Esses são os {} primeiros termos da sequencia Fibonacci.'.format(n))
|
ae08c3beee3159bd8cdd61be9e93db76c0035788 | caroline-pech/Run-Expectancy-Win-Probability-Models | /NLstandings.py | 1,650 | 3.5 | 4 | from bs4 import BeautifulSoup
import urllib2
import re
import csv
# script to scrape ESPN's MLB standings grid and write to csv file the NL standings
# input is current year as a string
def get_NL_standings(year):
csv_filename = 'NL-standings.csv'
url = 'http://espn.go.com/mlb/standings/grid/_/year/' + year
... |
e61bea58637a41824f3f988ae3da1566994cb565 | fkhrrz/Python | /Recur-Multiplier.py | 129 | 3.859375 | 4 | def multiplier(a,b):
if b == 1:
return a
else:
return a + multiplier(a,(b-1))
print(multiplier(8,8)) |
1a228312f6b829e74fb8e18e0dab76d09e2c9557 | herzenuni/modules-packages-itertools-oop-eslutskaya | /game.py | 3,668 | 3.671875 | 4 | ## game.py
## В этом файле будет располагаться класс, в котором
## будет содержаться логика игры
from config import config
from graphics import *
from stats import Stats
from player import Player
import random
class Game:
def __init__(self, whos_turn, path_to_stat_file, field_size, stats = None):
... |
e86194b74c95d315d7f4b3fd8ad22d6997a9a96b | AlbertRessler/itam_python_courses | /homeworks/chapter_1/homework_1_2_2.py | 613 | 3.609375 | 4 | N = int(input())
count_of_trues = 0
count_of_false = 0
count_of_none = 0
for i in range(N):
list = input()
list_splitted = list.split()
if list_splitted.count('True') == 1 and list_splitted.count('False') == 0:
count_of_trues += 1
elif list_splitted.count('True') == 0 and list_splitted.count('Fa... |
9fc3cd7ce4ac456cf36e10f1bf467eebe01026a6 | YannLee1980/yann_python | /assignment/week08/assi_2.py | 740 | 4.09375 | 4 | # 作业二:
# 自定义一个 python 函数,实现 map() 函数的功能。
#考虑接收函数可能会有多个参数的情况:
def mymap(func, *args):
'''
接收的函数参数长度不固定,返回生成器
'''
arg_couplets = zip(*args)
for arg_couplet in arg_couplets:
yield func(*arg_couplet)
#测试:
def test1(a):
return a**2
def test2(a, b):
return a+b
def test3(a, b, c):
r... |
1386f2e04346c0aa224fce2be4e4050f2296d330 | jasperbok/xapy | /xapy/game.py | 1,134 | 3.5625 | 4 | # encoding: utf-8
class Game:
XBOX_360 = 'Xbox 360'
XBOX_ONE = 'Xbox One'
WINDOWS = 'Windows'
UNKNOWN = 'Unknown platform'
def __init__(self, title_id: int, title: str, total_gamerscore: int, current_gamerscore: int,
current_achievements: int, platform: str = UNKNOWN):
""... |
9e88f4f0c7205455a69f5a0522cb2bf14f348d0b | babakmahdavi/HFTE | /HFTEgameWithMarketMaker.py | 10,149 | 3.84375 | 4 | """
Created on Tue Jan 15 21:06:07 2019
Last Update: Friday 29 January 09:17:00 2021
Context: Supporting material for the paper "Guidelines for Building a Realistic Algorithmic Trading Market Simulator for Backtesting while Incorporating Market Impact"
What it does: This is a simplification of the HFT game. We examine,... |
b1fd7b933289c34d84c7776585cf46c367bd772f | ilannd/learningNumpy_Pandas | /Numpy_learning/01BasicOperationOfNum.py | 3,773 | 3.90625 | 4 | import numpy as np
# 不要把文件名命名为numpy
# 两行三列的矩阵
array = np.array([[1, 2, 3],
[2, 3, 4]])
print(array)
print('number of dim:', array.ndim) # 数组的维数
print('shape:', array.shape) # 数组的行列,以元组形式输出 (2, 3)
print('size:', array.size) # 数组元素个数
a = np.array([2, 3, 4]) # 用列表的形式来创建
print(a)
b = np.array([2, 3... |
c3d80c73ead6a69b34a9fb42a9778b11f6754aad | EricaEmmm/CodePython | /LeetCode/Q337_BT_HouseRobberIII.py | 2,839 | 3.5 | 4 | # 打家劫舍 III
# 在上次打劫完一条街道之后和一圈房屋后,小偷又发现了一个新的可行窃的地区。这个地区只有一个入口,我们称之为“根”。
# 除了“根”之外,每栋房子有且只有一个“父“房子与之相连。一番侦察之后,聪明的小偷意识到“这个地方的所有房屋的排列类似于一棵二叉树”。
# 如果两个直接相连的房子在同一天晚上被打劫,房屋将自动报警。
# 计算在不触动警报的情况下,小偷一晚能够盗取的最高金额。
#
# 示例 1:
# 输入: [3,2,3,null,3,null,1]
# 3
# / \
# 2 3
# \ \
# 3 1
# 输出: 7
# 解释: 小偷一晚能够盗取的最高金... |
39635c12231d2afd22ccc24ee94c7be7fbddcb49 | EricaEmmm/CodePython | /NowCoder/input_output.py | 450 | 3.71875 | 4 |
if __name__ == '__main__':
"""输入"""
# 矩阵维度
n, m = map(int, input().split()) # 通过指定分隔符对字符串进行切片,输出是字符串列表,需转化为int
print(n,m)
# 数组
list_in = []
list_in = list(map(int, input().split()))
print(list_in)
# 矩阵
matrix_in = []
for i in range(m): # m行
matrix_in.append(list... |
52e2e83c0b62474742d839853d740707a0b7d12e | EricaEmmm/CodePython | /LeetCode/动态规划_416_分割等和子集_01背包.py | 2,174 | 3.546875 | 4 | '''
给定一个只包含正整数的非空数组。是否可以将这个数组分割成两个子集,使得两个子集的元素和相等。
注意:每个数组中的元素不会超过100,数组的大小不会超过200
示例1:
输入: [1, 5, 11, 5]
输出: true
解释: 数组可以分割成[1, 5, 5]和[11].
示例2:
输入: [1, 2, 3, 5]
输出: false
解释: 数组不能分割成两个元素和相等的子集.
'''
'''
问题转化:给定一个只包含正整数的非空数组,是否可以从这个数组中挑选出一些正整数,
使得这些数的和等于整个数组元素的和的一半。
'''
class Solution(object):
def ca... |
127c612c95ba2c64147dd7d1688693c9e1645fb7 | EricaEmmm/CodePython | /LeetCode/Q153_BS_FindMinimunmInRotatedSortedArray.py | 1,150 | 4.03125 | 4 | # 寻找旋转排序数组中的最小值
# 假设按照升序排序的数组在预先未知的某个点上进行了旋转。
# ( 例如,数组 [0,1,2,4,5,6,7] 可能变为 [4,5,6,7,0,1,2] )。
#
# 请找出其中最小的元素。
# 你可以假设数组中不存在重复元素。
#
# 示例 1:
# 输入: [3,4,5,1,2]
# 输出: 1
#
# 示例 2:
# 输入: [4,5,6,7,0,1,2]
# 输出: 0
class Solution(object):
def findMin(self, nums):
"""
:type nums: List[int]
:rtype: i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.