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 |
|---|---|---|---|---|---|---|
4836a6fe957b774cf73e639cdd0ed52de0bee688 | adamsar/geoqr_front | /GeoQR/geoqr/lib/googlemaps.py | 1,006 | 3.515625 | 4 | """
Library for accessing and massaging data from
google maps
"""
from httplib2 import Http
from urllib import urlencode
import json
GOOGLE_MAPS_GEOCODE = "http://maps.google.com/maps/api/geocode/json"
def get_entry(address):
"""
Returns the raw results for a look up based on an address
"""
h = Http(... |
0b81df2b602ee90edc1cdad356d76fdfa149b78b | wangjiaz/fxrules | /forex-emu.py | 7,781 | 3.625 | 4 | import random
import sys, os
class Account (object):
""" account is the money management unit of my forex game """
def __init__ (self, base, append_capital, growth, unit_ratio, bonus_ratio, bonus_level_gap, name):
self.base = base
self.append_capital = append_capital
self.growth = growth
self.unit... |
0985da7388e6573a22ed19db1187b199e94703ee | ihammad90/Jenkins-ML_pipeline | /Machine-Learning-Pipeline-Step3-Feature-Selection.py | 6,753 | 4.5625 | 5 | #!/usr/bin/env python
# coding: utf-8
# ## Machine Learning Model Building Pipeline: Feature Selection
#
# In the following videos, we will take you through a practical example of each one of the steps in the Machine Learning model building pipeline, which we described in the previous lectures. There will be a n... |
45b0d27a095c34b81a3084728b6ac2502c432c19 | RasikKane/problem_solving | /python/00_hackerrank/main.py | 4,322 | 4.65625 | 5 | import unittest
def is_sum_present_in_list(int_list):
"""
:param int_list:
:return True or False:
The is_sum_present_in_list() function accepts a list of integers and check if the sum of any two integers
is not contained in the list. If the above criteria is met, then True is returned, else False... |
7830f2711cd16350747357b1639b0f72d2974a68 | RasikKane/problem_solving | /python/00_hackerrank/python/08_list_comprehension.py | 631 | 4.375 | 4 | """
Let's learn about list comprehensions!
You are given three integers x, y and z representing the dimensions of a cuboid along with an integer n.
Print a list of all possible coordinates given by (i,j,k) on a 3D grid where the sum of i+j+k is not equal to n.
Here, 0 <= i <=x , 0 <=j <=y, 0 <= k <=z. Please use lis... |
e75ceccb0e5b105717604602b75da3fad31d92c4 | jrboyd90/DC-assignments | /projects/python2/stringExercises/long.py | 276 | 3.78125 | 4 | string = 'the fat pet ping got drunk, took walk'
string = string.lower()
vowels = ['aa', 'ee', 'ii', 'oo', 'uu']
longVowels = ['aaaaa', 'eeeee', 'iiiii', 'ooooo', 'uuuuu']
for i, letter in enumerate(vowels):
string = string.replace(letter, longVowels[i])
print(string)
|
73cd22c260d3219b25c03be3f2a6aac71f315d41 | jrboyd90/DC-assignments | /projects/python4/fileIO/phonebook.py | 1,174 | 3.78125 | 4 | from phoneFunctions import *
import pickle
phonebook = {}
num = ''
string = ''
while True:
selection = int(input('\nElectronic Phone Book\n=====================\n1. Look up an entry\n2. Set an entry\n3. Delete an entry\n4. List all entries\n5. Save entries\n6. Restore saved entries\n7. Quit\nWhat do you want to ... |
e58de85915709f2cb3cd1fa19ad55e934f0fcf70 | jrboyd90/DC-assignments | /projects/python4/dictionaryExercises/letter.py | 224 | 3.875 | 4 |
def letter_histogram(string):
list = {}
for char in sorted(string):
if char in list:
list[char] += 1
else:
list[char] = 1
return list
print(letter_histogram('cheese'))
|
aa1f819711e6d4dce654bd252eabc3c97b477e4f | jrboyd90/DC-assignments | /projects/python3/functionExercises/degree.py | 438 | 3.625 | 4 | import matplotlib.pyplot as plot
def cels(tempC):
tempF = tempC * 1.8 + 32
if tempF % 1 == 0:
tempF = int(tempF)
print(tempF)
return tempF
temp = int(input('Type a temperature: '))
xs = list(range(0,50))
ys = []
while temp != 0:
for x in xs:
ys.append(cels(temp))
temp = i... |
6ec2a5f41f813bc0d3b8bac97bff84a245517138 | jrboyd90/DC-assignments | /projects/python2/loopExcercises/box.py | 202 | 4.03125 | 4 | width = int(input('Width? '))
height = int(input('Height? '))
print('*' * width)
spaces = width - 2
spaces = ' ' * spaces
for i in range(height - 2):
print('*' + spaces + '*')
print('*' * width)
|
4d40c822164516d0a63ff94cb5af4ad4308f139c | jrboyd90/DC-assignments | /projects/python4/fileIO/word.py | 501 | 4 | 4 |
def word_histogram(string):
list = {}
temp = ''
for char in string.lower():
if char == ' ':
if temp in list:
list[temp] += 1
temp = ''
else:
list[temp] = 1
temp = ''
else:
temp = temp + char... |
c10d5d9f9e6ce643d91724700e023b46d4e165e4 | panchaoneu/CS5100-Foundations-0f-AI | /Assignment7/ProgrammingAssignment/ComputerVision/PA1.py | 1,731 | 3.546875 | 4 | #import necessary packages
import cv2
import imutils
# Read the Image
# obtain the height, width and no of channels of the image
# Display the Original Image
image = cv2.imread("lena.png")
(h,w,d)=image.shape
print(h,w,d)
cv2.imshow("LenaOriginal",image)
cv2.waitKey(0)
"Rotation of Image"
# Compute th... |
3141667a9ad93f70f542214b74ad25137bf80a5d | amazingvitor/Fasta-reader-PY | /FastaR/FastaR.py | 2,254 | 3.5 | 4 | def fileCheck(fileName):
try:
# Var do arquivo ja verificado
file = open(fileName)
# Fechando o arquivo
file.close()
except IOError:
print ('Arquivo nao achado, tente de novo.')
main()
def main():
desc = []
seq = []
soma = 0
sums = []
# Nome... |
9b1ebe0a307cea64c5e8135f9a70dde1cf3f1d16 | chvargas/Ucsc-PythonBeginners | /Python Beginners Hoeworks/Homework_1.py | 3,997 | 3.890625 | 4 | # -*- coding: cp1252 -*-
print' ___________________________________________________________________________________________________'
print 'Python Asignment 1 Christian Vargas'
#Creating Integers Variables
numOfWeeksYear = int (52)
numPythonStudents = int (35)
numParkingSpots = int (100)
numPlayersSoccerTeam =... |
beabbe5cad1b1b96decb0a7c0751e50bddc26158 | CodecoolBP20161/python-pair-programming-exercises-2nd-tw-misi_tami_p6 | /palindrome/palindrome_module.py | 446 | 3.984375 | 4 | import string
def palindrome(str):
str = str.lower()
test_str = ''.join(str.split())
temp = []
for c in test_str:
temp.append(c)
temp.reverse()
test_str_reversed = ''.join(temp)
if test_str == test_str_reversed:
return(True)
else:
return(False)
def main():
... |
4906e2419448cc454e6baa92bbced05756ebfb95 | zzibboo/Python_Machine_Learning | /chap02_01_a_perceptron.py | 1,543 | 3.671875 | 4 | import numpy as np
class Perceptron(object):
"""
perceptron classifier.
Parameters
alpha: learning rate (float)
no_epochs: number of epochs (int)
Attributes
weights_: weights (1d array)
errors_: number of misclassification (list)
"""
def __init__(self, alpha=... |
080a7c289bc3918381a054dbda8581a7ebb546f7 | SelinaWu/code-s- | /MergeSortedArray.py | 805 | 3.6875 | 4 | def merge(self, nums1, m, nums2, n):
"""
:type nums1: List[int]
:type m: int
:type nums2: List[int]
:type n: int
:rtype: None Do not return anything, modify nums1 in-place instead.
"""
used_ind = 0
main_ind = 0
used_ind2 = 0
... |
9b61a465bb1d741984873436091fa5fdc2387a3e | TimothySjiang/leetcodepy | /Solution_106.py | 748 | 3.796875 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def buildTree(self, inorder: List[int], postorder: List[int]) -> TreeNode:
rightPreorder = postorder[::-1]
return self.he... |
1060bf273ee8a7fd332658741f98ca6be4ec0ef4 | TimothySjiang/leetcodepy | /Solution_865_2.py | 851 | 3.6875 | 4 | class Solution(object):
def subtreeWithAllDeepest(self, root):
# The result of a subtree is:
# Result.node: the largest depth node that is equal to or
# an ancestor of all the deepest nodes of this subtree.
# Result.dist: the number of nodes in the path from the root
... |
713fb8f456370dc392adcb4bd8c6968b514b905a | TimothySjiang/leetcodepy | /Solution_536.py | 692 | 3.765625 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def str2tree(self, s: str) -> TreeNode:
ix = s.find('(')
if ix < 0:
return TreeNode(int(s)) if s else None
... |
d8c87a639d00b3c938b13a84e8ba9d4afb60ef0b | TimothySjiang/leetcodepy | /mostCommon.py | 373 | 3.890625 | 4 | import collections
def mostCommon(arr):
counter = collections.Counter(arr)
res = []
maxFreq = float('-inf')
for k in counter:
if counter[k] > maxFreq:
res = [k]
maxFreq = counter[k]
elif counter[k] == maxFreq:
res.append(k)
return res
if __name... |
ddea9e74da714a41eab3cabc1d2a60633ca59ea1 | TimothySjiang/leetcodepy | /Solution_95.py | 780 | 3.796875 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def generateTrees(self, n: int) -> List[TreeNode]:
if not n: return []
return self.helpGenerateTrees(1, n)
def helpG... |
7680e0bf67b146d360b4f323b60553e9eb083d85 | TimothySjiang/leetcodepy | /Solution_684.py | 860 | 3.546875 | 4 | class Solution:
def findRedundantConnection(self, edges: List[List[int]]) -> List[int]:
if not edges: return None
uf = UnionFind(len(edges))
for first, second in edges:
if not uf.query(first, second):
uf.connect(first, second)
else:
ret... |
2c3fc1e17417e38728265a2819946eb60c0b6b19 | TimothySjiang/leetcodepy | /Solution_337_2.py | 491 | 3.59375 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def rob(self, root: TreeNode) -> int:
return max(self.dp(root))
def dp(self, root):
if not root: return 0, 0
... |
6ec77e51d655c16c5260bcc0aa28c6ffa1444361 | TimothySjiang/leetcodepy | /Solution_245.py | 853 | 3.578125 | 4 | class Solution:
def shortestWordDistance(self, words: List[str], word1: str, word2: str) -> int:
distance = len(words)
index1 = index2 = -1
if word1 != word2:
for i in range(len(words)):
if words[i] == word1:
index1 = i
if i... |
8627dbf0de16b5d0ca36c906d7829dcf9398e700 | TimothySjiang/leetcodepy | /Solution_204.py | 310 | 3.546875 | 4 | class Solution:
def countPrimes(self, n: int) -> int:
count = 0
for i in range(2, n):
count += self.isPrime(i)
return count
def isPrime(self, n: int) -> int:
for i in range(2, n**0.5 + 1):
if not n % i:
return 0
return 1 |
178472d6dd1c32faa70fed7f283e8670df3ca1c2 | TimothySjiang/leetcodepy | /Solution_1008__2.py | 738 | 3.8125 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def bstFromPreorder(self, preorder: List[int]) -> TreeNode:
self.idx = 0
n = len(preorder)
return self.helper(pre... |
0e28d329b134f6de2b7f844dfe9d59b427ba32d0 | TimothySjiang/leetcodepy | /Solution_814.py | 735 | 3.828125 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def pruneTree(self, root: TreeNode) -> TreeNode:
if not root: return root
prev = TreeNode(0)
prev.left = root
... |
686558233e112c57cc9c343478899974d6eb9ca9 | TimothySjiang/leetcodepy | /Solution_99.py | 1,491 | 3.625 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def recoverTree(self, root: TreeNode) -> None:
"""
Do not return anything, modify root in-place instead.
"""
... |
6c83078c0202bb6137f0b4e351ea7fcafefa0873 | TimothySjiang/leetcodepy | /Solution_993.py | 793 | 3.609375 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def isCousins(self, root: TreeNode, x: int, y: int) -> bool:
self.seen = []
self.x = x
self.y = y
self.df... |
5796dd6cfd950ab85ac8feac5e5fb4bf4984673f | TimothySjiang/leetcodepy | /diagonalSort.py | 491 | 3.890625 | 4 | #Quora OA
def diagonalSort(matrix):
m = len(matrix)
n = len(matrix[0])
for d in range(n):
temp = sorted([matrix[i][i+d] for i in range(n-d)])
for i in range(n-d):
matrix[i][i+d] = temp[i]
if d:
temp = sorted([matrix[i + d][i] for i in range(n-d)])
... |
a44f407beac009e977a284c146407fbb7cca8d9b | TimothySjiang/leetcodepy | /Solution_144_2.py | 554 | 3.65625 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def preorderTraversal(self, root: TreeNode) -> List[int]:
return self.helpPreorder(root, [])
def helpPreorder(self, root, pr... |
dee0b0f0d8975be506f7499ae4080f6782ef8f23 | TimothySjiang/leetcodepy | /Solution_199.py | 668 | 3.703125 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def rightSideView(self, root: TreeNode) -> List[int]:
if not root:
return []
queue = [root]
result =... |
938feb7cd0c63ffd828359088ace0a1d5bd06aa1 | htliujy/Python-100-Days | /Day01-15/code/Day05/prime_num.py | 619 | 3.75 | 4 | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File : prime_num.py
@Time : 2019/11/02 14:34:24
@Author : Jack Lau
@Version : 1.0
@Contact : sysu.liujy@hotmail.com
@License :
@Desc : 输出100以内所有的素数。
'''
# here put the import lib
import math
prime = []
for i in range(2,100):
is_prime =... |
d810202a7323a5669c3ee20dbb2425a98ac66eee | gkbrk/RosalindSolutions | /revc/revc.py | 553 | 4.09375 | 4 | import sys
def complement(dna_string):
complemented_string = ""
for nucleotide in dna_string:
if nucleotide == "A":
complemented_string += "T"
elif nucleotide == "T":
complemented_string += "A"
elif nucleotide == "G":
complemented_string += "C"
... |
f6088f0f76c8499c4249eb30c220bd15a5d0c389 | lmnnarciso/math_tinik2 | /math_tinikwithClass.py | 8,536 | 3.71875 | 4 | import random
import time
import math
import re
class User(object):
def __init__(self, userName, score, error, time):
self.userName = userName
self.score = score
self.error = error
self.time = time
def correct(self):
self.score += 1
print("CORRECT!!!")
... |
1f5531d2baf05a71082b82f5f63fdd90f8e30a73 | elifustunel/elff | /lab3/1.py | 76 | 3.890625 | 4 | x=int(input("enter number"))
if x <= 0 :
print(-x)
else :
print(x) |
78865976dad2005a13b56616b6656cc9d20d7858 | elifustunel/elff | /lab5/1.py | 83 | 3.828125 | 4 | x=int(input("enter integer:"))
for i in range(1,11):
print(str(x),"x",i,"=",i*x) |
51ac5fba05dea57ebbc98fc66092876f2e867b82 | NoraIlisics/FirstRep | /for.py | 924 | 4.34375 | 4 | #Write a program which sums the integers from 1 to 10 using a for loop
# (and prints the total at the end).
total = 0
for i in range(1,11):
total += i
print(total)
#Can you think of a way to do this without using a loop?
total2 = sum(range(1,11))
print(total2)
#Write a program which finds the factorial of a g... |
d22c7eafec65b1c3d8c0cf5f26dfa70df3c11c60 | ryanbagwell/radar-detector | /lib/gpio_mixins.py | 6,713 | 3.796875 | 4 | import RPi.GPIO as GPIO
from numpy import median
import time
class ADCMixin(object):
""" A class to read values from the
mcp3008 analog-to-digital converter """
def __init__(self, clk_pin=18, miso_pin=23, mosi_pin=24, cs_pin=25):
self.clk_pin = clk_pin
self.miso_pin = miso_pin
... |
e7f453d21d8babda21318fc08c8da5f263848604 | netgb/uncompyle3 | /uncompyle3/tests/blackbox/res/misc/complex_script1.py | 187 | 3.96875 | 4 | base = 4
addition = 7
multiplication = 15
power = 2
add = True
if add:
result = (base + addition) ** power
else:
result = base * multiplication ** power
print('Result:' + result)
|
d7f902f2bbca8b47db72a2fa24b366e0427fb141 | julian-falco/FindAndReplace | /FindAndReplace.py | 6,105 | 3.75 | 4 | import os
from tkinter import *
from tkinter.filedialog import *
def getSeriesInfo(fileName):
"""Return the series name and number of sections."""
# get only the name
seriesName = fileName.replace(".ser", "")
# find out how many sections there are
sectionNums = []
# sear... |
2d9ce9f14e38ad7328e1e2da38c0b87f781ff873 | clenio77/Dio_seguranca_python | /verificador_telefone.py | 295 | 3.609375 | 4 | import phonenumbers
from phonenumbers import geocoder, timezone
phone = input('Digite o telefone no formato +551140028922: ')
phone_number = phonenumbers.parse(phone)
lugar = timezone.time_zones_for_number(phone_number)
print(geocoder.description_for_valid_number(phone_number, lugar, 'pt'))
|
9d585e1329e8c791889bb2ddbf012b4350b6e5a3 | sangeeetttt/INV | /inv.py | 3,734 | 3.640625 | 4 | from tkinter import *
import tkinter.messagebox as tkMessageBox
import sqlite3
import tkinter.ttk as ttk
root = Tk()
root.title("Inventory Management System by GARUDA")
width = 1024
height = 720
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
x = (screen_width / 2) - (width / 2)
y = ... |
b624555b4f9aa19bbd68d27425bceb148596de1e | tkdjohn/Students-Dilemma | /HumanPlayer.py | 3,818 | 3.75 | 4 | import Settings
class Human_Player(object):
'''Represents a human player.'''
@property
def Bonus(self):
return(self._bonus)
@property
def Score(self):
return(self._score)
@property
def Most_Recent_Choice(self):
return(self._most_recent_choice)
... |
6e5fc2994f314c0f0c9bedb158d14a217e6f449d | RagibAhashan/Fast-Drone-Delivery-System | /Arc.py | 977 | 3.71875 | 4 | #########################################################################################
# Class Arc: Contient les arcs
#########################################################################################
class Arc:
def __init__(self, firstVertex, secondVertex, distance):
self.firstVertex = firstV... |
0c0778d20c800cc2a3b7f1e0f1fd41719ff4ade7 | NickCampbell91/cse210-tc04 | /hilo_template/hilo/game/director.py | 1,592 | 3.625 | 4 | from game.dealer import Dealer
class Director:
def __init__(self):
self.keep_playing = True
self.score = 300
self.dealer = Dealer()
self.current_card = 0
def start_game(self):
while self.keep_playing:
#self.get_inputs()
#self.do_upd... |
9e53a7e119541abd676d261b39f58bc690f6f71d | ppius/csc202 | /ch4_recursion/recur_pal_checker.py | 588 | 3.609375 | 4 | def pal_checker(word):
"""
>>> pal_checker("kayak")
True
>>> pal_checker("aibohphobia")
True
>>> pal_checker("Live not on evil")
False
>>> pal_checker("Go hang a salami; I'm a lasagna hog")
True
>>> pal_checker("Kanakanak")
True
>>> pal_checker("Wasamassaw")
... |
2497b4759f3b05f449d78d4a3d035b5d0ceeeffc | mbilab/dom-adv-sigU | /utils/layers.py | 5,651 | 3.53125 | 4 | #!/usr/bin/env python3
import tensorflow as tf
def get_variable(name, shape=None, init_param=None, trainable=True):
"""Generate a variable.
Generate a variable with truncated normal distribution or initial value.
Arguments:
name (str): Name of variable.
shape (tuple or list): Shape of var... |
adb7158f944d8c7f9d7423de07b32faeaa695add | sachingore55/search | /search2.py | 1,027 | 4.0625 | 4 | import re
myString="""Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has s... |
2a3825465193b4d881acc1801cc1a1213cc2ceb7 | turgon/CLRS | /heapsort.py | 3,057 | 3.859375 | 4 | def parent(i):
"""
Get the parent index of i
>>> parent(1)
0
>>> parent(2)
1
>>> parent(3)
1
>>> parent(4)
2
"""
return i >> 1
def left(i):
"""
Get the index of the ith node's left child
>>> left(1)
2
>>> left(2)
4
>>> left(3)
6
"""
... |
57ddd657bd402e1b4666223f51ad8efcc17a070f | Nevashka/Project-Euler | /palindrome.py | 591 | 4.1875 | 4 | #Problem 4: Find the largest palindrome made from the product of two 3-digit numbers.
def largest(digits):
''' (int) -> int
return the largest palindrome from the product of the numbers with
the given number of digits
palindrome(2) -> 9009 '''
first = 10**(digits-1)
last = (10**digits)-1
... |
c497c4ebc5b4b361d52add9a62cb9569738e7fe4 | StefanIsaksson/learning-python | /Language/hello-world.py | 549 | 3.546875 | 4 | import platform
def get_message(user_name):
return f'Hello {user_name} says Python {platform.python_version()}'
def get_border(border_length):
return '*' * border_length
def print_message(message, show_border=True):
if show_border:
border = get_border(len(message))
print(border + '\n' + mes... |
ef66834107b1329f7b7a548af0ad956fffb57024 | sirpanda64/sirpanda64.github.io | /my_website/images/coding.py | 4,390 | 4.0625 | 4 | def play ():
print "You wake up from a bad dream"
choice = raw_input("Go to the bathroom? yes/no")
while choice != 'yes' and choice !='no':
choice = raw_input('Answer correctly! You uncultured, uneducated swine!')
if choice == "yes":
print "You do your business and leave the bathro... |
b6de5d4434c5d21dbbafe799879b02b43278c2ec | davidlbyrne/cybersecurity | /assignment2/des_cbc.py | 2,882 | 4.15625 | 4 | #!/usr/local/bin/python3
# Assignment2 - Assignment 2, due November 7, 2018: Problem 6.1
# in the lecture notes. You may import the following packages from
# Python libraries:
import sys
import binascii
from Crypto.Cipher import DES
from Crypto import Random
def checkpad(plaintext):
length= len(plaintext)
... |
55ea139a0fdfac6aafff28f46f3e17885cf80696 | bwoodske/Yahtzee | /score_card.py | 8,968 | 3.5625 | 4 | '''
Ones x amt
twos x amt
threes x amt
fours x amt
fives x amt
sixes x amt
bonus 35 pts if score is 63 <=
3 of a kind: ttl of all dice
4 of a kind: ttl of all dice
full house: 25 pts
small stright 30 pts
large straight 40 pts
yahtzee 50 pts
chance ttl of all dice
yahtzee bonus 100 each
... |
f6d5abdad6c23bb1a269f5e065827b81e9b7378a | vv31415926/lesson3 | /3seq.py | 1,187 | 3.78125 | 4 | '''
Пользователь вводит элементы 1-го списка (по очереди как в МОДУЛЬ 1 или вместе как в МОДУЛЬ 2)
Затем он вводит элементы 2-го списка
Удалить из первого списка элементы присутствующие во 2-ом и вывести результат на экран
Пример работы: Введите элементы 1-го списка: 1,2,3,4,5
Введите элементы 2-го списка: 2,5
Результа... |
6ee67e0c69bc0d67d893174679ff99b3885b3c4c | hgupta7557/PythonNetwork | /Sum_of_Range.py | 385 | 4.09375 | 4 | total = 0
num1=int(input("Enter the Start Number of a Range : "))
num2=int(input("Enter the End Number of a Range : "))
if num2<num1:
print("Make Sure Number 2 value is Higher than number 1")
print("program terminated, please run it again.")
else:
print("range number is : ", num1, num2)
for i in ran... |
b1dd96f1eeb8a1345932ac5edde5ce112578010b | hgupta7557/PythonNetwork | /MinMaxfromArray.py | 441 | 4 | 4 | list=[]
long=int(input("Enter the value of index : "))
for i in range(0,long):
print("Enter the value : ", i)
value=int(input())
list.append(value)
print(list)
min_element=list[0]
max_element=list[0]
for j in range(len(list)):
if list[j] < min_element:
min_element = list[j]
for k in ... |
04941365506b0e7b0a1c3b610365d6a0a0ff7355 | Kharianne/vysledky_prikladu | /05.2.py | 415 | 3.859375 | 4 | # Napiš program, který od uživatele přečte den v týdnu
# a řekne mu, zdali je to všední den nebo den víkendu.
day = input("Give me a name of day: ")
if day.lower() in ["saturday", "sunday"]:
print("It is a weekend day")
elif day.lower() in ["monday", "tuesday", "wednesday", "thursday", "friday"]:
prin... |
8ba9f43179a59d5b471cb36c642cf2d4321e6352 | Kharianne/vysledky_prikladu | /05.1.py | 241 | 3.875 | 4 | # Napiš program, který od uživatele přečte číslo
# a řekne mu, zdali je sudé nebo liché.
number = int(input("Give me a number: "))
if number % 2 == 0:
print("Your number is even.")
else:
print("Your number is odd.") |
d403632d4cf3b61e4b6e9b0aca720703d7e1df1b | MTE1991/Problem-solving | /task16.py | 250 | 3.96875 | 4 | def simple_calc(operator, operand1, operand2):
return eval("{operand1} {operator} {operand2}".format(operand1=operand1, operator=operator, operand2=operand2))
op = str(input())
x = float(input())
y = float(input())
print(simple_calc(op, x, y))
|
1fd539bb10b458cc2b02325d421593c361154080 | louisfghbvc/Leetcode | /Two Pointers/2105. Watering Plants II.py | 884 | 3.515625 | 4 | # Simulate O(N)
class Solution:
def minimumRefill(self, plants: List[int], capacityA: int, capacityB: int) -> int:
# two pointers, simulate the process
# when not enough, refill the water
n = len(plants)
l, r = 0, n-1
refill = 0
curA, curB = capacit... |
5776a68d4aa60a2c3689f9c46b828c516462ac29 | louisfghbvc/Leetcode | /Tree/1120. Maximum Average Subtree.py | 811 | 3.734375 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
# post order, just try to enumerate each node. and calculate value, and node numbers.
# O(N)
class Solution:
def maximumAve... |
817fb918e89e54bc74d8c1b59cd993a9a5d869b5 | louisfghbvc/Leetcode | /String/2129. Capitalize the Title.py | 520 | 3.796875 | 4 | # string process
# simulate
# O(N)
class Solution:
def capitalizeTitle(self, title: str) -> str:
# split the word
# then check size is 1 or 2
words = title.split()
res = []
for word in words:
if len(word) == 1 or len(word) == 2:
... |
de6c6bd549f97859147542760d060b8bdbba7aec | louisfghbvc/Leetcode | /Linked List/2130. Maximum Twin Sum of a Linked List.py | 579 | 3.53125 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def pairSum(self, head: Optional[ListNode]) -> int:
# convert to arr
arr = []
while head:
arr.append(hea... |
d5671da7005a93cd0285c4ccb912f9bb5455d3f0 | gyogo/Programming-Python- | /Employee.py | 708 | 3.890625 | 4 | #p200
class Person:
def __init__(self, name, age):
self.name=name
self.age = age
def eat(self, food):
print(self.name+"가 "+food+"을 먹습니다.")
def __str__(self):
return self.name+"는 "+str(self.age)+"살입니다."
class Employee(Person):
def __init__(self, name, age, salary):... |
ebdcac9519aaebe7b0a2c502a4986f45650da760 | gyogo/Programming-Python- | /패키지/datetimemodule.py | 800 | 3.625 | 4 | from _datetime import datetime
print('현재 날짜 시각 객체 얻기')
today = datetime.now()
print('today = datetime.now() : ', today)
print('년 월 일 : today.year, today.month, today.day ', today.year, today.month, today.day)
print('시 분 초 : today.hour, today.minute, today.second', today.hour, today.minute, today.second)
print('요일 : ',... |
22c231a984bba2dc5e62fffdb350708fd9378e41 | gzdnrgltkn/Deja-Vu | /code.py | 308 | 4.0625 | 4 | word=input()
letters=list(word) #converted input to a list letter by letter
sett=set(letters) #removed duplicate letters in the list so I used set function
if len(sett)!=len(letters): #ı checked if the original one and removed duplicates one have same lenght or not
print("Deja Vu")
else:
print("Unique")
|
1fbe1690404ede63cd37782112f96da3cd3181a5 | mdtngr/codeasylums | /10 dec/q1.py | 383 | 3.859375 | 4 | #Write a Python program to count the number of strings where the string length is 2 or
#more and the first and last character are same from a given list of strings.
n=int(input())
l=[]
while n!=0:
n=n-1
s=input()
l.append(s)
print("\n \n")
fl = list(filter(lambda x: (len(x)>= 2) , l))
fl2 = list... |
da89c092d8158826bfbb0ba3c7c4f01643d2536e | mdtngr/codeasylums | /8 dec/pattern.py | 320 | 3.796875 | 4 | #print the following pattern
#12345
# 2345
# 345
# 45
# 5
def design():
n = int(input())
for i in range(1,n):
for z in range(1,n):
if z<i:
print(" ",end='')
else:
print(z,end='')
print()
design()
|
9c3914db801d5067bc4201a02a328a0e1ac62edc | NTI-Gymnasieingenjor/AdventOfCode2020 | /Erik-solutions/day1/day.py | 1,192 | 3.65625 | 4 | inputDoc = open("input.txt")
docLines = inputDoc.readlines()
inputDoc.close()
# PART 1
# Find two numbers that add up to 2020 and multiply them
correct1 = []
for line in docLines:
line = int(line.replace("\n", ""))
for lineTwo in docLines:
lineTwo = int(lineTwo.replace("\n", ""))
if line + line... |
72e11ac47280c2ff079353f3e92a744fb16de490 | sabasharf123/word-frequency | /word-frequency-starter.py | 2,824 | 4.21875 | 4 | #set up a regular expression that can detect any punctuation
import re
punctuation_regex = re.compile('[\W]')
#open a story that's in this folder, read each line, and split each line into words
#that we add to our list of storyWords
storyFile = open('short-story.txt', 'r') #replace 'short-story.txt' with 'long-story.t... |
f254bca2a2f4c84f0dbe492d37c9e458c47b4fe6 | nwthomas/Graphs | /projects/ancestor/ancestor.py | 1,372 | 3.609375 | 4 | class Queue:
def __init__(self):
self.queue = []
def enqueue(self, value):
self.queue.append(value)
def dequeue(self):
return self.queue.pop(0)
def size(self):
return len(self.queue)
def create_reverse_graph(ancestors):
graph = {}
for edge in ancestors:
... |
80c4ac318f00b8cc10a938cfc432f09763e00871 | AngelmunozQ/An | /Clases/examen3.py | 1,552 | 4.125 | 4 | #1
"""def Calcu (num1,num2,num3):
Z=(num1*num2*num3)
f=(num1/num2/num3)
W=(num1**num2**num3)
print(f"{Z},{f},{W}")
print("""
#1. Multiplicacion,Potencia y Division.
#2.Salir
""")
Eleccion = (input("seleccione una opcion : "))
if Eleccion == "1":
a = int(input("ingresa numero : "))
y = int(... |
3c5554c2a4d892ff3aab9bd11b6179bfb68f909c | pupysheva/flask-project | /model/timer.py | 1,002 | 3.640625 | 4 | #!/usr/bin/python
# utf-8
import time
from functools import wraps
from math import trunc
def timer(text=''):
"""Декоратор, печатает время выполнения декорированной функции.
Аргумент:
Текст для печати
"""
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
... |
e67e96f32a9ac042a585544569c175376c117096 | skonstantinov89/hbExam | /exam-2/fill_pyramid_counter.py | 557 | 3.65625 | 4 | import math
def fill_tetrahedron(num):
volume = (num**3)/(6*math.sqrt(2))/1000
# the formula returns ml**3
return round(volume,2)
def tetrahedron_filled(num, water):
volumes = []
for eachEdge in num:
volumes.append(fill_tetrahedron(eachEdge))
counter = 0
isElements = len(volumes)
while water > 0 and isEle... |
61cbed2214f13e4f28b98f9c1b9539e60eb259ae | hammerkid/PT2-02-16-P1 | /sum and spam.py | 269 | 3.625 | 4 | def sum(*args):
array_sum=0
for digit in args:
for x in digit:
#print x
if type(x) == int:
array_sum = array_sum + x
return array_sum
sum ([1,2,3,'3'])
def spam(number):
return 'egg'*number
spam(10) |
9f2741473d5ba84708962e2cafe5a0e7ff8f6d74 | crhx/domletters | /domletters | 874 | 4.0625 | 4 | #!/usr/bin/env python3
import sys
# Lists and variables used in program
letter_counter = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
total_score = 0
words = []
# Splits the input into a list of words
for line in sys.stdin:
words += line.split()
# Examines each word if they only c... |
23f461a1f94f2786aeed9883b5a57316817fa502 | n30phyte/SchoolDocuments | /CMPUT274275/Assignments/Huffman/bitio.py | 2,025 | 4.03125 | 4 | # Adapted from http://rosettacode.org/wiki/Bitwise_IO#Python by Roshan
# Shariff. Licensed under the GNU Free Documentation License 1.2
class BitWriter:
def __init__(self, f):
'''f must be an output stream opened in binary mode.'''
self.accumulator = 0
self.bcount = 0
self.out = ... |
5b8af85fa33c8f9eb9be794cb6aa24a52ee4a781 | n30phyte/SchoolDocuments | /CMPUT274275/MorningProblems/large_points/soln/large_points.py | 544 | 3.640625 | 4 | import math
n = int(input())
x, y, r = [], [], []
# x, y, r are empty lists
for i in range(n):
x_in, y_in, r_in = map(float, input().split())
x.append(x_in)
y.append(y_in)
r.append(r_in)
m = int(input())
output = ["Small"] * m
for j in range(m):
x_in, y_in = map(float, input().split())
f... |
abae6669a21ef4712661fb9a742a1a7f66ef55ea | n30phyte/SchoolDocuments | /CMPUT274275/WeeklyExercise/password/validator.py | 3,563 | 3.78125 | 4 | # ---------------------------------------------------
# Name: Michael Kwok
# ID: 1548454
# CMPUT 274, Fall 2019
#
# Weekly Exercise 1: Password Validator and Generator
# ---------------------------------------------------
import string
import random
def validate(password):
""" Analyzes an input password to deter... |
3d77fb67063f0e9777c390fa2133742ebf8eae20 | JoeCaoV/Macgyver | /classes/display.py | 4,504 | 3.640625 | 4 | """import pygame to disply every elements
get every needed constants
"""
import pygame
from config import FONT, BIG_FONT, BOT_RIGHT, BOT_LEFT, TILE_SIZE, FLOOR, WALL
class Display:
"""This class, contains every action that must output or modify the display
of the game window, like moving the character, remove... |
4ac9d1b99ced57f795d1200905827cf3099a2641 | cifpfbmoll/practica-5-python-JaumeFullana | /Practica5/P5Ejercicio2.py | 412 | 4.03125 | 4 | #Escribe un programa que pida dos números y escriba qué números entre ese par
#de números son pares y cuáles impares
print("Escribe dos numeros enteros.")
numero1=int(input("Escribe un numero:"))
numero2=int(input(f"Escribe un numero mayor que {numero1}:"))
for i in range(numero1+1,numero2):
if (i%2==0):
... |
d38d216e04f63ac6514c4726ca63acb3b0a70fbc | ChristianTiani/Demo_Project | /Hello_World.py | 239 | 3.59375 | 4 | def hello():
print('Hello World!')
def intro():
name = input('\nPlease what is your name?: ')
print(f'Hello {name}, welcome to a real-life application of Python Programming!')
hello()
intro()
print("this is my test branch)
|
72f48d78e0f90cdfc9ff5475f188c7ed1ea21c5e | xiaoxiaoxiaoma/mycode | /nowcoder/Clearer.py | 688 | 3.859375 | 4 | # -*- coding:utf-8 -*-
#注意若 row=column=set(),这说明row和column所指向的内存区域是相同的
class Clearer:
def clearZero(self,mat,n):
row = set()
column = set()
for i in range(n):
for j in range(n):
if mat[i][j] == 0:
row.add(i)
column.add(j)
... |
de092e5bf752977b832288e93a93df331b33acc3 | TakeaimK/TakeaimK.github.io | /assets/baekjoon/2920_scale/python_2920.py | 569 | 3.640625 | 4 | if __name__ == "__main__":
set=0
dingdong = list(map(int, input().split()))
if(dingdong[0]==1):
for i in range(0, 8):
if(dingdong[i]!=i+1):
print("mixed")
set=1
break
if(set==0):
print("ascending")
elif(dingdon... |
d9c5a8f2afb1d6489fbfde5301661dcf91e87a00 | LauraTrujilloT/unican | /Python/Homework/Shapes.py | 8,811 | 3.734375 | 4 | import numpy as np
class Shape:
"""
A class used to represent a geometrical shape.
Attributes
----------
**kwargs (dictionary)
Methods
--------
Operators:
__add__ () add each parameter of object. *class should have items method
and new method implemented.
Comparators:... |
0ec6ac6bca952e4a4018deae6677c6a662229a11 | mini4wd14/Purwadhika | /Jawaban 2_def Nomor HP.py | 489 | 3.59375 | 4 | def nohp(a):
listNo = []
finalNo = ""
for i in a:
listNo.append(i)
if listNo[0] != '0' and listNo[1] != '8':
print("Nomor HP harus dimulai dengan","08")
elif len(listNo) > 13:
print("Nomor HP hanya maksimal 13 angka")
elif listNo[0] == '0' and listNo[1] == '8' an... |
64393d7f05416372b71c29a925431607541aba28 | mrmukto/Python-Practise | /compare.py | 306 | 3.6875 | 4 | nimberofdegit = 0
numofchracter = 0
textt = input()
for x in textt:
x = x.lower()
if textt >= 'a' and textt <= "z":
numofchracter = numofchracter +1
elif (textt >= '1' and textt <= '9'):
nimberofdegit = nimberofdegit + 1
print(numofchracter)
print(nimberofdegit)
|
756c2f4c720d5dab0db335cb64d1dda1b52acbf4 | jakeitegsy/how_to_tdd_python | /test_telephone.py | 398 | 3.546875 | 4 | import unittest
from telephone import Telephone
class TestPassingValues(unittest.TestCase):
def test_text_messages(self):
self.assertEqual(Telephone().text('hello'), 'i received this message: hello')
self.assertEqual(Telephone().text('yes'), 'i received this message: yes')
def test_phone_calls(self):
self.... |
a99ace172c436e9ebf88490ae7952dbd20d745a5 | emilwillems/adventofcode_2020 | /day1/part2.py | 546 | 3.671875 | 4 | INPUTFILE = "day1/input"
puzzle_input = set(int(l) for l in open(INPUTFILE, "r").readlines())
def find_solution(puzzle):
for pi1 in puzzle:
for pi2 in puzzle:
if pi1 == pi2:
continue
for pi3 in puzzle:
if pi1 == pi3 or pi2 == pi3:
... |
9a2335a856ac2d5df65b1ec7dce42b0510b384ab | emilwillems/adventofcode_2020 | /day12/day12.py | 1,200 | 3.734375 | 4 | #!/usr/bin/python
ANGLES = {
0: { "name": "north", "delta": (0, 1) },
90: { "name": "east", "delta": (1, 0) },
180: { "name": "south", "delta": (0, -1) },
270: { "name": "west", "delta": (-1, 0) }
}
DIRECTIONS = {"N": 0, "E": 90, "S": 180, "W": 270}
def get_md(position):
return abs(... |
5fc0bcad70b71e5c8e11f5597a5b40ae5eb545cb | Morrigan1807/Methods-for-protecting-computer-information | /lab9.py | 861 | 3.59375 | 4 | import time
alphabet='0123456789qwertyuiopasdfghjklzxcvbnm'
def rec_password(target_password,built_prefix,remaining_symbols):
if remaining_symbols==0:
if built_prefix==target_password:
return built_prefix
else:
return ''
else:
for sym in alphabet:
... |
966040ef07c0e5f4323f2ff65d042ef634eb5bbd | scanarjo/python-challenge | /equality/main.py | 78 | 3.546875 | 4 | def isCapital(char):
return char.isupper()
with open('input.txt') as file:
|
2c4d5dc270132e04f17b96d7f9c378f9091e47e4 | YasmineSAYAD/FormationPython | /initiation/venv/Include/LesListes.py | 1,094 | 3.6875 | 4 | #créer une liste pour stocker des pseudo pour simuler un jeu en ligne
online_players=["Graven", "Anana", "Cleymax","Bob"]
print(online_players)
print(online_players[0])
print(online_players[len(online_players)-1])
# modifier 'Graven' -->'Gravenilvec'
online_players[0]="Gravenilvec"
print(online_players[0])
#ajouter un ... |
63d00f635ef140b1e2b26d43969c156062135c78 | YasmineSAYAD/FormationPython | /Interface/VariableControle.py | 1,352 | 3.65625 | 4 | import tkinter
"""
StringVar(): chaine de caractères[str]
IntVar(): nombre entier[int]
DoubleVar(): nombre flottant[float]
BooleanVar(): booleen[bool] // 1 si vrai, 0 sinon
"""
# creer un observateur
def update_label(*args):
var_label.set(var_entry.get())
def update(*args):
if var.get():
print("c'est un ... |
1e6ad4a063f79667bd31557f2415eed321473c6c | YasmineSAYAD/FormationPython | /initiation/venv/Include/ExempleListe.py | 520 | 3.640625 | 4 | from statistics import mean
from random import shuffle
#jouer à la maitresse
notes=[8, 12, 10, 9, 4, 20, 14, 3]
print(notes)
#module: statistics
result=mean(notes)
print("la moyenne de l'élève est de {} ".format(result))
#module random
shuffle(notes)
print(notes)
# creer une liste
text=input("Entrer une chaine de la... |
e2894227e328e16667e6e69613e4b7bf22723a34 | YasmineSAYAD/FormationPython | /initiation/venv/Include/Conditions.py | 755 | 3.890625 | 4 | # creer porte monnaie d'une personne
wallet=5000
#prix d un ordinateur
computer_price=2000
#verifier si le prix d'un ordinateur est inferieur a 1000£
#print(computer_price<1000)
#if computer_price < 1000 :
#print("le prix de l'ordinateur est inférieur à 1000£")
#else:
# print("Non, le prix est supérieur à 1000£... |
5d39de35978ce8e4245fe47f02e6d92dd5ee426d | itaicaspi/AI | /HW2/amazons/amazons_board.py | 4,279 | 3.84375 | 4 | # games board and board movement.
class amazonsBoard:
# setting board (10 by 10, 2d board) and queen positions.
def __init__(self):
self.board = [[' ' for x in range(10)] for x in range(10)]
self.board[0][3] = self.board[0][6] = self.board[3][0] = self.board[3][9] = 'B'
self.board[6][0] = self.board[6][9] = s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.