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 |
|---|---|---|---|---|---|---|
91c081afcb0ca54068bd1a38049c3da5ddd73c6a | evantarrell/AdventOfCode | /2020/Day 2/day2.py | 1,622 | 4.21875 | 4 | # Advent of Code 2020 - Day 2: Password Philosophy
# Part 1, read input file with each line containing the password policy and password. Find how many passwords are valid based on their policies
# Ex: 1-3 a: abcde is valid as there is 1 a in abcde
# but 3-7 l: ablleiso is not valid as there are only 2 l's in ablleiso
... |
ebd321bd1afc8939ef1ad5206dffdb5dcf2970c7 | Karth1kMR/Projects-in-python | /modify.py | 8,932 | 3.515625 | 4 | from tkinter import *
import tkinter.messagebox
import sqlite3
conn = sqlite3.connect('database.db')
c = conn.cursor()
def modi(old):
root2= Tk()
class Modification:
def __init__(self, master):
self.master = master
# heading label
self.heading = La... |
4a49debc745b108349f65986a971038d3cf56e2f | lucaspagliari/maratona-programacao-1-fase | /celulas.py | 899 | 3.5625 | 4 | from math import sqrt, asin, hypot
def area_intersec(x1,y1,r1, x2, y2, r2):
global pi
d = hypot(x2 - x1, y2 - y1)
if d < (r1 + r2):
a = r1 * r1
b = r2 * r2
x = (a - b + d * d) / (2 * d)
z = x * x
y = sqrt(a - z)
if d < abs(r2 - r1):
return pi ... |
b7db85ca69c5da22e816a24737e4d51f19fa29dc | yongrl/TestNLP | /Utils/trie.py | 1,644 | 3.96875 | 4 | class Node():
def __init__(self, c=None, word=None):
self.c = c
self.word = word
self.childs = []
class Trie():
def __init__(self):
self.root = Node()
def findc(self, node, c):
childs = node.childs
len_ = len(childs)
if len_ == 0:
retur... |
83915ce80686220c36920f1c0d25dcac8ce4b9bf | Unit26/EpicPython | /82_postfix.py | 609 | 3.8125 | 4 | import doctest
def calc(s):
'''
>>> calc("1 2 + 4 * 3 +")
'15'
>>> calc("1 2 3 * + 2 -")
'5'
'''
lst = s.split()
stack = []
for x in lst:
if x.isdigit():
stack.append(x)
else:
a = int(stack.pop())
b = int(stack.pop())
... |
b69a75b4d39fad4bcaf2913ecfb6f39f22c404fd | Unit26/EpicPython | /51_random_letter1.py | 341 | 3.59375 | 4 | import random
s = ['самовар', 'весна', 'лето']
x = random.choice(s)
lst = list(x)
rand = random.choice(lst)
i = lst.index(rand)
lst[i] = '?'
s2 = ''.join(lst)
print(s2)
r = input("Введите букву: ")
if r == rand:
print("Победа!")
else:
print("Попробуйте еще раз. Слово: ", x)
|
c22e65e9d1008b7907219ffddafdda31740028c6 | Unit26/EpicPython | /32_random_game.py | 441 | 3.671875 | 4 | import random
def fun():
return random.randint(1, 4)
def fun1(y):
if y == x:
return 'Победа!'
else:
if y < x:
return 'Поворите еще раз! Ваше число меньше нужного'
else:
return 'Поворите еще раз! Ваше число больше нужного'
x = fun()
y = int(input('Введи... |
77285317f69fad6f4f0405fae4f0f670edbe66b4 | Unit26/EpicPython | /41_num_pi.py | 161 | 3.671875 | 4 | from math import pi
def fun(x):
return f'Ответ: {pi:.{x}f}'
x = int(input('Сколько знаков после запятой? '))
print(fun(x))
|
c2a349a9d9f7b432fe89a547fc35340968304681 | prat1991/Software-App-Dev | /RPS Game Console App/Source Code/RPSGame.py | 3,539 | 3.9375 | 4 | #Libraries
import random
#Instance Variables
computer_score = 0
player_score = 0
#Methods
def player_choice():
player_choice = input("Choose Rock (r), Paper(p) or Scissors(s): ")
if player_choice in [ "r"]:
player_choice = "r"
elif player_choice in ["p"]:
player_choice = "p"
... |
c14542736f9cfcd9a3cf574c8af91e5f02b3c93a | mlotfy1/Py-code | /py08.py | 280 | 3.890625 | 4 | from __future__ import print_function
numbers = range(5,50,10)
print(numbers)
for number in numbers:
print(number)
##############################################
names = ['Ben','Alice','Jack','Sarah']
print(names)
for name in names:
print(name,'is a great person!')
|
a39c80c4dae782fb5758cfc35982e43f503653ca | MicaHorton/other | /gaslaws.py | 1,705 | 3.890625 | 4 | import re
R = 0.0821
#Ask for user input
print('Enter the pressure:')
P = input()
print('Enter the volume:')
V = input()
print('Enter the amount of mols:')
n = input()
print('Enter the temperature:')
T = input()
print()
#convert NOT-MISSING items to simple numbers in proper units
if 'psi' in P or 'PSI' in P:
P = re... |
8d05ea91c50a53c4031c7578485d42a8fec492df | NDM2021/Module9 | /Chapter1.py | 1,334 | 3.859375 | 4 | import random
def main():
print("Chapter One")
main()
def introduction():
print("It's cold at night, wolves are howling, and almost time for bed")
print("Player is lurking through the woods to find shelter, not knowing something may be watching.")
print("Player is walking further into the w... |
2ed81826bd5979dfb2b87405901f552b614f00f6 | zanixus/py-hw-mcc | /professor_analysis_KM.py | 1,194 | 4.125 | 4 | #!/usr/bin/python3
"""
Kevin M. Mallgrave
Professor Janet Brown-Sederberg
CTIM-285 W01
16 Feb 2019
Grade analysis script that handles tuple input.
"""
def mean(number_list):
number_sum = 0
for i in number_list:
number_sum = i + number_sum
number_mean = number_sum / len(number_li... |
43af5f7ea43040ac5523d0c1b303739dc726042c | zanixus/py-hw-mcc | /cputime_km.py | 1,782 | 3.59375 | 4 | #!/usr/bin/python3
"""
Kevin M. Mallgrave
Professor Janet Brown-Sederberg
CTIM-285 W01
04 Mar 2019
"""
jobs = {'A':6,'B':12, 'C':4, 'D':16, 'E':10, 'F':2, 'G':13, 'H':8}
jobs_asc = sorted(jobs, key=jobs.__getitem__)
jobs_desc = sorted(jobs, key=jobs.__getitem__, reverse=True)
total_jobs = 0
for i in ra... |
f2eed69fe818c1ec70c27b27682fb7ab12f9b45e | zanixus/py-hw-mcc | /phonebill_km.py | 999 | 3.796875 | 4 | #!/usr/bin/python3
"""
Kevin M. Mallgrave
Professor Janet Brown-Sederberg
CTIM-285 W01
13 Feb 2019
This is a quick 15-line Python program to append lowest, highest
and average amounts of minutes spend on a list of phone bills.
It uses a for loop, list slicing and a function call to append
... |
b428edd394a44eb9a55cc078ea451cbd8621eae9 | ryyyyan-taylor/csci2824 | /Random/binToDecimal.py | 413 | 3.859375 | 4 | import sys
while True:
binary = input("Binary: ")
output = 0
count = 0
if binary == "q":
sys.exit()
if binary == "0" or binary == "1":
print(binary)
sys.exit()
else:
while binary != "":
output += int(binary[-1]) * (2 ** count)... |
30d8f7a796b5cdc07e36a08c19d738016104ea74 | ryyyyan-taylor/csci2824 | /HW9/prime_factorization.py | 519 | 3.640625 | 4 | def prime_factorization(n):
res = []
i = 2
while (i <= n):
isPrime = True
for j in range(2, i):
if (i % j == 0):
isPrime = False
if isPrime:
count = 0
while (n % i == 0 and isPrime):
count += 1
... |
27b3e5dd1bc8dbb1b8396831506b56dba348ae8a | ryyyyan-taylor/csci2824 | /HW7/insSort.py | 256 | 3.59375 | 4 | def insSort(arr):
count = 0
for i in range(1, len(arr)):
currentNum = arr[i]
j = i - 1
while j >= 0:
count += 1
if arr[j] > currentNum:
arr[j+1] = arr[j]
j -= 1
else: break
arr[j+1] = currentNum
return arr, count |
f6027ce04f1e52b06b3eda7e0ad5a6ae58c08b7c | TommyD-tech/gitclassv1 | /Budget_App.py | 2,216 | 3.859375 | 4 | class Budget:
def __init__(self,category):
self.category = category
self.amount = 0
def check_balance(self,amount):
if self.amount < amount:
return False
else:
return True
def deposit(self, amount):
self.amount += amount
return "... |
2d5ffa2e7beb503559b7362af8370598f3980e36 | sonalirahagude/CodingPractice | /python/2016/sorting/insertionSort.py | 231 | 3.953125 | 4 | #! /usr/bin/python
import sys
import numpy
def insertionSort(A):
for i in range(1,len(A)):
key = A[i]
j = i-1
while j >= 0 and key < A[j]:
A[j+1] = A[j]
j -= 1
A[j+1] = key
A = [4,3,2,1]
insertionSort(A)
print A
|
78bfe7a8cc305dae079b432e15f24b253a7657ad | michaelBenin/django-oscar | /oscar/apps/checkout/calculators.py | 1,178 | 3.703125 | 4 | class OrderTotalCalculator(object):
"""
Calculator class for calculating the order total.
"""
def __init__(self, request=None):
# We store a reference to the request as the total may
# depend on the user or the other checkout data in the session.
# Further, it is very likel... |
12e59d57b6ee756f85befaae1c87f9904a1aa895 | Redomeliu/Python | /编程题/第3章-1 3-1.大于身高的平均值 (10分).py | 190 | 3.546875 | 4 | t = input().split()
mylist = [int(t[i]) for i in range(0, len(t))]
ave = sum(mylist)/len(t)
for index in range(0,len(t)):
if mylist[index]>ave :
print(mylist[index] , end = " ")
|
8977a9a1d19afe97cfc25fc41a41a37bf7f46152 | Redomeliu/Python | /函数题/第6章函数-3 使用函数统计指定数字的个数 (20分).py | 298 | 4.03125 | 4 | def CountDigit(number,digit ):
s = 0
num = str(number)
for i in num:
if i == str(digit):
s += 1
return s
number, digit=input().split()
number = int(number)
digit = int(digit)
count = CountDigit(number, digit)
print("Number of digit 2 in "+str(number)+":", count) |
0157207fc905cbae0417437ad3be0a9a82eeaf64 | Redomeliu/Python | /编程题/第3章-11 字符串排序 (20分).py | 198 | 4 | 4 | word =input()
for i in word:
if i ==' 'or i=='\t' or i=='\n':
word=word.replace(i,' ')
list1 =list(word.split())
word = sorted(list1)
print("After sorted:")
for i in word:
print(i)
|
6cb06ea734d7a03e66f34d1866585dba9c8d1b19 | IvanChen008/PythonLearnProject | /PythonOOP/MetaClassUsing.py | 7,822 | 4.625 | 5 | # type()
'''
动态语言和静态语言最大的不同,就是函数和类的定义,不是编译时定义的,而是运行时动态创建的。
当Python解释器载入一个模块时,就会依次执行该模块的所有语句,执行结果就是动态创建一个该模块的class对象。
'''
class Hello(object):
def hello(self,name='world'):
print('Hello,%s' % name)
'''
>>> from MetaClassUsing import Hello
>>> h = Hello()
>>> h.hello()
Hello,world
>>> print(type(Hello... |
a602382f0a74af08a1fe39bc730f3c8e4b34375c | IvanChen008/PythonLearnProject | /ThirdProcedure.py | 6,035 | 3.796875 | 4 | #this is the first comment
spam = 1 # and this is the second comment
# ... and now a third!
text = "# This is not a comment because it's inside quotes."
# 以下内容为编译器直接输入学习内容
# >>> 2+2
# 4
# >>> 50 - 5*6
# 20
# >>> (50-5*6)/4
# 5.0
# >>> 8/5 # division always returns a floating point number
# 1.6
# >>> 5*... |
af55ecc1a1ee3c7f08e8bcce0bd052afc396dc69 | IvanChen008/PythonLearnProject | /基础相关/AliYunPython.py | 1,128 | 3.828125 | 4 | print("Hello Python!!!")
e=set("adsgjajsdlgagjlkj'''k")
f=set("wqtglkajskldgjqiotkln")
g=f-e
#Pyhon控制流
"""三种基本的控制流:
1、顺序结构
2、条件分支结构
3、循环结构"""
b="9"
if(b=="9"):
print("abc")
#if
a,b=10,1
if(a>19):
print(a)
if(b<9):
print(b)
elif(a>9 and a<=19):
print("a>9 and a<=19")
else:
print(... |
ad6e710434aa3698845cf6c6f6322912cac0904b | IvanChen008/PythonLearnProject | /webServer.py | 920 | 3.515625 | 4 | import socket
HOST,PORT = '',8888
listen_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
listen_socket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
listen_socket.bind((HOST,PORT))
listen_socket.listen(1)
print("Serving HTTP on port %s ..." % PORT)
while True:
client_connection,client_address = l... |
a7c7d495d153f988d2ec4da03ab36de4eb5428a0 | vitahoang/py4e_exercise | /Exercise-09/exc-09-04.py | 911 | 3.6875 | 4 | # Open the file
f_name = input("Enter file name: ")
if len(f_name) > 0: f_name = "mbox-short.txt"
# Handle exceptional case when open the file
try:
f_handle = open(f_name)
except:
print('Something wrong with the file')
d_counts = dict() # Histogram of number of emails have been sent by senders
l_senders = li... |
3d85c84cf3af9311d57451460a0e097d94b2c708 | vitahoang/py4e_exercise | /Exercise-10/exc-10-02.py | 1,084 | 3.625 | 4 | # Open the file
f_name = input("Enter file name: ")
if len(f_name) > 0: f_name = "mbox-short.txt"
# Handle exceptional case when open the file
try:
f_handle = open(f_name)
except:
print('Something wrong with the file')
d_counts = dict() # Histogram // number of emails sent by hour
d_count_sort = list() ... |
e472934017e48470bf114b0a103fc2571ad6a4a0 | KangziLi/AlgorithmByPython | /LeetCode/647. Palindromic Substrings.py | 816 | 4.0625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed May 23 14:53:11 2018
@author: Kangzi Li
LeetCode: 647. Palindromic Substrings
"""
# Given a string, your task is to count how many palindromic substrings in this
# string.
# The substrings with different start indexes or end indexes are counted as
#... |
1f716255e4bba6baef3dec5112927dab3da90ee1 | KangziLi/AlgorithmByPython | /LintCode/175 Invert Binary Tree.py | 693 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Dec 3 21:54:47 2017
@author: KangziLi
@source: lintcode - 175. Invert Binary Tree
"""
"""
Definition of TreeNode:
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
"""
class Solution:
"""
Invert a binary ... |
350780fc8dbc8aed8c9b0401623dfa5b6c47aa35 | KangziLi/AlgorithmByPython | /LintCode/110 Minimum Path Sum.py | 960 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Dec 6 23:59:39 2017
@author: KangziLi
@source: lintcode - 110. Minimum Path Sum
"""
class Solution:
"""
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right
@param: grid: a list of lists of integers
@return: An inte... |
d481469578f7df9465535d82aa9cf10395e83e1f | KangziLi/AlgorithmByPython | /LeetCode/728. Self Dividing Numbers.py | 1,091 | 3.890625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri May 25 08:45:52 2018
@author: Kangzi Li
LeetCode: 728. Self Dividing Numbers
"""
#
#A self-dividing number is a number that is divisible by every digit it contains.
#
#For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 1... |
0c7721ebc71284bc7417c52e8402abec184b4d0f | KangziLi/AlgorithmByPython | /LintCode/491 Palindrome Number.py | 498 | 3.9375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Dec 3 18:43:18 2017
@author: KangziLi
@source: lintcode - 491. Palindrome Number
"""
class Solution:
"""
Check a positive number is a palindrome or not.
A palindrome number is that if you reverse the whole number you will get exactly the same number.
@param:... |
fe0940b695b44ac86e972e9a510724d7639cb398 | KangziLi/AlgorithmByPython | /LintCode/041 Maximum Subarray.py | 626 | 3.84375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Dec 2 21:45:09 2017
@author: KangziLi
@source: lintcode - 41. Maximum Subarray
"""
class Solution:
"""
Given an array of integers, find a contiguous subarray which has the largest sum.
@param: nums: A list of integers
@return: A integer indicate the sum of m... |
a366ff6c469825f0a080e22c3c994a4409bb114b | KangziLi/AlgorithmByPython | /LintCode/114 Unique Paths.py | 816 | 4 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Dec 8 17:10:07 2017
@author: KangziLi
@source: lintcode - 114. Unique Paths
"""
class Solution:
"""
A robot is located at the top-left corner of a m x n grid.
The robot can only move either down or right at any point in time. The robot is trying to reach the bot... |
d17a2a20a1b85b4b7980c251ab7c69026ca4f0e4 | KangziLi/AlgorithmByPython | /LintCode/069 Binary Tree Level Order Traversal.py | 968 | 3.625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Dec 6 23:14:11 2017
@author: KangziLi
@source: lintcode - 69. Binary Tree Level Order Traversal
"""
"""
Definition of TreeNode:
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
"""
class Solution:
"""
Gi... |
c96643283f0416321ace8b6b681f177ce989fd69 | KangziLi/AlgorithmByPython | /LintCode/060 Search Insert Position.py | 866 | 3.703125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Dec 6 21:32:24 2017
@author: KangziLi
@source: lintcode - 60. Search Insert Position
"""
class Solution:
"""
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
... |
cb25c74c141dc18eb8be263370f1e50cf42bc06b | KangziLi/AlgorithmByPython | /LintCode/155 Minimum Depth of Binary Tree.py | 934 | 3.828125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Dec 8 20:05:06 2017
@author: KangziLi
@source: lintcode - 155. Minimum Depth of Binary Tree
"""
#Definition of TreeNode:
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
class Solution:
"""
Given a bina... |
df53e32495acefccd58928da7bdc1de86cdd835f | KangziLi/AlgorithmByPython | /LintCode/112 Remove Duplicates from Sorted List.py | 756 | 3.6875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Dec 8 17:10:03 2017
@author: KangziLi
@source: lintcode - 112. Remove Duplicates from Sorted List
"""
#Definition of ListNode
class ListNode(object):
def __init__(self, val, next=None):
self.val = val
self.next = next
class Solution:
"""
@param:... |
1271752294740883e4d0b2801206b7ceedb61381 | KangziLi/AlgorithmByPython | /LeetCode/575. Distribute Candies.py | 910 | 4.09375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu May 24 16:05:56 2018
@author: Kangzi Li
LeetCode: 575. Distribute Candies
"""
#Given an integer array with even length, where different numbers in this array
#represent different kinds of candies. Each number means one candy of the
#corresponding ki... |
f04af5deb60a35c8c2e12aa7755a3751dc15d5fc | kaushikram29/python1 | /factorials.py | 65 | 3.671875 | 4 | x=int(input())
y=1
for i in range(1,x+1,1):
y=i*y
print (y)
|
684f9a65b6c72684f2355958751ae8d4b1de97a5 | kaushikram29/python1 | /character.py | 220 | 4.21875 | 4 | X=input("Enter your character")
if((X>="a" and X<="z) or (X>="A" and X<="Z")):
print(X, "it is an alphabet")
elif ((X>=0 and Z<=9)):
print(X ,"it is a number or digit")
else:
print(X,"it is not alphabet or digit")
|
a016a84eb0f5087e392e1f64e53dce50caaa52fa | welenofsky/pwgen | /pwgen.py | 4,210 | 3.546875 | 4 | from __future__ import print_function
# This is a extension of the trifid cipher
import sys
import re
import argparse
# 64 character dictionary
dictionary = (
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.?"
)
def build_polybius(pw, dictionary):
pw_list = [c for c in pw]
while le... |
66c5f7707989fd436ebdf2d4bc293da68ab239da | mikisugimoto/orangengine | /orangengine/models/generic/address.py | 408 | 3.515625 | 4 |
"""address object constants"""
ADDRESS_TYPES = {
'ipv4': 1,
'dns': 2,
}
class Address(object):
def __init__(self, name, value, a_type):
"""init address object"""
self.name = name
self.value = value
self.a_type = a_type
def __getattr__(self, item):
if item =... |
971c0553d924c08c50f9c2afba14ddf1807a4923 | TehilaNaki/AI_Repository | /level_2/game.py | 5,860 | 3.515625 | 4 | '''
Tehila Naki-323071571
Merav Izhaki-322915430
'''
import copy
VIC = 10 ** 20 # The value of a winning board (for max)
LOSS = -VIC # The value of a losing board (for max)
TIE = 0 # The value of a tie
SIZE = 4 # The length of a winning sequence
COMPUTER = SIZE + 1 # Marks the computer's cells on the board
HUMAN... |
01c66200703ba9aff8ed876e9041a11299998249 | mackedinger1994/trapezoidal_rule | /trapizoidal rule.py | 973 | 3.59375 | 4 | import math
#this calculator is imperfect
n = float(input('n: '))
upperBnd = float(input('upper limit: '))
lowerBnd = float(input('lower limit: '))
def deltaD ( n, upperBnd, lowerBnd):
delt = (upperBnd - lowerBnd)/n
#print(delt)
return(abs(delt))
delta = deltaD( n, upperBnd, lowerBnd)
def inputValues(delt... |
4563448177ab9cd9c4ff9eb5b04ba08ee6a0e7f1 | voolverine/Labwork | /ISP/4_term/Lab2/task6.py | 1,107 | 3.6875 | 4 | class defaultdict(object):
def __init__(self):
self.d = dict()
def hashable(self, key):
if hash(key):
return True
else:
# Error in this case
return False
def __getitem__(self, key):
if self.hashable(key):
pass
if k... |
154517d9558849576bc4fbe7bdb8544b5e3aeff4 | threepinidea/age_judge | /age.py | 518 | 3.734375 | 4 | driving = input('是否開過車(請輸入有/沒有): ')
if driving != '有' and driving != '沒有':
print('只能輸入 有/沒有')
raise SystemExit
age = int(input('請輸入你的年齡: '))
if driving == '有':
if age >= 18:
print('通過測驗')
else:
print('這年齡開車 是不是違規偷開阿 ?')
elif driving =='沒有':
if age >= 18:
print('你可以考駕照開車了, 怎麼... |
757c7d67a17293dd34dd1530830678e4650e8b2b | ibiaalice/Python-Projects | /speech_to_text/main.py | 1,747 | 3.5625 | 4 | import speech_recognition as sr
import pyttsx3
import datetime
print('Loading your AI personal assistant - G One')
engine=pyttsx3.init()
def speak(text):
engine.say(text)
engine.runAndWait()
def wishMe():
hour=datetime.datetime.now().hour
if hour>=0 and hour<12:
speak("Hello,Good Morning")... |
0b5d01a6533552157663d92e53c2ee4bfe8fc939 | mshoaib6/FlaskPythonISD | /18079999D_import_airbnb.py | 5,115 | 3.578125 | 4 | import json
import sqlite3
#Do NOT put functions/statement outside functions
def start():
#import JSON into DB
file = 'airbnb.json';
with open(file, 'r',encoding="utf8") as myfile:
data=myfile.read()
# parse file
listing = json.loads(data)
conn = sqlite3.con... |
7ff26582448bbe30237af15ca11a0107df288b68 | encomp/dsan_project2 | /project2/collections/DoubleLinkedList.py | 3,796 | 4.03125 | 4 | from project2.collections.Node import Node
class DoubleLinkedList:
def __init__(self):
self.__size = 0
self.__head = None
self.__tail = None
def size(self):
return self.__size
# Inserts a node at the front of the double linked list
def insert_node_at_front(self, node... |
132c10218bc573e2c87c94bbf22b3216d94d6068 | Renato-Camapum/blind-auction | /main.py | 879 | 3.828125 | 4 | from replit import clear
from art import logo
#this is an exercise using dictionary and loops. enjoy!
print(logo)
print("Welcome to the blind auction App.")
bidder_dict = {}
should_continue = True
def better_bid(bid_record):
highest_bid = 0
winner = ""
for bids in bid_record:
bid_amount = bid_reco... |
2f25d9c66c415159dc530b5ce642cabea763d815 | KatyaEgorenkova/Python_1_lessons | /lesson_01/home_work/hw01_normal.py | 1,783 | 3.984375 | 4 |
__author__ = 'Ваши Ф.И.О.'
# Задача-1: Запросите у пользователя ввод произвольного целого числа
# Вывести самую большую цифру этого числа.
# Например, дается x = 58375.
# Нужно вывести максимальную цифру в данном числе, т.е. 8.
# Число приходит в виде целого беззнакового.
n = input(' введите n = ')
n = int(n)
max = ... |
c6171d3e06da2f43c6b4925d1f54bdf1a26ccb59 | yonisymonds/COMP30024 | /Chexers/webinar_code/mc-3/state.py | 2,487 | 3.875 | 4 | """
Missionaries and Cannibals Problem
Uninformed Search Approach
STATE REPRESENTATION
*--------------------------*
Author: Matthew Farrugia-Roberts
"""
class State:
"""
Represent a missionaries and cannibals problem state
"""
def __init__(self, missionaries, cannibals, boat):
self... |
948148dfc49179ad0f828a66a2272a4dd4963e92 | yonisymonds/COMP30024 | /Chexers/webinar_code/mc-1.py | 2,067 | 3.71875 | 4 | """
Missionaries and Cannibals Problem
Uninformed Search Approach
*--------------------------*
Author: Matthew Farrugia-Roberts
"""
"""
Initial
Side Goal
Boat |
M M M | -> |
C C C | |
"""
# how many on starting side?
initial_state = (3, 3, 1)
# | | |
# missionaries ... |
7eab6c0e7e96406065d31a8461081a52a140dc23 | BolysbayAskar/End-term-quiz | /end/updatecol.py | 872 | 3.96875 | 4 | #You can update a record, or document as it is called in MongoDB, by using the update_one() method
#The first parameter of the update_one() method is a query object defining which document to update
import pymongo
myclient = pymongo.MongoClient("mongodb://localhost:27017/")
mydb = myclient["mydatabase"]
mycol = mydb["... |
7aa3b50cdeea24ff582efe3a3369ed94ba95a7b4 | lagzda/MITx-6.00.1x | /Set1/counting_bobs.py | 473 | 4.0625 | 4 | #The title of this function is pretty self-explanatory (lowercase string assumed)
def count_bobs(s):
# Initialise the length of the string and bob counter to 0
s_len = len(s)
bobs = 0
# No point in looking for bob if the string is too near the end
for i in range(s_len - 2):
#Splicing funct... |
d790a96b241a30cc1f6649b48c23a657b8a97f39 | jeffrey-kor/python-class | /jeffrey/python_tutorial/basicSyntax.py | 2,114 | 3.765625 | 4 | # part 1
print(1+2);
print(3-4);
print(12*12);
print(24/2);
print(24%3);
# part 2
Helloworld = "Helloworld!";
name = "James";
print(name + " " + Helloworld);
# part 3
happy = ["dog", "family", "money", "job"];
print(len(happy));
print(happy[1]);
happy.remove(happy[0]);
print(len(happy));
# part 4
num = 1;
while num ... |
84e8e612cd31611f20d67599785906b25a3f9923 | rlefkowitz/2048twist | /2048/board.py | 6,155 | 3.5625 | 4 | import math
import pygame
import random
from grid import Grid
SLIDE_UP = 1 << 0
SLIDE_DOWN = 1 << 1
SLIDE_LEFT = 1 << 2
SLIDE_RIGHT = 1 << 3
class Board(object):
def __init__(self, width=4, height=4):
self.grid = [[Tile(r, c) for c in range(width)] for r in range(height)]
self.width = width
self.height = he... |
8dc28648691fa7bb5b237badf19beac62432f483 | BarabaraLee/Multivariate-Statistical-Methods | /HW1/HW1_P2_NonBiNormal.py | 488 | 3.859375 | 4 | import numpy as np
import matplotlib.pyplot as plt
'''
This is a demonstration that two normal RVs
form a distribution that is not bivariate
normal distributed.
'''
X1=np.random.randn(500)
def X2(X1,c):
X2=[]
for i in range(len(X1)):
if X1[i]>=c or X1[i]<=-c:
X2.append(X1[i])
eli... |
bc2229d2578f385b18d65df6ff2a8d58fd9a1277 | Alejandro-Paredes/EECS337---NLP-Project-2 | /conversions.py | 3,722 | 3.5625 | 4 | def convertTeaspoonToCup(teaspoon):
cup = round(teaspoon*0.021, 2)
return cup
def convertCupToTeaspoon(cup):
teaspoon = round(cup/0.021, 2)
return teaspoon
def convertTeaspoonToTablespoon(teaspoon):
tablesoon = round(teaspoon/3, 2)
return tablespoon
def convertTablespoonToTeaspoon(tablespoon):
teaspoon = rou... |
d169cda2839bb2451d3a5d0e3411e4d846e70616 | KarlaFRM/Tarea_08 | /listas.py | 4,818 | 3.703125 | 4 | #Autor Karla Fabiola Ramirez Martines - A01746769
#Palabras de prueba
lista0=[1,2,3,4,5,6,7,8,9]
lista2=[]
lista3=[8,3,8,1,9,5,3,1,4,342,3,434,]
lista4=[2,4,6,7,8,23,45]
lista1=[5,5,3,1,4,55,5,55,5,5,33,1,23]
listaA=["h","o","l","a"]
listaB=["c","a","m","a","r","a"]
listaC=["m","o","r","a"]
listaD=["a","m","o"... |
72d779221652c23ebc973b443b9b3e6e0545b2a1 | urbanskii/UdemyPythonCourse | /secao05/se05E12.py | 447 | 4 | 4 | """
12 - Ler um número inteiro. Se o número lido for negativo, escreva a mensagem "Número
inválido". Se o número for positivo, calcular o logaritmo deste numero.
"""
import math
def main():
numero = int(input('Digite um numero inteiro: '))
if numero > 0:
print(f'A soma dos algarismos do numero di... |
8a2759019bed13876781303d25cf050cc83e9bc6 | urbanskii/UdemyPythonCourse | /secao04/se04E08.py | 430 | 4.03125 | 4 | """
8 - Leia uma temperatura em graus Kelvin e apresente-a convertida em graus Celsius.
A fórmula de conversão é: C=K-273.15, sendo C a temperatura em Celsius e K a
temperatura em Kelvin.
"""
def main():
temp_kelvin = float(input('Digite a temperatura em Kelvin: '))
temp_celsius = temp_kelvin-273.15
... |
c17a66237825077916c7c9b03add598dc9017e55 | urbanskii/UdemyPythonCourse | /secao05/se05E27.py | 690 | 4.25 | 4 | """
27 - Escreva um programa que, dada a idade de um nadador, classifique-o em uma das
seguintes categorias:
Categoria Idade
Infantil A 5 a 7
Infantil B 8 a 10
Juvenil A 11 a 13
Juvenil B 14 a 17
Sênior maiores de 18 anos
"""
def main():
idade = int(input('Informe a idade: '))
if 5 <= idade <= 7:
... |
e09f4233d7f2b2cff76cde0daee108b1b631613c | urbanskii/UdemyPythonCourse | /secao04/se04E46.py | 411 | 4.375 | 4 | """
46 - Faça um programa que leia um número inteiro positivo de três dígitos (de 100 a 999).
Gere outro número formado pelos dígitos invertidos do número lido, Exemplo:
Númerolido = 123
NúmeroGerado = 321.
"""
def main():
numero = input('Digite o numero de 3 digitos: ')
print(f'Númerolido: {numero}')
... |
1cc9feef4fdfac3acb291296bfb09f9eeb9ff74b | urbanskii/UdemyPythonCourse | /secao04/se04E23.py | 414 | 3.90625 | 4 | """
23 - Leia um valor de comprimento em metros e apresente-o convertido em jardas. A fórmula
de conversão é: J = M/0.91 sendo J o comprimento em jardas e M o comprimento em metros.
"""
def main():
valor_metros = float(input('Digite o valor em metros: '))
valor_jardas = valor_metros/0.91
print(f'Valor ... |
7415957d0b47b9bc0c8aaff627164e34272fd1cb | urbanskii/UdemyPythonCourse | /secao05/se05E15.py | 814 | 3.71875 | 4 | """
15 - Usando switch, escreva um programa que leia um inteiro entre 1 e 7 imprima o dia
da semana correspondente a este numero. Isto é, domingo se 1, segunda-feira se 2, e
assim por diante.
"""
def main():
dia = int(input('Informe um numero inteiro: '))
if dia == 1:
print(f'Dia da semana = Domi... |
02f0bf58d7c57dac995888980e0dc1aeeb03be48 | urbanskii/UdemyPythonCourse | /secao04/se04E06.py | 519 | 4.125 | 4 | """
6 - Leia uma temperatura em graus Celsius e apresente-a convertida em graus Fahrenheit.
A fórmula de conversão é: F = C*(9.0/5.0)+32.0, sendo F a temperatura em Fahrenheit
e C a temperatura em Fahrenheit.
"""
def main():
temperatura_celsius_input = float(input('Digite a temperatura em Celsius: '))
... |
f2e5f9819023e7ada7494adcbddc129a9567586e | urbanskii/UdemyPythonCourse | /secao05/se05E29.py | 1,151 | 4.0625 | 4 | """
29 - Faça uma prova de matemática para crianças que estão aprendendo a somar números
inteiros menores do que 100. Escolha números aleatórios entre 1 e 100, e mostre na tela a
pergunta: qual é a soma de a + b, onde a e b são os números aletatórios. Peça a
resposta. Faça cinco perguntas ao aluno, e mostre para ele a... |
873807c7f844a745f82ba4db84dacb0b333eb63c | urbanskii/UdemyPythonCourse | /secao04/se04E51.py | 372 | 3.96875 | 4 | """
51 - Escreva um progama que leia as coordenadas xe y de pontos no R² e calcule sua distância
da origem (0, 0).
"""
import math
def main():
x = float(input('Digite a coordenada X: '))
y = float(input('Digite a coordenada Y: '))
r = math.sqrt(math.pow(x,2) + math.pow(y,2))
print(f'A distância é ... |
9035b3faa2a4970955d628c1d91584c1a3033b9e | urbanskii/UdemyPythonCourse | /secao04/se04E14.py | 412 | 4.125 | 4 | """
14 - Leia um ângulo em graus e apresente-o convertido em radianos.
A fórmula de conversão é: R = G* π (Pi)/180, sendo G o Ângulo em graus
e R em radianos e π (Pi) = 3.14.
"""
def main():
angulo = float(input('Digite um ângulo em graus: '))
radiano = angulo * 3.14/180
print(f'Resultado do ângulo em ... |
6701c714d5dfef2b71e9dc7f39a6c906fb73b849 | urbanskii/UdemyPythonCourse | /secao04/pep8.py | 1,731 | 4.125 | 4 | """
PEP8 - Python Enhancement Proposal
São propostas de melhorias para a linguagem Python
The Zen of Python
import this
A ideia da PEP8 é que possamos escrever códigos Pỳthon de forma Pythônica.
[1] - Utiliza Camel Case para nomes de Classes;
class Calculadora:
pass
class CalculadoraCientifica:
pass
[2]... |
fd31927f70af66205523edd928a9cc4a430ab555 | Lekuro/advent_of_code | /01/2_2020.py | 644 | 3.890625 | 4 | # get numbers from file
lines = []
with open('numbers.txt', 'r') as f: # adventofcode/
for line in f:
# print(line)
lines.append(line)
numbers = []
for item in lines:
numbers.append(int(item))
# print(numbers)
# choose three numbers
num1 = 0
num2 = 0
num3 = 0
for i in numbers:
for j in numb... |
953e28ed2d6e8bea121f446a252250e377bd9483 | Lekuro/advent_of_code | /06/2.py | 895 | 3.828125 | 4 | import re
# get data from file
with open('data.txt', 'r') as f: # _example
lines = []
part = ''
for line in f:
# print(line)
if line == '\n':
lines.append(part)
part = ''
else:
part += line
if part != lines[-1] and part != '':
lines.ap... |
0cb2ccd07dd0dbe94c7e1c3722d13817762e52a0 | mattquint111/Learning-Python | /day3-assignment1.py | 512 | 4.1875 | 4 | # Assignment 1 - Factorial
#number = int(input("Enter a non-negative number: "))
# def factorial():
# soln = 1
# for i in range(1, number+1):
# soln *= i
# return soln
#print(factorial())
# Recursive factorial function
def factorial2(n):
# default solution for n == 0 (n! == 1)
... |
3d75a6ad62e84014cf30093ef1a1eed234a3c7d3 | mattquint111/Learning-Python | /week2/read_write_files/reading_file.py | 787 | 3.828125 | 4 | # with open('pi_digits.txt') as file_object:
# contents = file_object.read()
# print(contents)
# # with open('test_txt_file.txt', 'w') as f:
# # f.write('this is test text in the file')
# with open('test_txt_file.txt') as f:
# file_content = f.read()
# just create a new file
# my_file = open('new_file.tx... |
d23fc35a56312dd1b511715aceea67c71f0c7d73 | mattquint111/Learning-Python | /week2/project-PoolTableApp/test_app.py | 589 | 3.734375 | 4 | import unittest
import datetime
import functions as f
class TestTable(unittest.TestCase):
def setUp(self):
self.table = f.Table('table 1')
# Check that inital table status = "UNOCCUPIED"
def test_status(self):
self.assertEqual("UNOCCUPIED", self.table.status)
# check that inital cost f... |
14a4ed8730578aa3a1fcf7bf32b3096835ac221c | Clearymac/Integer-division-and-list | /task 2.py | 864 | 4.28125 | 4 | #LIST RETARRD
list = ['Evi', 'Madeleine', 'Cool guy', 'Kelsey', 'Cayden', 'Hayley', 'Darian']
#sorts and prints the list
list.sort()
print('Sorted list:', list)
#asks the user to input their name
name = input("What is your name? ")
name = name.title()
#checks if name is in list and gives option to add to list
if na... |
eb93519875ce65d293ef8b702770259ef79d61a7 | frankisgreat/PythonRepo | /queue.py | 2,905 | 3.859375 | 4 | #!/usr/bin/env python
#-*- encoding: utf-8 -*-
"""
@File : Queue.py
@Version : 1.0.0
@Author : oldLuckyKing
@License : (C) Copyright 2006-2019
@Software: vsCode
@Time : 2019/9/26
@Desc :
"""
import sys
a = 0
b = 0
c = 0
list_A = [] # 1人就餐
list_B = [] # 2人就餐
list_C = [] # 4人就餐
pos_dict = {"一人座位":... |
cced778b114e7a0a12d68052ebbd33ad30a392c1 | SOURAV-ROY/2020-PYTHON | /List.py | 493 | 3.984375 | 4 | grocery_list = ['rice', 'potato', 'tomato', 'onion', 'apple']
L2 = list()
print(grocery_list)
grocery_list.sort()
print(grocery_list)
numbers = [10, 30, 15, 6, 20, 2020, 2005]
# numbers.sort()
print(numbers)
sorted_list = sorted(numbers)
print(sorted_list)
second_item = grocery_list[1]
print(second_item)
print(grocer... |
31e7aefed7ec6ece0920f71375d545f787f601a0 | SOURAV-ROY/2020-PYTHON | /Hello.py | 102 | 3.71875 | 4 | username = input('Your Name PLZ:')
print(f'Hello {username} !!!')
print("OHO {} !!".format(username))
|
c19c1037df80b19b054900aac1a56bf8eba3384f | the-code-critics/001-datastructures | /bad_code.py | 1,046 | 3.734375 | 4 | """
BAD CODE
The problem is in the data structure. Loading the movie database as a list
of lists causes the function movies() to find the movies of a user to be
of linear complexity O(1) and the function shared() to find shared movies to be
of quadratic complexity O(m*m).
The good code has constant complexity O(1) fo... |
1f7000d8e15f8f692162b13c608cf6c891a94b03 | ALgosZen/practice-python | /data-structures/stack-cylinders.py | 1,103 | 3.796875 | 4 | #!/bin/python3
import os
#
# Complete the 'equalStacks' function below.
#
# The function is expected to return an INTEGER.
# The function accepts following parameters:
# 1. INTEGER_ARRAY h1
# 2. INTEGER_ARRAY h2
# 3. INTEGER_ARRAY h3
#
def equalStacks(h1, h2, h3):
# Write your code here
s1, s2, s3 = map(su... |
84c61f2ec03d29e7005502a8a728db4fb49c3ad4 | compserv/hknweb | /hknweb/tutoring/scheduler/graph.py | 532 | 3.65625 | 4 | from typing import Dict, List
from collections import namedtuple
Edge = namedtuple("Edge", "weight a b")
Pair = namedtuple("Pair", "weight b")
class Graph:
def __init__(self, num_nodes: int):
self.neighbors: Dict[int, List[Pair]] = {i: [] for i in range(num_nodes)}
def add_edge(self, a: int, b: in... |
26231eb3162ac1c98ee2e72b5c44284c403f1c57 | yfeng75/learntocode | /python/escapechar.py | 516 | 3.734375 | 4 | splitString = "This string has been\nsplit over\nseveral\nlines"
print(splitString)
tabbedString="1\t2\t3"
print(tabbedString)
print('The pet shop owner said "No, no, \'e\'s uh,...he\'s resting".')
# or
print("The pet shop owner said \"No,no, 'e's uh,...he's resting\".")
print("""The pet show owner said "No,no,'e's uh,... |
b94dc2d008b9a102fdde7ea8755449e518ad76ed | yfeng75/learntocode | /python/operators.py | 125 | 3.6875 | 4 | a = 12
b = 3
print(a+b)
print(a - b)
print(a * b)
print(a / b)
print(a // b)
print(a % b)
print()
print(a + b/3 - 4*12)
|
a421d26ec9850e4430424be0c72e9109af4fb090 | yfeng75/learntocode | /python/challenge_dict.py | 1,043 | 4.125 | 4 |
locations={0: "You are sitting in front of a computer learning python",
1: "You are stadning at the endo f a road before a small brick building",
2: "You are at the top of a hill",
3: "You are inside a building, a well house for a small stream",
4: "You are in a valley b... |
8b7f7265bd3d8c12e2da0756c9a6aa8b91ca8f2e | yfeng75/learntocode | /python/demo.py | 105 | 3.890625 | 4 | a=b=c=d=12
print(c)
a,b=12,13
print(a,b)
a,b = b,a
print("a is {}".format(a))
print("b is {}".format(b)) |
6c89697c59a7095066624d0550d1632f90813c7d | Anirudh07-max/Data-Structures | /Week_2_Priority Queues_and_Disjoint_Sets/1.1_buid_heap_shiftup.py | 2,445 | 3.5625 | 4 | # python3
class Heap:
def __init__(self):
self.swaps = []
self.data = []
self.n = 0
def read(self):
# f = open('tests/04', 'r')
# self.n = int(f.readline())
# dat = f.readline().split()
self.n = int(input())
dat = map(int, input().sp... |
6ec12b5fa9ca0d9a71d86b9c7d7a562dd35a1738 | dsysoev/fun-with-algorithms | /operations/performance.py | 1,837 | 3.84375 | 4 | """
Implementing performance for basic math operation in python
"""
from time import time
from functools import wraps
import numpy as np
import pandas as pd
def measure(func):
@wraps(func)
def _time_it(*args, **kwargs):
start = int(round(time() * 1000))
value = func(*args, **kwargs)
... |
06664ec135ff28ebc997107a6f650e8138e94052 | dsysoev/fun-with-algorithms | /sort/quicksort.py | 3,625 | 4.25 | 4 | # coding: utf-8
import random
def partition(lst, start, end):
"""
move elements below pivot value to left half of list and bigger to right half
return the new position of the pivot element
"""
# use pivot as the last element in list
# get it value
x = lst[end]
# initial store_index
... |
7ef02dd0334ef240943e995b55559ee5919f184c | maxwagner440/python_patterns | /PrototypeClone.py | 676 | 3.890625 | 4 |
import copy
class Prototype:
def __init__(self):
self._objects = {}
def register_object(self, name, obj):
self._objects[name] = obj
def unregister_object(self, name):
del self._objects[name]
def clone(self, name, **attr):
obj = copy.deepcopy(self._objects.get(name))
obj.__dict__.update(attr)
re... |
6931feec4e641ddd9ffe73db230833ff47a3a1d7 | maxwagner440/python_patterns | /Singleton.py | 687 | 3.765625 | 4 | class B:
_shared_state = {}
def __init__(self):
self.__dict__ = self._shared_state
class Singleton(B):
"""This class inherits from the B class every time its instantiated which allows access to the _shared_state object that is global"""
def __init__(self, **kwargs):
B.__init__(se... |
4d6b70ceda0b338bbca98208f250bb05862ea480 | svssindhu/Sentiment_Analysis | /Sentiment_analyzer.py | 297 | 3.828125 | 4 | from textblob import TextBlob
sentence=input("Have you watched the Movie? How was it! : ")
edu=TextBlob(sentence)
p=edu.sentiment.polarity
print("The reaction is: ",end=' ')
if p<0:
print(":( 'Negative'")
elif p>0 and p<1:
print(":) 'Positive'")
else:
print(":| 'Neutral'")
|
f35174f8fcb3ec806d5ad4e3030ab3540cac7aca | dpetry/obelics-git-demo | /fib.py | 155 | 3.796875 | 4 | def fib(n):
"""
fibonacci
"""
if n == 0 or n ==1:
return 1
rval = fib(n - 1) + fib(n - 2)
print(rval)
return rval
|
94cb1bfe43400a61c35296f8ce2ee252ed5d3067 | JackTackettJr/youtubkeywords | /ut-keywords.py | 527 | 3.546875 | 4 | import requests
url = input('Enter youtube url: ')
#url = 'https://www.youtube.com/watch?v=O5kJ69bPDME'
try:
r = requests.get(url)
#r.text
urltext = r.text #(convert from request type into a string)
keywords_string = urltext.partition("\"keywords\":[")[2].partition("]")[0]
if len(keywords_string) != 0:
l=ke... |
396fe31c127d8b63d3cf84762d7cf11eb9611096 | jackliddle/JLChess | /LegalMoves.py | 5,955 | 3.625 | 4 | from Board import Board
from collections import defaultdict
from itertools import chain
import pdb
opposition = lambda(side): 'BLACK' if side == 'WHITE' else 'WHITE'
def boundCheckPos((row,col)):
"""
True if the position is inside the board
"""
r = range(8)
return row in r and col in r
def pa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.