blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
bd9a09532638a2f1c8746abb1d759af0a9770ce1 | Genghis77777/Item-Comparison | /Test.py | 1,281 | 4.0625 | 4 | product_details = []
product_name = ""
product_status = ""
best_value = []
worst_value = []
while product_name != "X":
product_name = input("\nPlease enter the name of the product: ")
if product_name == "X":
break
else:
product_weight = float(input("Please enter the weight/volume of the "
... |
43b36d5346f4c2028460d512fd558b6d718e1c8c | eliaskousk/example-code-2e | /17-it-generator/coroaverager.py | 888 | 3.515625 | 4 | """
A coroutine to compute a running average
# tag::CORO_AVERAGER_TEST[]
>>> coro_avg = averager() # <1>
>>> next(coro_avg) # <2>
0.0
>>> coro_avg.send(10) # <3>
10.0
>>> coro_avg.send(30)
20.0
>>> coro_avg.send(5)
15.0
# end::CORO_AVERAGER_TEST[]
# tag::CORO_AVERAGER_TEST_CONT[... |
23d1af69bd1560673e3ad498ab3ef57b8e837a16 | sunanqi/algorithms | /dfs.py | 1,317 | 3.71875 | 4 | """
- Problem:
traverse nodes in a graph
- Algorithm:
DFS
- time complexity:
O(V+E)
optimization: before dfs, convert adjacency list to iterator
- input:
graph represented as adjacency list
- output:
reachable nodes
"""
import collections
import datetime
def dfs(G, s):
for k in G:
G... |
bd39c0259a611da6809fb047f9eabc8f0230cbca | xaviruvpadhiyar98/Python-Assignments | /missingElement().py | 304 | 3.671875 | 4 | # finds the msiing elemnt from first to second arr
def MissingElement(a,b):
for x in a:
if x in b:
b.remove(x)
a.remove(x)
for x in a:
if x not in b:
print(x)
a=[1,2,3,4,5,6,7]
b=[3,7,2,1,4,6]
MissingElement(a,b) |
069d037b0914392b786ee77f7c37e4f248f8b506 | zhouyanasd/SNN_framework | /src/data/__init__.py | 525 | 3.5 | 4 | '''
The type of data is N groups in a python list,
and each group is a numpy array which form is [feature, number].
Example: python-list[np.array[feature, number],...]
[array([[0, 0, 1, ..., 0, 0, 0],
[2, 2, 0, ..., 1, 0, 4],
[1, 0, 2, ..., 3, 0, 1],
[1, 1, 0, ..., 1, 0, 1],
[1, 1, 3, ...,... |
3d06021a04644cddeb73d5ccc6ef51129b715647 | ShriyaChandran/C97Homework | /Homework97.py | 652 | 4.1875 | 4 | import random
print("The number guessing game")
guessCount=0
number=random.randint(1,9)
introString=int(input("Enter a number from 1 to 9"))
while(guessCount<6):
if(introString>number):
print("The number is lesser than")
print(introString)
introString=int(input("Enter a number fro... |
8eb47fd7811e5b2de75a1f75d21210e64c99e540 | seanbrede/Leetcode | /0055_Jump_Game.py | 577 | 3.546875 | 4 | class Solution:
def canJump(self, nums: List[int]) -> bool:
last_pos = len(nums) - 1
steps_left = 0
i = 0
# while we are within the array and still have steps left
while i < last_pos:
# update the number of steps left, if none then quit
steps_left = m... |
b8db204d634ce6b6ea3ad868dd02b0747e289348 | Saransh-kalra/Python-Labs | /Python/grading_system.py | 286 | 3.984375 | 4 | print("welcome to the grading system")
marks=float(input("enter your marks: "))
if(marks>=90.0):
print("you got an A")
elif(marks>=80.0):
print("you got a B")
elif(marks>=70.0):
print("you got a C")
elif(marks>=60.0):
print("you got a D")
else:
print("you got a F")
|
32b4bac7d801b62e129244f09eed2a1eb8d1ac96 | varughese/CS8-Spring19-Recitation | /week4/SOL03a.py | 308 | 4.03125 | 4 | # Python program that play guess game with a user
from random import randint
#This allows to the user to input his first number
user_number=int(input("Guess the number:"))
number = randint(1, 10)
while number!= user_number:
user_number=int(input("Guess the number:"))
print("Yay :), you found it!") |
1c53736b4f25a908d89099ee6cfd1beaf4be90fb | beardnick/LeetCode | /src/practice/travel.py | 160 | 3.515625 | 4 | # -*- coding: utf-8 -*-
n = int(input())
nums = []
for i in range(n):
nums.append(list(map(int,input().split())))
print("n =" , n)
print("nums = " , nums) |
8b9f0f2a61abfbb34fd1788996c31135343cbf16 | iagotito/hacktoberfest | /python/topological_sort.py | 774 | 3.671875 | 4 | clothes = {
0: 'underwear',
1: 'pants',
2: 'belt',
3: 'suit',
4: 'shoe',
5: 'socks',
6: 'shirt',
7: 'tie',
8: 'clock'
}
graph = [
[1, 4],
[2, 4],
[3],
[],
[],
[4],
[2, 7],
[3],
[]
]
visited = [0 for x in range(len(graph))]
stack = []
def print_s... |
9ebba8140c0240ee2a3a946226b30bf3b03a5e64 | doPggy/py-try | /12-list-comprehension.py | 611 | 4.1875 | 4 | # 产生式表达式
## 循环生成 list
values = [10, 21, 3, 44, 5]
squares = []
for x in values:
squares.append(x ** 2)
print(squares)
## 列表生成式生成 list
values = [10, 21, 3, 44, 5]
squares = [x ** 2 for x in values]
print(squares)
'''还可以带判断语句'''
squares = [ x ** 2 for x in values if x >= 10 ]
print(squares)
## 生成集合字典
values = [10, 2... |
2efd25d52393850c991ba24cd1b1fcb6545f001a | glendaascencio/Python-Tutorials | /scalene_isosolis_equilateral_triangle.py | 692 | 4.4375 | 4 | # Python-Tutorial
Tutorial for learning how to Program with python
''' We'll pront the user to enter the size of a triangle and
we'll determine if it is an scalene, isosolis, or equilateral triangle
* Scalene triangle= is when the sizes has different lenghts
* Isosceles triangle = has two equal lenghts
* Equilateral ... |
1be23e11c00d86c31357bb3f6519cc2a9272801e | Vinod096/learn-python | /lesson_02/personal/chapter_5/01_km_convertor.py | 350 | 4.5 | 4 | #Write a program that asks the user to enter a distance in kilometers, and then converts that
#distance to miles. The conversion formula is as follows:
#Miles = Kilometers * 0.6214
def miles():
kilometers = float(input("enter kilometers :"))
miles = kilometers * 0.6214
print("distance travelled in miles :{... |
7a314ba94d77439e3a5755032c853fbcf7177490 | forrestjan/Labos-MCT-19-20 | /2019-prog-labooefeningen-forrestjan/week4/oefening7.py | 348 | 3.609375 | 4 | def print_list(soort, lijst):
print(f"verzameling: {soort} ")
for item in lijst:
print(f"{item} staat op positie {lijst.index(item)}")
lijst = [12, 45, -9, -15]
print_list = ("gehele getallen", lijst)
lijst = ["maandag", "moet", "ik", "s'avonds",
"ook", "iets", "doen", "voor", "school"]
prin... |
ffb8f3bd438cb358141d443394258d60a14e3e43 | shaikbabafakruddin/babafakruddin-python-and-network-security | /project1.py | 313 | 3.796875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Jul 4 16:58:29 2021
@author: Shinjon Mukherjee
"""
# Project 1 = Program to generate md5 hash of the given data
import hashlib
word=input("Enter the word You want to encode = ")
enc=word.encode("utf-8")
digest=hashlib.md5(enc.strip()).hexdigest()
print(diges... |
57aa091a308335dfd8e0e4d711850c78d71c4691 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2776/58586/271275.py | 605 | 3.546875 | 4 | words=eval(input())
ans=[]
def dfs(words,temp,depth):
if len(temp)==0:
if depth>=2:
return True
else:
return False
for i in range(0,len(words)):
if len(words[i])>len(temp):
continue
else:
if temp.find(words[i])!=-1:
... |
1aca501a366d2e63b4339e090506b91cee599d92 | VipulGirishKumar/Cinema-Hall-Booking-System | /Project- Cinema Seat Booking.py | 6,598 | 3.765625 | 4 | #Cinema Hall - Seat Booking Booking System
print("Cinema Hall - Seat Booking Booking System")
seats = []
seats.append([0,0,1,0,1,1,0,1])
seats.append([0,1,1,0,0,1,0,1])
seats.append([1,0,0,1,1,1,0,0])
seats.append([0,1,0,1,1,0,0,1])
seats.append([0,0,1,1,0,1,0,0])
seats.append([1,0,0,1,0,1,1,0])
#Password
d... |
926b0b00b37df4fa12cf3b2b2214f3cc7ceddcde | christina57/lc-python | /lc-python/src/lock/314. Binary Tree Vertical Order Traversal.py | 2,335 | 4.0625 | 4 | """
314. Binary Tree Vertical Order Traversal
Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom, column by column).
If two nodes are in the same row and column, the order should be from left to right.
Examples:
Given binary tree [3,9,20,null,null,15,7],
3
/\... |
af7e780c79b07dedfece45cdf33c046d4edf7667 | slickFix/Python_algos | /DS_ALGO/GFG_practise/BST_pred_succ.py | 2,093 | 3.96875 | 4 | class Node:
def __init__(self,data):
self.key = data
self.left = self.right = None
def find_pre(root):
curr = root
while curr.right is not None:
curr = curr.right
return curr
def find_suc(root):
curr = root
while curr.left is not None:
curr = curr.left
... |
103dba9895515b9c9ecd70d661d1e458ce578ac2 | darthHelmet/MadLibs | /MadLibs.py | 1,254 | 3.578125 | 4 | def madlib():
print "Welcome to Madlibs"
NOUN_PLURAL_1 = raw_input("Enter a Plural Noun: ")
PLACE = raw_input("Enter a Place: ")
NOUN_1 = raw_input("Enter a Noun: ")
NOUN_PLURAL_2 = raw_input("Enter a Plural Noun: ")
NOUN_2 = raw_input("Enter a Noun: ")
ADJECTIVE_1 = raw_input("Enter an Adjective: ")
VERB_1 ... |
c585aea808a15886dbb4b531db0d43c0da54b3e9 | museHD/NCSS-Int-2020 | /Raise the Roof/raise_the_roof.py | 433 | 4.0625 | 4 | breads = {}
while len(breads) < 5:
name = input("Name: ")
bread = input("What kind of bread are you bringing? ")
if breads.get(bread,0) == 0:
breads[bread]=name
print(f"{name} is bringing a {bread}!")
elif breads.get(bread,0) != 0:
print("Someone else is bringing that already.")
print("The party is organ... |
d1ee7b87bb3429afe702688330432ee6db4c41fa | dgjung0220/codingtest | /dfs_stack.py | 493 | 3.609375 | 4 | import collections
def iterative_dfs(start_v):
discovered = []
stack = [start_v]
while stack:
v = stack.pop()
if not v in discovered:
discovered.append(v)
for w in graph[v]:
stack.append(w)
return discovered
if __name__ == "__main__":
... |
25fb8391021e590426d416b8e4180375fcb95156 | pactonal/cse231 | /proj05.py | 2,298 | 3.875 | 4 | #!/usr/bin/python3
'''Put overall header comments here.'''
import string
def open_file():
'''Insert function DocString here.'''
opened = 0
while opened != 1:
try:
filename = input("Enter a file name: \n")
f = open(filename, "r")
opened = 1
except IOError... |
057495adcdf3173d3eeab5129ea0cd60a0a4f6fb | zixing23/wpm | /test/5.py | 1,733 | 3.53125 | 4 | import pickle
class AthleteList(list):
def __init__(self,a_name,a_dob=None,a_times=[]):
list.__init__([])
self.name = a_name
self.dob = a_dob
self.extend(a_times)
def top3(self):
return(sorted(set([sanitize(t) for t in self]))[0:3])
def sanitize(time_string):
# 如果'-'在... |
a51c13c8d18ce0253ed476a19b91c23852524a38 | andynines/3tmaster | /tictactoe.py | 1,821 | 3.78125 | 4 | """
tictactoe.py
Tic-tac-toe game engine
"""
import collections
class BoardStr(str):
def __str__(self):
# render board as 3x3 grid for terminal output
return '\n'.join([self[:3], self[3:6], self[6:9]])
class Game:
default_space = '-'
player_syms = ('X', 'O')
gamestate = collections.namedtuple("GameState", ... |
b9dfb6c28943fdf4336694b8d880b2e28ad861a2 | abcrohit/codeforces_rohit | /1521A.py | 189 | 3.53125 | 4 | T=int(input())
for i in range(T):
a,b=(input().split(" "))
a=int(a)
b=int(b)
if(b==1):
print("NO")
else:
print("YES")
print(f"{a} {a*b} {a*b+a}") |
ef1149db5fa83151b2c2aea6af830238942c83cf | jc451073/workshops | /CP5632_assignment1.py | 4,809 | 3.875 | 4 | __author__ = 'jc451073'
# Initialize the constants
FILE = "books.csv"
MENU = "Menu: \nR - List required books\nC - List completed books\nA - Add new book\nM - Mark a book as completed\nQ - Quit"
def main():
print("Reading List 1.0 - by Moolayil Josmi")
booklist = []
load_books(booklist)
... |
690b2a6c55918dc81e356dd68e760d4fd658f171 | AravindSK1/Code-Everyday | /01. Python/Day 0019.py | 902 | 4.0625 | 4 | """
1. Given an array, find which two numbers form the target?
"""
class array_problems:
def __init__(self, arr, target_sum):
self.arr = arr
self.length = len(arr)
self.target = target_sum
def get_pairs(self):
"""
1. Create a dictionary to hold the pairs
2. The k... |
574fa2bd9786e2a1e18fb04d5f64d2e0355a6a72 | hansrajdas/random | /practice/trie_autocomplete.py | 2,688 | 3.53125 | 4 | ALPHABET_SIZE = 26
class TrieNode:
def __init__(self):
self.children = [None for _ in range(ALPHABET_SIZE)]
self.is_end_of_word = False
class Trie:
def __init__(self):
self.root = TrieNode()
def _char_to_index(self, c):
return ord(c) - ord('a')
def _index_to_char(self... |
4d6cc112ac22ce560d127b6aacc59aa0f7683302 | JackyTao/algorithm | /threesum.py | 540 | 3.78125 | 4 | # -*- coding: utf-8 -*-
def threesum(a, target):
# a is already sorted
if len(a) <= 2:
return 0, 0, 0
i = 0
while i < len(a) - 2:
j, k = i + 1, len(a) - 1
while j < k:
if a[i] + a[j] + a[k] == target:
return i, j, k
elif a[i] + a[j] + a[k... |
db96cf906c34d902d49e55d31a150959d66345f4 | NitishReddy26/python | /grocery.py | 1,561 | 3.6875 | 4 | while True:
budget = float(input("Enter your budget : "))
available=budget
break
d ={"name":[], "quantity":[], "price":[]}
l= list(d.values())
name = l[0]
quantity= l[1]
price = l[2]
while True:
ch = int(input("1.ADD\n2.EXIT\nEnter your choice : "))
if ch == 1 and... |
83320f3d42afbc1c9e87926a26162af392a0b11f | augustedupin123/python_practice | /p11_new.py | 1,254 | 3.828125 | 4 | '''for i in range(1,6):
for j in range(1,6):
print(j, end="")
print()'''
'''for i in range(1,6):
for j in range(1,6):
print(j, end="")'''
'''for i in range(1,6):
for j in range(1,6):
print(j)'''
'''for i in range(1,6):
print(str(i)*5)'''
'''for i in range(1,6):
... |
5778497ccf5e554d8d6a99f21f6ecc6d1733ade7 | zhangcj5131/AI_teaching | /basic/26.闭包中使用外部变量.py | 732 | 3.9375 | 4 | # 定义一个外部函数
def func_out(num1):
# 定义一个内部函数
def func_inner(num2):
# 这里本意想要修改外部num1的值,实际上是在内部函数定义了一个局部变量num1,如果想调用外面的 num1,必须使用nonlocal
nonlocal num1 # 告诉解释器,此处使用的是 外部变量a
# 修改外部变量num1
num1 = 10
# 内部函数使用了外部函数的变量(num1)
result = num1 + num2
print("结果是:", resul... |
8ed80228ad2b2991f0c247497fd0cd601eabe17d | fjfhfjfjgishbrk/AE401-Python | /zerojudge/a883.py | 279 | 3.515625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 3 11:58 2020
@author: fdbfvuie
"""
a, b = map(int, input().split())
c, d = map(int, input().split())
e, f = map(int, input().split())
if c >= b and e >= b and e >= d:
print("Happy")
else:
print("QQ") |
0b2ee115102da0dff844ffdbfff0f1445e2b6017 | anantkaushik/leetcode | /1329-sort-the-matrix-diagonally.py | 1,243 | 4.375 | 4 | """
Problem Link: https://leetcode.com/problems/sort-the-matrix-diagonally/
A matrix diagonal is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and
going in the bottom-right direction until reaching the matrix's end. For example, the matrix diagonal starting from mat[2][... |
f1d2bd988e26ad29e12893c175013dfd270e0327 | idebosmitha/Python-practice | /Day 6/factors.py | 108 | 3.890625 | 4 | n = int(input('Enter a number: '))
f = 2
while n != 1:
if n % f == 0:
print(f)
n /= f
else:
f += 1
|
8d8e8b8f85eb796a4528edea56a12e91678d2f17 | DrewOrtego/Order-Book-Programming-Problem | /Pricer.py | 12,767 | 3.9375 | 4 | """
Pricer.py
Andrew Ortego
12/27/2017
Description:
Solves the Order Book Programming Problem. Reads an input-file containing one command per line. Each command will run an
Add or Remove order. When the size of an order matches or exceeds the given target size, output is printed to the
console reporting the best buy o... |
bef1890ddee968d62ecb44f0926de06da4b4dc91 | abidmuin/AI_Lab | /BFS.py | 1,247 | 4.0625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Mar 11 08:58:22 2019
@author: muin
"""
from collections import defaultdict
class Graph:
#Constructor
def __init__(self):
#default dictionary to store graph
self.graph = defaultdict(list)
#function to add edge to graph
... |
40f259e226818c6752ea031bae1c052893eaa918 | martynov85m/pyTests | /04_student.py | 1,176 | 4 | 4 | # -*- coding: utf-8 -*-
# (цикл while)
# Ежемесячная стипендия студента составляет educational_grant руб., а расходы на проживание превышают стипендию
# и составляют expenses руб. в месяц. Рост цен ежемесячно увеличивает расходы на 3%, кроме первого месяца
# Составьте программу расчета суммы денег, которую необходимо... |
a61ca628156a0b89bbf084475faf02727f41280f | LeenaKH123/Python2 | /06_advanced-python-concepts/06_07_setcomp_union.py | 1,110 | 4.21875 | 4 | # Use the union operator `|` to intersect the two given sets
# inside of a set comprehension that squares each item of the
# set if the number is higher than `2`.
# You should write the whole code logic in only one line.
#
# Expected output: {16, 9, 25, 49}
#
# Remember that sets are unordered collections, so your numb... |
e501dba7446860753ad3b1b2637ca862e7703bda | arsaikia/Data_Structures_and_Algorithms | /Data Structures and Algorithms/Cracking The Coding Interview/Arrays and Strings/5. One Away.py | 1,307 | 3.984375 | 4 | '''
1.5 One Away: There are three types of edits that can be performed on strings: insert a character,
remove a character, or replace a character. Given two strings, write a function to check if they are
one edit (or zero edits) away.
EXAMPLE
pale, ple -> true
pales, pale -> true
pale, bale -> true
pale, bae ... |
27cdd19f57e62ffd7c3649eee3dcda7ff4b2ceb1 | eugen1701/BKT-plan | /menu.py | 2,521 | 3.546875 | 4 | #CONSTANTS:
NUMBER_DIRECTIONS = 8
NUMBER_OF_THE_UPPERLEFT_EDGE = 0
NUMBER_OF_THE_LOWERRIGHT_EDGE = 9 #because python I cannot set it in main :)
di = [-1, -1, 0, 1, 1, 1, 0, -1]
dj = [0, 1, 1, 1, 0, -1, -1, -1]
#DECLARATION:
matrice = []
matrice2 = []
#matrice is for the data we read and matrice2 is for comp... |
5cf3208cdd55b8300b541000192bab8fadb470ee | vikasdongare/python-for-everbody | /Using Python to Access Web Data/Assign2.py | 512 | 3.921875 | 4 | #In this assignment you will read through and parse a file with text and numbers
#You will extract all the numbers in the file and compute the sum of the numbers
#Date :- 29 April 2020
#Done By :- Vikas Dongare
import re
name = input("ENTER FILENAME: ")
if len(name) < 1: name = "sample.txt"
handle = open(name)... |
e14c5a6c8279621ac9775e68821535853f05a9a2 | WickedWahine/calculator-2 | /calculator.py | 1,364 | 4.25 | 4 | """CLI application for a prefix-notation calculator."""
from arithmetic import (add, subtract, multiply, divide, square, cube,
power, mod, )
#Start loop to receive calculation request
while True:
input_string = input("Calculate > ")
tokens = input_string.split(' ')
operator = token... |
ca9f45a6fbfc6745ea7880e5910e36ab0fe9c159 | UtkarshGoelUT/Git-Contri-Tutorial | /char_count.py | 352 | 3.84375 | 4 | # return dictionary with charater as key and number of occurences as value
def char_count(s):
# initializing dicionary
count = dict()
# iterating over string
for c in s:
if c in count:
count[c] += 1
# find the error here
return count
if __name__ == "__main__":
s = i... |
d0bd6a5abe4d04708e3a09d149845066ba8dd50c | nickbuker/toy_airflow | /src/file_creator.py | 204 | 3.515625 | 4 | class FileCreator:
def __init__(self, file: str):
self.file = file
def create(self) -> None:
with open(self.file, 'w+') as f:
f.write('Hello, PuPPy!')
return
|
a0b5644e3c0997760724051c66d8b78aad3fec47 | AtsukiImamura/parking-kyoto | /constants/maneuver.py | 1,183 | 3.734375 | 4 |
from enum import Enum
def get_by_key(key):
"""
ケバブケースの文字列から動作タイプを取得する。定義されていない場合は Maneuver.STRAIGHT を返す
"""
for man in Maneuver:
if key == man.to_kebab_case():
return man
return Maneuver.STRAIGHT
class Maneuver(Enum):
"""
右左折などの動作タイプを定義
"""
STRAIGHT = 0
... |
e64450c52f65ff365c173d3ec4226c08969d8072 | vim-hjk/python-algorithm | /code/merge_2.py | 910 | 4 | 4 | def mergesort(num):
if len(num) > 1:
mid = len(num) // 2
left = num[:mid]
right = num[mid:]
left_list = mergesort(left)
right_list = mergesort(right)
return merge(left_list, right_list)
else:
return num
def merge(left_list, right_list):
left_idx = 0... |
b042b3a3edde2e5a083c4157b258d566c2eda36d | lgabs/udacity-bikeshare | /chicago_bikeshare_pt.py | 17,787 | 4.125 | 4 | # coding: utf-8
# autor: Luan Fernandes (lgabs)
# Resumo do código:
# Trata-se de tarefas que exploram os dados de uso de bicicletas compartilhadas na região de Chicago pela empresa Divvy
# As tarefas compõem o projeto 1 do curso de Data Science 1 da Udacity
# Começando com os imports
import csv
import matplotli... |
632e73e544dcfa1f77dda3d11c631ca9ba15ab71 | manojnayakkuna/leetcode_easy | /problems/leetcode_476_numberComplement.py | 1,347 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
Given a positive integer num, output its complement number. The complement strategy is to flip the bits of its binary representation.
Example 1: Input: num = 5
Output: 2
Explanation: The binary representation of 5 is 101 (no leading zero bits), and its complement is 010. So you need to outpu... |
775f325220328192092331ed46821b5e614f23af | Nitin-patil2209/US-state-game | /main.py | 727 | 3.671875 | 4 | from turtle import Turtle, Screen
import pandas
data = pandas.read_csv("50_states.csv")
list_of_states = data["state"].to_list()
screen = Screen()
i = 1
turtleg = Turtle()
screen.title("U.S State Game")
img = "blank_states_img.gif"
screen.addshape(img)
turtleg.shape(img)
while i <= 51:
screenprompt = ... |
a53c785051eb587ef90e8e39bf1123f08119ea4f | lancerdancer/leetcode_practice | /code/trie/211_add_and_search_word.py | 1,841 | 3.953125 | 4 | """
https://leetcode.com/problems/add-and-search-word-data-structure-design/
Design a data structure that supports the following two operations:
void addWord(word)
bool search(word)
search(word) can search a literal word or a regular expression string containing only letters a-z or .. A . means it can
represent any o... |
3fe096e53a31c92da006403f6acef2c0f3ecbf4d | bpuderer/python-snippets27 | /stdlib/time_qs.py | 1,541 | 4 | 4 | import time
print "snoozing 300 ms...zzzzzzz"
time.sleep(0.3)
# precision is platform dependent but a float is always returned
print "seconds since epoch as a float:", time.time()
# returns string for a tuple/struct_time in format "%a %b %d %H:%M:%S %Y"
# if no arg is provided it uses localtime()
print "current loc... |
b081dab1bd11ed6c1e0c434e6978ed23c72dec78 | BhushanTayade88/Core-Python | /Feb/day 11/table.py | 104 | 3.703125 | 4 | n=int(input("Enter any no :"))
print("Table of Numer ",n)
for i in range(1,11):
print(n,"x",i,"=",n*i) |
fe959408275196b2eb1e81b02cf9f00a146dc846 | vikram-vijay/Exercism_python | /simple-cipher/simple_cipher.py | 791 | 3.515625 | 4 | from random import choices
from string import ascii_lowercase as letters
from itertools import cycle
class Cipher:
def __init__(self, key="".join(choices(letters, k=100))):
self.key = key
assert self.key.islower(), ValueError("key should be all lower case.")
@staticmethod
def _new_text(st... |
a231d8bf67fedee787fec9f89ead07a4acc68bf5 | william1357chen/fcc-scientific-computing-with-python | /fcc-arithmetic-formatter/arithmetic_arranger.py | 2,783 | 3.84375 | 4 | def arithmetic_arranger(problems, ans = False):
arranged_problems = ""
# check if there are too many problems. The limit is 5
if len(problems) > 5:
return "Error: Too many problems."
for i in range(len(problems)):
problems[i] = problems[i].split()
problem = problems[i]
o... |
b92f01ceeb830fd3b62864eda4699f436f301f62 | GSimas/PyThings | /Coursera/Python for Everybody/2-Data Structures/assignment9_4.py | 864 | 4.34375 | 4 | ## Python for Everybody Coursera
## Assignment 9_4
## Gustavo Simas da Silva - 2017
## Python Data Structures, Dictionaries
#use mbox-short.txt as filename
name = input("Enter file:")
if len(name) < 1: name = "mbox-short.txt"
fh = open(name)
all_emails = list()
mail_count = dict()
#iterates through lines of the fil... |
f0db15166f9fb876a23a774eef96569d7c7ab431 | PedroHenriqueSimoes/Exercicios-Python | /Mundo 2/File 057.py | 315 | 3.890625 | 4 | sex = ((str(input('Qual seu genero? [M/F] '))).strip()).upper()[0]
while sex !='M' and sex != 'F':
sex = ((str(input('Não entendi o que digitou ! Tente outra vez [M/F] '))).strip()).upper()[0]
if sex == 'M':
print('Sexo masculino registrado !')
else:
print('Sexo feminino registrado !')
print('FIM !')
|
2976357b8eba00691dd4a806c4c67f54a643842b | erjan/coding_exercises | /lexicographically_smallest_equivalent_string.py | 6,657 | 4.03125 | 4 | '''
You are given two strings of the same length s1 and s2 and a string baseStr.
We say s1[i] and s2[i] are equivalent characters.
For example, if s1 = "abc" and s2 = "cde", then we have 'a' == 'c', 'b' == 'd', and 'c' == 'e'.
Equivalent characters follow the usual rules of any equivalence relation:
Reflexivity: 'a'... |
973e0eebc3d620ec08d3f25b97a8220b6fd0ff2b | maggiepitt/tic-tac-toe | /tictactoe.py | 2,728 | 3.796875 | 4 | #main
player1 = input ("Player 1, please enter a name: ")
player2 = input ("Player 2, please enter a name: ")
players = [player1, player2]
players.sort()
for i in players:
print (players[0]+", you are X!")
print (players[1]+", you are O!")
break
row1 = [" ", " ", " "]
row2 = [" ", " ", " "]
row3 = [" ", ... |
51033624394c62c952b6c453f0d94e4a26252199 | codewithgauri/HacktoberFest | /python/En19cs306027_Lovesh_Kumrawat_Self_created_function_similar_to_'.astype'_in_numpy.py | 838 | 3.5 | 4 | # In 'numpy' we can convert values of matrix into 'integer' by 'np.matrix('1.4 0.6;1.8 3.2;1.4 4.2',dtype=int)' or 'matrix_variable.astype('int32')' but i created a function for this.
import numpy as np
def matrix_integer_values_any_shape(inp): #* For any shape of matrix.
lst=[]
mtx=np.matrix([int(j) for i in np.a... |
e9bbac8440944a604eb55584129a3f815457e964 | AaronBangs/PyCheckers | /py_checkers/ai_api/bot.py | 3,252 | 3.796875 | 4 | #JMJ
#Agent.py
#An interface to work with the class competition.
#Programmed by Ben Campbell
"""
Board Conventions:
Ben and I discovered while trying to get our bots to play each other that we need a standard convention for numbering the board. We've decided on the following conventions:
1. The columns are numbered ... |
7a96bb4b679a75f3462f8750b9f0ca9355c50962 | MartaVohnoutovaBukovec/IOS-655-Python-a-Bash | /IOS 655 Python a Bash/homework/Lysov/AL_HW_10/subst_decipher.py | 1,256 | 4.03125 | 4 | #!/usr/bin/env python3
#
# Subject: UAI / 655, Lecturer Ing. Marta Vohnoutová
# Homework No 10: create a program that breaks the substitution cipher
# using 'brute force' approach by seeking patterns in the English dictionary
#
# Author: Alexandre Lysov
# Date: April 2017
#
# on Linux: python3 subst_decipher.p... |
b4a7a4abc8098c4d3bd27e3532532d101ae0e8ca | eklavyapatel/Access-Control-System | /canAccess.py | 2,187 | 3.71875 | 4 | from Objects import *
# Test whether a user can perform a specified operation on an object. Optionally, an object may be NULL, in which case CanAccesschecks allows access if a user is part of a group for an operation on which no object group was defined.
# The program will check whether the user is allowed to perform t... |
c2cb537f158dd780c9a2af8848369339e53f997f | ht-dep/Algorithms-by-Python | /Problem Solving with Algorithms and Data Structures using python/05 Sorting and Searching/Sort/01 bubble sort/bubble_sort.py | 484 | 3.984375 | 4 | # coding:utf-8
# bubble sort:循环比较两个相邻位置之间的大小关系
def bubbleSort(num_list):
L = len(num_list)
while L > 1:
for i in range(L-1):
if num_list[i]>num_list[i+1]:
temp = num_list[i]
num_list[i] = num_list[i+1]
num_list[i+1] = temp
L -= 1
... |
e1adb5f703564b298c888369d03340d9e2e4eff3 | sasdf/ADLxMLDS2017 | /hw2/special/utils.py | 275 | 3.5 | 4 | #!/usr/bin/env python3
# coding=utf8
# version: 1.0.0
def trim_phone(x):
r = []
l = -1
c = 0
for p in x:
if p != l:
l = p
c = 0
else:
c += 1
if c == 1:
r.append(p)
return r
|
cf167583c3c263737f388df9f1cd6a566f9df818 | drugotosto/Simulazione | /analisiOperazionale/bootlneckAnalysis.py | 2,183 | 3.609375 | 4 | __author__ = 'maury'
import numpy as np
def calcoloVisite(md,ind):
""" Visit vector is computed using
V = VQ
The Scipy library can solve only linear system
in the form A X = b
So we transform the system in:
VQ = V => VQ -V = 0
=> V (Q -I) = 0... |
6e1e1be01326a849e17039f6c751a60f51b02558 | mtkent/SeniorProject | /binaryConvert.py | 344 | 3.921875 | 4 | def convertToBinary(n):
if n > 1:
convertToBinary(n//2)
print(n % 2,end = '')
# # decimal number
# dec = 4530 # = 13 bit number
convertToBinary(100)
# binary = 11001
# decimal = 0
# for digit in binary:
# decimal = decimal*2 + int(digit)
# print (decimal)
# bin = str(101001)
# toPrint = int(bin, base=2)
# p... |
31ce9b48c5ac9acdd6cb262ba7f93b5a4f390f84 | mglerner/MathematicalPhysics | /Bessel/basicbessel.py | 898 | 3.546875 | 4 | #!/usr/bin/env python
from __future__ import division
from numpy import array, linspace
import scipy
import scipy.special
from scipy.special import j0,j1,jn,y0,y1,yn
import matplotlib.pyplot as pl
x = linspace(0,20,10000)
fig = pl.figure()
N = raw_input("How many bessel functions of the first kind to plot? ")
N = i... |
f728d9fa7c7a1c32173b014984f16bc34fa838db | wangshunzi/Python_Demo | /01-微信+体脂率计算/05-微信+体脂率计算.py | 2,900 | 3.953125 | 4 | # 案例要求: 给定一个人的体重,身高,年龄,性别,打印其体脂率
class Person:
def __init__(self, name, age, sex, height, weight):
try:
self.body_fat = 0
self.name = name
if isinstance(age, str):
self.age = int(age)
if isinstance(sex, str):
if sex in ("男",... |
91f107b4b1cc73dd7a69855199b2e12e302b0f4a | fractal1729/trash-classifier | /Features/extra_stuff/extra_edge_sliders.py | 3,082 | 3.53125 | 4 | #import the necessary packages
import argparse
from Tkinter import *
import cv2
import imutils
# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True,
help="Path to the image to be scanned")
args = vars(ap.parse_args())
#... |
98fadaa24406457cdc5669979002817cc57727f4 | dalalsunil1986/Interview-Prep | /Medium/breadthfirstsearch.py | 1,991 | 4.28125 | 4 | # Do not edit the class below except
# for the breadthFirstSearch method.
# Feel free to add new properties
# and methods to the class.
from collections import deque
class Node:
def __init__(self, name):
self.children = []
self.name = name
def addChild(self, name):
self.children.appen... |
67c709027732791799706d8d0aedd308532d262f | lygeneral/LeetCode | /Python/Array/middle/15_3sum.py | 1,667 | 3.6875 | 4 | '''
15. 三数之和
给你一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?请你找出所有满足条件且不重复的三元组。
注意:答案中不可以包含重复的三元组。
示例:
给定数组 nums = [-1, 0, 1, 2, -1, -4],
满足要求的三元组集合为:
[
[-1, 0, 1],
[-1, -1, 2]
]
通过次数373,027
提交次数1,237,156
'''
class Solution:
def threeSum(self, nums):
'''
@describe: 排序+... |
fad5097c471a11095cd9586e86eec728f5c29efc | williamslai/driving | /driving.py | 338 | 3.859375 | 4 | #driving
country = input('請輸入國家')
age = int(input('請輸入年齡'))
if country == '台灣':
if age >= 18:
print('你可以考駕照')
else:
print('不可以考駕照')
elif country == '美國':
if age >= 16:
print('你可以考駕照')
else:
print('不可以考駕照')
else:
print('只能輸入台灣&美國')
|
0eab71a12f7464d35fbfc77953de5ea81b465f7d | saisudheer123/sudheer3python | /palindrome.py | 146 | 3.546875 | 4 | sai=int(raw_input())
sum=0
n=sai
while sai!=0:
rem=sai%10
sum=sum*10+rem
sai=sai/10
if sum==n:
print("yes")
else:
print("no")
|
eb07cb091bdd28a65d602b73a25e4798ce7c6d97 | Linkitz/exercises-coronapython | /chapter_3_3_9.py | 887 | 4.09375 | 4 | # 3-9. Dinner Guests: Working with one of the programs from Exercises 3-4 through 3-7 (page 46), use len() to print a message indicating the number of people you are inviting to dinner.
# Exercise 3-5
strangeperson = ['Strange Nº 1', 'Strange Nº 2', 'Strange Nº 3']
print("Yoooo! " + strangeperson[0] + ", let's dinner... |
ec0a0698929c2836cef786bf0cfb439023400529 | styphoiz/code-challenges | /task4.py | 282 | 3.859375 | 4 | def task4(num1,num2):
if(num1 == 3 or num2 ==3):
for i in str(int(num1 + num2)):
if i=="3":
return True
return False
else:
return False
#tests
print(task4(3,5))
print(task4(3,10))
print(task4(13,10))
print(task4(20,3))
|
d8bf4aa2d843da7379dfe38e0c88692260de1bf5 | Jennifer974/my-projects | /data_scientist_projects.py | 1,464 | 3.90625 | 4 | class DataScientist():
'''This class describes Data Science projects I realized.
'''
def __init__(self, github='Jennifer974', school='VIVADATA'):
'''This function initializes attributes of DataScientist class
'''
self.github = github #Name of my Github account
self.sc... |
1427fa269da1beb8166b3c6df473f2f4da2d23bf | laxmanuppada/Python-Lab | /day2/Life-in-weeks.py | 384 | 3.984375 | 4 | age = input("what is your current age ? : ")
# print (age)
age_as_int = int(age)
years_remaining = 90 - age_as_int
days_remaining = years_remaining * 365
weeks_remaining = years_remaining * 52
months_remaining = years_remaining * 12
# print(days_remaining)
message = f"you have {days_remaining} days, {weeks_remain... |
1e8db3c251d7294be8a97058fd2e5a2b366e057c | korayszn/Pre-Release-2021 | /PreleaseMaterial.py | 3,708 | 4.125 | 4 | TutorGroup = input("Type the tutor group to set up votes for Eg. 7A")
while len(TutorGroup) != 2 and len(TutorGroup) != 3:
TutorGroup = input("Error. Type the tutor group to set up votes for Eg. 7A: ")
NumStudents = int(input("Please input the number of students in this tutor group: "))
while NumStudents < 28 or... |
b00a8e297133ef6a32834f0c714254c4f24cc8ee | GhulamMustafaGM/PythonChallenges | /Basketball RosterApp.py | 2,590 | 4.03125 | 4 | # Lists Challenge - Basketball Roster Program
print("Welcome to the Basketball Roster Program")
# Get user input and define our roster
roster = []
player = input("\nWho is your point guard: ").title()
roster.append(player)
player = input("Who is your shooting guard: ").title()
roster.append(player)
player = input("Wh... |
08a1c96fc366b8ba554ddc14d48ba206cfa8c531 | Gideon-Felt/Homework-Bottega | /11-11-19/Filter_Emails_and_departments.py | 1,893 | 4.1875 | 4 | """
You have been given a raw data dump that has an array of objects. The objects keys are companies, and the values are arrays of emails followed by a 3 digit department number.
I need you to write a program that will go through the data, return the emails for each company and what department number that email belongs... |
49cc39121a6eb26d733af1158bf335aa5a4c376a | mandrakean/Estudo | /Python_Guan/ex069.py | 649 | 3.921875 | 4 | print('-=-'*20)
print('Cadastro de pessoas')
print('-=-'*20)
print('')
sup18 = 0
h = 0
m20 = 0
teste = 'S'
while teste is 'S':
idade = int(input('digite a idade: '))
sexo = ' '
while sexo not in 'MF':
sexo = str(input('digite o sexo (M/F): ')).upper().strip()[0]
if idade < 20 and sexo is "F":
... |
2da454af1558927b7e56640e0391784aef1760f5 | dhazu/Mygit | /python_workbook/ch1/ex9.py | 1,012 | 3.84375 | 4 | """Exercise 9: Compound Interest
Pretend that you have just opened a new savings account that earns 4 percent interest
per year. The interest that you earn is paid at the end of the year, and is added
to the balance of the savings account. Write a program that begins by reading the
amount of money deposited into the ac... |
6ff7e7e86a8b49b3ed11ff81ff7e41f03896cf20 | Mjusten/pythonElaborata | /Aula07_Ex02.py | 241 | 3.84375 | 4 | soma = lambda x,y,z : x+y+z
entrada1 = float(input("Entre o primeiro valor: "))
entrada2 = float(input("Entre o segundo valor: "))
entrada3 = float(input("Entre o terceiro valor: "))
saida = soma(entrada1,entrada2,entrada3)
print(saida) |
503188d81e07fe54d1ec2a93aa0b5e77765af641 | janethuyx/algorithm | /diameter_binary_tree.py | 510 | 3.6875 | 4 |
class Solution:
"""
@param root: a root of binary tree
@return: return a integer
"""
def diameterOfBinaryTree(self, root):
# write your code here
self.max = 0
self.dfs(root)
return self.max
def dfs(self, node):
if not node:
return 0
... |
8627f0e47e8483c3d334c062809d5a7c86809758 | 4LuckyMove/Education_Space_Lab | /MVC_MVP_MVVM/MVP/model.py | 415 | 3.5 | 4 | class ModelCalculator:
def __init__(self):
self.result = 0
def calc(self, val1, operation, val2):
if operation == '+':
self.result = val1 + val2
elif operation == '-':
self.result = val1 - val2
elif operation == '*':
self.result = val1 * val2
... |
c96774bb58457b697504d0a70c79007ff0a99f24 | ShaeBrown/seng474 | /proj.py | 2,722 | 3.53125 | 4 | import csv
import sys
#create array to put attributes into
data_array= []
#array for classes
class_array= []
#open pordate file
f=open("pordate.csv", "r")
reader=csv.reader(f)
#go through data file and create arrays of 0 and 1's for each student (breakdown on google docs)
for row in reader:
tmp= []
cmp=[]
#mal... |
6fc8482d210dda5ddf5ed8f4fc83417623b9a12d | Cryptofrye/vegas | /vegas/player.py | 1,377 | 3.703125 | 4 | import vegas.invalid_bet
class Player(object):
"""A roulette Player (abstract class)."""
def __init__(self, table, verbose=False):
"""Constructor."""
self.table = table
self.stake = 100
self.roundsToGo = 1
self.verbose = verbose
def setStake(self, stake):
"""Set Player's stake to be th... |
fdad571b11cb63f86958d6717aa33b07301e8593 | lizetheP/PensamientoC | /programas/Laboratorios/4_While/tareaCiclos.py | 765 | 4.15625 | 4 | def factorial(n):
i = 1
acum = 1
while i <= n:
acum = acum*i
i= i+1
return acum
def multiplicacion(n1, n2):
i = 1
acum = 0
while i <= n2:
acum = acum + n1
i = i + 1
return acum
def menu():
print()
print("1. Factorial")
print("2. Multiplicació... |
62eff33d377ade411916b96b85821a3de52c5a60 | crosstuck/iot-analytics | /iot_analytics/models.py | 2,547 | 3.53125 | 4 | class BaseEvent(object):
def is_valid(self):
"""
An account ID and an event type are required.
"""
if self.property_id and self.type and self.type in EVENT_TYPES:
return True
return False
def clean_data(self, data):
"""
Removes any fields fr... |
79629994e53654d6b8f014c0932662dcd289f5fb | sunminnies/python3 | /05list.py | 4,598 | 3.890625 | 4 | # 파이썬 리스트
attendList = ['순철','병헌','민우','찬호','민태']
print(attendList)
numbers = [1,2,3,4,5,6,7,8,9]
print(numbers)
complex = [1, 2.0, 3.1415, 40, '5', "6"]
print(complex)
for data in numbers: # iterable
print(data)
for data in complex:
print(data)
len(numbers)
msg = 'Hello, World!'
len(msg)
# 메세지 입력받고 ... |
8cb87158bddbbfb99bf494811bfd911874eab124 | JyHu/PYStudy | /source/sublime/QuesIn2CTO/ques18.py | 617 | 3.953125 | 4 | #coding:utf-8
'''
题目:求s=a+aa+aaa+aaaa+aa...a的值,其中a是一个数字。例如2+22+222+2222+22222(此时共有5个数相加),几个数相加有键盘控制。
'''
import math
def simSum(num, nums):
assert ((nums < 0) or not isinstance(nums, (int, long)) or (num < 0) or not isinstance(num, (int ,long))), "错误的数据类型"
# if (nums < 0) or not isinstance(nums, (int, long... |
4a673877070d7a9d9cd6e370062449c8d18fadeb | daianasousa/Gerador-de-Comprimentos | /personalizacao_de_comprimentos.py | 1,453 | 4.125 | 4 | from random import *
executa = True
adjetivos = [ "maravilhoso", "acima da média", "excelente" ]
hobbies = ["andar de bicicleta", "programar", "fazer chá" ]
print("Gerador de Cumprimentos")
print("--------------------")
nome = input("Qual é o seu nome?: ")
print('''
Menu
c = obter cumprimento
a = adicionar hobby
d ... |
4a9a02bfc0a4543efca9c67ad95b1b40be3191fd | goagain/Contests | /codeforces/1058/D/d.py | 794 | 3.609375 | 4 | import math
line = input().split()
n = int(line[0])
m = int(line[1])
k = int(line[2])
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, (a % b))
target = n * m * 2 // k
if n * m * 2 % k or k < 2:
print("NO")
else:
target = int(target)
exgcd = gcd(target, n)
if exgc... |
ad41e7ad6ec43b090ce51192781d785353be497a | fredkeemhaus/zero_base_algorithm | /algo/4-3.py | 883 | 3.515625 | 4 | def solution(a):
match = ''
stack = list()
# print(a)
for index in range(len(a)):
left, right = '', ''
# stack이 비어있을 경우 일단 문자열 하나를 추가한다
if len(stack) == 0:
stack.append(a[index])
else:
# left > 스택에 들어있던 문자열
# right > 스택에 넣으려고 했던 문자열
... |
e16e3716d08cc0c0826127c6a67882e261689d33 | ysmintor/MLAlgorithm | /work23/LeetCode66.py | 1,369 | 4 | 4 | from typing import List
# 66. Plus One
# Given a non-empty array of digits representing a non-negative integer, plus one to the integer.
#
# The digits are stored such that the most significant digit is at the head of the list, and each element in the array contain a single digit.
#
# You may assume the integer does no... |
dd86a5e2219834d137099b9d103506de318489dd | Hishikoz/vscode2019 | /python/006 function.py | 1,009 | 4.21875 | 4 | # 在参数名前面的*表示args是一个可变参数
# 即在调用add函数时可以传入0个或多个参数
def add(*args):
total = 0
for val in args:
total += val
return total
print(add())
print(add(1,2,3))
def is_palindrome(num):
temp = num
total = 0
while temp > 0:
total = total *10 + temp % 10
temp //=10
return total ==... |
b9a3ce444339451026d9d55cb755cae739d56e70 | xiaochenai/leetCode | /Python/Text Justification.py | 953 | 3.5 | 4 | class Solution:
# @param words, a list of strings
# @param L, an integer
# @return a list of strings
def fullJustify(self, words, L):
res = []
i = 0
while i<len(words):
size=0
begin=i
while i < len(words):
newsize = len(words[i]) if size==0 else size+len(words[i])+1#count in at least ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.