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 |
|---|---|---|---|---|---|---|
1f1720189686223a6d8c6dc0a93ea768a6ddbe81 | zhaogaofeng/pythonTest | /函数/高级特性.py | 598 | 3.546875 | 4 | from collections import Iterable
L = ('Michael', 'Sarah', 'Tracy', 'Bob', 'Jack')
print(L[-2:])
L = list(range(100))
print(L[:2:5])
print(isinstance("fd", Iterable))
for i, value in enumerate(L):
print(i, value)
for x, y in [(2, 3), (4, 5)]:
print(x, y)
print(range(10))
L = list(range(1, 11))
L = (x... |
2864b9433004e306bef0ccaa1b3315d330410932 | GeorgOhneH/WerbeSkip | /deepnet/layers/activations/leaky_relu.py | 603 | 3.75 | 4 | from deepnet.layers import Layer
import numpywrapper as np
class LReLU(Layer):
"""
Leaky ReLU is an activation function
It behaves like a layer
The shape of the input is the same as the output
"""
def __init__(self, alpha=0.01):
self.z = None
self.alpha = alpha
def forwar... |
236bba6660dbca2eaa34a161b84f14b3260975f5 | GeorgOhneH/WerbeSkip | /deepnet/layers/core/fullyconnected.py | 2,653 | 3.828125 | 4 | from deepnet.layers import Layer
import numpywrapper as np
class FullyConnectedLayer(Layer):
"""
after https://sudeepraja.github.io/Neural/
weight initializer after http://neuralnetworksanddeeplearning.com/chap3.html
The FullyConnectedLayer saves the weights and biases of the layer
As the name ... |
044bcaf6563c135f8e58b75cd25ba2e18312dc78 | GeorgOhneH/WerbeSkip | /deepnet/layers/activations/tanh.py | 528 | 3.65625 | 4 | from deepnet.layers import Layer
import numpywrapper as np
class TanH(Layer):
"""
TanH is an activation function
It behaves like a layer
The shape of the input is the same as the output
"""
def __init__(self):
self.z = None
def forward(self, z):
return np.tanh(z)
def... |
8740ac9f9857af67eda3e8feb4e46919c7b0565a | iiiramal/python-challenge | /PyPoll/.ipynb_checkpoints/main-checkpoint.py | 2,525 | 3.578125 | 4 |
#
import os
import csv
#Declare CVS Path
csvpath = os.path.join(os.getcwd(),'Python Challenge', 'PyPoll','Resources','election_data.csv')
printpath = os.path.join(os.getcwd(),'Python Challenge','PyPoll','Analysis','PollAnalysis.text')
with open(csvpath) as csvfile:
# CSV reader specifies delimiter and variable ... |
dadac8975af6f547ec524245aa1e77e941390c76 | phramos07/taskminer | /tests/temp/rubens/ldp/utils/graph-generator-narytree.py | 601 | 3.828125 | 4 | #!/usr/bin/python
from sys import argv, exit
from random import randint
if len(argv) != 3:
print("%s <arity:int> <height:int>" % (argv[0]))
exit()
N = int(argv[1])
height = int(argv[2])
count = 0
edges = []
stack = [(0, 0)]
while stack:
(label, index) = stack[-1]
if index == N: stack.pop(); continue
count ... |
87470701bf7ac97e3edd933477be0b63e696f424 | Kirank8502/typingspeed | /typingspeed.py | 3,263 | 3.5 | 4 | from tkinter import *
import random
from tkinter import messagebox
##############Root###########################
root = Tk()
root.geometry('800x600+400+100')
root.configure(bg='powder blue')
root.title('Typing speed game')
words = ['Apple','Time','Really','service','order','Little','small','fight','italian'... |
4de7a69cc3d91d2145bdc663fe9613cb622064eb | nadjet/keras-bert | /utils/df_utils.py | 555 | 3.671875 | 4 | from pandas import DataFrame
import pandas as pd
pd.set_option('mode.chained_assignment', None)
def one_to_many(df : DataFrame, column_name):
columns = sorted(list(set(df[column_name].tolist())))
for column in columns:
df[column] = 0
df[column] = df[column].astype(int)
for i, row in df.it... |
4b5e4c6e23a66cd5510accd02b012d7e5fc6ab25 | Kwon1995-2/BC_Python | /chapter3/problem4.py | 870 | 4.0625 | 4 | """사용자로부터 현재 시간을 나타내는 1~12의 숫자를 입력받는다.
또 "am" 혹은 "pm"을 입력받고 경과 시간을 나타내는 값을 입력 받는다.
이로부터 최종 시간이 몇 시인지 출력하는 프로그램 작성 """
c_hour = int(input("Enter the hour : "))
daynight = str(input("'am' or 'pm' : "))
plus_hour = int(input("How many hours ahead? "))
new_hour = c_hour + plus_hour
if daynight == 'am' :
if... |
b9e6f248199d58f6f185160a24febe997becf9e0 | Kwon1995-2/BC_Python | /chapter4/problem3.py | 564 | 4.46875 | 4 | """3명 이상의 친구 이름 리스트를 작성하고
insert()로 맨 앞에 새로운 친구 추가
insert()로 3번째 위치에 새로운 친구 추가
append()로 마지막에 친구추가
"""
friend = ["A","B","C"]
friend.insert(0,"D") #
friend.insert(3,"E")
print(friend)
friend.insert(100, "X") #append와 비슷한 기능
friend.append('a')
print(friend)
# numli = [1,2,3]
# numli.insert(1,17)
# print(... |
e2d3b918735e9376cc3e6e71b6c09e2c251afffd | Kwon1995-2/BC_Python | /chapter3/problem10.py | 732 | 3.828125 | 4 | """반복문과 조건문을 사용해 점수를 계속 입력 받아 90점 이상이면, A
80이상이면 B, 60점 이상이면 C, 40점이상이면 D, 39점 이하이면 F
출력
입력받는 점수가 음수일 때 종료"""
while 1:
score = int(input("Input the score : "))
if score >= 0 :
if score >= 90 :
print("A")
continue
elif score >= 80 :
print("B")
... |
238000878a26755b076e7034d6fdf4bda21066d7 | Kwon1995-2/BC_Python | /chapter4/problem.4.1.11.py | 162 | 3.859375 | 4 | str1 = str(input("Input the string : "))
for i in range(0, len(str1)):
if str1[i] == 'a':
print('e',end='')
else :
print(str1[i],end='')
print("\n")
|
8edcb34c53ab2479656e589eff5e75ba3d463cbc | Kwon1995-2/BC_Python | /chapter5/example5.1.py | 2,694 | 3.953125 | 4 | # def welcome():
# print("hello, everybody!")
# welcome()
##################################
# def prtStr(str):
# print("%s"%str)
# str = "Welcome to Python"
# prtStr(str)
##################################
# def squareArea(s):
# # area = s*s
# # return area
# return s*s
# a = squareArea(5)
# b = squareArea(... |
8fe8a7e6c41cd6010b927577beebb0bd78faefef | Kwon1995-2/BC_Python | /chapter4/problem.4.2.1.py | 312 | 3.828125 | 4 | friend = ['A','B',"C"]
friend.insert(0,'D')
friend.insert(2,"E")
friend.append("F")
print(friend)
num_list = [1,2,3]
num_list.insert(1, 17)
print(num_list)
num_list.append(4)
num_list.append(5)
num_list.append(6)
print(num_list)
del(num_list[0])
print(num_list)
num_list.sort()
num_list[3] = 25
print(num_list)
|
83dc8cec0c931dc505aa1db24a3c72968e2baafd | Kwon1995-2/BC_Python | /chapter2/[Ex]2_3.py | 986 | 3.796875 | 4 | #부울형
# aVar = True
# bVar = False
# print(type(aVar))
# a = 1
# b = 2
# c = a > b
# print(c)
# d= a < b
# print(d)
#정수형
# intVar = 0
# print(type(intVar))
# intVar = 0b110010
# print(type(intVar))
# intVar = 0o1
# print(type(intVar))
# intVar = 0x1
# print(type(intVar))
#실수형
# fVar = 1.0
# print(type(fVar))
# fVar = ... |
d690cb88233e7814d0f84b3d328ab239139702f0 | schiob/OnlineJudges | /hackerrank/algorithms/implementation/sherlock_and_squares.py | 253 | 3.5 | 4 | from math import ceil
from math import sqrt
t = int(input())
for _ in range(t):
x, y = list(map(int, input().split()))
bot_root = ceil(sqrt(x))
count = 0
while bot_root**2 <= y:
count += 1
bot_root += 1
print(count)
|
c82702ec10d3658cf6351e71d23074e94c6fdda0 | schiob/OnlineJudges | /COJ/python/2382.py | 158 | 3.609375 | 4 |
# coding: utf-8
# In[11]:
num = input().split(" ")
# In[16]:
print('YES') if int(num[0], int(num[1])) % int(num[2]) == 0 else print('NO')
# In[ ]:
|
f2bc72233bc9e5f0bd3fd0064707dda8b481b17a | schiob/OnlineJudges | /COJ/python/2699.py | 92 | 3.53125 | 4 | sum = 0
for x in xrange(30):
sum += int(raw_input())
print('%.3f') % (sum / 30.0 + sum)
|
7e3829e573eff90fed0992032bc737f4bcd79dbc | aveusalex/OBI | /Acelerador.py | 244 | 3.921875 | 4 | distancia_percorrida = int(input())
while distancia_percorrida > 8:
distancia_percorrida -= 8
if distancia_percorrida == 8:
print(3)
elif distancia_percorrida == 7:
print(2)
elif distancia_percorrida == 6:
print(1)
|
1a49fc913e65610488f7f497b635b45129023f72 | ryvengray/algorithm_learning | /python/linked_list/merge-k-sorted-lists.py | 1,037 | 4 | 4 | from python.commons.node import ListNode, generate_list_node, print_list_node
from queue import PriorityQueue
# leetcode [23]
class Solution:
# 两数相加
@staticmethod
def merge_k_list(lists: [ListNode]) -> ListNode:
# 傀儡
dummy = ListNode(0)
current = dummy
p = PriorityQueue()... |
1a4f54d3720a86864288b258f1e976e5d4ec3157 | c-elliott96/fall_20_ai | /a01/a01q02/main.py | 759 | 3.828125 | 4 | def move(direction = None, m = None):
space_val = m.index(" ")
n = m[:]
if direction == 'right':
if space_val == len(n) - 1:
return n
else:
temp = n[space_val + 1]
n[space_val + 1] = n[space_val]
n[space_val] = temp
return n
eli... |
63886ae23df34a323359c48f73db96cf125177e5 | c-elliott96/fall_20_ai | /othello-project/testing/test.py | 3,184 | 4.5 | 4 | ## Author: Kevin Weston
## This program will simulate a game of othello in the console
## In order to use it, you need to:
## 1. Import code for your AIs.
## 2. You also need to import a function which applies an action to the board state,
## and replace my function call (main.get_action(...)) within the while loop.
#... |
ec45b798cbfb0053bc23464485d4a38efae8b894 | carlmcateer/lpthw2 | /ex45/Boxing/make_object.py | 1,963 | 3.78125 | 4 | import random
import time
wait_time = .5
class Boxer(object):
def __init__(self, name = '', life = 0, stamina = 0):
self.name = name
self.life = life
self.stamina = stamina
def print_stats(self):
print "name: "+self.name
print "life: "+str(self.life)
print "sta... |
797cdc5d2c7d19a64045bc0fc1864fcefe0633b4 | carlmcateer/lpthw2 | /ex4.py | 1,065 | 4.25 | 4 | # The variable "car" is set to the int 100.
cars = 100
# The variable "space_in_a_car" is set to the float 4.0.
space_in_a_car = 4
# The variable "drivers" is set to the int 30.
drivers = 30
# The variable "passengers" is set to the int 90.
passengers = 90
# The variable cars_not_driven is set to the result of "cars" m... |
41da391efc2d5e51686e56d9f3bb7034670ef74a | gsnelson/censor-dispenser-project | /censor_dispenser.py | 4,127 | 3.90625 | 4 | # These are the emails you will be censoring. The open() function is opening the text file that the emails are contained in and the .read() method is allowing us to save their contexts to the following variables:
email_one = open("email_one.txt", "r").read()
email_two = open("email_two.txt", "r").read()
email_three = o... |
6574d794c152f0cc7a8f7c2193af7483014690a7 | gaochenchao/test | /test.py | 2,403 | 3.671875 | 4 | # -*- coding: utf-8 -*-
class Person(object):
def __init__(self, name, age):
self.name = name
self.age = age
def __cmp__(self, other):
if self.age > other.age:
return 1
elif self.age < other.age:
return -1
else:
return 0
def __r... |
23a0df7b971e178b0fcf59d993247a3b97a3ae96 | gaochenchao/test | /single_list.py | 3,701 | 3.59375 | 4 | # -*- coding: utf-8 -*-
__author__ = 'gaochenchao'
class ListNode(object):
def __init__(self, value, next):
self.value = value
self.next = next
def __repr__(self):
return "[ListNode] %s" % self.value
class LnTool(object):
def __init__(self):
self.head = ListNode(None, ... |
c5a4f56e243b17df1ae3f76c63171b99fb6d8ccd | vincemaling/Full-Stack-Web-Dev-P1 | /movies/media.py | 922 | 4.0625 | 4 | class Movie():
"""This class builds movie information to be displayed in a web browser"""
# Initalizes an instance of Movie
def __init__(self, movie_title, movie_storyline, poster_image, trailer_youtube, imdb_rating, cast):
self.title = movie_title
self.storyline = movie_storyline
s... |
325fcf8ad719e1f728dd4f4b4681e6c6980ef07d | Interligo/tetrika-school-tasks | /task3_appearance_intervals.py | 5,490 | 3.984375 | 4 | import time
def len_is_even(element: list) -> bool:
"""Службная функция для проверки интервалов на четность."""
return len(element) % 2 == 0
def data_is_correct(data: dict) -> bool:
"""Службная функция для проверки переданных данных на корректность."""
if len(data) != 3:
return False
fo... |
0bdde125872c900b739a8f3dfe4a692a4bb374e2 | Rahkeen/Hyperbolic-Time-Chamber | /CTCI/Arrays-Strings/1-7.py | 486 | 3.828125 | 4 | def matrix_rc_zero(matrix):
rows = set()
cols = set()
for col in xrange(len(matrix)):
for row in xrange(len(matrix[0])):
if matrix[col][row] == 0:
rows.add(row)
cols.add(col)
for col in xrange(len(matrix)):
for row in xrange(len(matrix[0])):
... |
6c81cc65adb9651088c975a02cfab4b304bf6187 | INDAPlus20/oskhen-task-15 | /dataguess.py | 1,931 | 3.78125 | 4 | #!/usr/bin/env python3
# Types: stack/queue/prio/not sure/impossible
while True:
try:
n = input()
except:
exit()
if n == "":
exit()
n = int(n)
stack_bag = list()
queue_bag = list()
prio_bag = list()
bagtype = [True]*3
for _ in range(n):
line = lis... |
796e6b1fd24d439e7e29aa2bd6d9bb895f5a316f | manasjainp/BScIT-Python-Practical | /5c.py | 391 | 4.03125 | 4 | """
Youtube Video Link :- https://youtu.be/AB4S9uMpFKY
Write a Python program to sum all the items in a dictionary.
Save File as 5c.py
Run :- python 5c.py
"""
#Method2
dic2 = {'python':90, 'cpp':100, 'java':80, 'php':50}
print("sum is ")
print(sum(dic2.values()))
print()
#Method1
dic1 = {'python':90, 'cpp':100, 'j... |
093233f29bfc50e37eb316fdffdf3a934aa5cea3 | manasjainp/BScIT-Python-Practical | /7c.py | 1,470 | 4.40625 | 4 | """
Youtube Video Link :- https://youtu.be/bZKs65uK1Eg
Create a class called Numbers, which has a single class attribute called
MULTIPLIER, and a constructor which takes the parameters x and y (these should
all be numbers).
i. Write a method called add which returns the sum of the attributes x and y.
ii. Write a class... |
ea5f8250e93c2b98745db0ed964e5dbfb0bcca48 | jimi79/cistercian_clock | /clock.py | 3,257 | 3.625 | 4 | #!/usr/bin/python3
import random
import time
import datetime
class Printer:
def __init__(self):
self.initValues()
def initValues(self):
self.values = []
value = [];
# 0
value.append(' ')
value.append(' ')
self.values.append(value)
value = [];
# 1
value.append(' ')
value.append('¯ ')
self.val... |
6c5ef2ab95ad0bff6989ef33222d174381182bf4 | CameronSCarlin/acute-commute | /QueryMaps.py | 1,753 | 3.578125 | 4 | from datetime import datetime
import googlemaps
import keys
import pprint
from Trip import Trip
class QueryMaps(Trip):
"""
Provides access to Google Maps API.
"""
def __init__(self, start, end, mode, departure_time=None, arrival_time=None):
"""
:param start (str or dict): Start locati... |
5da49d4c685b6a9a0cbdab2a985bf40a6b4e072c | jdavisrader/dealerRater | /review.py | 1,618 | 3.703125 | 4 | class Review(object):
score = 0
def __init__(self, title, rating, review):
self.title = title
self.rating = int(rating)
self.review = review
def score_review(self):
self.score = (self.review.count("wonderful") * 3) + (self.review.count("painless") * 2) + (self.review.count("fant... |
4e1d6e98e53fd8cabfe87651e40ac430f09dde88 | pouerietwilmary/202010451 | /Ejercicio 4.py | 230 | 3.9375 | 4 | # 4 Crear un programa que muestre las letras de la Z (mayúscula) a la A (mayúscula, descendiendo).
import string
def listAlphabet():
return list(string.ascii_uppercase)
print('alfabeto en mayuscula')
print(listAlphabet())
|
e5c32e02bee32823803cbd24ecd90ecd8c39da9f | 510404494/test4 | /booktest/testwo.py | 1,157 | 3.90625 | 4 |
def quick_sort(L):
return q_sort(L, 0, len(L) - 1)
def q_sort(L, left, right):
if left < right:
pivot = Partition(L, left, right)
q_sort(L, left, pivot - 1)
q_sort(L, pivot + 1, right)
return L
def Partition(L, left, right):
pivotkey = L[left]
while left < right:
... |
c71d7f8ce9996471b72e084a237929a7eed0bf18 | abhisheks008/Data-Structure-and-Algorithm-Week-12 | /Week 12 Q5.py | 486 | 3.734375 | 4 | def enqueue (x,y):
global k
if (int(y)>int(k)):
l.append(x)
k = y
elif (int(y)<int(k)):
l.insert(0,x)
k = y
def display():
for j in range (0,len(l)):
print ('{}|{}'.format(l[j],j+1),end = " ")
if (j<(len(l)-1)):
print ("->",end = " ")
i = 0
l... |
c19eeeacd474a323bf38154200bc8a7e73004415 | kimtree/algorithms-and-data-structures | /181003-codeplus/codeplus4.py | 328 | 3.671875 | 4 | import itertools
numbers = [1, 2, 3, 4, 5]
answer = 8
result = set()
combinations = itertools.combinations(numbers, 3)
for c in combinations:
if sum(c) == answer:
result.add(c)
if not result:
print("NO")
else:
result = list(result)
result.sort()
for r in result:
print(r[0], r[1],... |
f38eea4820e785ac951f08b86581d2ab82bcdcfe | ikita123/list-python | /even.py | 232 | 3.921875 | 4 | element=[23,14,56,12,19,9,15,25,31,42,43]
i=0
even_count=0
odd_count=0
while i<len(element):
if i%2==0:
even_count+=1
else:
odd_count+=1
i=i+1
print("even number",even_count)
print("odd number",odd_count) |
b98ae22ff3666f3ce22bc8cc57b3f343a6c8f17b | ZakirQamar/gems | /src/python_structures_tricks/python_structures_tricks.py | 1,169 | 4.09375 | 4 |
def unpacking_a_sequence_into_variables():
"""
Any sequence (or iterable) can be unpacked into variables
using a simple assignment operation. The only requirement
is that the number of the variables and structures match
the sequence.
Example:
>>> p = (5, 6)
>>> x, y =... |
d916840b3ec5c3efbb4ee0b1c1aea1ad42844d66 | omushpapa/minor-python-tests | /Large of three/large_ofThree.py | 778 | 4.40625 | 4 | #!/usr/bin/env python2
#encoding: UTF-8
# Define a function max_of_three()
# that takes three numbers as arguments
# and returns the largest of them.
def max_of_three(num1, num2, num3):
if type(num1) is not int or type(num2) is not int or type(num3) is not int:
return False
num_list = [num1, num2, n... |
e6134ced3a1fc1b67264040e64eba2af21ce8e1d | omushpapa/minor-python-tests | /List Control/list_controls.py | 900 | 4.15625 | 4 | #!/usr/bin/env python2
#encoding: UTF-8
# Define a function sum() and a function multiply()
# that sums and multiplies (respectively) all the numbers in a list of numbers.
# For example, sum([1, 2, 3, 4]) should return 10, and
# multiply([1, 2, 3, 4]) should return 24.
def sum(value):
if type(value) is no... |
6c58ca9f940f7ab15d3b99f27217b3bd485b01f9 | omushpapa/minor-python-tests | /Operate List/operate_list.py | 1,301 | 4.1875 | 4 | # Define a function sum() and a function multiply()
# that sums and multiplies (respectively) all the numbers in a list of numbers.
# For example, sum([1, 2, 3, 4]) should return 10,
# and multiply([1, 2, 3, 4]) should return 24.
def check_list(num_list):
"""Check if input is list"""
if num_list is Non... |
a193124758fc5b01168757d0f98cf67f9b98c664 | omushpapa/minor-python-tests | /Map/maps.py | 388 | 4.25 | 4 | # Write a program that maps a list of words
# into a list of integers representing the lengths of the correponding words.
def main():
word_list = input("Enter a list of strings: ")
if type(word_list) != list or len(word_list) == 0 or word_list is None:
print False
else:
print map... |
b0956c92848ea9087b83181d0dfcd360e45bdade | hubieva-a/lab4 | /1.py | 718 | 4.4375 | 4 | # Дано число. Вывести на экран название дня недели, который соответствует
# этому номеру.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
if __name__ == '__main__':
n = input("Number of the day of the week")
n = int(n)
if n == 1:
print("Monday")
elif n== 2:
p... |
21587730b4d4ee204bb42c9c44a469c6d7c00c04 | endokazuki/deep_leaning | /perceptron/perceptron.py | 1,934 | 3.84375 | 4 | import numpy as np
x1 = input('Enter 0 or 1 in x1: ')
# Enter x1
x1=int(x1)
x2 = input('Enter 0 or 1 in x2: ')
x2=int(x2)
# Enter x2
selected_gate =input('Enter gate(and,or,nand,xor): ')
class perceptron:
#liner--直線で表現が可能(XORは曲線)
#def __init__(self,x1,x2):
# self.x1=x1
# self.x2=x2
... |
50923882ada4e539df923241e35ec0f2aa3984ad | isabelgaldamez/linked_list | /SLL.py | 1,210 | 3.75 | 4 | import list
mylist = list.SList() # instantiating the class of SLL
mylist.add_to_back(10)
mylist.add_to_back(1)
mylist.add_to_back(8)
mylist.add_to_back(11)
mylist.add_to_back(22)
mylist.print_list()
print("******")
mylist.add_to_front(2)
mylist.print_list()
print("******")
mylist.insert_after_node(2, 4)
mylist.insert... |
897b41cb4fe3e3562afc2236bc3be3eae93be49f | jch427/directed-study | /CH_3_EX_3_7.py | 2,561 | 3.53125 | 4 | dinner_gusset = ['erica', 'alexis', 'mando', 'yoda', 'stan lee']
dinner_gusset.append('ducky')
message = f'Heloo, {dinner_gusset[0].title()} would you care to join me for dinner this evening?'
message_1 = f'Heloo, {dinner_gusset[1].title()} would you care to join me for dinner this evening?'
message_2 = f'Heloo, ... |
80cb3ef92cec41b4ff72e5c980ef05f7a0830a40 | jch427/directed-study | /CH_3_EX_3_8.py | 433 | 3.625 | 4 | vacation_spots = ['tokyo', 'pairs', 'austen', 'singapore', 'japan']
print(vacation_spots)
print(sorted(vacation_spots))
print(vacation_spots)
print(sorted(vacation_spots, reverse=True))
print(vacation_spots)
vacation_spots.sort(reverse=True)
print(vacation_spots)
vacation_spots.sort(reverse=False)
print(vacati... |
bc6ffe075520ed7f6b1feebb383833335cf20799 | jch427/directed-study | /CH_4_EX_4_1.py | 176 | 3.953125 | 4 | pizza = ['pepperoni', 'ham', 'BBQ']
for pizza in pizza:
print(f"{pizza} is one of my favorite types of pizza")
print(f"pizza is one of the foods i could eat every day.") |
41ac9a3fd5d3c74de4f73aa4e7451b94f43d46c8 | jonathancohen1/extracting_data_y_net | /Article.py | 3,028 | 3.578125 | 4 | import csv
from TextFromURL import TextFromURL
class Article:
#TODO Create a Class for "PAGE"
#TODO Class will include the following attributes:
'''
1. page address - link
2. location of the scraped data file
3. article's basic data:
#date
#name of writer/reporter
#secti... |
298a63d6370e9e6179194e26aa46d7ef0de913d4 | weixinCaishang/pyspider | /练习/pachong.py | 4,021 | 3.609375 | 4 | # -*- coding: UTF-8 -*-
#http请求模块
import re
import requests
#HTML解析的工具包
from bs4 import BeautifulSoup
def qiushibaike():
content = requests.get("http://www.qiushibaike.com").content
soup = BeautifulSoup(content, "html.parser")
#class:content是根据html中我们想要的格式来进行匹配的
for div in soup.find_all('div', {'c... |
f2ea73f7c80f873f8405eb2c3930439b57eb11ce | hlane6/biotracker | /tracker/models/target_manager.py | 4,204 | 3.53125 | 4 | from collections import namedtuple
from .associate import associate
from .tracker import Tracker, Target
import csv
import cv2
class TargetManager:
""" A TargetManager is responsible for generating Targets for a given
video. This is a three step process:
1. Using a Tracker, perform an initial first pa... |
54c2ac0456ebb81e141570e3d80cca21277c2d78 | LiuyajingMelody/vscode_learning | /dichotomy.py | 386 | 3.609375 | 4 |
import math
def binary(list, item):
low = 0
high = len(list)-1
while low <= high:
mid = math.floor((low+high)/2)
guess = list[mid]
if guess == item:
return mid
if guess <= item:
low = mid+1
else:
high = mid+1
return None
... |
506198b6c9182bc55b941b8aa678b884ac441d35 | Porkwaffle/Christmas-Bingo-PC | /ChristmasBingo.py | 4,184 | 3.546875 | 4 | #! python3
# ChristmasBingo.py
import random
from tkinter import *
words = ['Mary', 'Joseph', 'Jesus', 'Frosty', 'Manger', 'Presents', 'Snow', 'Chimney', 'Fireplace', 'Star', 'Garland', 'Ornaments',
'Tinsel', 'Mistletoe', 'Church', 'Carols', 'Santa', 'Candy Cane', 'Sledding', 'Elf', 'North Pole', 'Rud... |
897d2858ebbcd23487e8b63241decd66f557ef30 | simhaonline/ERP-2 | /hr/hr.py | 3,582 | 3.828125 | 4 | """ Human resources module
Data table structure:
* id (string): Unique and random generated identifier
at least 2 special characters (except: ';'), 2 number, 2 lower and 2 upper case letters)
* name (string)
* birth_year (number)
"""
# everything you'll need is imported:
# User interface module
im... |
96f5fbe27bf7bd62b365d50f0266ce8297042094 | amanotk/pyspedas | /pyspedas/dates.py | 1,592 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
File:
dates.py
Description:
Date functions.
"""
import datetime
import dateutil.parser
def validate_date(date_text):
# Checks if date_text is an acceptable format
try:
return dateutil.parser.parse(date_text)
except ValueError:
raise ValueError("Incorre... |
5b083920802fc4b757b8bf06445afdbd9222fd38 | VictorDMe/FitnessFunction-with-ComplexNumbers | /Program.py | 594 | 3.578125 | 4 | import cmath
for x in range(0, 11):
a = x / 10
for y in range(-10, 11):
b = y / 10
numero = complex(a, b)
conta = (-(pow(numero, 3)) + 4 * (pow(numero, 2)) - 6 * numero + 4) / 5
modulo = cmath.sqrt(conta.imag**2 + conta.real**2)
if modulo.real > 0.90:
print... |
d5d65042a3159b4490e540d752e7191d37b44fda | veera789/project1 | /practice1.py | 135 | 3.765625 | 4 | def func(arg):
"""
:param arg: taking args
:return: returning square
"""
x = arg*arg
return x
print(func(20)) |
5e0ca56488a3cda328eb88bd0a1fdd7ba6cb2bb8 | sreckovicvladimir/hexocin | /sqlite_utils.py | 1,702 | 4.125 | 4 | import sqlite3
from sqlite3 import Error
def create_connection(db_file):
""" create a database connection to the SQLite database
specified by db_file
:param db_file: database file
:return: Connection object or None
"""
conn = None
try:
conn = sqlite3.connect(db_file)
ret... |
729de941fa2acf25946f792a079ea801a691e229 | JhoplaINC/randomnumb | /randomnumb.py | 267 | 3.859375 | 4 | # -*- coding: utf-8 -*-
print("\nIngrese el número del cual quiera saber cuantas combinaciones posibles tiene:")
num=int(input())
print("\n**************")
num=(num-1)*num
print("La cantidad de combinaciones posibles es: "+str(num))
print("**************")
|
ca6f4a332a7d24905318f6744a92d376d9e9727c | nishi-ai/adventure_game | /adventure_game2.py | 1,733 | 4.09375 | 4 | import time
import random
def print_pause(message_to_print):
print(message_to_print)
time.sleep(0.3)
def intro():
print_pause("""You find yourself standing in an open field,
filled with grass and yellow wildflowers.""")
print_pause("""Rumor has it that a wicked fairie is somewhere around here,
... |
9676010d8ebd0abd607591d4a983e1d624c2cde4 | rundongwen/Connect-4-1 | /main.py | 2,751 | 3.9375 | 4 | width = 7
height = 6
board = []
for i in range(height):
board.append([" "] * width)
def get_move():
column = int(input("Which column do you want? (1-7) "))
if (column > 7 or column < 1):
print("ERROR CHARACTER OUT OF RANGE")
column = get_move()
column -= 1
column_full = False
... |
d0d2fa19d12568cc791210027b37317a9c1d3a93 | sxlijin/copenhagent | /lib/logger.py | 2,816 | 3.890625 | 4 | #! /usr/bin/env python
"""Provides methods to log information to the console and process logs."""
import time, traceback
LOG_STR = '[ %10.6f ] %12.12s : %s'
def log(event, message=''):
"""
Logs to console in specific format: [time] event : message.
Returns time.clock() at which log() was called.
... |
d5c9916bbc6ae82b54e17f804d24914f8fb89e7e | yudantoanas/PTI | /H02-16518332/H02-16518332-03.py | 1,244 | 3.5625 | 4 | # NIM/Nama : 16518332/Dhafin Rayhan Ahmad
# Tanggal : 22 September 2018
# Deskripsi : Membuat segitiga dari 3 lidi
# Input
y = int(input("Masukkan banyaknya stik Tuan Yon: "))
print("Masukkan panjang stik Tuan Yon:")
sy = [0 for i in range(y)] # list panjang stik-stik Tuan Yon
for i in range(y):
sy[i] ... |
886597d6b011d22ad5b9dfc4caca918a73096c5a | yudantoanas/PTI | /P02-16518332/P02-16518332-01.py | 1,312 | 3.65625 | 4 | # NIM/Nama : 16518332/Dhafin Rayhan Ahmad
# Tanggal : 19 September 2018
# Deskripsi : Menjodohkan laki-laki dan perempuan berdasarkan tingkat kegantengan dan kecantikan
# Meminta input data laki-laki
N = int(input("Masukkan jumlah laki-laki: ")) # banyaknya laki-laki
G = [0 for i in range(N)] # declare array tingkat k... |
a16fe06da38ea6187da8abddebe261036b5d534b | stjordanis/Activaiton-Funciton-form-Scratch | /tanH/tanH.py | 568 | 3.59375 | 4 | from matplotlib import pylab
import pylab as plt
import numpy as np
#sigmoid = lambda x: 1 / (1 + np.exp(-x))
def sigmoid(x):
return (1 / (1 + np.exp(-x)))
def tanh(x):
return (2/(1+np.exp(-2*x)))-1
x_axis = plt.linspace(-10,10)
y_axis = plt.linspace(-1,1)
x = plt.linspace(-10,10,100)
black ... |
2583173e3cd813e909c5cc267eadda53088acf5c | airlivered/python_homework | /laboratory3/task1/WordReplace/separator.py | 253 | 3.6875 | 4 | def separate(sentence, character):
"""
:param sentence: string
:param character: string char
:return:
"""
words = sentence.split(character)
return words
if __name__ == "__main__":
print(separate("Oh my"," ")) |
1578548e1b5a7e37e2ca0dcfdd610cbdb8e491c8 | Summersummer3/LeetCodeInPython | /com/example/cipher/gcd.py | 470 | 3.625 | 4 | # -*- coding: utf-8 -*-
# __author__ = 'summer'
def gcd_1(x, y):
if x < 0:
x = -x
if y < 0:
y = -y
if x < y:
return gcd_1(y, x)
else:
if y % x == 0:
return x
else:
return gcd_1(y, x - y)
def gcd(x, y):
if x < 0:
x = - x
if... |
1787ce826a6d13c27631aefad09e6def1698ecfb | Summersummer3/LeetCodeInPython | /com/example/LeetCode/luckyString.py | 793 | 3.5 | 4 | # -*- coding: utf-8 -*-
# __author__ = 'summer'
def luckyString(str):
"""
Microsoft coding test
:param str:
:return:
"""
res = []
fb = [1, 1]
while fb[-1] < 26:
fb.append(fb[-1] + fb[-2])
for i in xrange(len(str)):
j = i
while j <= len(str):
cou... |
95d1ceac57777490313fbc3f6024c1fb93edbcfb | Summersummer3/LeetCodeInPython | /com/example/LeetCode/MinSubstring.py | 634 | 3.625 | 4 | # -*- coding: utf-8 -*-
# __author__ = 'summer'
"""
any two chars in str2 should not be identical.
"""
def minSubtring(str1, str2):
lst = list(str2)
pos = [-1] * len(str2)
length, s, t = 0, 0, 0
for i, c in enumerate(str1):
if c in lst:
pos[lst.index(c)] = i
if -1 not in p... |
c11dea262eb49ade8ffdd84256c1831f976ce74a | Summersummer3/LeetCodeInPython | /com/example/sort/quickSort.py | 1,698 | 4.03125 | 4 | import random
def quicksort(arr,begin,end):
if begin < end:
middle = partition(arr, begin, end)
quicksort(arr, begin, middle-1)
quicksort(arr, middle+1, end)
def partition(arr,begin,end):
position = end
para = arr[end]
while begin < end:
if arr[begin] > para:
... |
03a9338b9bac7b896e2550a539c99e7ae93ccaca | Summersummer3/LeetCodeInPython | /com/example/LeetCode/climbStairs.py | 272 | 3.65625 | 4 | __author__ = 'summer'
def climbStairs(n):
"""
:type n: int
:rtype: int
"""
dp =[1, 2]
index = 2
while len(dp) < n:
dp.append(dp[index - 1] + dp[index - 2])
index += 1
return dp[0] if n == 1 else dp[-1]
print climbStairs(3) |
04da350a513c7cc103b948765a1a24b9864686e1 | JayHennessy/Stack-Skill-Course | /Python_Intro/pandas_tutorial.py | 631 | 4.28125 | 4 | # Python Pandas tutorial (stackSkill)
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib import style
data = pd.read_csv('C:/Users/JAY/Desktop/Machine_Learning_Course/KaggleCompetions/titanic_comp/data/test.csv')
# shows data on screen
print(data.head())
data.tail()
#print the number of rows (incldu... |
5a4c3d746a52616fc62d93a90f15e44f2ef8dd74 | Kstyle0710/KOR_NLP | /test.py | 567 | 3.578125 | 4 | # a = "abd cdf ede kdof diknd"
# print(type(a))
#
# b = [x for x in a.split(" ")[:-1]]
# print(b)
# print(type(b))
#
# k = "my home"
#
# print(f"제가 있는 장소는 {k}")
## 단어간 동일성 비교 테스트
print("절단"=="절단")
print("절단"=="절단기")
print("절단"in"절단")
print("절단"in"절단기")
print("-"*30)
target = ["절단기", "절단장비"]
def including_check(... |
f62bd2ec440e3929c5aee99d0b90fd726e3f3eff | aniket0106/pdf_designer | /rotatePages.py | 2,557 | 4.375 | 4 | from PyPDF2 import PdfFileReader,PdfFileWriter
# rotate_pages.py
"""
rotate_pages() -> takes three arguements
1. pdf_path : in this we have to pass the user pdf path
2. no_of_pages : in this we have to pass the number of pages we want to rotate if all then by
default it takes zero then we re-intialize it to total n... |
6dfb27bd2d23c7523d8566fc4aa82301c7072e0f | vikashsingh3/Python_3.7_Codewars | /mexican_wave_codewars_com.py | 1,921 | 4.09375 | 4 | # Title: Mexican Wave
# Source: codewars.com
# Site: https://www.codewars.com/kata/58f5c63f1e26ecda7e000029
# Code by: Vikash Singh
#
# Description:
# Introduction
# The wave (known as the Mexican wave in the English-speaking world outside North America) is an example of metachronal
# rhythm achieved in a packe... |
94ddb075e4106f14c1c445b7164c3b6cffd93d57 | amigo7777/-Pyhton-2 | /Фильтр.py | 193 | 3.609375 | 4 | n = int(input())
lst =[]
for i in range(n):
s = input()
if s.startswith('%%'):
s = s[2:-1]
if not s.startswith('####'):
lst.append(s)
print(*lst, sep='\n')
|
18e6cbf32704a4a009fff77d18aaf6e8e5417615 | rishabhsagar123/PYTHON-PROJECTS | /Dictionary.py | 1,373 | 3.84375 | 4 | from tkinter import *
window=Tk()
window.title("First Application of Tkinter")
def click():
entered_text=textentry.get()
output.delete(0.0,END)
try:
defination=my_compdictionery[entered_text]
Label(window,text="Yes in dictionery Check Console",fg="yellow",bg="red").grid(row=10,... |
25c7f9ba79d68d3c30cbd4ceb1bee12105a24ea0 | abhayycs/BlockChain | /others/key_generation.py | 1,108 | 3.5625 | 4 | from Crypto.PublicKey import RSA
from Crypto import Random
random_generator = Random.new().read
# ARGUMENTS: 1) KEY_LENGTH, 2) RANDOM NUMBER GENERATOR
key = RSA.generate(1024, random_generator)
print('key:\t',key)
# WRITE DOWN PUBLIC AND PRIVATE KEY IN A FILE
with open('mykey.pem','wb') as file:
file.write(key.expor... |
10fd4011d6f775bbb9a5cad35e2e267ea43ade18 | Gabriel-f-r-bojikian/RPN-calculator | /calculadoraRPN.py | 1,952 | 3.828125 | 4 | #Calculadora implementada como uma classe. As operações aritméticas básicas e potenciação foram implementadas
import operacoes
import entrada
class calculadoraRPN:
def __init__(self):
self.operadoresAceitos = operacoes.operadoresAceitos
self.pilhaDeNumeros = []
self.pilhaDeOperacoes = []
self.fluxoEn... |
d1a5ff40143e7adbbb8dd7c7928c389488701a3a | ardulat/deep-learning | /amaratkhan_assignment1.py | 3,375 | 4.0625 | 4 | import numpy as np
import matplotlib.pyplot as plt
from random import randint
def partition(A, start, end):
pivot = A[end]
partitionIndex = start
for i in range(start, end):
if (A[i] < pivot):
A[i], A[partitionIndex] = A[partitionIndex], A[i]
partitionIndex += 1
A... |
dde08f772720d8f6935ed1f2a200eb65d1406f0a | JRJurman/persistent-number-generator | /functions/mapListToBase.py | 374 | 3.703125 | 4 | from functions.toBaseN import toBaseN
def originalAndStringOfBaseN(base):
def originalAndString(number):
return (number, toBaseN(base)(number))
return originalAndString
def mapListToBase(numbers, base = 10):
"""
convert numpy array into integer of base
only use for printing
"""
return list(map(orig... |
4e39f38eee0b84dcd74e15281ae99759faa53362 | liorkesten/Data-Structures-and-Algorithms | /Algorithms/Sorting_Algorithms/Linear_Sorting/BinSort.py | 748 | 4.0625 | 4 | def binSort(A, m):
"""
Bin Sorting_Algorithms - algorithm: gets an array of int numbers, find the maximum value
(m) in the array, than create an list of [0,1,...,m] and than increase
the counter of the A array. Put the amount of each index in
ret array and return ret
:param m:
:param A: a... |
e340d8b94dc7c2f32e6591d847d8778ed5b5378b | liorkesten/Data-Structures-and-Algorithms | /Algorithms/Arrays_Algorithms/isArithmeticProgression.py | 666 | 4.3125 | 4 | def is_arithmetic_progression(lst):
"""
Check if there is a 3 numbers that are arithmetic_progression.
for example - [9,4,1,2] return False because there is not a sequence.
[4,2,7,1] return True because there is 1,4,7 are sequence.
:param lst: lst of diff integers
:return: True... |
ab37c638cb42eea91065d8280e4f5ae74539a56a | liorkesten/Data-Structures-and-Algorithms | /Algorithms/BinaryRep_Algorithms/BinaryRepresantion.py | 2,081 | 4.03125 | 4 | from Data_Structures.my_doubly_linked_list import *
def binaryRep(n):
"""
Function that gets an int number and return a linked list the represent the
number in binary representation
Time complexity: log(n)
:param n: integer number
:return: linked list - binary representation of n
... |
6101f3df70700db06073fd8e3723dba00a02e9d9 | liorkesten/Data-Structures-and-Algorithms | /Algorithms/Arrays_Algorithms/BinarySearch.py | 577 | 4.21875 | 4 | def binary_search_array(lst, x):
"""
Get a sorted list in search if x is in the array - return true or false.
Time Complexity O(log(n))
:param lst: Sorted lst
:param x: item to find
:return: True or False if x is in the array
"""
if not lst:
return False
i... |
4ad8813ec4be6393f4e8900885e900db9ddb7b32 | liorkesten/Data-Structures-and-Algorithms | /Algorithms/Sorting_Algorithms/QuickSort.py | 735 | 4 | 4 | from Algorithms.Arrays_Algorithms.Partition import rand_partition
# _____________________________Random sorting_________________________________
def quick_sort(lst, s=0, e=-1):
"""
Quick Sorting_Algorithms - Random pivot.
Time complexity - n*log(n) in the avg case.
... |
ffbf1e335934e537f4d29e1391595edc49761389 | patpiet/Projects_Learning | /clock_timer/countdown_clock.py | 1,885 | 3.9375 | 4 | import time
from tkinter import *
from tkinter import messagebox
root = Tk()
root.title("Countdown App")
root.geometry("300x250")
# Create count variables
hour = StringVar()
minute = StringVar()
second = StringVar()
title = StringVar()
hour.set("00")
minute.set("00")
second.set("00")
# Create Labels
hour_label = Lab... |
fe8691af8e917efb28d2311a0ee093d1edb34787 | samanthaWest/Python_Scripts | /HackerRank/MinMaxSum.py | 450 | 3.515625 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'miniMaxSum' function below.
#
# The function accepts INTEGER_ARRAY arr as parameter.
#
def miniMaxSum(arr):
arr_length = len(arr)
sorted_arr = sorted(arr)
print(sum(sorted_arr[:4]), sum(sorted_arr[a... |
bc575d9e0b25e519b50e9b22c038975fc85aeef8 | samanthaWest/Python_Scripts | /DataStructsAndAlgorithms/Searching/JumpSearch.py | 1,888 | 4.03125 | 4 | # Jump Search
# https://www.geeksforgeeks.org/jump-search/
# Alg for sorted arrays, check fewer elements then linear
# search by jumping ahead by fixed steps or skipping some eements in place of searching all ele
# Binar ysearch is better then jump search but jump searches advantage is being able to traverse back o... |
d37d608744317b4e7957d53a77ce52f3483161ce | samanthaWest/Python_Scripts | /DataStructsAndAlgorithms/Stack/QueueUsingStacks.py | 2,043 | 4.0625 | 4 |
# Costly enque operation
# Enqueing from the left and dequing from the right
class Queue:
def __init__(self):
self.s1 = []
self.s2 = []
def enQueue(self, x): # TC: O(n)
# Emptying list one into list 2 from the end of list 2
# List 1 : 1 , 2 , 3
# After... |
a0e52ed563d1f26e274ef1aece01794cce581323 | samanthaWest/Python_Scripts | /DataStructsAndAlgorithms/TwoPointersTechnique.py | 784 | 4.3125 | 4 | # Two Pointers
# https://www.geeksforgeeks.org/two-pointers-technique/
# Used for searching for pairs in a sorted array
# We take two pointers one representing the first element and the other representing the last element
# we add the values kept at both pointers, if their sum is smaller then target we shift left... |
68c804bf7acf9572256e553810571de3f10f151f | samanthaWest/Python_Scripts | /DesignPatterns/design_pattern_observer_weather_app.py | 2,400 | 3.578125 | 4 | from abc import ABC, abstractmethod
##############
# Interfaces #
##############
# Observer Interface
class Observer(ABC):
@abstractmethod
def update(self):
pass
# Display Element Interface
class DisplayElement(ABC):
@abstractmethod
def display(self):
pass
# Subje... |
6686c069121b9b4d384c0f2ec5fb3293dee4d8a9 | samanthaWest/Python_Scripts | /HackerRank/Trees/Insertion.py | 373 | 3.78125 | 4 | class newNode():
def __init__(self, data):
self.key = data
self.left = None
self.right = None
def insert(temp, key):
if not temp:
root = newNode(key)
q = []
q.append(temp)
while (len(q)):
# Take no from the queue to search throu... |
c98020ca384a60af1a0e53dc6369e3eee5867884 | Fahien/pyspot | /test/script/map-test.py | 228 | 3.515625 | 4 | import pyspot
def create_week():
week = pyspot.test.Week()
if week.days[1] == "monday":
return week
else:
return None
def modify_monday( week ):
days = week.days
days[1] = "tuesday"
week.days = days
|
e965acf456da9568da5112a120d9d7d3bec34132 | animan123/inference | /input.py | 2,313 | 3.765625 | 4 | from term import term
def get_operator (op):
if op == '=':
return 'imply'
if op == '|':
return 'or'
if op == '&':
return 'and'
raise Exception ("Invalid operator " + op)
def isUpper (x):
return x>='A' and x<='Z'
def get_pred_dict (pred_string):
first_bracket = pred_string.index('(')
pred_name = pred_str... |
fb876f79260e8f65d452ad3674b2fbe5a8bd174a | priscila-rocha/Python | /Curso em video/ex007.py | 129 | 3.8125 | 4 | n1 = int(input('Digite sua 1ª nota: '))
n2 = int(input('Digite sua 2ª nota: '))
print('Sua média foi: {}'.format((n1+n2)/2)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.