blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
914a2b3e4081eaae9523ed7d8d67cab354ad8541 | baohongfei/learn-python3 | /samples/functional/do_filter.py | 239 | 3.875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
def is_odd(n):
return n%2 == 1
L = range(100)
print(list(filter(is_odd,L)))
def not_empty(s):
return s and s.strip()
print(list(filter(not_empty,['A','','B',None,'C',' '])))
|
a73568cf79a4737f8f3cd4108e0e616840eadec5 | sayan1995/Strings-1 | /problem1.py | 895 | 3.5625 | 4 | '''
Time Complexity: O(n+m) n is length of S and m is length of T
Space Complexity: O(m) - > m is the length of T
Did this code successfully run on Leetcode : Yes
Explanation: Count all the characters from T. For ever character in S multiple the character in S by the number of times
the character occurs in T and do th... |
41ac0a6044d72a4f7a5e89951929eca1ec8ae275 | alexwlchan/github-code-search | /render_search_results.py | 7,518 | 3.578125 | 4 | #!/usr/bin/env python
# -*- encoding: utf-8
"""
Given a search result from the GitHub API, render the results in a way that
minimises duplication.
Usage: render_search_results.py <SEARCH_RESULT_JSON> [--api_token=<TOKEN>]
"""
import base64
import hashlib
import json
import docopt
import hyperlink
from jinja2 import ... |
c9184fb486c7fbabae7c6153125020fcfa892995 | caahnuns/URI | /AD-HOC/2417_campeonato.py | 312 | 3.828125 | 4 | info = input().split()
gol_c = int(info[2])
gol_f = int(info[5])
pt_c = (int(info[0]) * 3) + int(info[1])
pt_f = (int(info[3]) * 3) + int(info[4])
if((pt_c > pt_f) or (pt_c == pt_f and gol_c > gol_f)):
print("C")
elif((pt_f > pt_c) or (pt_c == pt_f and gol_f > gol_c)):
print("F")
else:
print("=") |
887ad8c9fe04899150f70bef74e9a260f1f035ea | caahnuns/URI | /Matemática/2232_triangulo_de_pascal.py | 194 | 3.703125 | 4 | t = int(input())
v = 1
for v in range(1, t+1):
n = int(input())
triangulo = 0
for i in range(n-1, -1, -1):
linha = 2 ** i
triangulo += linha
print(triangulo) |
512928e95fa6a63d36a2f5b7ff991f1c79aff638 | caahnuns/URI | /Iniciante/1154_idades.py | 215 | 3.734375 | 4 | executar = 1
total = 0
cont = 0
while(executar == 1):
idade = int(input())
if(idade < 0):
executar = 0
else:
total += idade
cont += 1
print("{:.2f}".format(total/cont)) |
7a49723113a7c58e126368565332991d67d96315 | Hugerds/URI-ONLINE-JUDGE | /URI - 1005 - Python.py | 106 | 3.609375 | 4 | A = float(input())
B = float(input())
p1 = A*3.5
p2 = B*7.5
s = (A*3.5+B*7.5)/11
print("MEDIA = %.5f"% s) |
16a77e35f811dd29d690ab5d8f7f7fe837efa8b4 | syvertsj/leetcode.syvertsj | /3_longest_substring_without_repeating_characters/python.longest_substring_without_repeating_characters/longest_substring_without_repeating_characters.standalone.py | 1,831 | 3.5625 | 4 | #!/usr/bin/env python
# https://leetcode.com/problems/longest-substring-without-repeating-characters/
class Solution(object):
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
head = 0; tail = 0; foundchar = {} # head and tail indices and list for en... |
b3e9e4a331f727f0fd7de6f4fd727143babfabe0 | violachyu/Python_Challenge | /007.py | 1,065 | 4.3125 | 4 | '''Python Challenge - 7
Take a look at the example data structure below. Create a function called breeds.
It will receive 1 parameter, a data structure like the one below.
Return a list of all the pet breeds a person has.
For example, using the data structure below, the function should return ['American Shorthair', 'Pi... |
1a6a40fb79b13b1554eb95bb15ee0025786de41d | Amar1729/pip-rewind | /pip_rewind/parser.py | 797 | 3.515625 | 4 | #! /usr/bin/env python3
"""
Dumb parser for a requirements.txt file.
ONLY supports lines of the following formats:
(any text can follow the first equality directive)
pkgname==version.number
pkgname<=version.number[...]
pkgname>=version.number[...]
pkgname!=version.number[...]
"""
import re
import warnings
fro... |
d3ce9711758747a77d5656b5d490839d98362880 | canxkoz/Competitive-Programming | /LeetCode/Happy-Number.py | 1,993 | 4.0625 | 4 | # Happy Number
# Write an algorithm to determine if a number is "happy".
# A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops end... |
b59c6060eb60092f55bf4218145bf540a04930c8 | kartikarora1/python | /regex.py | 429 | 4.15625 | 4 | import re
string = input()
uppercase = re.findall(r"[A-Z]", string)
lowercase = re.findall(r"[a-z]", string)
numerical = re.findall(r"[0-9]", string)
special = re.findall(r"[, .!?]", string)
print("Total uppercase characters is", len(uppercase))
print("Total lowercase characters is", len(lowercase))
... |
76cf46ae35f9ef656cbe0d0b84cb551ab26d650c | kartikarora1/python | /Numpy/memoryOccupied.py | 185 | 3.6875 | 4 | import numpy as np
X = np.array([1, 7, 13, 105])
print("Original array:")
print(X)
print("Size of the memory occupied by the said array:")
print("%d bytes" % (X.size * X.itemsize)) |
66303024e10e3b99d8a4a6ab9d4844612712c6cb | kartikarora1/python | /additionMatrix.py | 280 | 3.578125 | 4 | X = [[1,9,3],
[2 ,5,7],
[6 ,6,6]]
Y = [[5,7,1],
[9,7,3],
[4,2,9]]
result = [[0,0,0],
[0,0,0],
[0,0,0]]
for i in range(len(X)):
for j in range(len(X[0])):
result[i][j] = X[i][j] + Y[i][j]
for r in result:
print(r) |
4efba1d05ee41ae2282a61018c297c2177fa3cc4 | weikunzz/test_cases | /购物车.py | 3,135 | 3.515625 | 4 | # -*- encoding:utf-8 -*-
import sys
def inputFun(src):
return input(src)
def printFun(src,mode=1,srcLen=None):
if not src:
return
temp_len = len(src) if not srcLen else srcLen
if mode ==1:
print src.center(temp_len)
elif mode == 2:
print src.ljust(temp_len)
else:
... |
a26d7420a5e99c03273c4ab2dd2ea2de412e94a3 | artliou/chess | /eloSystem.py | 1,981 | 3.90625 | 4 | #Fun fact: the ELO rating system used for chess is also used to rank Players in League of Legends (LoL)
#Rating_a is Rating for Arthur (example)
#Rating_b is Rating for Bob
class Player(object):
def __init__(self, name, rating, p):
self.name = name
self.rating = rating
p = 1 #player starts... |
a52698a299c1025a1d985b53600fc277e3271352 | AdiSassonA/Practice_Python | /list.py | 230 | 3.625 | 4 | #!/usr/bin/env python3
#Answer to exercise number 2
a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
b = []
for number in a:
if (number % 2 == 0):
b.append(number)
#b = [number for number in a if number % 2 == 0]
print(b)
|
47eb5b5d050626584c7b827c822a0f242686509e | gsuemith/Data-Structures | /stack/stack.py | 3,436 | 3.9375 | 4 | #Import linked list
#Folder name.file name, thing to import
# from singly_linked_list.singly_linked_list import LinkedList
import sys, os
sys.path.append(os.path.join(os.path.dirname(sys.path[0]), 'singly_linked_list'))
from singly_linked_list import LinkedList
"""
A stack is a data structure whose primary purpose is... |
e3439211968c48ed526c0dfa59d1153186545f56 | Kreshel/ECL2017S | /homework/hw9/advancedIO.py | 5,839 | 3.53125 | 4 | #!/usr/bin/env python
import urllib.request as ur
def parseTable(html):
#Each "row" of the HTML table will be a list, and the items
#in that list will be the TD data items.
ourTable = []
#We keep these set to NONE when not actively building a
#row of data or a data item.
ourTD = None #Stor... |
bf366be3b7db8862e55957507a891d0b8f80c3b7 | Kreshel/ECL2017S | /homework/hw5/prime.py | 326 | 3.890625 | 4 | def is_prime_helper(n,div):
if n <= 1:
return False
else:
if n % div == 0:
return False
elif n % div != 0 and div != 2:
return is_prime_helper(n, div-1)
elif n % div != 0 and div == 2:
return True
def is_prime(n):
return is_prime_helper(n,... |
6325373efc601b73fcc0c9922ca977fc80b135ff | bentleyj68/python-challenge | /PyBank/main.py | 3,214 | 3.796875 | 4 | # PyBank Analysis script - main.py
import os
import csv
# Function - Show results on screen and write to a text file
# - Input parameter is a dictionary of the analysis
def show_results(final_rslt):
# Specify the file to write the financial analysis result to
output_path = os.path.join('analysis'... |
1823df6083a5eaf50f38de2ab0df361b5545aaf7 | timp555/SP | /5/7172_sia.py | 2,474 | 3.5 | 4 | from threading import Thread
# https://docs.python.org/3/library/threading.html
# Задание: написать две программы. Первая реализует алгоритм умножения двух векторов произвольной длины. Вторая -
# умножает матрицу произвольного порядка на вектор, при этом умножение каждой строки на вектор производить в
# отдельном проц... |
0625b0a1dae727873a15b1dc443ea8892dcc43c8 | AlexCarolan/PythonMathsGame | /Games.py | 2,016 | 4.03125 | 4 | import random
difficulty = 4
diffCheck = 0
def game(gameNum):
check = True
global diffCheck
global difficulty
difficulty = 4
diffCheck = 0
score = 0
while(check == True):
#Generate the question values at random between 1 & the difficulty level
A = random.randint(1, difficulty)
B = random.randint(1, d... |
680ec877cc5857a06e98264a6312caae334c8084 | shangliy/SL_Model_Methods | /triplet_learning/matching/nets.py | 821 | 3.59375 | 4 | """
Basic nets
"""
def bilstm_test():
model = Sequential()
input_shape = (149, 40)
model.add(Bidirectional(LSTM(units=20, return_sequences=True), input_shape=input_shape))
model.add(Dropout(0.5))
model.add(BatchNormalization())
model.add(TimeDistributed(Dense(1, activation='sigmoid')))
# mo... |
6334218936be3a8a9281222ba7e79dcaa284a87b | IPPMCMP07/compiler | /examples/compilex-Demo1/temp/bb4km2n.py | 63 | 3.671875 | 4 | a=5
b=3
print(a+b)
c=input()
d=input()
#d=4
e=int(c*d)
print(e) |
f2234bb351c875fa19f6096eb9a64d94e2e0f92f | bonkstok/python | /udemy/test-lambda.py | 727 | 4.25 | 4 | from functools import reduce
def printLine(*args):
if args:
print("###{}###".format(args[0]))
else:
print("######")
#map
#map applies a function to all items in an input list:
#print("###MAP###")
printLine("MAP")
items = [1,2,3,4,5]
squared = list(map(lambda x: x**2, items))
print(squared)
printLine()
printLi... |
570a69dffe9c949ed2c662669f9403e3765ff89e | bonkstok/python | /udemy/decorators.py | 901 | 4.46875 | 4 | # is a function that gets called before another function
import functools #function tools
#create your own decorator(func)
def my_dec(func): # when calling the decoratir, the function that calls is will be the argument
@functools.wraps(func) #wrap something around the calling function
def function_that_runs_func()... |
095cdb96243b7f62d5dd0a2170b64f97f8f0cd19 | FRIENDS123123/Project-100 | /PROJECT100.py | 922 | 3.828125 | 4 | class Atm:
def __init__(self,cardnumber,pin):
self.cardnumber=cardnumber
self.pin=pin
def check_balance(self):
print("balance is 500")
def withdrawl(self,amount):
new_amount=500-amount
print("withdrawl amount"+str(amount)+"remaining balance"+str(new_amount))
... |
779b1c1457e1e01845eb6788fc6d88aacca37589 | seadhant/KOMODO-app | /ml implementation for object identifier/ml.py | 3,999 | 3.53125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Feb 11 07:26:32 2020
@author: UMESH DASPATTANAYAK
"""
#converting the image into grayscale
import cv2
image=cv2.imread(r"C:\Users\UMESH DASPATTANAYAK\Downloads\Compressed\Garbage classification\Garbage classification\plastic\plastic32.jpg")
#using opencv con... |
4b9f6cb193b535ea21e0275f35e67b617f656161 | zhoyze-zz/WorkSpace | /Python_WorkSpace/pythonshiyan4/Ex4_4.py | 459 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Oct 27 22:15:35 2018
@author: fengl
"""
import matplotlib.pyplot as plt
plt.plot([1,3,2,4,5,6,7,8]) #绘制图,数组为y轴的坐标,x轴默认为01234567
plt.plot([0,1,2,3],[1.5,2,3,4.5],'b') #绘制图,x轴坐标和y轴坐标,颜色为b
plt.plot([0,1,2,3],[2.5,3,4,5.5],'r-')
plt.ylabel('some numbers') #设置y轴标签
plt.xla... |
0aa18c6159063c53720150c1d96571f38e158d17 | zhoyze-zz/WorkSpace | /Python_WorkSpace/pythonshiyan5/Ex5_5.py | 1,142 | 3.828125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Nov 13 12:16:06 2018
@author: fengl
"""
import turtle
def draw_brach(brach_length,ratio=0.8,ps=10):#递归
if brach_length > 20:
if brach_length < 40:
turtle.color('green')
else:
turtle.color('brown')
#绘制本层次树枝
if (ps>... |
bb0d812d4f173fa9526bbdf13101efe0e0fc5bb2 | musicalmacdonald/class_exploration | /dog_cat.py | 889 | 4.375 | 4 | """An exploration of python classes using dogs and cats
Basic class format:
class Class_name:
pass
OR
def __init__(self, variables): #this initializes the class variables
self._variables = variables #use _ for arguments you don't want the user to have access to
def class_function(self, vari... |
530f4d4203d9f573a1f6a65f7e0776db198534b9 | zhaolixiang/Python3-Deeply-Simply-Machine-Learning | /14-6.py | 913 | 3.59375 | 4 | # 导人多项式朴素贝叶斯
from sklearn.naive_bayes import MultinomialNB
from sklearn.datasets import make_blobs
from sklearn.model_selection import train_test_split
# 导入数据预处理工具MinMaxScaler
from sklearn.preprocessing import MinMaxScaler
# 生成样本数量为500 ,分类数为5的数据集
X, y = make_blobs(n_samples=500, centers=5, random_state=8)
# 将数据集拆分成训练集... |
35cd3caf5bfaa8f90eb9577b20c868922d029b56 | ReillyBova/spades | /spades.py | 1,847 | 4.15625 | 4 | # Author: Reilly Bova
# Date: 30 September 2018
# File: spades.py
# About: The main file for my "Spades" python program for the terminal
import os
from game import Game
from spades_utils import *
# Welcome message for the user
def welcome():
os.system("clear")
print(HEADER)
hello_msg = ("Welcome to a... |
cc0cd49ca8e213f291d1fdbd9840f61583eb5105 | bhagatdharmendra/heart- | /heart_shape .py | 278 | 4.125 | 4 | for row in range(6):
for col in range(7):
if(row == 0 and col %3 !=0) or ( row == 1 and col%3 == 0) or (row-col == 2) or (row+col == 8) :
print("*",end="")
else:print(end=" ")
print(" ")
|
e129434c39c4547abde3d7d073bed9b4f4072bf6 | bencouser/project_euler | /35.py | 863 | 3.5 | 4 | # The number 197 is a circular prim as 197, 971 and 719 are all themselves prime
# How many circular primes are there below one million
import MyModule as mm
count = 0
listPrimes = []
def digit_to_number(digits):
s = ''.join(map(str, digits))
return int(s)
def find_circular_perms(digits):
all_perms = []... |
db2a7de92cb661b9205f45530ca4f05d78659586 | bencouser/project_euler | /21.py | 1,122 | 3.65625 | 4 | # d(n) is the sum of divisors of n
# if d(a) = b and d(b) = a, where a != b
# this is an amicable pair
# d(220) = 284 and d(284) = 220 for example
# evaluate the sum of all amicable numbers under 10000.
import math
def factors(number):
half_factors = []
factors = []
for potentialFactor in range(1, int(mat... |
e388df76c50e779cb9f473147aebfb7545faef9a | bencouser/project_euler | /37.py | 475 | 3.53125 | 4 | # Find the sum of the only eleven primes that are both truncatable from left to right
# and right to left
import MyModule as mm
countTruncatableBoth = 0
sumTruncatableBoth = 0
number = 13
while countTruncatableBoth < 12:
if mm.is_it_prime(number):
digits = mm.find_digits(number)
length = len(digi... |
2bc0d020ca7f3090245fdecc7ef470037ce9146e | bencouser/project_euler | /34.py | 375 | 4 | 4 | # Find the sum of all numbers which are equal to the sum of the factorial of
# their digits
import MyModule as mm
totalSum = 0
for number in range(10, 1000000):
digits = mm.find_digits(number)
factorial_sum = 0
for digit in digits:
factorial_sum += mm.find_factorial(digit)
if factorial_sum ... |
d79e9f17d92b2c30f9089ff908f5b455b64ddaf9 | megaSpoon/serious_coding | /tree/traversal/postorder_traversal.py | 518 | 3.5625 | 4 | from tree.utils.predefined_trees import full_tree_example
def postorder_traversal_recursive(root):
ret = []
def post_order(root):
nonlocal ret
if root:
post_order(root.left)
post_order(root.right)
ret.append(root)
print(str(root.val) + ' ', end=... |
d79289b5b4aa906c64dd49ce75e7a8de411cfb8c | Yefei100/CTCI_py_v1 | /chap1ArraysStrings/permutation.py | 764 | 3.84375 | 4 | """
Page 73
Given 2 strings, write a method do decide if one is a permutation of the other
ans: pg 174
"""
def is_permutation(string1, string2):
# we only count lower case, which is not always true ...
string1 = string1.lower().strip()
string2 = string2.lower().strip()
char_list1 = {}
for char i... |
601ba500170cf05c4ce74725f23f9debd3ac6663 | CapacitorSet/shor-demonstration | /RSA.py | 2,092 | 3.734375 | 4 | from math import sqrt
import random
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
def mod_inverse(a, m):
for x in range(1, m):
if (a * x) % m == 1:
return x
return -1
def isprime(n):
if n < 2:
return False
elif n == 2:
return... |
942001d5078bbfd0292ced3f2da6e631f3edb8a1 | miqueiasmiguel/mesa_de_coordenadas | /src/database/repository/position_repository.py | 2,095 | 3.625 | 4 | import sqlite3
from datetime import datetime
from typing import Tuple, List
class PositionRepository:
"""Classe para administrar o repositório de 'positions'"""
def insert_position(
self,
x_axis: int,
y_axis: int,
date_time: datetime,
user_id: int,
x_speed: int... |
f3506e489aa41258165a0c53e84b474f920b5423 | TonyPwny/CS352DNS | /anthonyProject1/rs.py | 2,916 | 3.6875 | 4 | # Anthony Tiongson (ast119) with assistance from Nicolas Gundersen (neg62)
# RS (a simplified root DNS server)
# resources:
# https://www.pythonforbeginners.com/system/python-sys-argv
import sys, threading, time, random, socket
def server():
# Establish port via command-line argument
port = int(sys.arg... |
e12a32ffe6231ee28b49decd2e1679e2f497ee82 | EkaterinaArseneva/hometask2 | /task2.4.py | 512 | 4.4375 | 4 | """Пользователь вводит строку из нескольких слов, разделённых пробелами.
Вывести каждое слово с новой строки. Строки необходимо пронумеровать.
Если в слово длинное, выводить только первые 10 букв в слове.
"""
text = input('введите строку ')
words_list = text.split(' ')
print(words_list)
for word in words_list:
pri... |
a4d8265c75adb0e2101a74b5645003adae50d690 | caiiolliima/Exercicios-Basico-Python | /Ex013.py | 111 | 3.65625 | 4 | n1 = int(input('Digite o valor do salario: '))
a = n1 + (15/100*n1)
print('O novo salário é {}!'.format(a)) |
60be2fe8bf97e001076a59cb671fbc39a8993e63 | acmerfight/share | /encapsulation.py | 733 | 3.703125 | 4 | # coding=utf-8
from datetime import date
class Person(object):
def __init__(self, birth_day, sex, children, lover):
self.birth_day = birth_day
self.sex = sex
self.children = children
self.lover = lover
self.age = self.compute_age()
def compute_age(self):
toda... |
d3e72a7b4250a5372e3cf938b499450ea3ba8891 | Maharshi6897/Pattern-Programming | /Z.py | 661 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Dec 24 23:23:16 2019
@author: Maharshi
"""
import time
letter_height = int(input())
letter_width = int(input())
pattern = input()
print()
def print_Z1(h,w,p):
for row in range(h):
for col in range(w):
if(row==0 or row==h-1 or row+col... |
25d7e30d96fd07dc04883d14a119a8ba7a90f1a4 | Maharshi6897/Pattern-Programming | /right_angle_reverse.py | 406 | 3.703125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Dec 22 20:27:59 2019
@author: Maharshi
"""
# * * * * *
# * * * *
# * * *
# * *
# *
import time
def pattern7(n,p):
for i in range(n,0,-1):
print((p+' ')*i)
lines = int(input("Enter number of rows : "))
p = input("Enter patte... |
38da38cc5f88db5d961eadbac584ad73ed939490 | Maharshi6897/Pattern-Programming | /pattern2.py | 316 | 3.828125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Dec 24 23:53:38 2019
@author: Maharshi
"""
#
# 1
# 2 3
# 4 5 6
# 7 8 9 10
# 11 12 13 14 15
n = int(input("Enter number of rows"))
a=1
for i in range(1,n+1):
for j in range(1,i+1):
print(a,end=' ')
a+=1
print()
|
82d9f2fab1b6e3c5e63345b052b3cf475a66dc30 | Maharshi6897/Pattern-Programming | /Pyramid_pattern_Reverse.py | 696 | 3.625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Dec 22 19:53:31 2019
@author: Maharshi
"""
# * * * * *
# * * * *
# * * *
# * *
# *
import time
def pattern5(n,p):
for i in range(n,0,-1):
for j in range(n-i):
print(' ',end='')
for j in range(i):
... |
ea128e06379d14df091f13ac0d0e139d1b08233f | Bhyan/blackjack | /main.py | 3,659 | 3.6875 | 4 | # -*- coding:utf-8 -*-
import blackjack.blackjack
player = blackjack.blackjack.Blackjack()
blackjack.blackjack.header()
print('''The number of decks goes from one to eight, the larger the amount the
greater the difficulty''')
decks = int(input('Insert the quantify of decks: '))
while player.money > 0.0:
p... |
fab1b2010e44b51057d6c61988ff5e67fe4ffecb | nehararora/practise-code | /python/dsa/trees.py | 1,672 | 4.21875 | 4 | """
trees.py: Basic Tree data structure algorithm implementations.
refer: Chapter 8, Data Structures and Algorithms in Python, Goodrich et al.
"""
__author__ = 'nehar'
from abc import ABCMeta, abstractmethod
class TreeADT(metaclass=ABCMeta):
"""
The Tree abstract data type.
"""
@abstractmethod
... |
47e8fbb996f018490073ac07d31a7f88011d253f | nehararora/practise-code | /python/dsa/arrays.py | 10,383 | 3.9375 | 4 | # -*- coding: utf-8 -*-
"""
arrays.py: Algorithms based on array operations.
"""
import ctypes
__author__ = 'nehar'
class DynamicArray(object):
"""
Dynamic Array class.
Implements a dynamic array based on the low level ctypes array.
"""
def __init__(self):
"""
Create an empty ... |
3a375510ea0d079f3db45515774641e2424c8601 | purpleHey/purplehey.github.io | /sample/Thurs.py | 705 | 3.625 | 4 | # def is_leapyear(year):
# if year % 4 == 0:
# if year % 100 == 0:
# if year % 400 == 0:
# return True
# return False
# return True
# return False
# for year in range(1900, 1910):
# if is_leapyear(year):
# print(f"{year} is a leap year - {year... |
3dc08cccdb3dafed269a377b63f61d534b5d56d7 | AustinRheyne/Teaching-Programs | /SimpleInterestCalculator.py | 399 | 3.984375 | 4 | # I = Prt
# P = Present Amount
# R = Interest rate (5%)
# T = Time in years
current = int(input("How much money do you have now? "))
interest = float(input("How much is the interest? (Input in decimal form [6% = 0.06]) "))
time = int(input("How many years? "))
total = (current * interest * time) + current
... |
ee5ef233b63e35da74961349ca17228a3a420f68 | AustinRheyne/Teaching-Programs | /CarSalesman.py | 376 | 3.875 | 4 | #Car Salesman Program
#
#User will input car prices and the program
#will add on fees to the price
price = input("What's the price of the vehice? ")
price = int(price)
tax = price * 0.05
license = price * 0.07
prep = 150
destination = 300
print("\nYour vehicle will cost $", str(price + tax + license + p... |
c96bd81c95aa9019bb2c89566e44cd6d73fca645 | AustinRheyne/Teaching-Programs | /UselessTrivia-Austin.py | 953 | 4.28125 | 4 | #Useless Trivia
#
#Gets personal information from the user and then
#print true but uselss information about him or her
#Ask the questions
name = input("Hi. What's your name?")
age = input("How old are you?")
age = int(age)
weight = int(input("Okay, last question. How many pounds do you weigh?"))
#Pr... |
d95d3fa715219af6b3c2c6769c613aebb135494f | DReis98/Tese_Server | /dates.py | 2,154 | 4.28125 | 4 | """
Receives a date in dictionary.
Returns the next day in a dictionary
"""
def nextDay(date):
day = date["day"]
month = date["month"]
year = date["year"]
ret = {}
# treating day
if day >= 31:
new_day = 1
else:
new_day = day + 1
# treating month
if new_day == day +... |
ae6b2e3621b33f209f19f4aad16332f7a68688b6 | Moshiro896/Trabalho-de-Andr | /Trabalho de André.py | 1,564 | 3.75 | 4 | nome=[]
nota=[]
sexo=[]
def cadastrar(a, n, s):
nome.append(a)
nota.append(n)
sexo.append(s)
def lista():
for c in range(0,len(nome)):
print("\n Aluno: {} nota: {} sexo: {}\n".format(nome[c],float(nota[c]),sexo[c]))
print(input("Pressione enter para prosseguir"))
#def consultar(n):
#l=no... |
ef99b111131ad9d7521b2bd0d2d2ebd800d0e067 | miuiunguyen/100days-of-Coding | /Day-4-100days-of-Coding/finalproject.py | 1,066 | 4.28125 | 4 | rock = '''
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
'''
paper = '''
_______
---' ____)____
______)
_______)
_______)
---.__________)
'''
scissors = '''
_______
---' ____)____
______)
__________)
(____)
---.__(___)
'''... |
ba6779d7821c7c73e6648dbeb949a7df008dda06 | cianmce/MontyHall | /monty.py | 1,017 | 3.53125 | 4 | from random import shuffle, randint
def get_doors(n):
doors = ['car']
for i in range(n-1):
doors.append('goat')
shuffle(doors)
return doors
def monty(stay=True):
num_doors = 3
doors = get_doors(num_doors)
user_choice_index = randint(0, num_doors-1)
user_choice = doors.pop( us... |
4c2e8ae90def8d9265d95a0a1c5f5e1c4c0c6336 | krisbuote/covalent-task | /covalent-task.py | 5,413 | 3.625 | 4 | ### TASK ###
# Write a program that queries Covalent's API ticker endpoint.
# Collect null contract address results for 60 samples at a rate of 1 sample per minute.
# After 60 samples, display a histogram of null results. Only include currencies that have >0 null address responses.
### AUTHOR ###
# Kristopher ... |
abd5f1d47d424c48879e81354ee767f0ea7dca2f | k4t0mono/regex-to-code | /Minimiza/Minimiza.py | 655 | 3.609375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
from Minimiza.Estruturas import Automato
import sys
def Minimiza(args):
#~ if(len(sys.argv) != 4):
#~ print("Modo de execucao: ")
#~ print("python Main.py <arquivoEntrada> <arquivoTabela> <arquivoNovoAutomato>")
#~ else:
entrada= args[0]
ta... |
e9922fb2e2cc61e9b93d3f70e3dd0de5127c3a15 | udoy382/IntermediateAdPy | /iap_3.py | 364 | 3.890625 | 4 | # try:
# open("this.txt")
# except Exception as e:
# print(e)
# # open("that.txt")
# print("Program zinda hai")
#-------------
try:
file = open("that.txt", "r")
except EOFError as e:
print("eof error")
except IOError as e:
print("We can handle this error")
finally:
print("This will be printe... |
2bb5520112d4e0ccafa5417818871b81bd38ca60 | Lucca-GB/Python_Practice | /World 2/Exercício 36 – Aprovando Empréstimo.py | 469 | 3.828125 | 4 | casaValor = float(input('\nValor da casa? R$ '))
salario = float(input('Salario? R$ '))
anos = int(input('quantos anos de financiamento? '))
prestacao = casaValor / (anos * 12)
minimo = salario * 30 / 100
print('\npara pagar uma casa de R${:.2f} em {} anos'.format(casaValor, anos), end='')
print(' a prestacao ser... |
e623bca3f4154443a09d8295365ac6fd4e63852e | Lucca-GB/Python_Practice | /World 1/Exercício 19 – Sorteando um item na lista.py | 271 | 3.578125 | 4 | from random import choice
nome1 = str(input('nome um: '))
nome2 = str(input('nome dois: '))
nome3 = str(input('nome tres: '))
nome4 = str(input('nome quatro: '))
lista = [nome1, nome2, nome3, nome4]
escolhido = choice(lista)
print('aluno escolhido: {}'.format(escolhido)) |
23772f27b1c41fb00700966d529c1ce2fa7d83bb | Lucca-GB/Python_Practice | /World 1/Exercício 16 – Quebrando um número.py | 152 | 3.984375 | 4 | from math import floor
num = float(input('Digite um numero: '))
RealNum = floor(num)
print('A porção inteira de {} é {}'.format(num, floor(RealNum))) |
4b9f724f321c34155edf2d45c376a02df707b73b | Lucca-GB/Python_Practice | /World 2/Exercício 39 – Alistamento Militar.py | 705 | 3.96875 | 4 | from datetime import date
anoAtual = date.today().year
anoNasc = int(input("\nem que ano vc nasceu? "))
qntAnos = anoAtual - anoNasc
print('\nquem nasceu em {} tem {} anos em {}'.format(anoNasc, qntAnos, anoAtual))
if(qntAnos < 18):
saldo = 18 - qntAnos
print("\nvocê ainda vai se alistar no exército. Faltam... |
6e97979c957b36997bbc48591327df403e34fafc | Lucca-GB/Python_Practice | /World 1/Exercício 35 – Analisando Triângulo v1.0.py | 267 | 4.0625 | 4 | r1 = float(input('segmento 1:'))
r2 = float(input('segmento2: '))
r3 = float(input('segmento3: '))
if r1 < r2 + r3 and r2 < r1 + r3 and r3 < r1 + r2:
print('os segmentos podem formar um triangulo')
else:
print('os segmentos nao podem formar um triangulo :(') |
1d97d6ad2ce7ad0fe7679c72272eb2c5e70dc072 | chen-venix/Learning-Notes | /技术学习/算法学习/算法图解/sum.py | 196 | 3.96875 | 4 | def sum(arr):
total = 0
for x in arr:
total += x
return total
def sum_recursive(arr):
if len(arr) == 0:
return 0
return arr[0] + sum_recursive(arr[1:])
print(sum_recursive([1,3,6,4])) |
ca82de69dfe03e0d0a233c4e148b35bb352bd45a | wuji1738675589/88 | /mypy88_1.py | 865 | 4.5 | 4 | #测试的是类的定义
#了解一下什么是类
'''Python中一切都是对象,那对象是怎么产生的呢?
对象是由类产生的,如果把对象比作饼干,那么类就是定义对象的模具
同时类也时产生对象的对象。类是将方法(行为)和属性(状态)包裹起来,对象与类共享方法,属性不共享,方法一样,但处理的数据类型可能不一样,产生的属性值可能就不一样'''
#定义类
class Student: #class是定义类的关键字;类名首字母大写;多个单词时采用驼峰原则,例如GoodStudent
def __init__(self,name,age): #定义构造函数
self.name = nam... |
3cea67d6aa4f907a5114412f5468731764f38164 | poncovka/vype-compiler | /src/test/test_examples.py | 1,954 | 3.875 | 4 | '''
test_examples.py
Tests with examples from assignment..
'''
from base import TestCase, Error
class ExamplesTestCase(TestCase):
prefix = 'ex'
#-----------------------------------
def test_factorial(self):
self.input = \
r'''
/* Program 1: Vypocet faktorialu (iterativne) */
int main(void) { // Hlavni telo ... |
89537b891209255e9e7de50d2430600938390159 | f18-os/python-intro-judit8ha | /wordCount.py | 764 | 3.890625 | 4 | #! /usr/bin/env python3
import string
# print ui for file names
# open file to read from
fileNameIn = input('Please enter filename ')
ff = open(fileNameIn, "r")
# open file for writing or create if it does not exists
fileNameOut = input('Enter output file name ')
f = open(fileNameOut, "w")
# create a dictionary
word... |
eb1a3d973f0c9fe7f801be9dc731b1486f51864e | RyanPennell/Python | /Pset1.1_vowles.py | 350 | 3.765625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 5 16:24:13 2019
@author: ry4n
"""
s = 'azcbobobegghakl'
a = "a"
A = "A"
e = "e"
E = "E"
i = "i"
I = "I"
o = "o"
O = "O"
u = "u"
U = "U"
vowels = 0
for char in s:
if char in "aeiouAEIOU":
vowels = vowels+1
print(... |
889af0638e9b1b968ccab176f6d333dd690b3701 | TmadonnaD/midsessionsubmit | /Midsession_loops_conditionals.py | 1,446 | 4.375 | 4 | # -----------------------------------------------------
# 1.
# Write a function that takes an integer and prints
# that number of rows and columns of asterisks.
# -----------------------------------------------------
# PSEUDOCODE/notes:
# ~ for loop, because its a defined number of iterations.
#- - - - - - - - - -... |
9189533da63085f2b76cbd5e2bf4b0cbb305f344 | geeeh/boot-camp | /room/room.py | 656 | 3.921875 | 4 | class Room(object):
"""class to model object room"""
def __init__(self, room_name):
if type(self) == Room:
raise NotImplementedError("object cannot be instantiated directly")
self.room_name = room_name
class Office(Room):
""" class office extending Room class"""
def __init... |
11d47a3456d5c9e58eb46ce84abed124ea6035cb | youngclick/advGIS | /paycalc.py | 278 | 4.21875 | 4 | # Arup Guha
# 2/16/2013
# Pay Calculator - calculates how much money we made for an hourly job.
payrate = float(input("How much do you get paid an hour?\n"))
hours = int(input("How many hours did you work?\n"))
money = payrate*hours
print("You will make",money,"dollars")
|
0a8bf92fcd1a3b69ca4056bd9dacda182241313f | youngclick/advGIS | /prime3.py | 201 | 3.71875 | 4 | n = int(raw_input("what number should I go up to? "))
for p in range(2, n+1):
for i in range(2, p):
if p % i == 0:
break
else:
print p,
print 'Done' |
0c535ce07090e2d69cadb668b7d63135da912df0 | StevenGreenup/fraction_calculator | /script.py | 2,279 | 4.1875 | 4 | #!/usr/bin/env python3
import argparse
from lib.equation_parser import EquationParser
from lib.evaluate_equation import EvaluateEquation
"""
Author: Steven Greenup
Date: 10.15.19
Problem:
Coding Challenge
Write a command line program in the language of your choice that will take operations on fractions as an inp... |
0322a8e777170ed2899718dd79460a9477147c41 | 502BadGateway/transition_repo_2-3 | /traffic_light.py | 1,575 | 3.625 | 4 | import pygame #imports pygame library
import time #imports time api
import random #imports random api
class trafficLights: #a class for the traffic light
def __init__(self, x, y): #stores all variables
self.state = 3 #variable initiated by keyword "self" in this case variable is state for array 3
... |
7c260e18e6f708800554d32b39f66b56b361b00b | code-moe/newbie | /#04 Play with string.py | 1,619 | 3.859375 | 4 | #name : Python Strings
#author : CodeMoe
#date : August 10,2019
print("You can do four operations on string type variable")
print("1. First is Concatenation")
print("e.g -> ab = 'a' + 'b' ")
ab='a'+'b'
print('result of operation = '+ab)
print('')
print('2. Second is Multiplication')
print("e.g -> ab = ab*10 ")
pri... |
48b73acdbea803d5ddb1e9f45f2a8ecd2ca2b09d | code-moe/newbie | /#12 Iteration using For Function.py | 857 | 4.4375 | 4 | #name : Python Game Rock Paper Scissors
#author : CodeMoe
#date : August 21,2019
#Iteration using for
#For 'every character' in 'string'
for char in 'for loop':
print(char)
#Same with above just you can do more (Upper function)
for c in 'byting python':
print(c.upper())
#Print number from a range
for numbe... |
d6b0f4ab27eb38c39b25eb801de94c6b318698e7 | Nicofaienza/mi_primer_programa | /comer_helado.py | 1,518 | 4.21875 | 4 | apetece_helado_input = input("Te apetece un helado? (Si/No) ").upper()
if apetece_helado_input == "SI":
apetece_helado = True
elif apetece_helado_input == "NO":
apetece_helado = False
else:
print("No me dijiste ninguna de las dos opciones, voy a tomarlo como un NO")
apetece_helado = False
tiene_diner... |
929e15b2ed2bce6b839f9ad7a5b8073cbb0c01d6 | TheRealStayman/pyVote | /VotingMachine.py | 3,038 | 3.59375 | 4 | from Tkinter import *
import math
master = Tk()
criteria = ["Cheesiness", "Cowbellness", "Coolness", "Likability"]
ideas = ["Cheese", "Cowbell", "Stephen Colbert", "Ricky Gervais"]
bios = ["Man's never hot", "According to all known laws of aviation", "There is no reason a bee should be able to fly", "The bee o... |
accccd6907e6c2dc613d5d2c6bf1ab623c4426e2 | bjbaer/Prob | /prob.py | 1,031 | 3.765625 | 4 | import numpy as np
import scipy.stats as stats
import matplotlib.pyplot as plt
import collections
data = [1, 4, 5, 6, 9, 9, 9] # I was not sure if we were supposed to use this data or the longer set or random data, I tested using all three in place of this and they worked
count = collections.Counter(data)
count_sum ... |
dc9819cab55f9516eeb29ea431b1f65739e380b0 | pastelmind/d2txt | /samples/group_weapons_by_hand.py | 2,761 | 3.734375 | 4 | #!/usr/bin/env python
"""
Assigns item codes to `type2` of all weapons based on the number of hands required.
Note: This script modifies Weapons.txt.
"""
import argparse
import sys
from d2txt import D2TXT
def check_item_code(item_code):
"""Checks if item_code is a valid item code. Used to validate argparse op... |
f0af0be75312362117131199da47dc974e617cbc | 19101990/wtaRanking | /WTARanking.py | 1,931 | 3.765625 | 4 | '''
Note:
for this program to run beautifulsoup4 and lxml are needed
if you don't have it installed on your computer, go to cmd and type:
pip install beautifulsoup4
pip install lxml
'''
import bs4 as bs
import urllib.request
sauce = urllib.request.urlopen('http://www.tennis.com/rankings/WTA/').read()
soup =... |
92138c0e41b3c37b2010de89c7bec71d66d52bae | KapishPandoh/Python-Project | /Guess_the_no/Guess_the_no.py | 441 | 4 | 4 | import random
no = random.randrange(1,100)
guess = int(input("Guess a no between 1 and 100 : "))
while(guess!=no):
if(guess<no):
print("You need to guess higher..Try again")
guess = int(input("\nGuess a no between 1 and 100 : "))
else:
print("You need to guess lower..Try ag... |
4e652ed3b69f994760f90d6f2e6775f037087571 | ebyron-arch/HAD-INDIA | /Code/problem.py | 260 | 3.609375 | 4 | A=[]
n=int(input("ENTER THE FINAL ODD NUMBER YOU WISH"))
for i in range(0,n):
if (i%2!=0):
A.append(i)
print(A)
B=[]
c=[1,2]
D=[]
for i in A:
fn=((3**i)/2**(i-1))*((i+1)-2)
B.append(fn)
if fn in c:
D.append(fn)
print(B)
print(D) |
24fdbbefad2d6f05beea82f6cac702ea4232060e | ESzabelski/Good-Projects | /brute force.py | 6,597 | 4.15625 | 4 | #a brute force password breaker demo. This is for demo purposes of using a password 8 letters long composed
#with a defined range of letters
#key lessons, when adding the 3rd letter, i realized i had to have a blank string in the 2 letter section to cycle correctly
letters=["a","b","c","d","e","f","... |
12c7b64553797fd9960026214ea78a8f877e3362 | matpsandoval/python-exercises | /activity-02/exercise4.py | 315 | 3.765625 | 4 | import random
rows = int(input("Ingrese la cantidad de filas:"))
columns = int(input("Ingrese la cantidad de columnas:"))
c = 0
while rows > c:
x = 0
a = []
while columns > x:
a.append(random.randint(-(rows*columns), rows*columns))
x += 1
print(a)
c += 1
|
61ddda325ddacd46255429d8a620d0ec72cc69e6 | MiningMouse/GeneralAssemblyDataScience2013 | /HomeworkAssignment_05/clustering_health.py | 6,879 | 3.890625 | 4 | """Perform k-means clustering on a dataset containing various health metrics
for countries as gathered by The World Bank.
http://data.worldbank.org/topic/health
http://api.worldbank.org/datafiles/8_Topic_MetaData_en_EXCEL.xls
Requirements:
pandas Version 0.12+
xlrd For Excel file reading. (pip install xlrd)
"""
... |
78407f8ad0d6ca681b776f83f922af5cbc6b9486 | tnktakuma/competition | /bellman_ford.py | 1,466 | 4.03125 | 4 | from typing import List, Union
class BellmanFord:
"""Bellman-Ford Algorithm returns the shortest path at weighted graph.
Args:
n (int): number of the vertices.
edge (List[(i, j, w)]): weighted edge list.
i (int): the edge's source.
j (int): the edge's destination.
... |
450de1346cae3a3a7024b0eefdb2987b27e79f23 | roosterhat/Personal | /Python/School/Quiz4/BinarySearchTree.py | 4,407 | 3.78125 | 4 | class BinaryTree:
def __init__(self,value=None,parent=None,comparator=None):
self.value = value
self.parent = parent
self.left = None
self.right = None
if comparator is None:
self.comparator = lambda x,y: x-y
else:
self.comparator = comparator
... |
404f864cc86f8c0b5e3432cf86e60226814b73b6 | roosterhat/Personal | /Python/Final/HashDict.py | 3,560 | 3.5 | 4 | from AbstractDictionary import AbstractDictionary
import random
class HashDict(AbstractDictionary):
def __init__(self, size=10, hashcomp=None):
self._dict = {}
self.size = size
if hashcomp is None:
self.hashComparator = HashComparator()
else:
self.hashCompar... |
297696bb23ff1ab3af1c2b33c2442f5fa80374e0 | roosterhat/Personal | /Python/School/Quiz1.py | 1,704 | 3.609375 | 4 | import math
def isfibo(num):
l = 0
c = 1
for i in range(0,num):
o = c
c = l+c
l = o
if num==c:
return True
return False
def isfiboR(num):
def fibor(l,c):
o = c
c = l+c
l = o
if(c>num):
return False
if(c... |
9059501f2dc0b2555343d45e05cc743d7d6e4e08 | Sakshi0810/Hackerrank_30_days_of_code | /Day2_Operators.py | 483 | 3.703125 | 4 | import math
import os
import random
import re
import sys
# Complete the solve function below.
def solve(meal_cost, tip_percent, tax_percent):
tip=float(meal_cost*(tip_percent/100))
tax=float(meal_cost*(tax_percent/100))
total=meal_cost+tip+tax
print(round(total))
if __name__ == '__main__':
... |
a6f3629af0708bb13f12688751e0c39ec9998261 | JackHumphreys/Functions | /functions_currency_convertor.py | 111 | 3.5 | 4 |
def currency():
currency = input("Please enter your currency. Either Pounds, Dollars or Euro: ")
|
6b0228247b31467c8ea61498603fc01d3c4cc560 | DePaulaRafael/Python-Bossini | /aritmetica.py | 2,894 | 3.765625 | 4 | a = int(input())
b = input()
c = int(input())
d = input()
e = int(input())
action1 = str
# d = -
if b == '+' and d == '-':
action1 = a + c - e
elif b == '-' and d == '-':
action1 = a - c - e
elif b == '*' and d == '-':
action1 = a * c - e
elif b == '/' and d == '-':
if a ==0 or c == 0 :
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.