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 |
|---|---|---|---|---|---|---|
08a776b2bb053d2c687f44434b0e2be618761c0f | dipanshuchaubey/face-recognition | /draw_around_faces.py | 1,702 | 3.671875 | 4 | import face_recognition
from PIL import Image, ImageDraw
from fetch import fetchfaces
# fetch all face from the database
known_face_encodings, known_face_names = fetchfaces.fetchAllFaces()
print(known_face_encodings)
print(known_face_names)
# Load an image with an unknown face
unknown_image = face_recognition.load_i... |
3a735f5d50b0915bd1ab9f6684ba6fffeacf4605 | PratikBali/python-learning | /asgn/a05/a5q3.py | 895 | 3.859375 | 4 | from itertools import permutations
def Permutation(param):
permList = permutations(param)
for perm in list(permList):
print (''.join(perm))
# def Permutation2(param):
# s1 = []
# for i in range(len(param)):
# m = param[i]
# remLst = param[:i] + param[i+1:]
# for p in Per... |
abf698f17800474b89630d241be76ea41f35e156 | PratikBali/python-learning | /asgn/a08/a8q1.py | 565 | 3.625 | 4 | import threading
def even(no):
counter = 1
while no > 0:
if counter % 2 == 0:
print('Even: ', counter)
no -= 1
counter += 1
def odd(no):
counter = 1
while no > 0:
if counter % 2 != 0:
print(' Odd: ', counter)
no -= 1
cou... |
16a9fab1c66f7d99c2b2d9188e1e041d7f356a62 | PratikBali/python-learning | /asgn/a03/a3q3.py | 357 | 3.75 | 4 | arr = list()
def fun(n):
for i in range(0,int(n)):
no = input('Num: ')
arr.append(int(no))
if i == 0:
min1 = arr[i]
else:
min2 = arr[i]
if min2 < min1:
min1 = min2
return min1
n = input('Enter no of elements: ')
ret = fun(n)
... |
637cae26a80dce910b7065e1e8e4945473491dfb | PratikBali/python-learning | /asgn/a10/auto/ExtensionRename.py | 1,022 | 3.515625 | 4 | from sys import argv
import os
argc = 3
def fun(find, replace):
# print('file: {}, prev ext: {}, new ext: {} '.format(argv[1], find, replace))
# o = dir_path = os.path.dirname(os.path.realpath(__file__))
path = os.getcwd()
# print('{}, {}'.format(o,path))
for dir,subdir,files in os.walk(path):
... |
20ef55c11e0fde085d0510f5effa456499a35c95 | PratikBali/python-learning | /ml/Clustering_random_KMeans_UserDefAlgo.py | 3,686 | 3.765625 | 4 | import numpy as np
import pandas as pd
from copy import deepcopy
from matplotlib import pyplot as plot
def KMean():
# Set three centers, the model should predict similar result
center_1 = np.array([1, 1])
print(center_1)
center_2 = np.array([5, 5])
print(center_2)
center_3 = np.array([8, 1])... |
ffe201d1eab6825a2018daf00d6474b44d4de8f1 | PratikBali/python-learning | /pandas/regex.py | 425 | 3.890625 | 4 | import re
print('hi')
str = "Maharashtra chi language Marathi ahe ani mipan marathi ahe jay maharashtra"
x = re.findall('ma', str)
print('1',x)
x = re.findall('Ma', str)
print('2', x)
str = 'India is my country'
x = re.search('^India', str)
print('3', x)
str = 'Royal is always royal'
x = re.split('\s', str)
print... |
bcad09d3323ee4446d63c27d880864a5828b85ab | Luke-Wilson/Python-practice | /TicTacToe.py | 3,140 | 4.03125 | 4 | #http://www.practicepython.org/exercise/2015/11/26/27-tic-tac-toe-draw.html
def createboard():
#when called, creates the board for the game
global board
board = []
for x in range(3):
board.append(["-","-","-"])
return board
def print_board():
#prints the board in an easy to read format
print board[0]
print b... |
c10b40de253be40d0797fb7e1034a1701297946e | shamikbose/python_examples | /replaceWithRegex.py | 208 | 3.609375 | 4 | # replaceWithRegex.py
import re
text = "Today is 10/29/2019. Deadline is 11-15-2019"
print(text)
print(re.sub(r"(\d+)/(\d+)/(\d+)", r"\1-\2-\3", text))
print(re.sub(r"(\d+)-(\d+)-(\d+)", r"\1/\2/\3", text))
|
9bd76ced109cad700e43bf37c565d36bcf81d2be | shamikbose/python_examples | /GroupBy_Demo.py | 979 | 3.5 | 4 | # GroupBy_Demo.py
rows = [
{"address": "5412 N CLARK", "date": "07/01/2012"},
{"address": "5148 N CLARK", "date": "07/04/2012"},
{"address": "5800 E 58TH", "date": "07/02/2012"},
{"address": "2122 N CLARK", "date": "07/03/2012"},
{"address": "5645 N RAVENSWOOD", "date": "07/02/2012"},
{"address"... |
8bacb8563b59093b1f6fd7022a8ff04c6930d833 | shamikbose/python_examples | /Sorting.py | 2,892 | 3.84375 | 4 | import random
import copy
import time
import sys
def main():
a = []
if sys.argv[1] == "1":
print "Testing with smaller arrays..."
for x in range(10):
a.append(random.randint(0, 100))
print a
b = copy.deepcopy(a)
start = time.time()
mergeSort(a, 0, le... |
3f88cab2104384aed0d5e1b0352fa9abd7443ec8 | shamikbose/python_examples | /allSubstrings.py | 251 | 3.8125 | 4 | from itertools import combinations
# initializing string
test_str = "Geeks"
# printing original string
print("The original string is : " + str(test_str))
res = [test_str[x:y] for x, y in combinations(range(len(test_str) + 1), r=2)]
print(str(res))
|
7e753f0d11f0ac3eb9e4a8678b5255534dd9303b | shamikbose/python_examples | /heapsort.py | 1,237 | 3.9375 | 4 | # heapsort.py
def heapify(a, i):
l = 2 * i + 1
r = l + 1
if l < heap_size and a[l] > a[i]:
largest = l
else:
largest = i
if r < heap_size and a[r] > a[largest]:
largest = r
if largest != i:
a[i], a[largest] = a[largest], a[i]
# print a
heapify(a, l... |
f146ea60b6020a1fb84af44b1bd5985841807deb | barlima/LBL-dataset | /ImportToPSQL.py | 2,569 | 3.640625 | 4 | import sys
import psycopg2
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
def connectToDatabase(connection):
#print the connection string we will use to connection
print "Connecting to postgres:\n%s" % (connection)
#get a connection, if a connect cannot be made an exeception will beraised h... |
41a764eaebbdd5b33e8e715c60aeeac3fe9be45b | SophieYu1014/Emulator | /rocky.py | 951 | 3.796875 | 4 | from time import sleep as slp
import numpy as np
import datetime
def repeat(i):
string = "今天是第%d天" % i
print(string)
eat()
sleep()
code()
i += 1
# Calling a function inside itself, this is called RECURSION.
if i < 3:
repeat(i)
print(i)
def get_date():
today = dateti... |
2da63276d8dfcc353214816807d241feeb2db59e | Taewan-P/python_study | /exercise_2017/14th_week/bouncingball.py | 3,705 | 3.515625 | 4 | from tkinter import *
class Box:
def __init__(self, size, stake_size):
self.size = size
self.stake_size = stake_size*2
def in_horizontal_contact(self, x):
return x <= 0 or x >= self.size
def in_vertical_contact(self, y):
return y <= 0 or y >= self.size
... |
8c4b747ff5636c601aaadfd4985409eba43d7fc3 | Taewan-P/python_study | /exercise_2017/9th_week/dplab.py | 1,664 | 3.671875 | 4 | def minsteps0(n):
if n > 1:
r = 1 + minsteps0(n - 1)
if n % 2 == 0:
r = min(r, 1 + minsteps0(n // 2))
if n % 3 == 0:
r = min(r, 1 + minsteps0(n // 3))
return r
else:
return 0
# print(minsteps0(1))
# print(minsteps0(2))
# print(minsteps0(3))
# prin... |
8eecd733caba30fc1f8f472ca67b76e9f2d097a8 | Taewan-P/python_study | /exercise_2017/15th_week_teamproj_presentation/programming_team/jatoe.py | 9,075 | 3.5 | 4 | # 수독 9x9
import random,time,pygame
from tkinter import *
from tkinter import messagebox
#Model
class Board:
@staticmethod
def create_board():
"""create initial board"""
seed = [1, 2, 3, 4, 5, 6, 7, 8, 9]
random.shuffle(seed)
n1 = seed[0]
n2 = seed[1]
n3 = seed[2]
n4 = seed[3]
n5 = seed[4]
n6 = see... |
4b2e01d18aae5f4b863e9aa610ea0fb1c8f6fdf5 | Taewan-P/python_study | /exercise_2017/5th_week/assignment_2.py | 1,745 | 3.71875 | 4 |
WRITE_CODE = False
# 1. 곱셈 함수(꼬리 재귀)
def mult1(m,n):
def loop(n,ans):
if (n>0):
return loop(n-1,m+ans)
else:
return ans
return loop(n,0)
# 2. 곱셈 함수(while문)
def mult2(m,n):
ans = 0
while (n>0):
ans += m
n = n-1
return ans
###################
# 수정 X #
# 곱셈 함수 보조 함수 #
def double(n): #... |
5cd4ded3853a9e791429cec6e216829bc380991c | Taewan-P/python_study | /exercise_2017/10th_week_canceled/test.py | 1,095 | 3.671875 | 4 | def split_digit(num):
a = num
a.split()
first = int(a[0])
second = int(a[1])
third = int(a[2])
fourth = int(a[3])
result = [first, second, third, fourth]
return result
def anagram(lists):
list_sort = []
printer = []
num = 0
# hoz = 0
ver = 0
#4자리 숫자를 한개씩 나눈후 정렬한 뒤에 2차원 배열에 넣기
for i in lists:
a = s... |
60d6b3c1bcbeb94d4e9ef6ec3cae76c2813e40d3 | Taewan-P/python_study | /exercise_2017/4th_week/assignment_3.py | 1,426 | 3.875 | 4 | # -*- coding: utf-8 -*-
# UTF-8 encoding when using korean
def get_number():
return input("수를 입력하세요.\n")
def print_result(srm,res):
print(srm,"의 제곱근은",res,"입니다.")
def isfloat(s):
(m,_,n) = s.partition(".")
return m.isdigit() and (n.isdigit() or n=="") or \
m == "" and n.isdigit()
#여기서 리턴뒤에 있는 문장을 실행하면... |
6c2baf7368766828aac712bf591db8fba027a420 | LabheshLalka11/SortingAlgorithms-Python | /InsertionSortAlgorithm.py | 487 | 4 | 4 | '''
The time complexity of Insertion sort is : O(n²)
The Space complexity of Insertion sort is : O(1)
'''
array = [5,4,2,6,8,-1]
def Insertionsort(array):
for i in range(1,len(array)):
current_value = array[i]
position = i
while(position>0 and current_value<array[position-1]):
arra... |
ccd78e2f0e5049b19308ebff2cbe09af4b61f251 | drewserles/Project-Euler | /55_LychrelNumbers.py | 1,379 | 3.671875 | 4 | """
PROBLEM 55
https://projecteuler.net/problem=55
-----------------------------------------------------------------------------
OBSERVATIONS
-Problem is asking us to find the numbers that don't become palindromes
in less than 50 iterations
-It does not count if the number is a palindrome to begin with. The clue says
4... |
08c2e5891f5b0766f106745a33a606e136ee4470 | drewserles/Project-Euler | /57_SquareRootConvergents.py | 1,039 | 3.578125 | 4 | """
PROBLEM 57
https://projecteuler.net/problem=57
-----------------------------------------------------------------------------
OBSERVATIONS
-----------------------------------------------------------------------------
STRATEGY
Brute force solution. Do the calculation for each expansion number on its own.
Compare the... |
57a63562bee47320de53269acdf627f37298f89a | JogvanPatursson/raest | /rpi/led.py | 1,117 | 3.84375 | 4 | # led.py
# Libraries
import RPi.GPIO as GPIO
import time
# Pin number 24 is used for blue LED
BLUE_PIN = 24
# Pin number 25 is used for green LED
GREEN_PIN = 25
# Pin number 8 is used for red LED
RED_PIN = 8
# Switch off warnings
GPIO.setwarnings(False)
# Setting pin numbering to BCM
GPIO.setmode(GPIO.BCM)
# Sets a... |
87d51004bca71bfe7a716e2cdc1b460170b17d68 | Valentina1502/LABA_3 | /zd3.py | 388 | 3.578125 | 4 | #!/usr/bin/env python3\
# -*- coding: utf-8 -*-
def f():
proizv = 1
while True:
mnogitel = int(input("Введите множитель: "))
proizv *= mnogitel
if mnogitel == 0:
print("Произведение = 0")
break
else:
print(f"Произведение = {proizv}")
if __na... |
09b2f7f25a5a841e136b25dc8a01bffa083b8346 | quarter64/small | /random_time.py | 745 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
brief:自动生成日期区间的时间戳python代码
bug:不能显示28以上日期
author:zwx
date:2015-4-15
"""
import time
import random
def limit(start,end):
return(random.randint(start,end))
def connent(num):
date_result = ""
for i in range(num):
year = limit(2015,2015)
moon = limit... |
fdb96fda230a988dbc4f8756e873cd60d34d6093 | fromgopi/DS-Python | /src/strings/CharFreqCount.py | 284 | 3.796875 | 4 | def char_frequecy(str):
count = {}
for n in str:
keys = count.keys()
if n in keys:
count[n] += 1
else:
count[n] = 1
return count
if __name__ == '__main__':
print('Hello World!')
print(char_frequecy("abracadabra"))
|
df138a21727148ca2dbc3afded152bb211857400 | fromgopi/DS-Python | /src/processing/tax.py | 528 | 4 | 4 | import time
def basic_func(x) -> str:
"""
Basic function to check if number is odd or even.
:param x: Int
:return: String
"""
if x == 0:
return "zero"
elif x % 2 == 0:
return "even"
else:
return "odd"
if __name__ == '__main__':
start_time = time.time()
... |
00928fae0afba123c3a877a2d7f1cddcdd933447 | fromgopi/DS-Python | /Design-Patterns/designpatterns/creational/factoryPatter/database_connection/database_factory/database.py | 226 | 3.828125 | 4 | from abc import ABC, abstractmethod
class Database(ABC):
"""This is concrete Interface."""
@abstractmethod
def connection(self):
"""Abstract Method which will allow user to implement it."""
pass
|
58bd82ac0a4eb5331736225afcb3e1ec9865f0a7 | Stheycee/Exerc-cio | /stheyce_q2_tuplas.py | 1,325 | 4.625 | 5 | '''
é comum no jogo de dominó ter uma rodada antes de iniciar o jogo na qual todos os integrantes escolhem
apenas uma pedra e quem retirar o maior valor inicia o jogo,
outra situação é quando o jogo fecha e inicia a contagem de pontos, aquele que tiver a menor pontuação vence.
simule um jogo de dominó com quatro jogado... |
3fcc571bb9364361a1eceb784ae16dc5e57a4e30 | patilkrunal/Python-Mini-Projects | /Tkinter Course/tk_checkbox.py | 638 | 3.71875 | 4 | from tkinter import *
window = Tk()
window.title('Image Example')
img = PhotoImage(file='krunal.png')
label = Label(window, image=img, bg='yellow')
small_img = PhotoImage.subsample(img, x=2, y=2)
btn = Button(window, image = small_img)
txt = Text(window, width=28, height=13)
txt.image_create('1.0', image=small_img... |
a39a83abe6ca5ef7558c0dc506559962bf1f44df | patilkrunal/Python-Mini-Projects | /contact app tkinter/aboutus.py | 641 | 3.921875 | 4 | from tkinter import *
class AboutUs():
def __init__(self):
Toplevel.__init__(self)
self.geometry("650x650+600+200")
self.title("About us")
self.resizable(False, False)
self.top = Frame(self, height=650, width=650, bg="#ffa500")
self.top.pack(fill=BOTH)
sel... |
2f57c89bff47d1b6578a12d4dc56b76101f0529a | edmilsonchaves/python_code | /progressao_aritmetica.py | 1,187 | 3.59375 | 4 | #_______________________________________________________________________#
# Name: "Progressão Aritmética"
# Version: "1.0.0"
# Description: "Progressão aritmética"
# Author: edmilsonchaves
# Language: pt-br
#_________________________IMPORTANDO BIBLIOTECAS________________________#
from os import system
from time import... |
ae3e2d7310187c27d738617789e3dd2e8c751a68 | djkjohnston/hackerrank_sandbox | /algorithms/equality-in-a-array.py | 466 | 3.921875 | 4 | #equality-in-a-array
#https://www.hackerrank.com/challenges/equality-in-a-array/problem
#!/bin/python3
import sys
def equalizeArray(arr):
# Complete this function
value_counts = [arr.count(x) for x in set(arr)]
#print(value_counts)
return sum(value_counts) - max(value_counts)
if __name__ =... |
b4934c82cc47a7574cbe59a2f533b670f426f60b | djkjohnston/hackerrank_sandbox | /algorithms/climbing-the-leaderboard.py | 700 | 3.765625 | 4 | #climbing-the-leaderboard
#https://www.hackerrank.com/challenges/climbing-the-leaderboard/problem
#!/bin/python3
import sys
if __name__ == "__main__":
n = int(input().strip())
scores = list(map(int, input().strip().split(' ')))
m = int(input().strip())
alice = list(map(int, input().strip().split(' '))... |
dea655bf0cc1da98075f74475a349f66952c723e | djkjohnston/hackerrank_sandbox | /algorithms/cat_and_mouse.py | 501 | 3.65625 | 4 | # cat and mouse
# https://www.hackerrank.com/challenges/cats-and-a-mouse/problem
#!/bin/python3
import sys
def mouse_chase(x, y, z):
dist_a = abs(z-x)
dist_b = abs(z-y)
if dist_a < dist_b:
return("Cat A")
elif dist_b < dist_a:
return("Cat B")
else:
return("Mouse C")
... |
5b4d8c87bdac439f9129969434726c5f1d988172 | jeffalstott/powerlaw | /testing/walkobj.py | 2,106 | 4.21875 | 4 | """walkobj - object walker module
Functions for walking the tree of an object
Usage:
Recursively print values of slots in a class instance obj:
walk(obj, print)
Recursively print values of all slots in a list of classes:
walk([obj1, obj2, ...], print)
Convert an object into a typed tree
typ... |
16f321d3bc21655feba8e64610b2d97ef1ed721e | mndarren/Code-Lib | /Python_lib/coding_challenge/fun4.py | 857 | 3.75 | 4 | # find largest palindrom numbers
numbers = [12345, 6754, 9087, 1234562349240234234235645754632, 12123344213, 12359235934894378437238923892398575624]
def isPalindrom(num):
if len(num) < 3:
return true
num_str = str(num)
num_enum = enumerate(num_str)
index_last = len(num_str) - 1
for i, v in ... |
d05be8a4e6da5f68d5583a54b68420671ed73c1e | mndarren/Code-Lib | /Python_lib/coding_challenge/fun2.py | 191 | 3.53125 | 4 |
def generate_rule_nums():
base1 = 3
base2 = 5
my_sum = 0
my_max = 10000
for i in range(1, 10000):
if i%base1 == 0 or i%base2 == 0:
my_sum += i
print(my_sum)
generate_rule_nums()
|
5408a41de1285f67e1632668e2c739b847045300 | Federico-PizarroBejarano/Don-Mills-Online-Judge | /The Cell Sell.py | 846 | 3.625 | 4 | def round2(x):
x = list(str(x))
for i in range(len(x)):
if x[i] == ".":
if len(x[i:i+4]) <= 3:
return float("".join(x))
x = x[:i+4]
break
if int(x[-1]) >= 5:
x = list(str(float("".join(x)) + 0.01))
x = x[:-1]
return fl... |
2370b500f13402459e71b96992dbc310eb2a36d2 | Federico-PizarroBejarano/Don-Mills-Online-Judge | /Big Bang Secrets.py | 316 | 3.625 | 4 | alph = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", \
"p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z")
k = int(raw_input())
word = raw_input()
new = ""
for i in range(len(word)):
new += alph[(alph.index(word[i].lower())) - (3*(i+1) + k)%26].upper()
print new
|
dc0965c26c4ba80eae6ac74764519a06896834e3 | Federico-PizarroBejarano/Don-Mills-Online-Judge | /Square.py | 107 | 3.90625 | 4 | from math import sqrt
a = input()
print "The largest square has side length " + str(int(sqrt(a))) + "."
|
1d1f67313e2fbd6fb47dfe25a09ea2e05b4003d8 | Federico-PizarroBejarano/Don-Mills-Online-Judge | /I Speak TXTMSG.py | 1,025 | 3.765625 | 4 | a = True
b = []
while a:
item = raw_input()
if item=="CU":
b.append("see you")
continue
elif item==":-)":
b.append("I'm happy")
continue
elif item==":-(":
b.append("I'm unhappy")
continue
elif item==";-)":
b.append("wink")
... |
81cf13d3aea17939ec93e78871d79c02919847c3 | enibeni/6_password_strength | /password_strength.py | 2,171 | 3.734375 | 4 | import string
import getpass
import datetime
def check_pass_length_more_than(password, length):
return len(password) < length
def check_all_chars_are_not_the_same(password):
return password.count(password[0]) == len(password)
def check_all_chars_are_not_the_same_type(password):
return password.isdigit... |
78e15517a0f0774d2a76841f4164b395a8b6f6dc | seanchoi/algorithm01 | /algo_01.py | 326 | 3.65625 | 4 | # Input: "banana"
# Output: "anana"
# Input: "million"
# Output: "illi"
import math
class Solution:
def longestPalindrome(self, s):
# Fill this in.
for i in range(len(s)):
if s[i-1] == s[len(s)-1-i]:
# Test program
s = "tracecars"
print(str(Solution().longestPalindrome(s)))
# r... |
f430e71d435c22f2f75fa59697570c89462905eb | kozaka93/InterpretableHouseSalePrices | /Data/TrainAndTest/geofast.py | 1,431 | 3.96875 | 4 | import math
import numpy as np
def _dist(lon1,lat1,lon2,lat2):
"""
Very fast computation for distance between (lon1,lat1)
and (lon2,lat2) providing the locations are not so far
away, i.e. in one city.
Parameters:
lon1 : float
Longitude of the first point
lat1 : flo... |
ad58b9e2adc2a9f75a710d1236730ec2c9ff7f1d | slb6-final/PersonalLibrary | /slb6_Final_CheckIn.py | 3,494 | 3.859375 | 4 | # Shannon Buchanan
# Final Project Check-In
import csv
# function for Yes/No question, Boolean response
def yes_no(choice):
yes = set(['yes', 'y', ''])
no = set(['no', 'n'])
if choice in yes:
return True
elif choice in no:
return False
else:
print("Please ... |
3e4784128d4d57f99369faea4bc42b917b4cbada | thaonll88/self_learning | /main.py | 547 | 3.578125 | 4 | import Input
import account
def main():
print("Welcome to the atm.")
while True:
amount = None
selection = Input.get_selection()
if selection == "q":
break
elif selection == "s":
account.Account().show_balance()
elif selection is not None:
... |
dea24af2de89866d3a77fce75b268f6be6306b8d | AntGrimm/180bytwo_home_assignment | /app.py | 1,881 | 4.21875 | 4 | # Functions are commented out at the bottom, remove comment to run each function
import itertools
# Removing a character in a loop and checking word against dictionary
def check_super_word(check_str, dictionary):
for i in range(0, len(check_str)): # Removing each character in loop
new_str = ''.join([che... |
b50b9d299da795b7699ac093426ef429350d5209 | AlexandreVictor/exercicios_coursera | /3 - Week/Exerc_1.py | 246 | 3.828125 | 4 | """Exercício 1 - Par ou ímpar?
Receba um número inteiro na entrada e imprima
par - quando o número for par ou
ímpar - quando o número for ímpar."""
vlr = int(input("Par ou ímpar?"))
if(vlr%2==0):
print("Par")
else:
print("impar") |
c4d1da45a978d2a7ba362cff0a01c7a185d40975 | jdpinedaj/weather_request | /weather_request.py | 1,083 | 3.71875 | 4 | import requests
import json
import pandas as pd
def get_weather_data(lat, lon, time, key):
"""
Request weather data from the dark_sky API.
The key must be obtained from the official website.
"""
lat = str(lat)
lon = str(lon)
time = str(time)
time = pd.to_datetime(time,infer_datetime_... |
e927ae4ddbd88bd9318a2d9324073f3f14863360 | javiervertedor/IGCSE-2021-pre-release | /advanced.py | 2,744 | 3.703125 | 4 | class Train:
""" Train class that has """
def __init__ (self, totalSeats=480):
self.totalSeats = totalSeats
self._availableSeats = totalSeats
def __repr__ (self):
return f'{self.__class__.__name__}: Total seats: {self.totalSeats!r}, Available seats: {self._availableSeats!... |
92981d413c09f856be6dbc5a78c40717b8e04d69 | 5l1v3r1/Morpheos | /backend/modules/history/statistics.py | 735 | 3.609375 | 4 | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Statistics
#
# This file holds functions to be used with the results of
# sumarizations (see file summarize.py).
def most_repeated(summarized, n):
'''
Looks for most repeated items in summarization
This function looks for the most repeated keys i... |
41d2b009044c0725c83d588cc15700d4775a48a6 | KKEIO1000/Sorting-Algorithms | /Bubble Sort (Optimized Ω(n)).py | 707 | 4.3125 | 4 | import random
def bubble_sort(lst):
"""Function to sort a list via optimized bubble sort, O(n^2), Ω(n) if the list is already sorted"""
#Sets a flag so if no swap happened, the loop exits
sort = True
#Main body of the iterative loop
while sort:
sort = False
for i in range(len(lst)-1):
... |
79bbed5716dd9fffc021c3f09964a5a69efca328 | meghalmurkute/taskmanager | /Task Manager/Demo.py | 277 | 3.890625 | 4 | from datetime import date
from datetime import datetime
today = date.today()
now = datetime.now()
# dd/mm/YY
d1 = now.strftime("%d/%m/%Y")
t1=now.strftime("%H:%M")
print(d1, "\n", t1)
date="12/09/2020"
time=t1
task="Abc"
if d1== date:
if t1==time:
print(task)
|
2a55b6f2a7de70d39010353481990a428fd5a946 | margarineHound/graphical-puzzle-solver | /puzzle.py | 2,299 | 4.09375 | 4 | #!/usr/bin/env python3
class Puzzle(object):
"""
Puzzle class defines the structure and behavior of a collection of Tile objects. The state of a Puzzle is not mutated directly. Rather, the state of the Tile objects attached to a Puzzle instance are each mutable, implicitly modifiying the state of the Puzzl... |
e908e98c2fe35d9b4fd3a7e534f09a3773bf7658 | Camomilaa/Python-Curso-em-Video | /ex022.py | 392 | 3.921875 | 4 | nome = str(input('Digite seu nome completo: ')).strip()
print('Seu nome com todas as letras maiúsculas: {}'.format(nome.upper()))
print('Seu nome com todas as letras minúsculas: {}'.format(nome.lower()))
print('A quantidade de letras total é igual a {}'.format(len(nome) - nome.count(' ')))
esp = nome.find(' ')
print('A... |
302b3bcb67cdb3c0e2bce6170c834038fde31749 | Camomilaa/Python-Curso-em-Video | /ex038.py | 283 | 3.96875 | 4 | n1 = int(input('Insira um número: '))
n2 = int(input('Insira outro número: '))
if n1 == n2:
print(f'Os dois números são iguais, {n1}')
elif n1 > n2:
print(f'O primero valor é maior que o segundo, {n1}')
else:
print(f'O segundo valor é maior que o primeiro, {n2}')
|
a0aebdf0c9056f90ef637adb27a6a9c8eee8feb8 | Camomilaa/Python-Curso-em-Video | /ex065.py | 448 | 3.921875 | 4 | resp = ''
soma = quantV = 0
while resp != 'N':
n = int(input('Digite um número: '))
soma += n
quantV += 1
if quantV == 1:
maior = n
menor = n
else:
if n > maior:
maior = n
if n < menor:
menor = n
resp = str(input('Deseja continuar? [S/N] ')... |
3dc43bfd0de69339708cb7bf077758d7428be746 | Camomilaa/Python-Curso-em-Video | /ex054.py | 269 | 3.984375 | 4 | from datetime import date
maior = 0
menor = 0
for c in range(0,7):
ano = int(input('Informe o ano de nascimento: '))
if (date.today().year - ano) >= 18:
maior += 1
else:
menor += 1
print(f'{menor} menores de idade\n{maior} maiores de idade') |
090acdc12d72de98bda1d719f0b6a7921a3e03a0 | Camomilaa/Python-Curso-em-Video | /ex056.py | 546 | 3.53125 | 4 | totI = 0
velho = 0
mHom = ''
mulN = 0
for c in range(0, 4):
nome = str(input('Informe o nome: '))
idade = int(input('Informe a idade: '))
sexo = str(input('Informe o sexo: '))
totI += idade
if idade > velho and sexo.upper() == 'M':
velho = idade
mHom = nome
if sexo.upper() == '... |
caf6f82a750322f012a678ea48c8695db116a0a1 | Camomilaa/Python-Curso-em-Video | /ex048.py | 135 | 3.796875 | 4 | soma = 0
for c in range(1, 501, 2):
if c % 3 == 0:
soma += c
print(f'A soma de todos os multiplos de 3 é igual a {soma}')
|
f5ef3842d0533537c60c15580034098ddab41a8c | Camomilaa/Python-Curso-em-Video | /ex005.py | 132 | 4.0625 | 4 | num = int(input('Digite um número: '))
print('O número antecessor a ele é ', num-1)
print('O número posterior a ele é ', num+1) |
ec47f346ea89cec315b4e7c431affa08b63a5bb1 | Camomilaa/Python-Curso-em-Video | /ex028.py | 293 | 4 | 4 | import random
n = random.randint(0,5)
num = int(input('Tente adivinhar o número entre 0 e 5 em que o computador está pensando: '))
if n == num:
print('Parabens, você acertou! O número era {}!'.format(num))
else:
print('Que pena... O número era {} e você disse {}'.format(n, num)) |
d0d4a094ccbf7cd8fd7e757c18ac9b3ff700254f | Camomilaa/Python-Curso-em-Video | /ex059.py | 700 | 3.875 | 4 | n1 = int(input('Digite um número: '))
n2 = int(input('Digite outro número: '))
c = 0
while c != 5:
print('[ 1 ] somar\n[ 2 ] multiplicar\n[ 3 ] maior\n[ 4 ] novos números\n[ 5 ] sair do programa')
c = int(input('Escolha uma opção acima:'))
if c == 1:
soma = n1 + n2
print(f'{n1} + {n2} = {som... |
a2ea62c64fa681ce1986576579503873e5561dcb | Camomilaa/Python-Curso-em-Video | /ex093.py | 454 | 3.515625 | 4 | jogador = dict()
gols = 0
jogador['nome'] = str(input('Nome: '))
jogador['partidas'] = int(input('Partidas Jogadas: '))
for c in range(0,jogador['partidas']):
gols += int(input(f'Quantos gols realizados na partida {c+1}? '))
jogador['gols'] = gols
jogador['aproveitamento'] = gols/jogador['partidas']
for k,v in joga... |
7aeb0d15e738e6d0ef6162b4f171c31d96737a56 | Camomilaa/Python-Curso-em-Video | /ex058.py | 483 | 3.890625 | 4 | from random import randint
c = 0
pc = randint(0, 10)
vc = int(input('Advinhe qual número de 0 a 10 o computador está pensando: \n'))
if vc == pc:
print('Uau... de primeira!')
else:
while vc != pc:
if vc > pc:
print('QUASEE! tente um número menor!')
else:
print('QUASEE! te... |
f10d424047964311d557ed380863fdfbdf9f495b | Camomilaa/Python-Curso-em-Video | /ex014.py | 148 | 3.96875 | 4 | cel = float(input('Digite a temperatura em graus Celsius: '))
fah = (cel*(9/5))+32
print('A temperatura em Fahrenheit equivale a {}°'.format(fah))
|
2616719b9b2e640503ccdb559d81d67a583b3e9e | Shirmyyy/CS313E | /Geometry.py | 7,853 | 4.1875 | 4 | import math
class Point(object):
# constructor
def __init__(self, x=0, y=0):
self.x = x
self.y = y
# get the distance
def dist(self, other):
return math.hypot(self.x - other.x, self.y - other.y)
# get a string representation of Point
def __str__(self):
... |
32608ff3856ea3343d0712ab2829efb7d4b45aed | Shirmyyy/CS313E | /Poker.py | 13,008 | 3.765625 | 4 | # File: Poker.py
# Description: Assignmeng6
# Student's Name: Shimin Zhang
# Student's UT EID: sz6939
# Partner's Name: Zijie Pang
# Partner's UT EID: zp2478
# Course Name: CS 313E
# Unique Number: 51350
# Date Created: Sept 25
# Date Last Modified: Sept 28
import random
class C... |
2e9be66204114e7a8c66a058aa9319d293748a15 | Beor18/pong-programador9 | /lista2017.py | 95 | 3.640625 | 4 | # Listado de Prueba.
Lista = ["X","F4","2","3"]
print
for elemento in Lista:
print elemento
|
a55e7da40409b9160df98169b4bf7ac36eb7735b | sajay/learnbycoding | /learnpy/capital_city_loop.py | 1,449 | 4.5625 | 5 | #Review your state capitals along with dictionaries and while loops!
#First, finish filling out the following dictionary with the remaining states and their
#associated capitals in a file called capitals.py. Or you can grab the finished file directly from the exercises folder in the course repository #on Github.
#capit... |
3fe028c17fbe2be2504d6caee35ada09f9c008d2 | sajay/learnbycoding | /dailycodeproblems/car-cdr.py | 944 | 4.34375 | 4 | #This problem was asked by Jane Street.
#cons(a, b) constructs a pair, and car(pair) and cdr(pair) returns the first and last element of that pair.
#For example, car(cons(3, 4)) returns 3, and cdr(cons(3, 4)) returns 4.
# Given this implementation of cons:
# def cons(a, b):
# def pair(f):
# return f(a, b)
# ... |
7f851f88a3da17ef8172cfff579e7b76e0fe3c7a | sajay/learnbycoding | /dailycodeproblems/sum-in-list.py | 2,963 | 3.875 | 4 | #This problem was recently asked by Google.
#Given a list of numbers and a number k, return whether any two numbers from the list add up to k.
#For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17.
#Bonus: Can you do this in one pass?
from timeit import default_timer as timer
from datetime imp... |
5f27eb838bbb817223c1c7661659a02a974655e2 | Chipex1337/BarnsleyFernPygame | /Main.py | 1,895 | 3.59375 | 4 | import pygame
import random
import time
'''Please don't use this code to learn or anything, its garbage I suck at python, just needed to upload it for debugging'''
pygame.init()
pygame.display.set_caption("Fractal Fern Fun")
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
... |
5196bf1716062f91599b7fd2456156aaa5ef3e8f | Davidsaemund/TileTraveller_Assign_8 | /TileTraveller.py | 2,521 | 4.15625 | 4 | # Assignment 8
# Tile Traveler
# Program that moves NORTH, SOUTH, WEST and EAST in a 3v3 tile plan.
#Function that gets your current loc and tells you what options you have
def tile_traveller(x,y):
if (x == 1 and y == 1) or (x == 2 and y == 1):
print("You can travel: (N)orth.")
elif (x == 1 and y ==... |
1030840b3ca5e98c70aa8d878c41a3bffed72114 | niqaabi01/Intro_python | /Week2/Perimter2.py | 577 | 4.1875 | 4 | width1 = float(input("enter width one : "))
height1 =float(input("enter height one : "))
width2 = float(input("enter width two : "))
height2 = float(input("enter height two :"))
cost_mp =float(input(" enter price per meter :"))
height = 2 * float(height1)
width = float(width1) + (width2)
def multiply(width):
re... |
e063fce0e2239aa36d193ef463692c7b8984c87d | niqaabi01/Intro_python | /Week4/Printmonth.py | 585 | 4.09375 | 4 | #Printing months using 6 row by 7 column outputs
#Saaniah Blankenberg
#27 May 2020
day = input("Enter day of the week: ")
month = input("Enter month: ")
if month in ["January", "March", "May", "July", "August", "October", "December"]:
x = 31
elif month in ["February"]:
x = 28
else:
x = 30
DAY_OFF = ['Mon... |
c88fd99facf92fddccc57385059f67b68549e4c4 | niqaabi01/Intro_python | /Week7/SomeHelp.py | 749 | 3.671875 | 4 | #creating an automated tech response
#Saaniah Blankenberg
#2020/06/17
#somehelp.py
def intro():
print('Welcome to the automated technical support system.')
print('Please describe your problem.')
def add_input():
return input().lower()
def main():
import random
intro()
question = add_input... |
40f85622abca42425491ce80c7d0185da93f38a7 | niqaabi01/Intro_python | /Week6/bukiyip/Bukiyip.py | 980 | 3.953125 | 4 | # bukiyip.py base 3 counting mthod
# Saaniah Blankenberg
#2020/06/12
#converting base 3 into a decimal num #OPTION b
def bukiyip_to_decimal(a):
num =str(a)
index = 0
decimal = 0
for i in range(len(num)-1,-1,-1):
decimal += int(num[i])*3**(index)
index += 1
return decimal
# converti... |
fc2739929e07142c4feecde90a8ffe4c70b163eb | alessandromaggio/pythonping | /pythonping/utils.py | 402 | 3.75 | 4 | """Module containing service classes and functions"""
import string
import random
def random_text(size):
"""Returns a random text of the specified size
:param size: Size of the random string, must be greater than 0
:type size int
:return: Random string
:rtype: str"""
return ''.join(random.Sy... |
2551c03e063d0cd16da6e3e0ee2881f5279faaae | ewang14/hello-world | /pizza.py | 2,399 | 4.1875 | 4 | # pizzaQuiz2
# tell the user what's going on
print ("What Type of Pizza Are You?")
print (" ")
print ("Take our quiz to find out what type of pizza you are!")
print (" ")
# player information on the player
player = {
"name": "unknown",
"superpower": "unknown",
"faveColor" : "unknown",
"drink" : "unknown"
}
#... |
07dacf16fc30a8176b4a1692f5af0c482580d85b | hchin157/pythonstuff | /cookBook.py | 834 | 4.09375 | 4 | dict = {"6-pound Pekin duck": "1", "kosher salt": "3 tablespoons", "5-spice powder": "1 tablespoon", "large orange zested and cut into 6 wedges": "1", "grated ginger": "1 tablespoon ", "grated garlic": "1 tablespoon"}
lst = ["Step 1", "step 2", "step3", "step4"]
#gll = ["2 cups orange juice", "1 tablespoon honey", ... |
0167bd1d29aa076ee37384d0751a082a2c906887 | Kr0nuzz/math | /factorialfinder.py | 2,064 | 3.75 | 4 | import os
def menu():
print ("""
___________ __ .__ .__
\_ _____/____ _____/ |_ ___________|__|____ | |
| __) \__ \ _/ ___\ __\/ _ \_ __ \ \__ \ | |
| \ / __ \\ \___| | ( <_> ) | \/ |/ __ \| |__
\___ / (____ /\___ >__| \____/|__| |... |
4058a599a844f012a9a8367d8cce7c3fbad2cdea | StephanieTabosa/estudo-python | /aula07desafio008.py | 520 | 4.21875 | 4 | # Escreva um programa que leia um valor em metros e o exiba convertido em centímetros e milímetros
metros = float(input('Digite um valor em metros: '))
centimetros = metros*100
milimetros = metros*1000
dm = metros*10
dam = metros/10
hm = metros/100
km = metros/1000
print('\n O valor {} está em metros.\n Sua con... |
fa1e91ecda206b22c8e5f78feda5caf988b0fe5e | StephanieTabosa/estudo-python | /aula10desafio033.py | 429 | 4.125 | 4 | # Faça um programa que leia três números e mostre qual é o maior e qual é o menor.
import math
numero = float(input('Digite o primeiro número: '))
numero2 = float(input('Digite o segundo número: '))
numero3 = float(input('Digite o terceiro número: '))
lista = [numero, numero2, numero3]
print('O MENOR número é... |
cb18a1dcd25c786e4c5587f390991e02d345afb7 | StephanieTabosa/estudo-python | /aula07desafio013.py | 312 | 3.78125 | 4 | # Faça um algoritmo que leia o salário de um funcionário e mostre seu novo salário com 15% de aumento
salario = float(input('Digite o seu salário R$ '))
aumento = salario+(15/100*salario)
print('Seu salário era R$ {:.2f}. Com um aumento de 15%, passou a ser R$ {:.2f} !!!'.format(salario,aumento))
|
bccbd22809de29530793844909a5b2b01a08c9ea | Molczifootball/Coffee-machine | /main.py | 1,793 | 4.0625 | 4 | from machine import *
from coins import *
to_do = "x"
def report():
print(machine)
def check_machine(coffee):
if machine["Water"] - coffee["Water"] < 0:
print("Not enough water.")
return 0
elif machine["Milk"] - coffee["Milk"] < 0:
print("Not enough milk.")
return 0
elif ... |
6b9980138d8dabf2d03a2ef03417fbaf059783b2 | chavp/MyPython | /ui.py | 1,070 | 3.65625 | 4 | from tkinter import *
from tkinter.scrolledtext import ScrolledText
#top = Tk()
#btn = Button()
#btn['text'] = 'Click me!'
#btn.pack()
def clicked():
print('I ws clicked!')
#btn['command'] = clicked
#btn.config(text = 'Click me!', command = clicked)
#Button(text = 'Click me!', command = clicked).pack()
#Label(text... |
76404d2842a67699d4edd993309b18ced1dbf8e0 | chavp/MyPython | /ThinkPython/chp5.py | 1,149 | 3.875 | 4 | minutes = 105
print(minutes / 60)
hours = minutes // 60
print(hours)
ramainder = minutes - hours * 60
print(ramainder)
x = 9
if x > 0:
print('x is positive')
elif x == 0:
print('x is zero')
else:
print('x is negative')
if 0 < x < 10:
print('0 < x < 10')
#your_name = input('What is your name?')
#print('Hello,',... |
daad70c686aee4274b24c72860a8f6b568dc7d93 | michellekatkov/protocoin | /protocoin/util.py | 1,713 | 3.578125 | 4 | # The Base58 digits
base58_digits = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
from . import fields
def base58_encode(address_bignum):
"""This function converts an address in bignum formatting
to a string in base58, it doesn't prepend the '1' prefix
for the Bitcoin address.
:param a... |
a7080913a9523965af4cf68c4be5c206858baa17 | sakar123/Python-OOP | /QuickSort.py | 622 | 3.9375 | 4 | def partition(list, start, end):
to_compare = list[end]
p_index = start
for i in range(start, end):
if list[i] <= to_compare:
swap = list[p_index]
list[p_index] = list[i]
list[i] = swap
p_index += 1
swap = list[p_index]
list[p_index] = list[end... |
2e08dea70a9369288432ad86bdc317bb8c7a5f65 | meantaek/nlp | /entities/entities.py | 4,754 | 4.15625 | 4 | from collections import deque
class Token():
"""Represents a single token in a document.
For example, a token "Pittsburgh" with tags "NNP" and "LOC" can be
initialized with Token("Pittsburgh", ["NNP", "LOC"])
"""
def __init__(self, word, tags):
self.word = word
self.tags = set(ta... |
44f5e8b2a0617eb113fcae6b5aba4e75c2db9693 | musfirotum/Object-Oriented-Programming | /Materi/Class vs Object.py | 3,274 | 3.640625 | 4 | #nomer 1
class Kubus : #keyword class diikuti dengan nama class yang diinginkan dan lebih baik diawali dengan huruf kapital.
def __init__(self,s): #constructor menggunakan method bawaan dari python yg brnama init. method __init__() adalah metode konstruktor, yaitu metode khusus untuk menginisialisasi object dr cl... |
f77b6ce4c381d80656ff81fdfbed6baa475e701d | musfirotum/Object-Oriented-Programming | /Tugas Praktikum/Tugas Praktikum 3.py | 4,527 | 3.984375 | 4 | print("Nomer 1 - 3")
class KategoriBarang :
def __init__ (self, kode, deskripsi):
self.kode = kode
self.deskripsi = deskripsi
def tampil_kode (self):
print ("Kode barang :", self.kode, "\nDeskripsi:", self.deskripsi)
def tampil_kategori (self):
a = int (input("Pilih k... |
735db79beeb3cb7c513e97a79f5aa846b15d46d2 | rspurlock/SP_Online_PY210 | /students/rspurlock/lesson4/dict_lab.py | 2,290 | 4.5625 | 5 | #!/usr/bin/env python3
def printDictionary(dictionary):
"""
Function to display a dictionary in a nice readable fashion
Positional Parameters
:param dictionary: Dictionary to print key/value pairs for
"""
# Loop thru all the dictionary items (key/value pairs) printing them
for key, value... |
f07fbcf84b41c33c9ad3ec99c9c532128535a3e2 | rspurlock/SP_Online_PY210 | /students/rspurlock/lesson2/grid.py | 3,291 | 4.34375 | 4 | def printBeam(width):
"""
Function to print a single column of the beam pattern for a grid cell
:param width: Width of the grid cell
"""
print('+' + (' -' * width), end = ' ')
def printPost(width):
"""
Function to print a single column of the post pattern for a grid cell
:param wid... |
8431d76d7ea488b415a44872c3fe99f83bf18bfc | IcebagW/soja-box | /unittest_demo/soja_any_scale.py | 1,564 | 3.84375 | 4 | class Scale(object):
# 常用的字母代表数字的字典
dic = {'10': 'A',
'11': 'B',
'12': 'C',
'13': 'D',
'14': 'E',
'15': 'F'}
# 将weight进制的某一位的值对应的十进制的值算出来
@staticmethod
def place_value(n_value, scale, digits):
# 某一位的权值,初始为1
weight = 1
fo... |
25104049e2d21ce4b3d7624180efbc00dff29dbd | danilocecci/CEV-Python3 | /aula09.py | 883 | 4.03125 | 4 | frase = 'Curso em Vídeo Python'
print('Fatiamento =',frase[:6])
print('Fatiamento2 =',frase[::2])
print('count "O" =',frase.count('O'))
print('upper + count "O" =',frase.upper().count('O'))
print('lenght =',len(frase))
frase_torta = ' Curso em Vídeo Python '
print('strip =',frase_torta.strip())
print('strip r =', ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.