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 |
|---|---|---|---|---|---|---|
59ef10a8db6a7d42139753804685bc65326e9f4e | r4ghu/CSC564-Concurrency | /Assignments/Assignment1/python/src/readerWriter2.py | 1,580 | 3.53125 | 4 | """
Writer-priority Readers Writers
In this solution, we give priority to writer.
i.e., If one writer enters the critical section, no orther reader will
be allowed.
"""
from readerWriter import LightSwitch
from utils import Semaphore, Thread, execution_manager
import time
import random
score = 0
num_writers = 5
num_r... |
525f79074a02078edbeecc567d06f1770ed4a7b1 | light-weaver/MultiClassClassification | /Classification with costs and features.py | 2,966 | 3.515625 | 4 | """Conduct multi-class classification."""
from MultiClassClassification import multi_class_classification
import numpy as np
import pandas as pd
from sklearn.ensemble import BaggingClassifier as BC
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix
data = pd.read_csv("f... |
796c1c2cbfbda7d4fa198def44daf83998b9d1c2 | swaya7842/Python_Fundamentals | /Face_Recognition/FaceRecognition.py | 1,748 | 3.5 | 4 | import face_recognition as fr
from PIL import Image, ImageDraw #This pillow libary is required for drawing rectangle around the face
pics = fr.load_image_file('E:\\Python SEED\\Face_Recognition\\Unknown_Faces\\grup3.jpg') #Load the Image
face_loc = fr.face_locations(pics) #To find out the number of faces and its c... |
da149a930fc3b3a09650d67cd2de5064ec3c514b | hanwuji621/Computer-Network-and-Protocol | /Basic_Socket_Programming/Original/Muti-threaded_TCP_echo_server.py | 1,318 | 3.5625 | 4 | #!/usr/bin/python
'''
This is basically the same as the previous TCP echo server, but using threads
to handle multiple client connections
'''
import sys
from socket import *
from thread import *
myHost = '' # Symbolic name meaning all available interfaces
myPort = 8000 # Arbitrary non-privileged po... |
009e7d5d937cd40e6bfa66536a44201367c8f809 | josephdannemiller/News-Database-Reporting-Tool | /reporting_tool.py | 1,510 | 3.6875 | 4 | #! /usr/bin/env python2
import psycopg2
DBNAME = 'news'
def run_query(query):
'''Connects to the database and runs the query that is provided
as an argument. Returns the result of the query.'''
db = psycopg2.connect(dbname=DBNAME)
c = db.cursor()
c.execute(query)
results = c.fetchal... |
0e18f341ebe6a63f21fe0c296db2dea365fe3c6a | pawel-czarnecki/simple-rest-api | /reader.py | 974 | 3.609375 | 4 | import yaml
class Reader:
"""Implementation of YML file reader."""
def __init__(self, file_name='config.yml'):
self.__file_name = file_name
def read_yml(self):
"""
:return: Dictionary of all branches
"""
if not isinstance(self.__file_name, str):
raise T... |
9cbb0a2aa2cd2efde1fb8e4e69e7fbb022f4ff43 | SzymonStanczyk/excellentnumber | /exellentnumber.py | 1,466 | 3.59375 | 4 | import tkinter as tk
def check(entry):
try:
x = int(entry)-1
tab = []
while x:
x = x-1
if x != 0:
R = int(entry)%x
if R == 0:
tab.append(x)
if sum(tab) == int(entry):
label.con... |
aebb6ca872a62818c2bc83ee6616fabd6069e552 | kirito-k/Programming-Samples | /sentenceReverse/sentenceReverse.py | 1,602 | 3.84375 | 4 | """
File name: sentenseReverse
Language: Python3
Aurhor: Devavrat Kalam
Description: Given a list of space seperated characters, return reversed list of words in form of characters
"""
from typing import List
def reverse_words(arr: List[str]) -> str:
answer = []
start = None
for index in ... |
1358f5ab332abf8d3837b1218ac1d4f60b880a98 | kirito-k/Programming-Samples | /powerful_int/powerful_int.py | 1,654 | 3.9375 | 4 | """
File name: powerful_int.py
Authod: Devavrat Kalam
Language: Python 3.x
Description: Given x, y, bound, find out which of the numbers formed by x^i + y^j which are less than equal to bound
Time Complexity: O(a * b) where a and b are i max and j max respectively
"""
from typing import List
def ... |
8205305beae807db7b0c670d9e578b8c83762f51 | kirito-k/Programming-Samples | /sortedHasSum/sortedHasSum.py | 1,039 | 3.96875 | 4 | """
File name: sortedHasSum.py
Language: Python3
Author name: Devavrat Kalam
Description: In given sorted array, find if a pair exists whose sum is equal to given number x, in O(n).
No hash data structures allowed.
"""
from typing import List
def sortedHasSum(s: List[int], x: int) -> ... |
4700bb8c31594d76a2f4e96994cf0607fe02d50c | samanthagatt/Graphs | /projects/graph/src/graph_demo.py | 939 | 4.03125 | 4 | from graph import Graph
"""
Demonstration of Graph functionality.
"""
from sys import argv
def main():
graph = Graph()
graph.add_vertex('0')
graph.add_vertex('1')
graph.add_vertex('2')
graph.add_vertex('3')
graph.add_vertex('4')
graph.add_vertex('5')
graph.add_vertex('6')
graph.a... |
6a4156937d7da2fb47e0c9a4974a1ba62b545fbb | meteorfox/beaglebone-black-examples | /blink_led.py | 897 | 3.828125 | 4 | #!/usr/bin/env python
'''
Flashes on and off LED USR0.
Takes two arguments 'count' and 'period'.
'count' is an integer representing number of times LED cycles on and off.
'period' is a float representing the delay between on->off and off->on cycle.
IMPORTANT: Requires root privileges
Author: Carlos L. Torres 2017
'... |
b5be48b7e8b83d20d54ec317ed006dd229dec8aa | Ni3nayka/vanya_pingpong | /Egor/graphics.py | 2,312 | 3.515625 | 4 | from tkinter import *
#graphics_version = "1.0"
class coo:
def __init__(self,x,y):
self.x = x
self.y = y
class Graphics:
def __init__(self,AREA_X,AREA_Y):
self.window = Tk()
self.window.title('graphics_area')
self.canvas = Canvas(self.window,width=AREA_X,height=AREA_... |
d863f850a1410e6249a37ae2c4e6dc7da2796c33 | alejandrakudo/BinarySearch-Sorting | /CISC121_Assignment_4_sampleSolution.py | 5,123 | 4.09375 | 4 | ### Example solution for assignment 4 - CISC 121 Fal 2016
##### Task 1
def binarySearch(lst, target):
### init low and high at each end of list
low = 0
high = len(lst)-1
## search until either target found or search list empty
while high >= low:
mid = (high + low)//2
if target < ... |
28781da729cd078c4accfe5bbb082130be452640 | kai0511/MIT6.00.2x | /quiz/song_playlist.py | 1,106 | 3.765625 | 4 | def song_playlist(songs, max_size):
"""
songs: list of tuples, ('song_name', song_len, song_size)
max_size: float, maximum size of total songs that you can fit
Start with the song first in the 'songs' list, then pick the next
song to be the one with the lowest file size not already picked, repeat
... |
40f687383120f5b5279909d4dfc26a9a55f1e6dd | danielsuarez02/curso | /proyecto/quicksort.py | 419 | 3.96875 | 4 | def quicksort(lista,inicio,fin):
if inicio==fin:
return
for i in range(inicio,int(fin/2)):
if lista[i]>lista[fin-i]:
lista[i],lista[fin-i]=lista[fin-i],lista[i]
print(lista)
quicksort(lista,inicio,int(fin/2))
quicksort(lista,int(fin/2),fin)
lista=[2,5,1,4,9,7,8,6] #list(map(int,input("Dame una lista de ... |
0b0e136989d10c62f9da5c38041211552bda726b | danielsuarez02/curso | /proyecto/problema2.py | 191 | 3.609375 | 4 | #recibir varias palabras y devolver la mas larga
lista=input("Dame varias palabras: ").split(" ")
i=0
for n in range(0,len(lista)):
if len(lista[n])>len(lista[i]):
i=n
print(lista[i]) |
1abb1eb788e6a6e5547ec1d88ac238a800a15189 | zhulingxi/Zhulingxi | /RumbleStripCode/SounPlTxt.py | 651 | 3.546875 | 4 | #input the sound file only the \ and the file name without the extension
FileName=input("Please input the sound file that you wish to deal with:\n")
SoundFile="C:\Users\lzz0032\Documents\RumbleStrip\Data\sound"+FileName+".txt"
#deal with the sound data
Stxt=open(SoundFile)
Sdata=[]
for line in Stxt:
Sdata.appen... |
34000f83f3f401be7fccebfdca669817e0497407 | Zeeshan-Saleem/assignment1-2 | /Addition.py | 169 | 3.53125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[13]:
a= float(input('enter 1st num'))
b= float(input('enter 2nd num'))
c= a+ b
print ("sum is " + str(c))
# In[ ]:
|
c9aa1c4ac2dd6f3f6f6e51fef266e664f3a943ee | alexthomas2020/Banking | /Banklog.py | 1,062 | 3.5625 | 4 | # Banking Application
# Author: Alex Thomas
# Updated: 11/08/2020
import logging
"""
Banking Application - Logger. This can be invoked from other files.
# ****Log Params Captured*****
# asctime - Human-readable time when the LogRecord was created
# filename - Filename portion of pathname.
# funcName - Name of functio... |
ccb56373dde67a27e4c4bfabd234b6d0a310cf86 | alexthomas2020/Banking | /test_Account.py | 2,028 | 4.3125 | 4 | # Banking Application
# Author: Alex Thomas
# Updated: 11/10/2020
import unittest
from Account import get_account, get_accounts, Account
"""
Banking Application - Unit tests for Account class.
Run this program to view results of the tests.
"""
class TestAccount(unittest.TestCase):
def test_get_account(self):
... |
f45ca50134705d8bb8b304a2da9515743956c095 | subinYoun/CodeUp-1001-1099- | /1080.py | 397 | 3.640625 | 4 | #1080.언제까지 더해야 할까?(입력이 도출될때까지 계속 더해주고 마지막에 더해준 값을 출력한다.
#입력 예시: 55 ->출력 예시: 10
a=input()
n=int(a)
i=0
s=0
while s < n: #s의 값이 n이 될 때까지 더해주는 것이므로 s<n을 해주면 마지막 반복문이 실행될때 s값이 목표치(n)에 도달하게 된다
i += 1
s += i
print(i) |
b85df643e36f29d4e0365f1e1a87a7295f8fdcb5 | stoyaneft/HackBulgariaProgramming-101 | /week0/1.Simpleproblems/is_increasing.py | 224 | 3.953125 | 4 | def is_increasing(seq):
for i in range(len(seq) - 1):
if seq[i] >= seq[i + 1]:
return False
return True
def main():
print(is_increasing([1, 3, 4, 2]))
if __name__ == '__main__':
main()
|
bc90acd6bce1cbf8142151fbfc4631db3b1e000d | stoyaneft/HackBulgariaProgramming-101 | /week1/1-Python-OOP-problems-set/CashDesk.py | 969 | 3.59375 | 4 | class CashDesk:
def __init__(self):
self.money = {100: 0, 50: 0, 20: 0, 10: 0, 5: 0, 2: 0, 1: 0}
def take_money(self, money):
for note in money:
self.money[note] += money[note]
def total(self):
total_money = 0
for note in self.money:
total_money += ... |
78bacf7f42cf6e31b6f46fa1150bfdf7f34566d8 | stoyaneft/HackBulgariaProgramming-101 | /week0/2.Harder_problems/member_of_nth_fib_lists.py | 509 | 3.78125 | 4 | from nth_fib_lists import nth_fib_lists
def member_of_nth_fib_lists(listA, listB, needle):
if listA == needle or listB == needle:
return True
fib_num = 3
current_fib_list = nth_fib_lists(listA, listB, fib_num)
while len(current_fib_list) <= len(needle):
if needle == current_fib_list:
... |
645fb30ada4f767e7129fb0d0954c1dd5011cb0b | stoyaneft/HackBulgariaProgramming-101 | /week0/1.Simpleproblems/is_decreasing.py | 224 | 3.890625 | 4 | def is_decreasing(seq):
for i in range(len(seq) - 1):
if seq[i] <= seq[i + 1]:
return False
return True
def main():
print(is_decreasing([1, 1, 1, 1]))
if __name__ == '__main__':
main()
|
027b22e0996bedf3cf7710cea6e3eb0e1b7372d4 | stoyaneft/HackBulgariaProgramming-101 | /week0/1.Simpleproblems/zero_insert.py | 540 | 3.703125 | 4 | from number_to_list import number_to_list
from list_to_number import list_to_number
def zero_insert(n):
digits = number_to_list(n)
zero_inserted_digits = list(digits)
counter = 0
for i in range(len(digits) - 1):
if digits[i] == digits[i + 1] or (digits[i] + digits[i + 1]) % 10 == 0:
... |
3bf677e5a1212e9da159accadd00855ce1a38751 | stoyaneft/HackBulgariaProgramming-101 | /week0/2.Harder_problems/goldbach.py | 436 | 3.578125 | 4 | def is_prime(n):
n = abs(n)
if n == 1:
return False
else:
for divisor in range(2, int(n ** 0.5) + 1):
if n % divisor == 0:
return False
return True
def goldbach(n):
prime_numbers = list(filter(is_prime, range(2, int(n // 2 + 1))))
gb_conjecture =... |
16fd8ca6da00156151482cecfeaf0c6e9d008361 | stoyaneft/HackBulgariaProgramming-101 | /week0/2.Harder_problems/is_an_bn.py | 104 | 3.875 | 4 | def is_an_bn(word):
length = len(word)
return word == 'a' * (length // 2) + 'b' * (length // 2)
|
d4b09c8dcfd1163b48ab94bdcb1fce4b5d97e03c | stoyaneft/HackBulgariaProgramming-101 | /week0/1.Simpleproblems/is_int_palindrome.py | 235 | 3.984375 | 4 | def is_int_palindrome(n):
num_to_string = str(n)
reversed_num = ''.join(reversed(num_to_string))
return reversed_num == num_to_string
def main():
print(is_int_palindrome(11011))
if __name__ == '__main__':
main()
|
41aef41ec292cc83388d4119f2ecf5cf12812e77 | matthew02/project-euler | /p007.py | 545 | 3.84375 | 4 | #!/usr/bin/env python3
"""Problem 7 from Project Euler.
Find the nth prime number.
https://projecteuler.net/problem=7
Usage:
python3 p0007.py [number]
"""
import sys
from itertools import islice
from typing import Iterator
from euler import get_primes
def nth(iterable: Iterator, n: int):
"""Returns the ... |
6966ec8f669922fa1a78661630eb6732ba5b549a | matthew02/project-euler | /p005.py | 820 | 4.1875 | 4 | #!/usr/bin/env python3
"""Project Euler Problem 5: Smallest multiple
Find the smallest positive number that is evenly divisible by all of the
numbers from 1 to 20.
https://projecteuler.net/problem=5
Usage:
python3 p0005.py [number]
"""
import sys
from math import gcd
from typing import List
def smallest_multi... |
ade9f1bac5f95f330ba644593ba109c693f4640e | Jacobsmi/car_web_scraper | /App/user_parameters.py | 1,177 | 3.734375 | 4 | '''
In this module we will set user parameters to be checked against once information has been retrieved and parsed
'''
class User_Params:
def __init__(self):
self.LOW_PRICE = -1
self.HIGH_PRICE = -1
self.LOW_MILEAGE = -1
self.HIGH_MILEAGE = -1
self.EARLIEST_YEAR = -1
... |
68faac6543b6ddbe84dfcbac3257e38f33b4fbaa | Praz314159/Predicting_COVID19_Research_Influence | /build_coauthor_network.py | 3,766 | 3.6875 | 4 | '''
This code is meant to build a coauthor network using the COVID19 paper data set provided by the CDC
'''
import pandas as pd
import numpy as np
import string
import networkx as nx
import matplotlib.pyplot as plt
#first thing's first --> we want to read in the excel file and isolate the authors column
data = ... |
0199d6c494adb5515afe966ecc2dc3d96e49a386 | nikhilpi-zz/honeycombWordsearch | /dictionary.py | 366 | 3.9375 | 4 |
class Dictionary:
tree = None
def setup(self, words):
self.tree = self.make_trie(words)
def make_trie(self, words):
root = dict()
for word in words:
current_dict = root
for letter in list(word):
current_dict = current_dict.setdefault(letter, {})
current_dict = current_dict... |
7605cdead884bf91803f803b12eb2b048df73f8e | abbas-malu/python-notebooks | /home_system/matrix_multiplication.py | 1,150 | 4.0625 | 4 | row1 = int(input('Enter No of rows for first matrix: '))
col1 = int(input('Enter No of columns for first matrix: '))
row2 = int(input('Enter No of rows for second matrix: '))
col2 = int(input('Enter No of columns for second matrix: '))
if col1==row2:
mat1 = []
for i in range(row1):
col = []
for ... |
5b65d8cf38956db3dbda2872096049f06f7fa24d | coutino568/Proyecto_2 | /mathcou.py | 481 | 3.515625 | 4 | array1 = [4,-2,6]
array2 = [8,0,1]
array3 = [[0,1],[5,9]]
array4 = [[5,6],[8,11]]
def dotProductVectors(A, B):
resultado = 0
if len(A)== len(B):
print ("Same lenght on rows")
for item in range (0,len(A)):
resultado += A[item]* B[item]
print(resultado)
else:
print("Not the same lenght")
def matrixMulti... |
28838dbdefd15ced688656fba787d51305c7a836 | aqibbangash/searchbyimage-django | /cocktails/convertIngredients.py | 284 | 3.515625 | 4 |
class convertIngredients:
def run(string):
dict = {}
list = string.split(',')
for s in list:
s = s.split(':')
dict[s[0].strip()] = s[1].strip()
return dict
# return example {'Dry Vermouth': '1 part', 'Vodka': '2 parts'}
|
df6163ca6c71f566b989a15bc331f8fb402e0f86 | nix00000/Python-Projects | /FinanceApp/App/database.py | 655 | 3.5625 | 4 | import sqlite3
import csv
import sys
conn = sqlite3.connect('comp.db')
c = conn.cursor()
# c.execute("""
# CREATE TABLE companies (
# inds text,
# name text)
# """)
# data = open("comapniesBS.csv", "r")
# normal = []
# for d in data.readlines():
# p,r = d.split("\n")
# normal.a... |
72a6259e2d6a732a8dfaa954d3e3a32bf4669140 | yaHaart/hometasks | /Module20/06_pairs/main.py | 436 | 3.859375 | 4 | origin_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
new_list = list()
temp_list = list()
new_list1 = list()
for i in range(0, len(origin_list), 2):
temp_list.append(origin_list[i])
temp_list.append(origin_list[i + 1])
new_list.append(tuple(temp_list))
temp_list.clear()
print(new_list)
for i in range(0, len(... |
0e95436f7cef9f1bc87c4b3ac91f89700011f09b | yaHaart/hometasks | /Module19/02_geography/main.py | 1,000 | 3.6875 | 4 | number_countries = int(input('Кол-во стран: '))
countries_dict = dict()
for i_country in range(number_countries):
user_input = input(f'{i_country + 1} страна: ')
user_dict = user_input.split()
if countries_dict == {}:
countries_dict = {user_dict[0]: [user_dict[i] for i in range(1, 4)]}
else:
... |
3b6dce209cc8690c8c95e657893854655b5e5f73 | yaHaart/hometasks | /Module19/07_pizza/main.py | 1,063 | 3.828125 | 4 | db = dict()
n = int(input('Число заказов? '))
for _ in range(n):
# TODO Лучше сразу разложить данные по переменные - это удобно и индексы тогда будут читаемые.
# customer, pizza_name, count = input(f'{_ + 1} заказ: ').split()
user_input = input('Введите заказ ').split()
if user_input[0] not in db:
... |
675b3a5221d1b53ba53dcd613ded15c51fd0ae5b | yaHaart/hometasks | /Module19/04_goods/main.py | 948 | 3.828125 | 4 | goods = {
'Лампа': '12345',
'Стол': '23456',
'Диван': '34567',
'Стул': '45678',
}
store = {
'12345': [
{'quantity': 27, 'price': 42},
],
'23456': [
{'quantity': 22, 'price': 510},
{'quantity': 32, 'price': 520},
],
'34567': [
{'quantity': 2, 'price': ... |
86b7f1bc3ab068775439ceff32a8bde5fc51f5b4 | yaHaart/hometasks | /Module20/01_code_review/main.py | 912 | 3.78125 | 4 | students = {
1: {
'name': 'Bob',
'surname': 'Vazovski',
'age': 23,
'interests': ['biology', 'swimming']
},
2: {
'name': 'Rob',
'surname': 'Stepanov',
'age': 24,
'interests': ['math', 'computer games', 'running']
},
3: {
'name': ... |
99830f591829afbf9affcc2f61e661736d3fc387 | yaHaart/hometasks | /Module16/08_rhyme_cnt/main.py | 659 | 3.65625 | 4 | n_people = 5
count_out = 3
people = list(range(1, n_people + 1, 1))
start_count = 0
for _ in range(n_people - 1):
print('Текущий круг людей: ', people)
print('Начало счёта с номера ', people[start_count])
i_out = (start_count - 1 + count_out)
while i_out >= len(people):
i_out = i_out - len(peopl... |
a5d1b95b992613d8e573360803bae80890431195 | yaHaart/hometasks | /Module17/09_list_of_lists_2/main.py | 327 | 3.546875 | 4 | nice_list = [[[1, 2, 3], [4, 5, 6], [7, 8, 9]],
[[10, 11, 12], [13, 14, 15], [16, 17, 18]]]
new_list = [nice_list[x][y][z]
for x in range(len(nice_list))
for y in range(len(nice_list[0]))
for z in range(len(nice_list[0][0]))
]
print(new_list)
# зачёт! 🚀
|
7ecd7b3ee4f714573d899107fe04e6108b5a1d63 | yaHaart/hometasks | /Module17/06_list_compression/main.py | 321 | 3.890625 | 4 | numbers = [1, 2, 0, 2, 5, 0, 4, 2, 1, 0]
zero_count = numbers.count(0)
zip_numbers_with_0 = [x for x in numbers if x != 0]
for _ in range(zero_count):
zip_numbers_with_0.append(0)
print(zip_numbers_with_0)
zip_numbers = zip_numbers_with_0[:len(zip_numbers_with_0) - zero_count]
print(zip_numbers)
# зачёт! 🚀
|
b106295fc94ce7b8593e5b7af6f10ebb06b85aa4 | yaHaart/hometasks | /Module15/08_running_nums/main.py | 327 | 3.8125 | 4 | base_list = [1, 2, 3, 4, 5]
new_list = []
k = int(input('Сдвиг: '))
while k > len(base_list):
k -= len(base_list)
for i in range(len(base_list)):
new_list.append(base_list[i - k])
print('Изначальный список: ', base_list)
print('Сдвинутый список: ', new_list)
# зачёт! 🚀
|
5e8d00838e9a82b03de35bf595a3b140bfe5baa1 | yaHaart/hometasks | /Module21/03_fibonacci/main.py | 275 | 4.125 | 4 | index_number = 7
# 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233
def fibonacci(n):
if n <= 1:
return n
else:
return fibonacci(n-1) + fibonacci(n-2)
print(index_number, '-ый элемент ряда ', fibonacci(index_number))
# зачёт! 🚀
|
3d8813c43d8f57d133fb2f487cd15f65b9a59106 | gabrielbessler/ProgrammingCompetition | /AI18/AI18_1.py | 1,422 | 4.65625 | 5 | #!/bin/python3
import sys
'''
Problem Statement
You have been given an integer which represents
the length of one of cathetus of a right-angle triangle.
You need to find the lengths of the remaining sides.
There may be multiple possible answers; any one will be accepted.
'''
def pythagorean_triple(side... |
285c2b0c370899417eab292dbcbeaf7aa66f2522 | gabrielbessler/ProgrammingCompetition | /WoC33/WC33_3.py | 4,290 | 3.921875 | 4 | #!/bin/python3
import sys
import random
import time
from collections import defaultdict
'''
Problem Statement
Given a string, we want to find the longest palindrome subsequence
Constraints
n letters in our alphabet - up to 100,000
m is the # of integers we have - up to 1000
a are the starting numbe... |
801f77f1be2da2174303341dbfa03fd2e159201b | vijaykumarvg1/Scalable-FPGA-design-Tool-Flow | /src/tripleDES.py | 2,957 | 3.515625 | 4 | #!/usr/bin/env python
import os
import fileinput
import sys
from fast_tlutmap import run
print("Welcome to programme *** Generate Scalable VHDL design ***\n\n ")
# Asking Enter file name from user
while True:
try:
print("Enter the file name followed by .vhd: ")
filein = raw_input(">>> ")
... |
2903075b35a525c408fac8e42ae93e0c2581c63d | dudisgit/PaPiRus-boardGames | /games/2048.py | 8,496 | 3.734375 | 4 | from random import randint
class Main():
def __init__(self,game,exitGame):
game.downBind[0] = self.moveLeft
game.downBind[1] = self.moveUp
game.downBind[2] = self.button_3
game.downBind[3] = self.moveDown
game.downBind[4] = self.moveRight
self.scr = game
self... |
379c5421abc1e8f31dad7eb57e5cace766f92822 | dudisgit/PaPiRus-boardGames | /games/sudoku.py | 12,826 | 3.5625 | 4 | #Idk the name of this game
from random import randint
import pickle
class Main():
def __init__(self,game,exitGame):
self.scr = game
self.exitGame = exitGame
game.downBind[0] = self.nextIn
game.downBind[1] = self.nextOut
game.downBind[2] = self.increment
game.downBind... |
60e13ba060f0b1f56c9b92bef3224d7d922ddb80 | sungakim816/TrieDataStructure | /main.py | 351 | 3.828125 | 4 | from trie.trie import Trie
words = ['hell', 'apple pie', 'help', 'health', 'hello', 'hello world', 'apple', 'orange', 'heat', 'heal']
def main():
trie = Trie()
test_input = 'he'
trie.populate(words)
suggestions = trie.suggestions(test_input)
for word in suggestions:
print(word)
if __na... |
971eb97553fcfcdf304155f3eb6793b0428c292c | tuantt98/data-structures-and-algorithms | /fibonacci.py | 425 | 3.96875 | 4 | def fibonacci(num, dic):
key = str(num)
if key in dic:
return dic[key]
if num < 1:
return 0
if num < 2:
return 1
result = fibonacci(num-1, dic) + fibonacci(num-2, dic)
dic[key] = result
return result
myDic = {}
print(fibonacci(1000,myDic))
# i = 0
# mStr = ''
# whi... |
3ad65a370e54d39bb1da4c01dce63c4140209473 | KeikeiSo/Python_Tkinter | /hello.py | 265 | 3.890625 | 4 | """
Created on Sat Dec 26 12:08:28 2020
@author: callia
"""
import tkinter as tk
root = tk.Tk()
for i in range(10):
for j in range(10):
mylabel = tk.Label(root, text = "p" + str(i) + str(j))
mylabel.grid(row = i, column = j)
root.mainloop()
|
85f848d0e6e073ec282e96cb98481eda112c43e4 | dstamp1/FF-BoA-2020 | /day01/day01c-ForLoops.py | 2,787 | 4.6875 | 5 | ### For Loops ###
# Computers are really good at repeating the same task over and over again without making any mistakes/typos
# Let's imagine we were having a competition to see who could type out "print('hello')" as many times as we could without using copy and paste.
# We might type out
print('hello')
print('hello'... |
2287249506107bb7d4d3f1ddb5aab246baf58b61 | chrislloyd19/algorithm_practice | /insertion_sort.py | 289 | 4 | 4 | def insertion_sort(unsorted):
for i,c in enumerate(unsorted):
while i > 0:
if c < unsorted[i-1]:
# swap
temp = unsorted[i-1]
unsorted[i-1] = c
unsorted[i] = temp
i -= 1
return unsorted
|
d046075944390be63c59e666fd5624ccbb2e04bb | leongege/python | /day5_3/while2text.py | 435 | 3.65625 | 4 | #!/usr/bin/pyenv python
# -*- coding:utf-8 _*_
__author__ = "leon"
name = input("uname")
password = input("pswd")
sum = 0
while True:
if name == "tom" and password == "123":
print("successful")
break
else:
sum += 1
print("shibaicishu%s" %sum)
name = input("uname")
... |
5745bc25f3f6082a94a9fccfebfdcb323799797a | Aquaveo/xmsmesher | /_package/xms/mesher/meshing/poly_redistribute_points.py | 3,147 | 3.578125 | 4 | """Class for redistributing the points of a polygon."""
from .._xmsmesher.meshing import PolyRedistributePts as RedistPoints
class PolyRedistributePoints(object):
"""Class for redistributing the points of a polygon."""
def __init__(self, **kwargs):
"""Constructor.
Args:
**kwargs (... |
b2f7c7d70446879eef1adab0fcede98056238108 | Rarepepe720p/pyos | /os.py | 1,454 | 3.5625 | 4 | import os
import platform
def getarg():
arg = input()
if arg == "dir":
os.system("dir")
getarg()
elif arg == "cd":
os.system("cd")
getarg()
elif "print" in arg:
prst = input("Statement: ")
print(prst)
getarg()
elif "echo" in arg... |
b7889e6e5f68f3016889164a49452674aead24c5 | kammitama5/Inter-ctive-Python | /_011.py | 509 | 4.09375 | 4 | import math
def squareroot(n):
for n in range(1, 10):
print("square root is %.2f for value %d"%(n ** .5, n))
print(squareroot(2)) # --> just a pass through
# prints
# square root is 1.00 for value 1
# square root is 1.41 for value 2
# square root is 1.73 for value 3
# square root is 2.00 f... |
0dd9235ca0a01600ed7d7010159c3e8ea812b7a8 | KfirWilfand/Bootcamp | /week9/ex2.py | 429 | 3.8125 | 4 | def find_max(list,index):
if index == len(list):
return 0
nextItem = find_max(list, index + 1)
return nextItem if nextItem > list[index] else list[index]
assert(find_max([1, 2, 3], 0) == 3)
assert(find_max([100, 2, 100], 0) == 100)
assert(find_max([], 0) == 0) # what is your return value for empty l... |
add4b7aa4d2515355113944402a0cecbeb2f6a41 | Shoaibkhalid16/Round-Robin | /Round robin.py | 1,778 | 3.53125 | 4 | print(" This Is Round Robin Process")
size = int(raw_input("Enter How many Process you want to Enter ??"))
process = [0] * size
arrival = [0] * size
burst = [0] * size
totaltime = 0
for i in range(size):
process[i] = (raw_input("Enter process name"))
arrival[i] = int... |
4c61cb6e8d5338711e83d60a229b1f59c02d50b3 | Bogdii-15/HillelHomework | /Homework5.py | 1,775 | 3.921875 | 4 | from random import randint
#value = randint(1, 200)
#print('Если меньше 100,то равно половине значения value, в противном случае - противоположне value число')
#if value < 100:
# new_value = value / 2
# print('Цисло: ', value)
# print('Половина значения value: ', new_value)
#else:
# new_value = value * 2
# ... |
bfdc54f3d179befa3a6b34a70ceedcf7a6d2f87f | NoVa365/Games-Programming | /Assignment1-1st draft.py | 5,512 | 3.984375 | 4 | # This variable sets up the core game loop, this line states that the player is not dead at the start of the game.
dead = False
# This whole part is a function that plays out when a certain decision is made later on in the game.
def yourself():
print("You draw your handgun and slowly traverse your way u... |
073a59e2adb3eb72d3a0e1fc1ae186f7c01ac100 | AkshitCalonia/Basic-Reminders | /MainCode.py | 2,827 | 3.6875 | 4 | import time
import datetime
from pygame import mixer
initial2 = time.time()
for i in range(15):
# 15 times loop will repeat bcz its 9 to 5 job and the reminder will come in every 30 minutes between 9 a.m. and 5 p.m. in 16 segments
time.sleep(1800)
#its 1800 actually
# Starting the mixer
mixer.in... |
7a4b3aa644632ee1830efb12ce24d3c66fe6b842 | rezende-marcus/script-python | /teste01.py | 130 | 3.671875 | 4 | nome = input('Qual é seu Nome?')
idade = input('Quantos anos voce tem?')
peso = input('Qual seu peso?')
print(nome, idade, peso)
|
1e8b745bf92fb97571e3a759baae50816e974c09 | anajulianunes/aprendendo-python | /Curso-python-iniciante/Projetos do Curso em Vídeo/aula8/aula08g - sorteioitem.py | 294 | 3.796875 | 4 | from random import choice
a1 = input('Primeiro aluno: ')
a2 = input('Segundo alunno: ')
a3 = input('Terceiro aluno: ')
a4 = input('Quarto aluno: ')
# pra fazer lista coloca entre chaves
lista = [a1, a2, a3, a4]
escolhido = choice(lista)
print('O aluno escolhido foi: {}!'.format(escolhido))
|
16570a95496271887a2cbece3dac71f85065da78 | anajulianunes/aprendendo-python | /Curso-python-iniciante/Projetos do Curso em Vídeo/aula7/aula07g.py | 138 | 3.546875 | 4 | carteira = float(input('Quando vc tem na carteira? R$'))
print('Com R${:.2f} vc pode comprar U${:.2f}'.format(carteira, carteira / 5.32))
|
59beddfb8fa59f5c83a7cf502548f99356d1169c | anajulianunes/aprendendo-python | /Curso-python-iniciante/Projetos do Curso em Vídeo/aula7/aula07a.py | 320 | 4 | 4 | a = int(input('Digite um número: '))
b = int(input('Digite outro número: '))
s = a + b
d = a - b
m = a * b
div = a / b
p = pow(a , b)
di = a // b
r = a % b
print('A soma é {},\na diminuiçao é {},\na multiplicaçao é {}.'.format(s, d, m, div), end=' ')
print('A divisao inteira é {}, o resto é {}'.format(di, r))
|
43e6b014cd9e53fd21794668a77fde252063dd5c | anajulianunes/aprendendo-python | /Curso-python-iniciante/Projetos do Curso em Vídeo/aula9/9c - separa digitos de um numero.py | 280 | 4.21875 | 4 | numero = int(input('Insert a number: '))
u = numero // 1 % 10 #pega um número divide por 1 e depois por 10 e pega o resto da divisao
d = numero // 10 % 10
c = numero // 100 % 10
m = numero // 1000 % 10
print('Unidade: {}\nDezena: {}\nCentena: {}\nMilhar: {}'.format(u,d, c, m))
|
59654925f2361aab3d595446e97ebab06d75ea90 | anajulianunes/aprendendo-python | /Curso-python-iniciante/Projetos PUC PR/ATP1 - raciocinio computacional/ATP1 - raciocinio computacional.py | 3,030 | 3.890625 | 4 | # Esta é a atividade prática da máteria de Raciocínio Computacional da PUC PR
# ETAPA 1
# Conforme pedido vamos iniciar mostrando meu nome completo e o nome da minha loja
print('-=-'*20)
print("\33[1:35:40mOlá! Bem-vindo à loja da Ana Julia Nunes de Araujo\033[m")
print('-=-'*20)
print("Vamos iniciar sua análise de cr... |
a7d42f092467f23525ec7269cf8e586e0733914d | oampo/thinkful_bicycle_industry | /customer.py | 1,180 | 4 | 4 | from errors import InsufficientFundsError
class Customer(object):
""" A bike shop customer """
def __init__(self, name, money):
"""
Constructor
Args:
name: The name of the customer
money: The amount of money the customer has to spend on a bike
"""
... |
c59d35575a743a1ee4e2eedea1bacb6e2b203356 | oscarmendezm/baxter | /tennis_ball_sorter/PCA.py | 945 | 3.5 | 4 | import cv2 as cv
import Image
from matplotlib.mlab import PCA
import matplotlib.pyplot as plt
import numpy as np
def pca(image):
"""
Function to perform PCA on a passed in image
:param image:
:return:
"""
# PCA using OpenCV
# mean, eigenvectors = cv.PCACompute(image, np.mean(image, axis=0)... |
5d83f912b296770969348b3c8eb0403946514bd8 | sepandhaghighi/pycounter | /line_counter.py | 3,514 | 3.671875 | 4 | import os
import datetime
import platform
import string
def dash_print(file , length): # this function is for printing dash in the txt file
for i in range(length):
file.write("-")
file.write("\n")
def show(code_list): # this function print output
for i in code_list:
print(i)
def find_direc... |
ada59b93c132045eb73b8ee0438dea224bd4ef4f | cyrusaf/decision_tree | /modules/node.py | 2,653 | 3.546875 | 4 | # DOCUMENTATION
# =====================================
# Class node attributes:
# ----------------------------
# children - a list of 2 nodes if numeric, and a dictionary (key=attribute value, value=node) if nominal.
# For numeric, the 0 index holds examples < the splitting_value, the
# index hol... |
bae40fc0b28d48fde997f81c8bfd0a8b0f8245de | kimhg9511/Python_workspace | /pycharm/bigdata/12_closure.py | 928 | 4.03125 | 4 | # # 변수의 범위
# x = 10 # 전역 변수(global variable)
# def foo():
# x = 20 # 지역 변수(local variable)
# print(x) # 20
# foo()
# print(x) # 10
#
# def foo():
# x = 20
# y = 30
# return locals()
# dictTest = foo()
# print(dictTest['x'])
#
# # closure
# def calc():
# a = 3
# b = 5
# total = 0
# ... |
1e38a3b492df123086b3ce1028c97f6ba8720dae | kimhg9511/Python_workspace | /pycharm/bigdata/20_2_db_sqlite.py | 637 | 3.796875 | 4 | import sqlite3 as sqlite
data = []
datas = []
with sqlite.connect('testdb.sqlite') as conn:
# sql = """
# create table users(
# id integer not null primary key autoincrement,
# email varchar(255) not null,
# pw varchar(255) not null,
# );
# """
# cursor.ex... |
b8197ac544d29082c911e8a60dc567eb90cad5a0 | kimhg9511/Python_workspace | /pycharm/bigdata/02_tuple.py | 1,163 | 3.859375 | 4 | # # tuple() () 읽기모드 ArrayList index 0
# a = (10, "Python", True, 4.4, '50')
# print(a)
# print(type(a))
#
# # initialize
# a = (40,)
# print(a)
#
# # init + range()
# a = tuple(range(10))
# print(a)
# a = tuple(range(10, 0, -1))
# print(a)
#
# # list <=> tuple
# a = [1, 2, 3]0
# b = tuple(a)
# c = list(b)
# print(b)
# ... |
19e3f3f6eb59c38eaa77c53c9d7335c597f5b61f | kimhg9511/Python_workspace | /pycharm/bigdata/김현겸_sum_avg.py | 405 | 3.78125 | 4 | while True:
numbers = input('5개의 숫자를 띄어쓰기로 입력해 주세요.').split()
numbers = [int(number) if number.isnumeric() else 0 for number in numbers]
if numbers.count(0) > 0 or len(numbers) != 5:
print('다시 입력해 주세요.')
continue
break
numbersSum = sum(numbers)
print('합계 :', numbersSum)
print('평균 :', int... |
76b61c4dd5dc6291bedbe8c9046b9ef2e73a8610 | kimhg9511/Python_workspace | /pycharm/bigdata/05_if.py | 2,461 | 3.953125 | 4 | # x = 10
# if x == 10:
# print("10입니다.")
# elif x == 20:
# print("20입니다.")
# else:
# print("???")
#
# # A 기업의 입사 시험은 필기 시험 점수가 80점 이상 && 코딩 시험을 통과(True/False)해야 합격 / 불합격
# written_test = 75
# coding_test = True
# if written_test >= 80 and coding_test:
# print("합격")
# else:
# print("불합격")
#
# # 사용자 값... |
34667e063ec686d26779e1e7e885b4b5d248b319 | DavidLSmyth/TTTClientServer | /python_files/TTTPlayer.py | 568 | 3.53125 | 4 | from TTTBoard import TTTBoard
class TTTPlayer:
'''A class that represents a TTT player, used to provide basic functionality'''
def __init__(self, x_or_o):
self.TTTBoard = TTTBoard()
self.value = x_or_o
def make_move(self, move_index, x_or_o):
'''Returns true and makes move if vali... |
9ecf418e9cc56b222ac6bd93155e2767c76de353 | mayankp158/Data_Structure | /hackerrank.py | 1,627 | 3.59375 | 4 | # if __name__ == '__main__':
# x = int(input())
# y = int(input())
# z = int(input())
# n = int(input())
# arr = []
# for a in range(0,x+1):
# for b in range(0,y+1):
# for c in range(0,z+1):
# d = a+b+c
# if(d!=n):
# arr.app... |
6c18fe674794960666b39fcc98cabaf5d3149ea5 | Nasiya24/luminarpython | /pythoncollections/sumofnumbersuserinput.py | 375 | 3.921875 | 4 | #to input the list and find sum of numbers in list except one number and print them
limit=int(input("enter limit"))
lst=list()
for i in range(0,limit):
number=int(input("enter number"))
lst.append(number)
#finding total of list
#total=20
#20-2=18
#20-5=15
#20-6=14
#20-7=13
out=list() #empty list
total=sum(lst... |
a818291380bbc6e0aed33c2cb148c4982dbead54 | Nasiya24/luminarpython | /nas/sort3num.py | 103 | 3.84375 | 4 | num1=int(input("no1"))
num2=int(input("no2"))
num3=int(input("no3"))
if (num1>num2) & (num1>num3):
|
8c997e49168c94f312993b43f08b26c857579ba6 | vijaysharma1996/Python-LIst-Basic-Programmes | /list find the sum of element in list.py | 232 | 4.25 | 4 | # Python program to find sum of elements in list
# creating a list
list1 = [11, 5, 17, 18, 23]
# using sum() function
total = sum(list1)
# printing total value
print("Sum of all elements in given list: ", total)
|
56cc6ce5a3e7cbd90ce5af25cbea50307ded065b | shradha289/path-finding-algorithms-in-python | /a star search on maze.py | 2,353 | 3.703125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[8]:
import heapq
# In[9]:
class PriorityQueue:
def __init__(self):
self.elements=[]
def is_empty(self):
return not self.elements
def put(self,item,priority):
heapq.heappush(self.elements,(priority,item))
def... |
3eeaef090d8a7a20c3b6c578cb7994c569a30392 | ixe013/mongolito | /src/transformations/addattribute.py | 945 | 3.578125 | 4 | from transformations import BaseTransformation
class AddAttribute(BaseTransformation):
'''Adds an attribute to an object.
If the value is already present, it is added and the value
is turned into a list if it is not one already.
We make sure the object is a string, so that method can be passed
to... |
b489616b270128b30f5f06ad34c2e4f613cdf575 | imnikkiz/Conditionals-and-Variables | /guessinggame.py | 2,344 | 4.15625 | 4 | import random
def check_guess(guess, correct):
""" Compare guess to correct answer.
Return False once guess is correct.
"""
if guess == correct:
return False
elif guess < 1 or guess > 100:
print "Your guess is out of the range 1-100, try again."
elif guess > correct:
p... |
3d65fc67be24158f52601b8ebdc08b5220bc19f4 | Hoja1/amali_ishlarim | /royhatlar/royhat.py | 1,026 | 3.640625 | 4 |
"""
Created on Sat Jul 24 12:12:10 2021
@author: user
"""
def ishchiliar_uz(ism,familiya,otasni_ismi,tel_raqami,):
ishchi = {'ism':ism,
'familiya':familiya,
'otasni_ismi':otasni_ismi,
'tel_raqami':tel_raqami,
}
return ishchi
print("\nishchlar rohati")
... |
6ea099f57a14094b483750dcb516f167bd140533 | ShipOfNik21/Homework_Python | /Lesson_1/Task_2.py | 1,547 | 3.546875 | 4 | # Создать список, состоящий из кубов нечётных чисел от 1 до 1000 (куб X - третья степень числа X):
# Вычислить сумму тех чисел из этого списка, сумма цифр которых делится нацело на 7. Например, число «19 ^ 3 = 6859» будем включать в сумму,
# так как 6 + 8 + 5 + 9 = 28 – делится нацело на 7. Внимание: использовать тольк... |
6166a4a86a3a486745dee02399b400820ba446d9 | raresrosca/CtCI | /Chapter 1 Arrays and Strings/9_stringRotation.py | 847 | 4.125 | 4 | import unittest
def is_rotation(s1, s2):
"""Return True if s2 is a rotation of s1, False otherwise"""
for i, c in enumerate(s2):
if c == s1[0]:
if s2[i:]+s2[:i] == s1:
return True
return False
def is_rotation_2(s1, s2):
"""Return True if s2 is a rotation of s1, Fals... |
ca7cb0a813f7dca819895bcb55e0248fc9fe73de | raresrosca/CtCI | /Chapter 2 Linked Lists/7_intersection.py | 901 | 3.609375 | 4 | from linked_list_guy import LinkedList
def getIntersectionNode(ll1, ll2):
"""Using a dictionary"""
headA = ll1.head
headB = ll2.head
a = {}
while headA:
a[headA] = 1
headA = headA.next
while headB:
if headB in a:
return headB
headB = headB.next
re... |
92311150df08a9a9e9bdb4ceb42b3bb9196e1a0f | raresrosca/CtCI | /Chapter 4 Trees and Graphs/2_minimalTree.py | 1,444 | 3.96875 | 4 |
class Node:
def __init__(self, value = None):
self.data = value
self.left = None
self.right = None
def insert(self, value):
if self.data:
if value < self.data:
if self.left is None:
self.left = Node(value)
else:
... |
a9438a1046257da3bd09111edc41d4315497d47f | raresrosca/CtCI | /Chapter 2 Linked Lists/2_kthToLast.py | 566 | 3.828125 | 4 | from linked_list_guy import LinkedList
def kth_to_last(ll, k):
if ll.head is None:
return
current = ll.head
while current.next:
runner = current
distance = k
while distance:
runner = runner.next
distance -= 1
if runner.next == No... |
a9f9a5c501eaab905191d9ab5bf58c16b300d146 | MateusVS/Exercicios_Python | /18.py | 114 | 4.125 | 4 | num = int
while num <= 10:
num int = (input("Informe um numero: "))
if num > 10:
print('Valor Invalido')
|
a8804af0f8242ee2eefbd995e47d7e04539e03b7 | MateusVS/Exercicios_Python | /05.py | 90 | 3.859375 | 4 | medida = int(input ('Informe a medida em metros: '))
cent = medida*100
print (cent,'cm') |
28607fac4990748fed4ccc2ca7ff368d9cc65d5f | ibirdman/TensorflowExercise | /tf_test18.py | 774 | 3.515625 | 4 | from functools import reduce
import numpy as np
def char2num(s):
return {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}[s]
def str2int(s):
return reduce(lambda x, y: x * 10 + y, map(char2num, s))
def return_float(s):
base = 0.1
base_minus = 10
stra = "1"
for i in... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.