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 |
|---|---|---|---|---|---|---|
3ec338e1d1aa30d5d25657ee7d7722791b478d5e | BenjaminFu1/Python-Prep | /cube area calculator.py | 138 | 4.0625 | 4 | width=float(input("Give me the width of your cube"))
area=(width) * (width) * 6
print("{0:.1f} is the area of your cube".format(area))
|
a11e6981301bbdc6a6f55ac7853598ad3b61ede9 | BenjaminFu1/Python-Prep | /square area calculator.py | 205 | 4.1875 | 4 | length=float(input("Give me the lenth of your rectangle"))
width=float(input("Give me the width of your rectangle"))
area=(length) * (width)
print("{0:.1f} is the area of your rectangle".format(area))
|
3f620cb320f89f4e0f19bd2d09a30a9b9402b98f | tu-nguyen/linkedinlearning | /Master Python for Data Science/Python Essential Training 1/Chap11/hello.py | 453 | 4.15625 | 4 | #!/usr/bin/env python3
# Copyright 2009-2017 BHG http://bw.org/
# print('Hello, World.'.swapcase())
# print('Hello, World. {}'.format(42 * 7))
# print("""
# Hello,
# World.
# {}
# """.format(42 * 7))
# s = 'Hello, World. {}'
# print(s.format(42 * 7))
# class MyString(str):
# def __str__(self):
# ... |
f59fc77f6136f93879b9426fbcc4e4777cc0025b | tu-nguyen/linkedinlearning | /Master Python for Data Science/Python Essential Training 1/Chap08/dict.py | 537 | 4.09375 | 4 | #!/usr/bin/env python3
# Copyright 2009-2017 BHG http://bw.org/
def main():
# animals = { 'kitten': 'meow', 'puppy': 'ruff!', 'lion': 'grrr',
# 'giraffe': 'I am a giraffe!', 'dragon': 'rawr' }
animals = dict( kitten= 'meow', puppy= 'ruff!', lion= 'grrr',
giraffe= 'I am a giraffe!', dragon= 'r... |
27a9e19391c5cd966fd132ad08e56139a890064b | fyiidk/ITT109-GROUP_ASSIGNMENT | /Group 10.py | 439 | 3.53125 | 4 | from tkinter import filedialog
from tkinter import *
def mainscreen ():
print ("Main Program")
game = Tk()
game.title ("Bouncing Ball")
game.minsize (500,500)
lblimage = PhotoImage(file="Basketball.png")
Label(game, text="Welcome to Bouncing Ball", bg="white", fg="black",
font="none 20 bold"). ... |
1f5f0706f9b59da69a727bc528f761b076f2bfbe | CarlosCBar/Funciones | /Funciones.py | 6,594 | 3.984375 | 4 | # Reusando codigo con funciones
# Siempre se usa snake_case
# --- : ---- Marca el inicio del bloque de código
def saluda_usuario(): #para definir una función
print("Buenos días Krillin") #Puedes realizar cualquier acción
print("Es hora de entrenar")
# Para llamar la función escribiendo l... |
330b70a5f8e0ec9d0af07da1422697fcdf5738ef | friedrich-schotte/Lauecollect | /is_method.py | 593 | 3.671875 | 4 | """
Check if method is static
https://stackoverflow.com/questions/8727059/python-check-if-method-is-static
Author: Friedrich Schotte
Date created: 2022-03-28
Date last modified: 2022-03-28
Revision comment:
"""
__version__ = "1.0"
def is_method(f):
import types
return isinstance(f, types.MethodType)
if __n... |
fcc3df6bede7af239904e6f04332dfe35146e9c1 | bhaveshAn/carport | /src/parked_car.py | 358 | 3.609375 | 4 | class ParkedCar(object):
def __init__(self, reg_id, slot, colour):
"""
Class used to create an entry of car to be parked with
reg_id [STRING]: registration id
slot [INT]: slot number
colour [STRiNG]: colour of the car
"""
self.reg_id = reg_id
self.slo... |
77e9a95fd36b6b17a3c2a23206bc13f58ddb4cef | Romamart/-Course-work | /Simulation/src/main/blockchain/Block.py | 657 | 3.546875 | 4 |
class Block:
def __init__(self, previousBlock, mineBy, blockValue):
self.__previousBlock = previousBlock
self.__height = 0 if previousBlock is None else previousBlock.__height + 1
self.__mineBy = mineBy
self.__blockValue = blockValue
def getPreviousBlock(self):
return ... |
97fbe7d23827a18c5e4b5f2ad79458635cef4c16 | dupandit/Datastructure-and-Algorithms | /quicksort.py | 984 | 3.625 | 4 | import sys
sys.setrecursionlimit(1500)
def partition(arr,start,end):
pivot=arr[end]
print 'Before Partition : ',arr
i=start-1
j=start
while j < l:
if arr[j]>=pivot :
pass
else :
i=i+1
arr[i],arr[j]=arr[j],arr[i]
j=j+1
arr[i+1],arr[end]... |
aace893c2574b7983ef558b15bed5eb73dda8ccd | Location-Artistry/Simple-Stock-Viewer | /StockTicks.py | 1,371 | 3.59375 | 4 | import yfinance as yf
import streamlit as st
import pandas as pd
import datetime as dt
import numpy as np
today = dt.date.today()
# Simple streamlit app using python & yfinance to get information on stock highlighted in selectbox
# Working as a streamlit app test deploy to Heroku
st.write("""
# Stock Selector
""",""... |
d9d77e9c498f1a109352bf5b712af3f3f408d549 | imrehg/AdventOfCode2020 | /day06/day06.py | 884 | 3.609375 | 4 | import sys
def read_customs_file(filename):
declarations = []
with open(filename, "r") as f:
buff = []
for line in f.readlines():
if line.strip() == "" and buff:
declarations.append(buff)
buff = []
else:
buff += [{answer f... |
77311aaf7fe45fb27ba6d1e8f0e9ef7e416d8aa6 | croeder/Dataframes-Polyglot | /dataframes.py | 604 | 3.75 | 4 | #!/usr/bin/env python3
import pandas as pd
df = pd.read_csv("data.csv")
print(type(df))
print(df)
print("============1")
# key error, this isn't a dictionary in python, so square brackets here don't work
#print(type(df[1]))
#print(df[1])
print("============2")
# column, but they are implemented by column name
print... |
ecabe706a40628f8c87e4217ca084a044b880af4 | DemetreJou/AdventOfCode2018 | /13/solution.py | 2,552 | 3.859375 | 4 | import fileinput
# first time using a class!
# each cart object represents what turn cycle it's on
# where it is
# has method to move and check collision
# define up, down, left, right directions for ease
U, D, L, R = (0, -1), (0, 1), (-1, 0), (1, 0)
# convert symbols to directions
directions = {'^': U, 'v': D, '<':... |
637d088be0dd075129ba9732ffb5482038776e8a | DemetreJou/AdventOfCode2018 | /9/solution.py | 760 | 3.703125 | 4 | # deque.rotate(n) shifts everything n units to the right
from collections import deque
import fileinput
import re
# reads the only two numbers
num_players, num_marbles = map(int, re.findall(r'\d+', next(fileinput.input())))
def playgame(num_players, num_marbles):
circle = deque([0])
scores = [0] * num_player... |
cdf147a2c526c31f8f8850e79d3444bf86d67972 | WindTalker22/Data-Structures | /binary_search_tree/tempCodeRunnerFile.py | 593 | 3.578125 | 4 | # Print the value of every node, starting with the given node,
# # in an iterative breadth first traversal
# def bft_print(self, node):
# pass
# # Print the value of every node, starting with the given node,
# # in an iterative depth first traversal
# def dft_print(self, node):
# pass... |
866c36768b1363d7cd4adef7212458a470e6b0fd | kayshale/ShoppingListApp | /main.py | 1,196 | 4.1875 | 4 | #Kayshale Ortiz
#IS437 Group Assignment 1: Shopping List App
menuOption = None
mylist = []
maxLengthList = 6
menuText = '''
1.) Add Item
2.) Print List
3.) Remove item by number
4.) Save List to file
5.) Load List from file
6.) Exit
'''
while menuOption != '6':
print(menuText)
menuOption = input('Enter Selec... |
a22a1b2aec36a61acffd689b25f8466f2f8446f8 | Rhysoshea/daily_coding_challenges | /daily_coding_problems/daily17.py | 4,155 | 4.15625 | 4 | """
Suppose we represent our file system by a string in the following manner:
The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents:
dir
subdir1
subdir2
file.ext
The directory dir contains an empty sub-directory subdir1 and a sub-directory subdir2 containing a file file.ext.
The string "dir... |
a576ce778630dca3e72be470b615100b528e2cf8 | Rhysoshea/daily_coding_challenges | /daily_coding_problems/daily55.py | 1,342 | 3.78125 | 4 | # Implement a URL shortener with the following methods:
# shorten(url), which shortens the url into a six-character alphanumeric string, such as zLg6wl.
# restore(short), which expands the shortened string into the original url. If no such shortened string exists, return null.
# Hint: What if we enter the same URL twi... |
b0b67fba426642ef56a1cfa5d5e6a65a0286dacb | Rhysoshea/daily_coding_challenges | /other/sort_the_odd.py | 612 | 4.3125 | 4 | '''
You have an array of numbers.
Your task is to sort ascending odd numbers but even numbers must be on their places.
Zero isn't an odd number and you don't need to move it. If you have an empty array, you need to return it.
Example
sort_array([5, 3, 2, 8, 1, 4]) == [1, 3, 2, 8, 5, 4]
'''
def sort_array(source_arr... |
6a02c3fe5111ddf6690e5a060a543164b2db0563 | Rhysoshea/daily_coding_challenges | /daily_coding_problems/daily25.py | 1,686 | 4.5 | 4 | """
Implement regular expression matching with the following special characters:
. (period) which matches any single character
* (asterisk) which matches zero or more of the preceding element
That is, implement a function that takes in a string and a valid regular expression and returns whether or not the string match... |
be3a184aecc35085a7d69bc447eeaf99d5c2320b | Rhysoshea/daily_coding_challenges | /daily_coding_problems/daily44.py | 1,329 | 4.1875 | 4 | # We can determine how "out of order" an array A is by counting the number of inversions it has. Two elements A[i] and A[j] form an inversion if A[i] > A[j] but i < j. That is, a smaller element appears after a larger element.
# Given an array, count the number of inversions it has. Do this faster than O(N^2) time.
#... |
0f01a1e6aa57c4ed9dccf237df27db0465bae2cc | Rhysoshea/daily_coding_challenges | /daily_coding_problems/daily27.py | 848 | 4.15625 | 4 | """
Given a string of round, curly, and square open and closing brackets, return whether the brackets are balanced (well-formed).
For example, given the string "([])[]({})", you should return true.
Given the string "([)]" or "((()", you should return false.
"""
def solution(input):
stack = []
open = ["{", "("... |
be54b12d47844ada5311c08172c1222c7a84e90c | Rhysoshea/daily_coding_challenges | /leetcode/merge_two_sorted_lists.py | 1,187 | 4.09375 | 4 | """
Merge two sorted linked lists and return it as a new sorted list. The new list should be made by splicing together the nodes of the first two lists.
Example:
Input: 1->2->4, 1->3->4
Output: 1->1->2->3->4->4
Accepted
"""
# Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None)... |
1a7a90ea15fe4667345bda7154b3506edc315ba6 | Rhysoshea/daily_coding_challenges | /cracking_coding_interview/recursion_dp/triple_step.py | 360 | 3.984375 | 4 | # there are n steps, can take 1,2 or 3 steps at a time
# how many different ways are there to get up the steps
def staircase(n, X):
cache = [0 for x in range(n+1)]
cache[0] = 1
for i in range(len(cache)):
for x in X:
if i-x >= 0:
cache[i] += cache[i-x]
return(ca... |
e7bda5729093eb653d5912529dedfd08089fc192 | Rhysoshea/daily_coding_challenges | /daily_coding_problems/daily22.py | 1,974 | 4 | 4 | """
Given a dictionary of words and a string made up of those words (no spaces), return the original sentence in a list. If there is more than one possible reconstruction, return any of them. If there is no possible reconstruction, then return null.
For example, given the set of words 'quick', 'brown', 'the', 'fox', a... |
2fc536fe0a6e2100cdafea50d4bbdf27074fb229 | Rhysoshea/daily_coding_challenges | /daily_coding_problems/daily58.py | 1,447 | 3.765625 | 4 | # An sorted array of integers was rotated an unknown number of times.
# Given such an array, find the index of the element in the array in faster than linear time. If the element doesn't exist in the array, return null.
# For example, given the array [13, 18, 25, 2, 8, 10] and the element 8, return 4 (the index of 8 ... |
830adc77a4c5f9a880b0026f07392e5417664a72 | Rhysoshea/daily_coding_challenges | /daily_coding_problems/daily6.py | 5,437 | 4.09375 | 4 | '''
An XOR linked list is a more memory efficient doubly linked list. Instead of each node holding next and prev fields, it holds a field named both, which is an XOR of the next node and the previous node. Implement an XOR linked list; it has an add(element) which adds the element to the end, and a get(index) which ret... |
644db35d54066608b71f08932348352cc19d3e58 | lailson/uri | /python/1020.py | 185 | 3.546875 | 4 | tempo = int(input())
anos = tempo // 365
meses = (tempo % 365) // 30
dias = ( tempo % 365 ) - (30 * meses)
print(f'{anos} ano(s)')
print(f'{meses} meses(es)')
print(f'{dias} dias(s)') |
3b2ac1a78612657c7afe392d0e91bdb45149acae | hs929kr/study-algorithm | /basic_algorithm1/11_sum_of_matrix.py | 249 | 3.609375 | 4 | def solution(arr1, arr2):
answer = []
for i in range(len(arr1)):
row=[]
row1=arr1[i]
row2=arr2[i]
for j in range(len(row1)):
row.append(row1[j]+row2[j])
answer.append(row)
return answer |
8c18b80187b13cbcdbee6c169ad5b311e6ea4f47 | hs929kr/study-algorithm | /algorithm5_Hash/03_telephon_number_list.py | 409 | 3.71875 | 4 | from collections import deque
def solution(phone_book):
answer = True
phone_book=sorted(phone_book,key=lambda x:x)
phone_book=deque(phone_book)
now=phone_book.popleft()
while(True):
if(len(phone_book)==0):
break
new=phone_book.popleft()
if(new[0:len(now)]==no... |
246af78ee61f1079a14b08bda5e7361525c296d8 | xanwerneck/analisedealgoritmos | /sscm.py | 411 | 3.625 | 4 |
def ssctf(lista, n):
c = 1
for x in xrange(n-1, 0, -1):
if lista[x-1] <= lista[n-1]:
d = ssctf(lista, x)
if (d+1) > c:
c = d + 1
return c
def sscm(lista):
maior_tamanho = 0
for x in xrange(0,len(lista)):
tamanho = ssctf(lista, x + 1)
if tamanho >= maior_tamanho:
maior_tamanho = tamanho
retur... |
593e4d4643c9d81098828b22bc68e46c373ffa2c | pbuzzo/backend-katas-functions-loops | /main.py | 1,858 | 4.375 | 4 | #!/usr/bin/env python
"""Implements math functions without using operators except for '+' and '-' """
""" """
__author__ = "Patrick Buzzo"
def add(x, y):
new_num = x + y
return new_num
def multiply(x, y):
new_num = 0
if y >= 0:
for index in range(y):
new_num += x
else:
... |
06c3afda9608357987bb82366928845a7624b102 | LifeJunkieRaj/LinkedLists | /LinkedLists/ZipLinkedList.py | 1,637 | 3.96875 | 4 | # This is an input class. Do not edit.
class LinkedList:
def __init__(self, value):
self.value = value
self.next = None
# O(n) time | O(1) space - where n is the length of the Linked List
def zipLinkedList(linkedList):
if linkedList.next is None or linkedList.next.next is None:
return linkedList... |
e3c99fec8c179734cefc17df3277ac264051fc76 | BohaoTang/Stock | /ShareCompute.py | 302 | 3.765625 | 4 | #!/usr/bin/env python
#ShareCompute.py
def Profit(shares):
if shares:
count = 0
profit = 0
for share in shares:
profit += share['holdingQuantity'] * share['price_change']
count += 1
return "Profit rate yesterday is :{0}".format(profit / count)
else: return "Please choose shares ASAP." |
961840f1415ee7b2e6e4698bb4987f6ddde7aeb5 | bionboy/SMQ | /Graphical/SMQ_graphical.py | 3,592 | 3.59375 | 4 | from graphics import *
win = GraphWin("SMQ", 1000, 500)
win.setBackground('green')
def textInput (x, y, promptText, x1, y1):
textBox = Rectangle(Point(100, 50), Point(900, 150))
textBox.setFill('white')
textBox.draw(win)
textPrompt = Text(Point(x, y), promptText)
textPrompt.draw(win)
... |
c17f7c3412e332cac2664c7ec67f06ae32bf9ccd | splitio/python-client | /splitio/tasks/util/asynctask.py | 6,140 | 3.515625 | 4 | """Asynchronous tasks that can be controlled."""
import threading
import logging
import queue
__TASK_STOP__ = 0
__TASK_FORCE_RUN__ = 1
_LOGGER = logging.getLogger(__name__)
def _safe_run(func):
"""
Execute a function wrapped in a try-except block.
If anything goes wrong returns false instead of propag... |
de329425df3f2082bbf90c6b1cf98a7d83f373f5 | splitio/python-client | /splitio/engine/hashfns/legacy.py | 725 | 3.515625 | 4 | """Legacy hash function module."""
def as_int32(value):
"""Handle overflow when working with 32 lower bits of 64 bit ints."""
if not -2147483649 <= value <= 2147483648:
return (value + 2147483648) % 4294967296 - 2147483648
return value
def legacy_hash(key, seed):
"""
Generate a hash for ... |
c58c08253a70be56d77b540329420a21f7f6bdb8 | shreyashetty207/python_internship | /Task 4/Prb 2.py | 159 | 4.375 | 4 | # Create a tuple and print the reverse of the created tuple
#create another tuple
x = (5, 10, 15, 20)
# Reversed the tuple
y = reversed(x)
print(tuple(y)) |
8e3f51ca47d9937f5aae6b56f81bfdba273d3336 | shreyashetty207/python_internship | /Task 4/Prb1.py | 616 | 4.28125 | 4 | #1. Write a program to create a list of n integer values and do the following
#• Add an item in to the list (using function)
#• Delete (using function)
#• Store the largest number from the list to a variable
#• Store the Smallest number from the list to a variable
S = [1, 2, 3,4]
S.append(56)
print('Updated list... |
080b45684e8d98e2149bcba8f68fd62e4f763018 | shreyashetty207/python_internship | /Task 6.py | 2,274 | 4.09375 | 4 | # Write a program to loop through a list of numbers and add +2 to every value to elements in list
num= [1, 2, 3, 4, 5]
result = []
for i in range (0,len(num)):
result.append(num[i] + 2)
print("result:" +str(result))
# write a program in given pattern
# 54321
# 4321
# 321
# 21
# 1
for i in range(5,0,-1... |
68365d11cc574b9236848dcf1f69b7ba2a9d7ad3 | thibaudatl/SoftwareDesign | /homeworks/hw2/FermaFunction.py | 706 | 4 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Sep 14 09:20:49 2014
@author: leo
"""
def fermat(q, w, e, r):
s = q**r
f = w**r
d = e**r
t = s + f
print "%d + %d = %d = %d" % (s, f, t, d)
if r > 1:
if t == d:
print 'Fermat was wrong!'
else:
print "No ... |
9abd43bb4bceb59b3e0513262f909a1aa2acbce1 | frogsicle/abstractr | /abstractr.py | 3,560 | 3.546875 | 4 | """ The whole goal is to make papers more fun to read, but harder to understand =D
"""
__author__ = 'ali'
import random
import nltk
INTERESTING_TAGS = ['JJ', 'JJR', 'JJS', 'NN', 'NNP', 'NNPS', 'NNS', 'RB', 'RBR', 'RBS', 'VB', 'VBD',
'VBG', 'VBN', 'VBP', 'VBZ']
class Paper():
def __init... |
7d61a5d609915587cbc22b9397f1f19706e61a69 | MJAFort/SoftwareDesign | /hw02/problem3.5b.py | 749 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Feb 3 02:39:33 2014
@author: madeleine
"""
def make_grid(): #starting the function
rows = "|"
horiz = ("+" + "----" + "+" + "----" + "+" + "----"+"+" +"----"+"+")
side = (rows + " " + rows + " " + rows + " " + rows + " " + rows... |
ea780b1776ff950bbd1037e90c42cf6e520ac87b | alvinwan/materials | /src/problems/modulararithmetic/extended-gcd.py | 318 | 3.5625 | 4 | def extended_gcd(x, y):
print('x:', x, 'y:', y)
if y == 0:
### start a ###
return (x, 1, 0)
### end a ###
else:
### start b ###
d, a, b = extended_gcd(y, x % y)
print('d:', d, 'a:', a, 'b:', b)
return (d, b, a - (x // y)*b)
### end b ###
|
424d810d8f77e5d0a2aed7eb5d750ca8e3ac4b11 | huderlem/ToadsTool | /util.py | 1,480 | 3.5625 | 4 | # This file holds various utility functions.
import os
import sys
quiet = False
def print_info(message):
"""
Prints informational content to the console.
"""
if not quiet:
print(message)
def fatal_error(message):
"""
Exits the program with the given error message.
"""
sys.ex... |
dd70e9c9291611fd469418fef7df160b818c851e | terriwong/underpaid-customers | /find_underpaid_customer.py | 660 | 3.859375 | 4 | def underpaid_customer():
"""go through every line in the log to find underpaid customer"""
melon_cost = 1
the_file = open("customer-orders.txt")
for line in the_file:
tokens = line.split("|")
customer_name = tokens[1]
customer_melon = tokens[2]
customer_paid = tokens[... |
4ff05ce103e2efb079454848662ca09b080016c8 | omkumar40/Python-Learning | /sp.py | 565 | 3.625 | 4 | #program to find the sum and average in an web page of span element
from urllib.request import urlopen
from bs4 import BeautifulSoup
import ssl
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
#url=http://py4e-data.dr-chuck.net/comments_862639.html
url = input('Ent... |
ac595131e11cb058b77fab48a955d96d971f28f0 | micdean19/MNIST-Fashion-Covnet-Mini-Project | /train-model.py | 2,787 | 3.546875 | 4 | # %%
import tensorflow as tf
import tensorflow.keras as keras
import matplotlib.pyplot as plt
import pandas as pd
import pickle
# Importing the MNIST data and preprocessing it from API
(x_train, y_train), (x_test, y_test) = keras.datasets.fashion_mnist.load_data()
print(x_train.shape, y_train.shape, x_test.shape,y_tes... |
0487862c2daa0792a0c4b57cadbff95a3429cba0 | mf-2021/python_tutorial | /py_tuto_5.py | 4,203 | 3.625 | 4 | # 5.1 リストについての補足
# a = [66.25, 333, 333, 1, 1234.5]
# print(a.count(333), a.count(66.25), a.count('x'))
# a.insert(2, -1)
# a.append(333)
# print(a)
# print(a.index(333))
# a.remove(333)
# print(a)
# a.reverse()
# print(a)
# a.sort()
# print(a)
# a.pop()
# print(a)
# 5.1.1 リストをスタックとして使う
# stack = [3, 4, 5]
# s... |
0ea59dff442189f4f05326f201bf1b783a294930 | janeite/learnpythonthehardway | /Ex15_reading_files.py | 366 | 3.890625 | 4 | #coding=UTF-8
#导入sys中的参数
#from sys import argv
#分解两个参数
#script,filename = argv
#函数open(文件名,打开权限)
#txt = open(filename)
#print "Here is your file %r:" % filename
#read()读出文件内容
#print txt.read()
print "Type the filename again:"
file_again = raw_input(">")
txt_again = open(file_again)
print txt_again.read()
|
4baf15d94bb722e6233b901d421738e9ab6cdfef | ZiadGold/good_morning | /good_morning.py | 98 | 3.84375 | 4 | msg = input("Good Morning")
if msg.lower() == "good morning":
print(":)")
else:
print("-_-")
|
842925c8114b2ef21081a188beb897c876ff52a0 | mgongguy/Daily-Python-Script | /day10/todo | 448 | 3.703125 | 4 | #!/usr/bin/env python
import sys
from array import *
print "*" * 60
print "Todo List - Version 1.0"
print "Mark Gong-Guy"
print "*" * 60
#Initalizes todo list array
todo_list = []
while 1 == 1:
for todo in todo_list:
print "Todo Item : ", todo
choose = raw_input("New item(n) or quit(q):")
if cho... |
d62c4c46bd51183ddd687473f6b94fc0c3498f5b | mgongguy/Daily-Python-Script | /day11/budget | 984 | 3.703125 | 4 | #! /usr/bin/env python
import sys
from array import *
print "*" * 60
print "Personal Budget - Version 1.0"
print "Mark Gong-Guy"
print "*" * 60
#Global Variables
balance = raw_input("Enter current balance: ")
running = 1
ntrans = []
#Functions
def addTrans(name):
ntrans.append(name)
print "Added: ", nam... |
c5d047304387c73bf2d52deb855dba19a2754eb4 | brityboy/python-workshop | /day3/test_lecture.py | 706 | 3.859375 | 4 | import unittest
from lecture import foo, median_after_throwing_out_outliers
class ScratchTests(unittest.TestCase):
def test_foo(self):
expected = 7
result = foo(6)
self.assertEqual(expected, result)
def test_foo_negative_numbers(self):
expected = -7
result = foo(-8)
... |
55dca8c77d3eed88301fd93979dbd1b6b4ad657f | brityboy/python-workshop | /day2/exchange.py | 2,914 | 4.125 | 4 | # def test():
# return 'hello'
# this is the game plan
# we are going to make
# a function that will read the data in
# built into this, we are going to make functions that
# 1. creates a list of the differences <- we will use from collections
# Counter in order to get the amounts
# 2. We are going to create a fun... |
fbf19ba46bc93a50dac5dd82c8a425c116b27254 | Kokitis/pyregions | /pyregions/utilities/table_column_utilities.py | 7,514 | 3.6875 | 4 | from typing import List, Union, Tuple, Iterable, Any
from itertools import filterfalse
from pyregions.standard_definition import RequiredColumns
def parse_keywords(columns: Iterable[Any], candidates: List[str]):
""" Matches values in `columns` that are present in `candidates`
Parameters
----------
co... |
a7eccff12bec7115ab2652a9e16630d68f656aa9 | Sarah-HP/ed-elect | /scripts/tweet_filter.py | 9,013 | 3.765625 | 4 | #this code filters for tweets related to education and college
#affordability and outputs csvs of education tweets, affordability
#tweets, and csvs of the percentage of tweets about those subjects
#to feed into charts
#I've set up the file names with ../data in the expectation the
#program is run while in the scraping ... |
5f45056f5ca184fde07e69288e33b67b5c573946 | ShadowElf37/2DEquationMapper | /main.py | 2,467 | 3.5625 | 4 | import pygame
from math import *
def clamp(x, mn=0, mx=255):
if x < mn: x = mn
elif x > mx: x = mx
return x
def load_data():
global equation, size, screensize, inputs, screen, vscreensize
data = open('equation', 'r').read().split('\n')
size = int(data[0])
screensize = vscreensize = int(dat... |
5b495d8513ac730326b12bbc3c673628e14395ff | miranas/python | /funkcije/drzava_u.py | 943 | 3.703125 | 4 | podatki = {
"Slovenija":"Ljubljana",
"Avstrija":"Dunaj",
"Italija":"Rim"
}
def izpisi_gl_mesto(drzava):
return podatki[drzava]
def izpisi_drzavo(mesto):
for drzava in podatki.keys():
if (mesto == podatki[drzava]):
return drzava
# else namenoma manjka (da gre zanka... |
d53ad7f648e3ad58a7226c607a22734df800c1c8 | INF1007-2021A/2021a-c01-ch6-supp-2-exercices-Julien9969 | /exercice.py | 1,767 | 3.71875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
import copy
import itertools
def get_even_keys(dictionary):
return {k for k in dictionary if k%2==0}
def join_dictionaries(dictionaries):
return {
key : value
for d in dictionaries
for key, value in d.items()
}
def dictionary_from_lists(keys,... |
8d8ced3e693b0ba0763dd9b1861c896097bf7f3b | RomeLeader/Project-Euler-Problems | /largest_palindrome_product.py | 433 | 3.96875 | 4 | #!/usr/bin/python
def largest_palindrome_product():
current_largest = 0
for i in range(999, 1, -1):
for j in range(999, 1, -1):
product = i*j
if (str(product) == str(product)[::-1]): #Palindrome check on stringified numbers
if product > current_largest:
... |
de2d98dd58260e03a19d91e59ef1dc75091de366 | suneelkanthala/olympics-data-analysis | /Code_Analysis.py | 2,708 | 3.578125 | 4 | #Importing header files
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
#Path of the file is stored in the variable path
data = pd.read_csv(path)
#Code starts here
# Data Loading
data = data.rename(columns={"Total": "Total_Medals"})
#print(data.head(10))
# Summer or Winter
data['Better_Event'... |
06ba577a4a7ae06eb86f33c4eac43a7c7cb9e3ec | brunpersilva/python-treino2 | /ex22.py | 189 | 3.921875 | 4 | n = int(input('Digite um número: '))
n1 = str(n)
print('unidade: {} '.format(n1[3]))
print('dezena: {}'.format(n1[2]))
print('centena: {}'.format(n1[1]))
print('milhar: {}'.format(n1[0]))
|
16a69e78c954bdc7407e0cfb1243f93ccc69be66 | brunpersilva/python-treino2 | /ex5.py | 135 | 3.6875 | 4 | n1= int(input('Qual a sua primeira nota?'))
n2= int(input('Qual a sua segunda nota?'))
print('A sua média é de:{}'.format((n1+n2)/2)) |
8c9a9616f3c0766d4b78a550b3d0f0c98f7126ff | brunpersilva/python-treino2 | /ex8.py | 91 | 3.984375 | 4 | x=int(input('Digite um número: '))
for i in range(11):
print('{}x{}='.format(x,i),i*x) |
72f840a7c5240bde039940e66c802a1fd2c2b37a | Shivanshgarg-india/pythonprogramming-day-3 | /list comprehesion/question 2.py | 148 | 3.90625 | 4 | # Find all of the words in a string that are less than 5 letters
words = string.split(" ")
q5_answer = [word for word in words if len(word) < 5] |
9ea8bab5006bab192380d8edbdd87aec931654f2 | Shivanshgarg-india/pythonprogramming-day-3 | /list comprehesion/question 3.py | 154 | 3.828125 | 4 | # Remove all of the vowels in a string
string = 'my anme is shivansh '
answer = "".join([char for char in string if char not in ["a","e","i","o","u"]]) |
cd74e9f3c1a3cfcf339b601d3f1c83884fd27b2e | king1991wbs/WeldSeam | /python/plotwelddata_csv.py | 2,449 | 3.515625 | 4 | #-*- coding:utf-8 -*-
"""
version: python 2.7.8 win8 x64
author: wilson
email: wison_91@foxmail.com
date: 20140928
Descriptionl:
This python program is aimming at read data from a Excel file,and then plot those data
in diagram.
copyright reserved by CAD Center of Tongji University
"""
import csv
#import xlrd
imp... |
b67b1ae1028d01051e0ea355e587aeb928f87a32 | yangjiao2/leetcode-playground | /hashtable/560_equal-sum-k-array.py | 725 | 3.578125 | 4 | # Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.
# Example 1:
# Input:nums = [1,1,1], k = 2
# Output: 2
class Solution:
def subarraySum(self, nums: List[int], k: int) -> int:
acc, result = 0, dict()
counter = 0
... |
85ff05c6aa5a189ba98df91b0d7ca4689fb3e3a9 | yangjiao2/leetcode-playground | /greedy/45_jump-game-1and2.py | 974 | 3.75 | 4 | # Given an array of non-negative integers, you are initially positioned at the first index of the array.
# Each element in the array represents your maximum jump length at that position.
# Your goal is to reach the last index in the minimum number of jumps.
# Example:
# Input: [2,3,1,1,4]
# Output: 2
class Soluti... |
acc861f7666ec2291bcdf8ca8720282bf332eff3 | Astrolopithecus/Final-Project-prog-120 | /Final Project/Miles_Philips_objects_Phase_1.2.py | 3,032 | 3.90625 | 4 | # Miles Philips
# Prog 120
# Final ProjectProject Phase 1.2
# objects
# 5-31-19
#!/usr/bin/env python3
import random
CARDS_CHARACTERS = {"Spades": "♠", "Hearts": "♥", "Diamonds": "♦", "Clubs": "♣"}
##########################################################################
## Definitions for the classes: Ca... |
6a7e62f9592f2224ce6f7a8821775a12e80a4acd | TheHuessy/KeyLogger | /KeyLogger.py | 2,512 | 3.59375 | 4 |
from pynput.keyboard import Listener
def write_to_file(key):
letter = str(key)
letter = letter.replace("'", "")
# Need to set up handlers for non-character keys
# There are a few of them...
if letter == 'Key.space':
letter = " "
if letter == 'Key.alt':
letter = " [alt] "
... |
1ca8a404e0e7f7eccfdbb9ecbcf78ad792fd5cc8 | tmavre/blackjack | /blackjack.py | 1,946 | 3.6875 | 4 | import sys
from libs import deck
from libs import chips
from libs import hand
from libs import steps
def new_game(bet):
# Create & shuffle the deck, deal two cards to each player
initial_deck = deck.Deck()
# Set up the Player's chips
player_chips = chips.Chips()
# Prompt the Player for their bet... |
cffe7cb9f8ca4f65af36abcf8b26d44c9ac76da6 | linaresdev/cursoPY3 | /src/practicing/job4/item_10.py | 183 | 3.59375 | 4 |
def max_count_item(N=0, lists=[]):
out = []
for row in lists:
if len(row) > N:
out.append(row)
return out
print(max_count_item(4, ["hola", "que tal", "hola mundo"])) |
b83ab1e7568eb9603e03f690df2656bccdcc6a56 | linaresdev/cursoPY3 | /src/exercise/day3/funtion.py | 750 | 3.84375 | 4 | ## FUNCIONES
## Funcion saludar sin parametro
def saludar():
print("Hola Mundo")
## Funcion saludar con parametro
def hello(nombre):
print("Hola ", nombre)
## Crear una funcion que le permita ingresar un numero y que retorne su tabla
def verTabla(numero):
for row in range(1,10):
print(row, "X", numero, "=", (ro... |
e71f1186e900a609cfba091f9b972f80222a0a3b | linaresdev/cursoPY3 | /src/practicing/job1/item_3.py | 416 | 4.15625 | 4 | # Realizar un programa en Python que calcule el peso molecular (peso por cantidad de atomos solicitado
# por teclado) de una molecula compuesta de dos elementos
print("CARCULADORA DE PESO MOLECULAR");
peso = ( float(input("Introdusca peso del elemento a calcular:")) * int(input("Indique la cantidad del elemento espe... |
208b505cf4993dc9956437039e3b81df7f509d08 | cuicaihao/aerial-image-converter | /utils/invertBW.py | 644 | 3.546875 | 4 | # Resize and Preserve Aspect Ratio
import cv2
input_GT = "PNG/GT.png"
output_GT_invert = "PNG/GT_INV.png"
def invertBW(input, output):
''' 20% percent of original size
'''
image = cv2.imread(input, 0)
print('Original Dimensions : ', image.shape)
# resize image
invert = cv2.bitwise_not(image)... |
4e0dadf45d7c14b80b155a9c16ae3a1c6b2e686f | StepanBkv/Pythonlesson | /venv/Database.py | 943 | 3.53125 | 4 | def intersection(lang1, lang2):
result = []
for i in range(0, len(lang1)):
for j in range(0, len(lang2)):
if(lang1[i] == lang2[j]):
if(lang1[i] != ''):
result += lang1[i]
return result
if __name__ == '__main__':
languages = []
line = ''
ma... |
178592a57ce09b002482bc4e7638d25730b323ce | Smrcekd/HW070172 | /L03/Excersise 4.py | 385 | 4.34375 | 4 | #convert.py
#A program to convert Celsius temps to Fahrenheit
#reprotudcted by David Smrček
def main():
print("This program can be used to convert temperature from Celsius to Fahrenheit")
for i in range(5):
celsius = eval(input("What is the Celsius temperature? "))
fahrenheit = 9/5*celsius+32
print("The... |
46ec97e1477d1632b36816724c2b5ab77000437c | Smrcekd/HW070172 | /L05/Chapter 6/Excersise 2.py | 874 | 3.890625 | 4 | #Ants_Go_Marching.py
def ants():
ant = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']
add = ['suck his thumb','tie his shoe','steer the wheel', '','tie the rope','regain hope', 'give a bump','stop his lump', 'drum his drum', 'ant the ant']
for i in range (10):
p... |
ac4e2b8034d0c78d302a02c03fdb45ecb3026b56 | Smrcekd/HW070172 | /L04/Chapter 3/Excersise 15.py | 421 | 4.21875 | 4 | # Program approximates the value of pi
# By summing the terms of series
# by David Smrček
import math#Makes the math library available.
def main():
n = eval(input("Number of terms for the sum: "))
x = 0
m = 1
for i in range (1,2 * n + 1, 2):
x = x + (m *4/i)
m = -m
r... |
1cf8ef62ec43030d280a4de5c0722cff05ba079c | Smrcekd/HW070172 | /L06/Chapter 8/excersise5.py | 460 | 3.875 | 4 | #Prime value determinator
import math as m
def main():
n = eval(input("Write a positive whole number: "))
while (n < 1) or (n % 1 != 0):
n = eval(input("Error, write a positive whole number: "))
for i in range (int(m.sqrt(n))):
i = 2
if (n % (i)) != 0:
i ... |
b0088796e78a725b07d544a0491e59f316dd80a0 | Smrcekd/HW070172 | /L03/Excersise 11.py | 305 | 4 | 4 | #convert € to CZK.py
#A program to convert Euro to Czech Crowns
#by David Smrček
def main():
print("This program can be used to convert sum from Euros to Czech Crowns")
Euro = eval(input("What is the sum in Euros? "))
CZK = 27.28 * Euro
print("The sum is", CZK ,"CZK.")
main()
|
9116e73c00624fbd0b8b3488c7d41c722ddef3c8 | Smrcekd/HW070172 | /L05/Chapter 7/quadratic5.py | 571 | 4.0625 | 4 | #quadratic5.py
import math
def main():
print("This program finds the real solutions to a quadratic\n")
a= float(input("Enter coefficient a: "))
b= float(input("Enter coefficient b: "))
c= float(input("Enter coefficient c: "))
discRoot = math.sqrt(b*b-4*a*c)
root... |
6e5f674528d0a086e7d974f86b2440994650a047 | Smrcekd/HW070172 | /L05/Chapter 7/excersise 1.py | 391 | 3.890625 | 4 | #excersise1.py
def main():
hours = int(input("How many hours have you worked? "))
wage = int(input("How much do you earn per hour? "))
wph = hours * wage
if hours <= 40:
final = wph
print(final)
else:
final = 40* wage
final = (hours -... |
baf6d63b75ccf61540ffc32f91a10b48547e953c | Smrcekd/HW070172 | /L04/Chapter 5/Excersise 3.py | 372 | 3.984375 | 4 | #Examscore_to_grade_convertor.py
#by David Smrček
def main():
scale = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDDDDDDDDDDCCCCCCCCCCBBBBBBBBBBAAAAAAAAAAA"
grade1 = int(input("Please enter the quiz grade on a scale from 0 to 100: "))
grade2 = scale[grade1]
print("Your number o... |
34419d4f60cbbd2b2625ff1d8eae8b878610660c | LuizTiberio/Aula_Python_Maua_IOT | /Ex_pratico1.py | 415 | 3.9375 | 4 | import math
def distancia( p1,p2):
aux = (p2[0]-p1[0])**2+(p2[1]-p1[1])**2
dist= math.sqrt(aux)
return dist
p1=[]
p2=[]
p1.append(float( input("Por favor, digite o x do ponto 1: ")))
p1.append(float( input("Por favor, digite o y do ponto 1: ")))
p2.append(float( input("Por favor, digite o x do ponto 2:... |
d4202797cf6864c8c908e07a53d19ba8a78ec41c | TanyaSinha550/Complete-ML | /Multiple_Linear_Regression_Code1.py | 1,912 | 3.796875 | 4 | # Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
dataset = pd.read_csv('50_Startups.csv')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, 4].values
# Encoding the categorical data
# Encoding the Independent Variable
from sklearn.p... |
03f21363f201898a868ffd9636fcb46da6cd48e1 | emlslxl/myPython3 | /base/list.py | 384 | 3.671875 | 4 | # -*- coding: utf-8 -*-
# @Author: emlslxl
# @Date: 2016-12-12 13:37:20
# @Last Modified by: emlslxl
# @Last Modified time: 2016-12-12 13:53:58
my_list = ["emlslxl",30,173]
print("my name is",my_list[0] + ", my age is",str(my_list[1]) + ", my height is",str(my_list[2])+"cm")
my_list.append('basketball')
print(... |
0a054d104f3fff2b5def95f0c3bfbd15d37197aa | emlslxl/myPython3 | /function/var_args.py | 458 | 3.8125 | 4 | # -*- coding: utf-8 -*-
# @Author: emlslxl
# @Date: 2016-09-26 16:26:52
# @Last Modified by: emlslxl
# @Last Modified time: 2016-09-26 17:11:52
#args 可变长参数,不带有key值
def say_hello(greeting,*args):
if len(args) == 0:
print("%s!" %(greeting))
print()
else:
print("len(args) = %d" %(len(args)))
print('%s, %s!'... |
af92632b0665d96267df3bbcf22af66fa2286d84 | Sma6500/Tinyclues_test | /similarity/similarity.py | 926 | 3.6875 | 4 | """
This file contains the abstract class Recommendation
"""
### Import
import pandas as pd
import numpy as np
from abc import ABC, abstractmethod
### the abstract class for different recommendations
class Recommendation(ABC) :
def __init__(self, items : pd.DataFrame, users : pd.DataFrame, ratings : pd.Da... |
623e3a9f11289a040faa5e70ae0678739b5c6b94 | BoyOoka/Python36 | /Hello.py | 1,480 | 4.0625 | 4 | # -*- coding: utf-8 -*-
print("Hello World!")
print("中文")
#中文注释
if True:
print ("Answer")
print ("True")
else:
print ("Answer")
print ("False") # 缩进不一致,会导致运行错误
total = 'item_one' + \
'item_two' + \
'item_three'
total2 = ['item_one', 'item_two', 'item_three',
'item_four', 'i... |
8002ee891e29a1b8d96186ce36a9c543ec1c9211 | BoyOoka/Python36 | /function.py | 1,874 | 4.09375 | 4 | def add(a,b):
print(a + b)
c = a+b
return c
add(3,4)
print(add(2,3))
def ChangeInt( a ):
a = 10
return a
# print(a)
b=2
print(ChangeInt(b))
print( b ) # 结果是 2
def changeme( mylist ):
"修改传入的列表"
mylist.append([1,2,3,4])
print ("函数内取值: ", mylist)
return
# 调用changeme函数
mylist = [... |
a33f0548e4ab60c73bd27068eef0fd0dcf89a324 | w1033834071/qz2 | /oldboy/thread lock/Pool模块.py | 1,342 | 3.546875 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
from multiprocessing import Pool, TimeoutError
import time
import os
def f(x):
return x*x
if __name__ == '__main__':
#创建4个线程
with Pool(processes=4) as pool:
# 打印 "[0,1,2,3,4,5.......81]"
print(pool.map(f,range(10)))
# 使用任意顺序输出相同的数字
... |
f35b9f213a9f87930f82c3a264bfe07ca1ac16db | w1033834071/qz2 | /oldboy/day08/装饰器.py | 773 | 3.921875 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# 作用:
# 不改变原函数 在函数之前或之后再做点操作
# 装饰器原理
# 1、 将outer函数与需要的函数进行捆绑
# 2、 执行outer函数,并且将其下面的函数名当做参数
# 3、 将outer的返回值重新赋值给f100 = outer的返回值
# 新f100函数 = inner
def outer(func):
def inner():
print("hello")
print("hello")
print("hello")
r = func()
... |
dec5d647b9225b0a2863702d69e45118cd17e4cf | w1033834071/qz2 | /oldboy/day04/homework.py | 709 | 4.03125 | 4 | #!/usr/bin/env python
# -*- coding -*-
#列出商品 选商品
# li = ['手机','电脑','鼠标垫','游艇']
# for i,j in enumerate(li):
# print(i+1,j)
# num = int(input("num:"))
# if num > 0 and num <= len(li):
# good = li[num-1]
# print(good)
# else:
# print('商品不存在')
dic = {
"河北":{
"石家庄":["鹿泉","真诚","元氏"],
"邯郸... |
d8824bc95ba88d0ac03380b7cd4547a8f4d3b86c | w1033834071/qz2 | /oldboy/基础题考试/e2.py | 589 | 3.890625 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
s = " Edward 2222211"
# 其实返回的是一个元组或字典 并不是返回多个值
def c(string):
blank_space = 0
upper_case = 0
lower_case = 0
num = 0
for i in s:
if i.isspace():
blank_space += 1
elif i.islower():
lower_case += 1
elif i.... |
07cc3322a5f81a2f56ebdf99d489a5823e6b4198 | mttymtt/DrawBot-Sketchbook | /Classes/Andy-Clymer/2019-07-30/07_interpolate.py | 520 | 3.5625 | 4 |
def interpolate(percent, start, end):
value = start + (end - start) * percent
return value
total_frames = 10
for frame in range(total_frames):
percent = frame / (total_frames - 1)
print(frame, "-", percent)
newPage(300, 300)
x_1, y_1 = 30, 200
x_2, y_2 = 250, 19
new_x = interpo... |
3c56c31fb089c81cf46b815c6df76385b1505c61 | mttymtt/DrawBot-Sketchbook | /Classes/Andy-Clymer/2019-07-02/01_basics.py | 197 | 3.84375 | 4 | # Text = strings
print("Hello")
# Math
print(5 * 2)
print(40 / 3)
# Math with strings
print("Hello\r" * 5)
#Variables
nameFirst = "Matthew"
nameLast = "Smith"
print(nameFirst + " " + nameLast) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.