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 |
|---|---|---|---|---|---|---|
bcd6ddba72d2fe2c22112c11f6dbea95fe536d37 | shamim-ahmed/udemy-python-masterclass | /section-12/examples/example_kwargs.py | 323 | 4.3125 | 4 | #!/usr/bin/env python
def print_keyworded_arguments(arg1, **kwargs):
print("arg1 = {}".format(arg1))
for key, value in kwargs.items():
print("{} = {}".format(key, value))
# you can mix keyworded args with non-keyworded args
print_keyworded_arguments("Hello", fruit="Apple", number=10, planet="Jupiter... |
43836b3fe753f9a651cd9f6cbc636c462cd63c81 | shamim-ahmed/udemy-python-masterclass | /section-4/examples/guessinggame4.py | 416 | 4.0625 | 4 | #!/usr/bin/env python
import random
done = False
while done == False:
answer = random.randrange(1, 11)
guess = int(input("Please enter a number between 1 and 10: "))
if guess == answer:
print("Your guess is correct. The answer is {}".format(answer))
done = True
else:
print("S... |
f6008700b5aafa0c7f732e3d5e701832554017a7 | alihaiderrizvi/Leetcode-Practice | /all/29-Divide Two Integers/solution.py | 634 | 3.5625 | 4 | class Solution:
def divide(self, dividend: int, divisor: int) -> int:
if dividend > 0:
div_sign = 0
else:
div_sign = 1
if divisor > 0:
dvs_sign = 0
else:
dvs_sign = 1
dividend = abs(dividend)
divisor = abs(div... |
4ec2bd94203ef8db68cd0039227d84bc4ea4c62e | alihaiderrizvi/Leetcode-Practice | /all/20-Valid Parenthesis/solution.py | 457 | 3.828125 | 4 | class Solution:
def isValid(self, s: str) -> bool:
if len(s) % 2 != 0:
return False
stk = []
for i in s:
if i == "(" or i == "[" or i == "{":
stk.append(i)
elif stk and ((i == ")" and stk[-1] == "(") or (i == "]" and stk[-1] == "[")... |
7cae510cb7d7080ad784927bf19c07b3220aa64e | alihaiderrizvi/Leetcode-Practice | /all/720- Longest Word in Dictionary/720- Longest Word in Dictionary.py | 728 | 3.515625 | 4 | class Solution:
def longestWord(self, words: List[str]) -> str:
s = set(words)
good = set()
for word in words:
n = len(word)
flag = True
while n >= 1:
if word[:n] not in s:
flag = False
... |
ffb117397ed8532cd62567473b9fea61de0e3ee6 | Frankyyoung24/SequencingDataScientist | /Algrithms/week2/bm_algorithm.py | 1,283 | 3.5 | 4 | def boyer_moore(p, p_bm, t):
"""
Do Boyer-Moore matching.
p = pattern, t = text, p_bm = Boyer-Moore object for p (index)
"""
i = 0 # track where we are in the text
occurrences = [] # the index that p match t
while i < len(t) - len(p) + 1:
# loop though all the positions in t where ... |
617cd19401efd048959af80295b6a2fef88a15b6 | Amo123456/Assignment-submission | /project assignment/Project 1.py | 755 | 3.765625 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Develop a cryptography app using python?
# In[9]:
from cryptography.fernet import Fernet
def generate_key():
"""
Generates a key and save it into a file
"""
key = Fernet.generate_key()
with open("Secret.key","wb")as key_file:
key_file.write(key)
... |
e6f7d7097cd80230a9374bfa5067e0759030ba45 | setu-parekh/Interactive-Programming-in-Python-Coursera | /Project 4: Arcade game - Pong/pong_game.py | 4,341 | 3.84375 | 4 | # Implementation of classic arcade game Pong
import simplegui
import random
# initialize globals - pos and vel encode vertical info for paddles
WIDTH = 600
HEIGHT = 400
BALL_RADIUS = 20
PAD_WIDTH = 8
PAD_HEIGHT = 80
HALF_HEIGHT = HEIGHT / 2
HALF_PAD_WIDTH = PAD_WIDTH / 2
HALF_PAD_HEIGHT = PAD_HEIGHT / 2
ball_pos = [W... |
94dea85884bca08feccbf1c68e3bcc3388af668e | JosephLimWeiJie/algoExpert | /prompt/medium/MinHeightBST.py | 2,135 | 3.59375 | 4 | import unittest
def minHeightBst(array):
return constructMinHeightBST(array, 0, len(array) - 1)
def constructMinHeightBST(array, startIdx, endIdx):
if (startIdx > endIdx):
return None
midIdx = (startIdx + endIdx) // 2
bst = BST(array[midIdx])
bst.left = constructMinHeightBST(array, st... |
047b6808f400db0906409e22fb7e3897f9bda51a | kirillrssu/pythonintask | /PMIa/2014/Samovarov/task_3_17.py | 810 | 4.1875 | 4 | #Задача №3, Вариант 7
#Напишите программу, которая выводит имя "Симона Руссель", и запрашивает его псевдоним. Программа должна сцеплять две эти строки и выводить полученную строку, разделяя имя и псевдоним с помощью тире.
#Samovarov K.
#25.05.2016
print("Герой нашей сегодняшней программы - Симона Руссель")
ps... |
b40e51de38b2a5a3721f823e707b4bf526e1aefc | tioguil/LingProg | /-Primeira Entrega/Exercicio01 2018_08_14/atv1.py | 208 | 4.0625 | 4 | # 1 Faça um Programa que peça o raio de um círculo, calcule e
# mostre sua área.
raio = 0
print("Digite o Raio do circulo")
raio = int(input())
area = 3.14 * raio**2
print("Área do circulo: %s" %(area)) |
34a43cd286f6018aee4d23a683ee1e6211db43f1 | tioguil/LingProg | /-Primeira Entrega/Exercicio03 2018_08_28/atv18.py | 268 | 3.65625 | 4 | # 18. A série de Fibonacci é formada pela seqüência
# 1,1,2,3,5,8,13,21,34,55,... Faça um programa capaz de gerar a série
# até o n−ésimo termo.
a = 0
b = 1
n = int(input("Quantidade: "))
for i in range(n):
print(a)
aux = b
b = a + b
a = aux |
6820cd52316dc5bca7f89c75c7e7a1a6972981dd | tioguil/LingProg | /-Primeira Entrega/Exercicio03 2018_08_28/atv12.py | 1,154 | 4.09375 | 4 | # 12. Uma fruteira está vendendo frutas com a seguinte tabela de
# # preços:
# # Até 5 Kg Acima de 5 Kg
# # Morango R$ 2,50 por Kg R$ 2,20 por Kg
# # Maçã R$ 1,80 por Kg R$ 1,50 por Kg
# # Se o cliente comprar mais de 8 Kg em frutas ou o valor total da
# # compra ultrapassar R$ 25,00, receberá ainda um desconto de 10%... |
5b577b07f4542809d54f9b64631cf258fcfcce8a | tioguil/LingProg | /-Primeira Entrega/Exercicio01 2018_08_14/atv7.py | 961 | 3.65625 | 4 | # João Papo-de-Pescador, homem de bem, comprou um
# microcomputador para controlar o rendimento diário de seu
# trabalho. Toda vez que ele traz um peso de peixes maior que o
# estabelecido pelo regulamento de pesca do estado de São Paulo (50
# quilos8 deve pagar uma multa de R$ 4,00 por quilo excedente. João
# precisa ... |
33377065d8e963885d95fa94d891b11720bb44e9 | tioguil/LingProg | /-Primeira Entrega/Exercicio02 2018_08_21/atv05.py | 321 | 4.0625 | 4 | # 5 Escreva um programa que conta a quantidade de vogais em uma
# string e armazena tal quantidade em um dicionário, onde a chave é
# a vogal considerada.
print("entre com a frase")
frase = input()
frase = frase.lower()
vogais = 'aeiou'
dicionario = {i: frase.count(i) for i in vogais if i in frase}
print(dicionario) |
5d35beb083b9d0eff0c68ee9d8575431b5d6fb70 | tioguil/LingProg | /-Primeira Entrega/Exercicio01 2018_08_14/atv11.py | 574 | 3.78125 | 4 | # 11 Faça um programa que solicite a data de nascimento
# (dd/mm/aaaa8 do usuário e imprima a data com o nome do mês por
# extenso.
# Data de Nascimento: 29/10/1973
# Você nasceu em 29 de Outubro de 1973.
# Obs.: Não use desvio condicional nem loops.
import datetime
print("Informe sua data de nascimento ex: 01/01/201... |
b16820e8981e0acd4bb8d117ee31925e97f29dc2 | tioguil/LingProg | /-Primeira Entrega/Exercicio03 2018_08_28/atv11.py | 1,018 | 4.09375 | 4 | # 11. Faça um programa que faça 5 perguntas para uma pessoa
# sobre um crime. As perguntas são:
# "Telefonou para a vítima?"
# "Esteve no local do crime?"
# "Mora perto da vítima?"
# "Devia para a vítima?"
# "Já trabalhou com a vítima?"
# O programa deve no fnal emitir uma classifcação sobre a
# participação da pessoa ... |
9f73c064597a294823c10d6e511d4ddaacb55790 | dcassells/Rumour-Animation | /animated_rumour.py | 4,940 | 3.6875 | 4 | """
==================
Animated histogram
==================
Use a path patch to draw a bunch of rectangles for an animated histogram.
from terminal write:
python animated_rumour.py #number_of_nodes #number_of_initial_infective
"""
import sys
#import argparse
#parser = argparse.ArgumentParser(
# description = 'Sim... |
7e848517d2ba88ba39d23220858eb341a601d66d | Sullivannichols/classes | /csc321/hw/hw4/parse.py | 2,055 | 3.59375 | 4 | #!/usr/bin/env python3
import csv
import socket
import pygraphviz as pgv
def domains():
''' This function extracts domain names from a .tsv file, performs a
forward DNS lookup on each domain, performs a reverse DNS lookup on
each returned IP, then adds all of the info to a graph.
'''
g = p... |
e53f2538cd20c70b5a7a04de4f714f2077194c65 | cyrusv/Birthday-Problems | /puzzle2.py | 386 | 3.53125 | 4 | # Puzzle 2
# Do Men or Women take longer Hubway rides in Boston?
# By how many seconds? Round the answer DOWN to the nearest integer.
# Use the Hubway data from 2001-2013 at http://hubwaydatachallenge.org/
import pandas as pd
df = pd.DataFrame(pd.read_csv('hubway_trips.csv'))
mean = df.groupby('gender')['duration'].m... |
8eddcd6f8233db0f57f508f7dc69dc7acc870aea | yubaoliu/PythonFromScratch | /basics/directory.py | 1,518 | 3.890625 | 4 | import os
import tempfile
# define the access rights
access_rights = 0o755
print("===========================")
print("Creating a Directory ")
# define the name of the directory to be created
path = "/tmp/year"
print("Create directory: %s" % path)
try:
os.mkdir(path, access_rights)
except OSError as error:
pr... |
753239b3b82d38acc5ef487a3c2b29a0344a7584 | SarcoImp682/Zookeeper | /Topics/Program with numbers/Difference of times/main.py | 391 | 3.953125 | 4 | # put your python code here
# start time
hour_start = int(input())
minutes_start = int(input())
seconds_start = int(input())
# stop time
hour_stop = int(input())
minutes_stop = int(input())
seconds_stop = int(input())
# conversion
start = hour_start * 3600 + minutes_start * 60 + seconds_start
stop = hour_stop * 3600... |
9ad802d0eac6567184e459e7ce6f4e82bf8110c0 | agupta7/COMP6700 | /softwareprocess/test/AngleTest.py | 4,471 | 3.875 | 4 | import unittest
import softwareprocess.Angle as A
class AngleTest(unittest.TestCase):
def setUp(self):
self.strDegreesFormatError = "String should in format XdY.Y where X is degrees and Y.Y is floating point minutes"
# ---------
# ----Acceptance tests
# ----100 Constructor
# ----Boundary value confidence... |
6093dccc4f5ed895fb8f69572589deb55c086102 | talivaro/Generadores-aleatorios | /CongruCombinado.py | 417 | 3.8125 | 4 | __author__ = 'Talivaro'
xo1=int(input("Ingrese el valor de xo1: "))
xo2=int(input("Ingrese el valor de xo2: "))
xo3=int(input("Ingrese el valor de xo3: "))
repe=int(input("Numero de valores: "))
for i in range(repe):
xn1=float((171*xo1)%30269)
xn2=float((172*xo2)%30307)
xn3=float((173*xo3)%30323)
ui=flo... |
a6b2127082c3e3eccf8098d8e370d701c5a876db | BlackMetall/trash | /lesson 9 (practice1).py | 959 | 4.1875 | 4 | #Задача 1. Курьер
#Вам известен номер квартиры, этажность дома и количество квартир на этаже.
#Задача: написать функцию, которая по заданным параметрам напишет вам,
#в какой подъезд и на какой этаж подняться, чтобы найти искомую квартиру.
room = int(input('Введите номер квартиры ')) # кол-во квартир
floor = int... |
a40410c97ef48d989ce91b6d23262720f60138dc | rajeshberwal/dsalib | /dsalib/Stack/Stack.py | 1,232 | 4.25 | 4 | class Stack:
def __init__(self):
self._top = -1
self.stack = []
def __len__(self):
return self._top + 1
def is_empty(self):
"""Returns True is stack is empty otherwise returns False
Returns:
bool: True if stack is empty otherwise returns False
... |
04d70de92bfca1f7b293f344884ec1e23489b7e4 | rajeshberwal/dsalib | /dsalib/Sorting/insertion_sort.py | 547 | 4.375 | 4 | def insertion_sort(array: list) -> None:
"""Sort given list using Merge Sort Technique.
Time Complexity:
Best Case: O(n),
Average Case: O(n ^ 2)
Worst Case: O(n ^ 2)
Args:
array (list): list of elements
"""
for i in range(1, len(array)):
current_num = array[... |
a0f2d86b20acd3f19756667801f081902827b8d7 | Manoj-sahu/datastructre | /Stack/StackUsingList.py | 414 | 3.875 | 4 | class StackUsingList():
def __init__(self):
self.stack = []
def push(self, item):
self.stack.append(item)
def peek(self):
return self.stack[-1]
def pop(self):
self.stack.pop()
if __name__ == '__main__':
stack = StackUsingList()
stack.push(1)
s... |
8c7ab2d2161d94f612f7102e05c04c8e4e888a71 | Manoj-sahu/datastructre | /LinkedList/1.1.py | 1,083 | 3.53125 | 4 | """for finding duplicate first approach iterate to loop and maintain count in dictionary
and if you find then remove the refrence of that loop. brute force approcah could be take head item and keep checking for all the items"""
#import IP.LinkedList.10
#from IP.LinkedList.L import LinkedList
import L
newLinkedList =... |
7d1221ec5c9cdbb8435ecaf0be51a6daa11ae3d2 | nishthagoel712/DSA | /Graph/TopologicalSorting.py | 575 | 3.828125 | 4 | from collections import defaultdict
visited=defaultdict(bool)
stack=[]
def topological_sort_util(adj,vertex):
visited[vertex]=True
for node in adj[vertex]:
if not visited[node]:
topological_sort_util(adj,node)
stack.append(vertex)
def topological_sort(adj):
for vertex i... |
3009a3a33a23b282111c2fc0fba9cf050e0fe599 | nishthagoel712/DSA | /Dynamic Programming/Maximum size reactangle of all 1's.py | 1,543 | 3.59375 | 4 | # arr represent given 2D matrix of 0's and 1's
# n is the number of rows in a matrix
# m is the number of columns in each row of a matrix
def rectangle(arr, n, m):
maxi = float("-inf")
temp = [0] * m
for i in range(n):
for j in range(m):
if arr[i][j] == 0:
temp[j... |
fc89a46754b7a31c7335517bc4b639aa5eab6e12 | darksinge/rmb-search-engine | /bill_files/clean_empty_bills.py | 471 | 3.6875 | 4 | import glob, os
"""
Simple script to detect and remove files that have no information on them in this folder
"""
"""
files = glob.glob('*.txt')
for file in files:
f = open(file, 'r')
contents = f.read()
should_delete = False
if 'The resource you are looking for has been removed, had its name changed, o... |
93a955fcd9477724d916877075fac5b29227857a | darksinge/rmb-search-engine | /create_sparse_matrix.py | 3,142 | 3.703125 | 4 | """
Creates a sparse inverse dictionary for tf-idf searches. The CSV file produced by bill_data_analysis.py is so large
that this file is needed to produce something much smaller to be used for the searches
"""
import pandas as pd
import os
import json
import pickle
import sys
from default_path import default_path
de... |
22e56d8ab2a43434aac7d3c8c5aa589a3af5b2c5 | kori07/prak_asd_b | /UAS_044_047_053/aplikasi.py | 20,086 | 3.828125 | 4 | #Program by Kelompok Susi Triana Wati,Program Pencarian Serta Pengurutan dengan Bubble Sort.
from Tkinter import Tk,Frame,Menu
from Tkinter import*
import tkMessageBox as psn
import ttk
import tkFileDialog as bk
from tkMessageBox import *
import Tkinter as tk
from winsound import *
import platform
os = platfo... |
6705bd7dfa677bd27dbcf200aaa3f7dc6cd6cb55 | laurenc176/PythonCrashCourse | /Lists/simple_lists_cars.py | 938 | 4.5 | 4 | #organizing a list
#sorting a list permanently with the sort() method, can never revert
#to original order
cars = ['bmw','audi','toyota','subaru']
cars.sort()
print(cars)
#can also do reverse
cars.sort(reverse=True)
print(cars)
# sorted() function sorts a list temporarily
cars = ['bmw','audi','toyota'... |
68654f6011396a2f0337ba2d591a7939d609b3ed | laurenc176/PythonCrashCourse | /Files and Exceptions/exceptions.py | 2,711 | 4.125 | 4 | #Handling exceptions
#ZeroDivisionError Exception, use try-except blocks
try:
print(5/0)
except ZeroDivisionError:
print("You can't divide by zero!")
#Using Exceptions to Prevent Crashes
print("Give me two numbers, and I'll divide them")
print("Enter 'q' to quit.")
#This will crash if second number is ... |
b52ad63f303e4160d7a942cad8481f2f77edf1f0 | laurenc176/PythonCrashCourse | /Testing your code/testing_a_class.py | 3,250 | 4.40625 | 4 | # Six commonly used assert methods from the unittest.TestCase class:
#assertEqual(a, b) Verify a==b
#assertNotEqual(a, b) Verify a != b
#assertTrue(x) Verify x is True
#assertFalse(x) Verify x is False
#assertIn(item, list) Verify that item is in list
#assertNotIn(item, list) Verify that item is not in ... |
4ec62e344d96dbd9db5860338526bb608a702a99 | honzaKovar/docker_unittest | /prime_numbers.py | 423 | 3.90625 | 4 | import math
from random import randint
def is_prime(number):
if number < 2:
return False
for i in range(2, int(math.sqrt(number) + 1)):
if number % i == 0:
return False
return True
if __name__ == '__main__':
MIN_VALUE = 0
MAX_VALUE = 999
random_number = randint(M... |
fbc01f2c549fae60235064d839c55d98939ae775 | martinskillings/tempConverter | /tempConverter.py | 2,231 | 4.3125 | 4 |
#Write a program that converts Celsius to Fahrenheit or Kelvin
continueLoop = 'f'
while continueLoop == 'f':
celsius = eval(input("Enter a degree in Celsius: "))
fahrenheit = (9 / 5 * celsius + 32)
print(celsius, "Celsius is", format(fahrenheit, ".2f"), "Fahrenheit")
#User prompt t... |
3f6b3832e8c1b33cb1e03ae6a026236f1d82a171 | StarryLeo/learnpython | /day0/do_if.py | 286 | 4 | 4 | height = 1.75
weight = 80.5
bmi = weight/height * height
if bmi < 18.5:
print('过轻')
elif bmi >= 18.5 and bmi < 25:
print('正常')
elif bmi >= 25 and bmi < 28:
print('过重')
elif bmi >= 28 and bmi < 32:
print('肥胖')
else:
print('严重肥胖')
|
6d9c2f166469c4767ad6815edccc79f5306ae3c1 | est/snippets | /sort_coroutine/mergesort.py | 1,417 | 4.03125 | 4 | import random
def merge1(left, right):
result = []
left_idx, right_idx = 0, 0
while left_idx < len(left) and right_idx < len(right):
# change the direction of this comparison to change the direction of the sort
if left[left_idx] <= right[right_idx]:
result.append(left[le... |
fae09bb082a160bfc2cf1c165250c551d6f70387 | cdpruitt/CribbageAI | /GameActions.py | 5,135 | 3.5625 | 4 | from Card import *
from itertools import *
class History():
def __init__(self, playerToLead):
self.rounds = [RoundTo31(playerToLead)]
def isTerminal(self):
totalCardsPlayed = 0
for roundTo31 in self.rounds:
for play in roundTo31.board:
if(play=="PASS"):
... |
22c396d0cb06c25ea3162191dfa536672be1bd7c | GiPyoK/Sprint-Challenge--Data-Structures-Python | /names/binary_search_tree.py | 4,965 | 3.828125 | 4 | from dll_queue import Queue
from dll_stack import Stack
class BinarySearchTree:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
# Insert the given value into the tree
def insert(self, value):
# This would be only needed if there was deleted... |
39a26f9febc2acc3ce0e3291c1dbe45801418275 | deep-compute/deeputil | /deeputil/keep_running.py | 5,090 | 3.84375 | 4 | """Keeps running a function running even on error
"""
import time
import inspect
class KeepRunningTerminate(Exception):
pass
def keeprunning(
wait_secs=0, exit_on_success=False, on_success=None, on_error=None, on_done=None
):
"""
Example 1: dosomething needs to run until completion condition
wi... |
7011bfd3326ccb843859999aaf89c71a3137cdd4 | skylway/leetcode | /python/0344. 反转字符串/solution.py | 472 | 3.71875 | 4 | #!/usr/bin/python
from typing import List
class Solution:
def reverseString(self, s: List[str]) -> None:
# s.reverse()
# s[:] = s[::-1]
i = 0
len_list = len(s)
while i < len_list/2:
s[i], s[len_list-i-1] = s[len_list-i-1], s[i]
i += 1
"""
... |
79723bc580e8f7ccd63a8b86c182c783a56d3329 | SuzanneRioue/programmering1python | /Lärobok/kap 8/kap. 8, sid. 103 - list comprehensions.py | 1,297 | 4.34375 | 4 | #!/usr/local/bin/python3.9
# Filnamn: kap. kap. 8, sid. 103 - list comprehensions.py
# Kapitel 8 - Listor och tipplar
# Programmering 1 med Python - Lärobok
# Exempeldata
listaEtt = [9, 3, 7]
# Med listomfattningar (list comprehensions) menas att man skapar en ny lista
# där varje element är resultatet av någon op... |
417e9bbc0a001695bc2cd7586b71b5a8b89832ee | SuzanneRioue/programmering1python | /Arbetsbok/kap 14/övn 14.1, sid. 36 - söka tal.py | 1,443 | 3.921875 | 4 | #!/usr/local/bin/python3.9
# Filnamn: övn 14.1, sid. 36 - söka tal.py
# Sökning
# Programmeringsövningar till kapitel 14
# Programmet slumpar först fram 20 tal mellan 1 och 100 och lagrar alla talen i
# en lista och sedan skrivs listan ut på skärmen. Därefter frågar programmet
# användaren efter ett tal som ska ef... |
f38757087bf31b61d8238f3e98798a8799f1b6f8 | SuzanneRioue/programmering1python | /Lärobok/kap 8/kap. 8, sid. 104 - sammanfattning med exempel.py | 2,712 | 4.1875 | 4 | #!/usr/local/bin/python3.9
# Filnamn: kap. 8, sid. 104 - sammanfattning med exempel.py
# Kapitel 8 - Listor och tipplar
# Programmering 1 med Python - Lärobok
# Exempeldata
lista = [7, 21, 3, 12]
listaLäggTill = [35, 42]
listaSortera = [6, 2, 9, 1]
listaNamn = ['Kalle', 'Ada', 'Pelle', 'Lisa']
# len(x) Ta reda på an... |
d5448c074c4419908d4c5246e1d87f792fd28731 | SuzanneRioue/programmering1python | /Arbetsbok/kap 14/övn 14.3, sid. 37 - gissa ett tal.py | 1,650 | 3.921875 | 4 | #!/usr/local/bin/python3.9
# Filnamn: övn 14.2, sid. 36 - söka tal med funktion.py
# Sökning
# Programmeringsövningar till kapitel 14
# Programmet slumpar först fram ett tal mellan 1 och 99 och lagrar det talet.
# Därefter frågar datorn användaren vilke tal datorn tänker på och användaren
# får gissa tills han/hon... |
60febc4082a4c46d7a0da215bc70e5531777ad75 | SuzanneRioue/programmering1python | /Arbetsbok/kap 3/övn 3.4 - ange valfri rabatt på vara - kap 3, sid. 5.py | 1,098 | 4.09375 | 4 | #!/usr/local/bin/python3.9
# Filnamn: övn 3.4 - ange valfri rabatt på vara - kap 3, sid. 5.py
# Skapa program eller skript
# Programmeringsövningar till kapitel 3 - Arbetsbok
# Programmet frågar först efter ordinarie pris på en vara. Därefter frågar det
# efter en godtycklig rabattprocent
# Till sist skriver det ut ... |
4ceb64bae252b6c7acd59332297c3ccc02023694 | SuzanneRioue/programmering1python | /Arbetsbok/kap 10/övn 10.1 - lottorad.py | 1,306 | 3.546875 | 4 | #!/usr/local/bin/python3.9
# Filnamn: övn 10.1 - lottorad.py
# Slumptal i programmering
# Programmeringsövningar till kapitel 10
# Programmet slumpar fram en lottorad, 7 tal i intervallet 1 - 35 där samma
# nummer inte får uppkomma 2 gånger
from random import randrange
# Funktionsdefinitioner
def lottorad(): ... |
a969e3ff963ef2ed1980e8ff48bf4c048dfefde9 | SuzanneRioue/programmering1python | /Lärobok/kap 6/kap. 6, sid. 76 - kontrollera innehåll och tomma strängar.py | 842 | 3.703125 | 4 | #!/usr/local/bin/python3.9
# Filnamn: kap. 6, sid. 76 - kontrollera innehåll och tomma strängar.py
# Kapitel 6 - Mer om teckensträngar i Python
# Programmering 1 med Python - Lärobok
# Kontrollera innehåll i en sträng med operatorn in
if 'r' in 'Räven raskar över isen': # Kontroll av enstaka tecken
print('Bok... |
e415fc6296d368d63a75ef1a8a50e7182820a49c | SuzanneRioue/programmering1python | /Arbetsbok/kap 3/övn 3.7 - Additionsövning med formaterad utskrift med flyttal - kap 3, sid. 6.py | 759 | 3.90625 | 4 | #!/usr/local/bin/python3.9
# Filnamn: övn 3.7 - Additionsövning med formaterad utskrift med flyttal - kap 3
# sid. 6.py
# Skapa program eller skript
# Programmeringsövningar till kapitel 3 - Arbetsbok
# Additionsövning med formaterad utskrift
# Programmet skriver ut tal i en snygg additionsuppställning
# Skriv ut p... |
1a6cf574b1498ca03608892dcfe185605b909bd5 | SuzanneRioue/programmering1python | /Lärobok/kap 16/kap. 16, sid. 186 - omvandla dictionary till olika listor.py | 929 | 3.609375 | 4 | #!/usr/local/bin/python3.9
# Filnamn: kap. 16, sid. 186 - omvandla dictionary till olika listor.py
# Kapitel 16 - Mer om listor samt dictionaries
# Programmering 1 med Python - Lärobok
# Kodexempel från boken med förklaringar
# Skapa en associativ array (dictionary) med namn som nycklar och anknytningsnr
# som vär... |
38bfae3b5387684afe8dc8b4787087bdd786d2c0 | SuzanneRioue/programmering1python | /Arbetsbok/kap 8/övn 8.3 - beräkna summa och medelvärde av lista - kap. 8, sid. 21.py | 1,289 | 4.03125 | 4 | #!/usr/local/bin/python3.9
# Filnamn: övn 8.3 - beräkna summa och medelvärde av lista - kap. 8, sid. 21.py
# Listor och tipplar
# Programmeringsövningar till kapitel 8
# Programmet frågar efter hur många tal du vill mata in, låter dig sedan mata
# in dessa en i taget. Efter varje inmatning läggs det inmatade talet ... |
43b89ba2d0757f49a5d86da45c98930f65d600d4 | SuzanneRioue/programmering1python | /Arbetsbok/kap 14/övn 14.6, sid. 38 - datorn gissar ett tal.py | 2,362 | 3.78125 | 4 | #!/usr/local/bin/python3.9
# Filnamn: övn 14.6, sid. 38 - datorn gissar ett tal.py
# Sökning
# Programmeringsövningar till kapitel 14
# Programmet låter dig tänka på ett tal mellan 1 och 99.
# Första gången gissar datorn på talet i mitten utifrån det givna intervallet 1
# till 99. Dvs. talet 50. Svarar användaren ... |
c183615f347834216b4f3f12cd97e6e22a07d472 | SuzanneRioue/programmering1python | /Arbetsbok/kap 4/övn 4.4 - priskoll på bensin - kap 4, sid. 7.py | 831 | 3.671875 | 4 | #!/usr/local/bin/python3.9
# Filnamn: övn 4.4 - priskoll på bensin - kap 4, sid. 7.py
# Skapa program eller skript
# Programmeringsövningar till kapitel 4 - Arbetsbok
# Programmet frågar efter bensinpris och som sedan med villkor talar om
# om det är billigt eller inte.
# Skriv ut programmets rubrik
print('Priskoll... |
281e7f4dd1ef0495d3213f59afd0007d0426134a | SuzanneRioue/programmering1python | /Arbetsbok/kap 6/övn 6.4 - vänder på meningen - kap. 6, sid. 15.py | 313 | 3.5 | 4 | #!/usr/local/bin/python3.9
# Filnamn: övn 6.4 - vänder på meningen - kap. 6, sid. 15.py
# Mer om teckensträngar i Python
# Programmeringsövningar till kapitel 6
# Programmet ber användaren mata in en meninig och skriver sedan ut den
# baklänges
mening = input('Skriv en mening: ')
print(mening[::-1])
|
e691e8b4c3ad89fdc107b6b9bb2a37f4ba34091d | AmishiBisht/PythonProject | /Calculator.py | 6,120 | 4.1875 | 4 | from tkinter import *
from math import *
win = Tk()
win.title("Calculator") # this title will be displayed on the top of the app
#win.geometry("300x400") # this defines the size of the app of window
input_box = StringVar() # It gets the contents of the entry box
e = Entry(win,width = 50, borderwidth = 5, textva... |
3a96ab91401def3cb21863b4eeb3d0f082d07811 | zhenya-paitash/course-python-ormedia | /lesson__6_homework.py | 4,806 | 4.34375 | 4 | from math import pi # число ПИ для 2ого задания
import random as R # для генерации рандомных чисел в решении заданий
# 1. Определите класс Apple с четырьмя переменными экземпляра, представляющими четыре свойства яблока
class Apple:
def __init__(self, c, w, s, v):
self.color = c
self.weight = w... |
faa30b2222bde8849d6d452736f025f0bd80ecdb | HelloYuiYui/Fun-with-PyTurtle | /Dots.py | 759 | 3.796875 | 4 |
from turtle import *
import random
#setting up the environment.
bgcolor("#ffebc6")
color("blue", "yellow")
speed(10)
def dots():
#hiding turtle and pen to avoid creating unwanted lines between dots.
penup()
hideturtle()
dotnum = 0
limit = 200 #change number to create more or less dots.
while ... |
aefe923d857f9ab74c65429ebfae3d539b7fb007 | Snowerest/leetcodeQuestion-Python | /stack.py | 399 | 3.8125 | 4 | class Stack(object):
def __init__(self):
self.__v = []
def is_empty(self) -> bool:
return self.__v == []
def push(self, value: object) -> None:
self.__v.append(value)
def pop(self) -> object:
if self.is_empty():
return None
v... |
968c16becdcdaaea847617224ea4fb776865d839 | Snowerest/leetcodeQuestion-Python | /ball_sort.py | 291 | 3.609375 | 4 | def ball_sort(nums: list) -> list:
ln = len(nums)
if ln <= 1:
return nums
i = 0
while i < ln:
j = i
while j < ln:
if nums[j] <= nums[i]:
nums[j], nums[i] = nums[i], nums[j]
j += 1
i += 1
return nums
|
78ed8e3e2072193899cc73f9224cbec04e10e593 | kushagrasurana/Minuet-server | /app/responses.py | 1,429 | 3.546875 | 4 | from flask import jsonify
from . import app
def make_response(code, message):
"""Creates an HTTP response
Creates an HTTP response to be sent to client with status code as 'code'
and data - message
:param code: the http status code
:param message: the main message to be sent to client
:return:... |
17aa9df4e57e711c87f41b3e101d894ce19c50ba | DrakeVorndran/Tweet-Generator | /Code/reaarrange.py | 602 | 3.84375 | 4 | import sys
import random
def reaarrange(words):
for i in reversed(range(1,len(words))):
pos = random.randint(0,i-1)
words[i], words[pos] = words[pos], words[i]
return(words)
def reverseString(string, seperator=""):
if(seperator == ""):
return_string = list(string)
else:
return_string = string.... |
be6b2ac375fb83d117835be397d7aa411afb94a8 | SourDumplings/CodeSolutions | /Course practices/小甲鱼课程:小甲鱼—《零基础入门学习Python》/005闰年判断.py | 425 | 3.890625 | 4 | print('------------酸饺子学Python------------')
#判断一个年份是否是闰年
#Coding 酸饺子
temp = input('输入一个年份吧:\n')
while not temp.isdigit():
print('这个不是年份吧……')
year = int(temp)
if year/400 == int(year/400):
print('闰年!')
else:
if (year/4 == int(year/4)) and (year/100 != int(year/100)):
print('闰年!')
else:
p... |
5eadae3b9e4e99640a7ec52cf0483eaf9c2fbf4b | SourDumplings/CodeSolutions | /Course practices/小甲鱼课程:小甲鱼—《零基础入门学习Python》/030搜索文件.py | 667 | 3.609375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2017-06-16 23:11:30
# @Author : 酸饺子 (changzheng300@foxmail.com)
# @Link : http://bbs.fishc.com/space-uid-437297.html
# @Version : $Id$
import os
content = input('请输入待查找的目录:')
file_name = input('请输入待查找的目标文件:')
def Search(path, file_name):
path_list =... |
2feef38d5f8ce0751dbecbb098d0936c5df0cf17 | SourDumplings/CodeSolutions | /OJ practices/PAT甲级真题练习/1039. Course List for Student-超时.py | 1,188 | 3.5625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2017-12-06 16:05:13
# @Author : 酸饺子 (changzheng300@foxmail.com)
# @Link : https://github.com/SourDumplings
# @Version : $Id$
'''
https://www.patest.cn/contests/pat-a-practise/1039
'''
def main():
temp = input().split(' ')
N = int(temp[0])
K =... |
e33f3ad1ed5312c6c2e9726f243b005719f02ee4 | SourDumplings/CodeSolutions | /Book practices/《简单粗暴 TensorFlow 2.0》练习代码/1.基础/2.自动求导机制.py | 929 | 3.53125 | 4 | import tensorflow as tf
# 计算函数 y = x^2 在 x = 3 处的导数
# x = tf.Variable(initial_value=3.)
# with tf.GradientTape() as tape: # 在 tf.GradientTape() 的上下文内,所有计算步骤都会被记录以用于求导
# y = tf.square(x)
# y_grad = tape.gradient(y, x) # 计算y关于x的导数
# print([y, y_grad])
# 多元函数,对向量的求导
X = tf.constant([[1., 2.], [3., 4.]])
y = tf.const... |
d070a6c21e6788543c94e042ddc9a1a6e6822029 | SourDumplings/CodeSolutions | /Course practices/小甲鱼课程:小甲鱼—《零基础入门学习Python》/014check.py | 1,957 | 3.859375 | 4 | #密码安全检查
#Coding 酸饺子
# 密码安全性检查代码
#
# 低级密码要求:
# 1. 密码由单纯的数字或字母组成
# 2. 密码长度小于等于8位
#
# 中级密码要求:
# 1. 密码必须由数字、字母或特殊字符(仅限:~!@#$%^&*()_=-/,.?<>;:[]{}|\)任意两种组合
# 2. 密码长度不能低于8位
#
# 高级密码要求:
# 1. 密码必须由数字、字母及特殊字符(仅限:~!@#$%^&*()_=-/,.?<>;:[]{}|\)三种组合
# 2. 密码只能由字母开头
# 3. 密码长度不能低于16位
print('-------------酸饺子学Python-----... |
3b17c72973b952d716cdd263b5faf377f3ec143c | SourDumplings/CodeSolutions | /OJ practices/牛客网:PAT真题练兵场-乙级/有理数四则运算.py | 2,615 | 3.515625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2017-11-16 10:28:17
# @Author : 酸饺子 (changzheng300@foxmail.com)
# @Link : https://github.com/SourDumplings
# @Version : $Id$
'''
https://www.nowcoder.com/pat/6/problem/4060
'''
import math as m
def main():
def gcd(a, b):
r = a % b
w... |
5d0e1b4504139b2166783311414a30d8ed0e3be7 | SourDumplings/CodeSolutions | /OJ practices/PAT甲级真题练习/1012. The Best Rank.py | 2,536 | 3.53125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2017-11-28 19:18:52
# @Author : 酸饺子 (changzheng300@foxmail.com)
# @Link : https://github.com/SourDumplings
# @Version : $Id$
'''
https://www.patest.cn/contests/pat-a-practise/1012
'''
def main():
temp = input()
temp = temp.split(' ')
N = int(... |
00f241c31584d25d9a8eb0c93aeb1fdff2c5a5bc | SourDumplings/CodeSolutions | /Course practices/小甲鱼课程:小甲鱼—《零基础入门学习Python》/025通讯录.py | 1,712 | 3.71875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2017-06-13 17:22:08
# @Author : 酸饺子 (changzheng300@foxmail.com)
# @Link : http://bbs.fishc.com/space-uid-437297.html
# @Version : $Id$
contact = {}
print('''|--- 欢迎进入通讯录程序---|
|--- 1 :查询联系人资料 ---|
|--- 2 :插入新的联系人 ---|
|--- 3 : 删除已有联系人 ---|
|--- 4 : 退出通讯录... |
89a06671ad98cebf5590a4ece8ad192d2954819b | SourDumplings/CodeSolutions | /OJ practices/PAT甲级真题练习/1035. Password.py | 957 | 3.71875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2017-12-05 20:30:26
# @Author : 酸饺子 (changzheng300@foxmail.com)
# @Link : https://github.com/SourDumplings
# @Version : $Id$
'''
https://www.patest.cn/contests/pat-a-practise/1035
'''
def main():
N = int(input())
modified = []
flag = 0
... |
ae952d0a06fff2b4f8ced902cd7355a19e0b17a1 | SourDumplings/CodeSolutions | /OJ practices/LeetCode题目集/88. Merge Sorted Array(easy).py | 943 | 3.65625 | 4 | '''
@Author: SourDumplings
@Date: 2020-02-16 19:37:18
@Link: https://github.com/SourDumplings/
@Email: changzheng300@foxmail.com
@Description: https://leetcode-cn.com/problems/merge-sorted-array/
双指针法,从后往前填
'''
class Solution:
def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None:
""... |
70a075b1fba763f3a12d1baecbc20c50930c0c3d | SourDumplings/CodeSolutions | /Course practices/小甲鱼课程:小甲鱼—《零基础入门学习Python》/010向列表中添加成绩.py | 287 | 4.21875 | 4 | #向列表中添加成绩
#Coding 酸饺子
print('-------------酸饺子学Python-------------')
member = ['小甲鱼', '黑夜', '迷途', '怡静', '秋舞斜阳']
member.insert(1, 88)
member.insert(3, 90)
member.insert(5, 85)
member.insert(7, 90)
member.insert(9, 88)
print(member)
|
ebc51cdc6f85317dc3e53bd614184c5b9a15519b | SourDumplings/CodeSolutions | /Course practices/小甲鱼课程:小甲鱼—《零基础入门学习Python》/064tk2.py | 692 | 3.53125 | 4 | # encoding: utf-8
"""
@author: 酸饺子
@contact: changzheng300@foxmail.com
@license: Apache Licence
@file: tk2.py
@time: 2017/7/25 10:00
tkinter演示实例2,打招呼
"""
import tkinter as tk
def main():
class APP:
def __init__(self, master):
frame = tk.Frame(master)
frame.pack(side=tk.LEFT, padx... |
de09ee49797be6b1931cec7a4b4a17c50aa78b0f | SourDumplings/CodeSolutions | /Course practices/小甲鱼课程:小甲鱼—《零基础入门学习Python》/009输入密码.py | 483 | 4.09375 | 4 | #输入密码
#Coding 酸饺子
print('-------------酸饺子学Python-------------')
count = 3
code = 'SourDumplings'
while count != 0:
guess = input('您好,请输入密码:')
if guess == code:
print('密码正确!')
break
elif '*' in guess:
print('密码中不能含有*!')
print('您还有', count, '次机会')
else:
count -= ... |
6df6963f07c1073e3ae63b8ab99850fe90355a76 | SourDumplings/CodeSolutions | /OJ practices/PAT甲级真题练习/1023. Have Fun with Numbers.py | 692 | 4.0625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2017-12-01 20:52:18
# @Author : 酸饺子 (changzheng300@foxmail.com)
# @Link : https://github.com/SourDumplings
# @Version : $Id$
'''
https://www.patest.cn/contests/pat-a-practise/1023
'''
def main():
n = input()
num = int(n)
num *= 2
doubled_... |
9348714135c920044a7664b82b4b8648b88a424f | SourDumplings/CodeSolutions | /Course practices/小甲鱼课程:小甲鱼—《零基础入门学习Python》/042字符串ASCII码四则运算.py | 1,054 | 3.921875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2017-06-30 18:23:48
# @Author : 酸饺子 (changzheng300@foxmail.com)
# @Link : http://bbs.fishc.com/space-uid-437297.html
# @Version : $Id$
class Nstr(str):
def __add__(self, other):
a = 0
b = 0
for each in self:
a += o... |
6baa21538651c4b215d774f883d17b0824f23a6a | guilfojm/01-IntroductionToPython-201930 | /src/m6_your_turtles.py | 2,180 | 3.703125 | 4 | """
Your chance to explore Loops and Turtles!
Authors: David Mutchler, Vibha Alangar, Matt Boutell, Dave Fisher,
Aaron Wilkin, their colleagues, and Justin Guilfoyle.
"""
########################################################################
# DONE: 1.
# On Line 5 above, replace PUT_YOUR_NAME_HERE with ... |
a4f4a928befdb63ceaf7f834d6b6641a7922674a | Debonairesnake6/ClashBot | /src/player_ranks.py | 2,521 | 3.75 | 4 | """
This file will gather all of the information needed to create a table showing each player's rank
"""
from text_to_image import CreateImage
class PlayerRanks:
"""
Handle creating the player ranks table
"""
def __init__(self, api_results: object):
"""
Handle creating the player rank... |
9d7c247e69d6d3a3f39d5124275746beb844ef77 | kaarthikalagappan/sonos-jukebox | /rfidOperations.py | 3,561 | 4.03125 | 4 | #!/usr/bin/env python
import RPi.GPIO as GPIO
from mfrc522 import SimpleMFRC522
def writeToTag(data):
""" Function to write to the tag """
reader = SimpleMFRC522()
#Only 48 characters can be written using the mfrc522 library
if len(data) > 48:
print("""Can accept only string less than 48 ch... |
332db90717d18029d34aa1bbca1ce2d43fdd2a1d | InfiniteWing/Solves | /zerojudge.tw/a780.py | 361 | 3.53125 | 4 | def main():
while True:
try:
s = input()
except EOFError:
break
o, e, a = float(s.split()[0]),float(s.split()[1]),float(s.split()[2])
if(o == 0 and e == 0 and a == 0):
break
m = o / e
f = a / m
print('{0:.2f}'.format(round(m... |
d3e7eed51bfb47b69c552328c2c584658200f54e | InfiniteWing/Solves | /zerojudge.tw/c082.py | 1,507 | 3.515625 | 4 | alert=[]
class Robot:
def __init__(self,x, y, d,map,alert):
self.x = x
self.y = y
self.alive = 1
self.alert=alert
self.lastLocation = map
if(d=='W'):
self.d = 1
if(d=='N'):
self.d = 2
if(d=='E'):
self.d = 3
if(d=='S'):
self.d = 4
self.map=map
def Action(self,c):
if(c=='L'):
se... |
ec8bf34b460455bd32a2607fa7bab4ee23f15e4a | InfiniteWing/Solves | /zerojudge.tw/c419.py | 274 | 3.546875 | 4 | def main():
while True:
try:
n = int(input())
except EOFError:
break
for i in range(n-1,-1,-1):
ans = ''
for j in range(n):
ans += '*' if(j>=i) else '_'
print(ans)
main() |
e7ef5b40ececc2999a68c6873dde147dd5e725e3 | gahogg/Cracking-the-Coding-Interview-6th-Edition-Answers | /linked_lists/Return kth to last 2.py | 406 | 3.90625 | 4 | # Implement an algorithm to find the kth to last element
# of a singly linked list
from singly_linked_list_node import SinglyLinkedListNode
# O(n) runtime, O(1) space
def kth_to_last(head, k):
cur = head
while True:
k -= 1
if k == 0:
return cur
cur = cur.next
head = Singl... |
d5a296818f6bd02b8c03c76b2aa042abbcb4ee17 | AlexanderOHara/programming | /week03/absolute.py | 336 | 4.15625 | 4 | # Give the absolute value of a number
# Author Alexander O'Hara
# In the question, number is ambiguous but the output implies we should be
# dealing with floats so I am casting the input to a flat
number = float (input ("Enter a number: "))
absoluteValue = abs (number)
print ('The absolute value of {} is {}'. format... |
027ae9177f91395fd0b224ace53b431bad3af815 | BaselECE/Assignment1 | /Question_1/B.py | 435 | 4.09375 | 4 | number1 =eval (input ("enter the first number : "))
number2 =eval (input ("enter the second number : "))
process =input ("enter the process(*,/,+,-):") # ask user to type process
# test what process to do
if (process=='*') :
print (number1*number2)
elif (process=='/') :
print... |
11a6a3f01707ad71dd18ea2e9a7bd330791ca7bb | fenghui2018/python | /lesson_9/op_oo.py | 929 | 3.984375 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
def getup(name):
print(name+' is getting up')
def eat(name):
print(name+' eats something')
def go_to_school(name):
print(name+' goes to school')
def op():
person1 = 'xiaoming'
getup(person1)
eat(person1)
go_to_school(person1)
person2 = 'xiaoh... |
3c4bf7743c3aa9b70eaf040e8ed461bc6c8d9c6f | kyleedwardsny/monty_hall | /monty_hall.py | 627 | 3.6875 | 4 | import random
def monty_hall(size, omniscient, switch):
prize = random.randint(1, size)
choice = random.randint(1, size)
if not omniscient or choice == prize:
unopened = random.randint(1, size)
while unopened == choice:
unopened = random.randint(1, size)
else:
unop... |
607120b19311605f418307cffc49981af62672c5 | miker7790/Arcade | /manager/games/hangman.py | 3,456 | 3.734375 | 4 | import os
import csv
import random
class HANGMAN:
def __init__(self, word=None, attempts=None):
self.word = word.lower() if word else self._selectRandomWord()
self.remainingAttempts = attempts if attempts else self._getInitialRemainingAttempts()
self.remainingLetters = list(self.word... |
d50309f43cb772cdc2f212c0b6437a1c444a24a3 | tanmay-raichur/assignment-one | /morrisons/csv_converter.py | 4,728 | 3.84375 | 4 | """ This is a CSV file converter module.
It reads CSV file and creates a json file
with parent-child structure.
"""
import sys
import pandas as pd
import json
import logging as log
log.basicConfig(level=log.INFO)
def csv_to_json(ip_path: str, op_path: str) -> None:
""" Converts given csv file into j... |
a43ea1df7cbf7ab62ae50e8385d8d70c127d16b4 | PhillipDHK/Recommender | /RecommenderMaker.py | 1,488 | 3.546875 | 4 | '''
@author: Phillip Kang
'''
import RecommenderEngine
def makerecs(name, items, ratings, numUsers, top):
'''
This function calculates the top recommendations and returns a two-tuple consisting of two lists.
The first list is the top items rated by the rater called name (string).
The second l... |
87b052581e7ad1fe51f8e06fe1658b9d3d69ee26 | vdeangelis/Flask | /routes.py | 936 | 3.59375 | 4 | from flask import Flask, url_for, request, render_template
from app import app
# server/
@app.route('/')
def hello():
createLink = "<a href='" + url_for('create') + "'>Create a question</a>"
return """<html>
<head>
<title>Ciao Mondo!!'</title>
</head>
<body>
""" + createLink + """
<h1>Hell... |
6859cc2ba2ed3ba969b42861bc701dd1d0ca59fe | Neraverin/codewars-python | /Simple Encryption #1 - Alternating Split/main.py | 2,128 | 3.609375 | 4 | import unittest
class KataTest(unittest.TestCase):
@staticmethod
def decrypt(encrypted_text, n):
for i in range(n):
first = encrypted_text[:int(len(encrypted_text)/2)]
second = encrypted_text[int(len(encrypted_text)/2):]
if len(first) < len(second):
... |
ddb2e24756117bf6869a1b10b93237566c9d1eae | LavaTime/Envelopes | /forthStrategy.py | 1,767 | 3.78125 | 4 | from envelope import Envelope
class N_max_strategy:
"""
can run the forth strategy on a set of envelops
Attributes:
envelops (list): list of envelops to run the strategy one
N (int): holds the N for the strategy
"""
def __init__(self, envelops):
self.envelops = envelops
... |
bfd3fe14514baab0e66c20b18a6ff2e098781415 | hamzahibrahim/Projects-with-python | /Tkinter/YouTube video downloader.py | 1,236 | 3.5625 | 4 | from pytube import YouTube
print('===================')
# =========================
rerun = "y"
while rerun == "y":
try:
url = input('Enter the YouTube link for the video u want: \n')
the_video = YouTube(url)
# =========================
print('===================')
print('you... |
faf268ea926783569bf7e2714589f264ed4f3554 | Teddy-Sannan/ICS3U-Unit2-02-Python | /area_and_perimeter_of_circle.py | 606 | 4.1875 | 4 | #!/usr/bin/env python3
# Created by: Teddy Sannan
# Created on: September 16
# This program calculates the area and perimeter of a rectangle
def main():
# main function
print("We will be calculating the area and perimeter of a rectangle")
print("")
# input
length = int(input("Enter the length (mm... |
c3c084946fd1e0634b9670fc1ef058fbc4c98045 | theguythatdoes/coding-assignments | /CreateAcronym.py | 381 | 3.609375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Sep 22 15:34:58 2020
@author: reube
"""
def acronym(phrase):
y=phrase
phrase=phrase.split(' ')
mystring=len(phrase)
s=''
for k in range(0,mystring):
n=phrase[k]
s+=n[0]
return s
if __name__=="__main... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.