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
8c724b66ec28febfd4ed64281f3fe9e3c2f3565e
ardhysevenfold/animasi
/animasi_v2.py
1,230
3.546875
4
from tkinter import * import time import math lebar = 1200 tinggi = 700 class adr(object): lWidth = lebar lHeight = tinggi px = 50 py = 200 def __init__(self): self.root = Tk() self.root.title("Animasi Pantul Bola") self.canvas = Canvas(self...
3d040c8ba32255c11706892b511e5e8cc62e7747
ardhysevenfold/animasi
/Tugas1_E1E115010_ChaerilAksan.py
1,776
3.8125
4
# Assuming Python 2.x # For Python 3.x support change print -> print(..) and Tkinter to tkinter from Tkinter import * import time import math class alien2(object): lWidth = 500 lHeight = 600 posX = 50 posY = 150 def __init__(self): self.root = Tk() ...
df3476d79235a10e745f1e698f1f7546ec545369
ardhysevenfold/animasi
/segitiga_atas_bawah_hafid.py
1,432
3.59375
4
from tkinter import * import time import math class segitiga(object): def __init__(self): #Membuat Layar self.root = Tk() self.canvas = Canvas(self.root, width=1000, height = 1000) #Membuat Objek Segitiga self.canvas.pack() self.model = self.canvas....
42ae77e45855d832f43c777f4177340d2cba64b5
khanal-ananta/Pattern-oriented-software-design
/iterator.py
1,360
3.765625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Apr 26 01:36:15 2020 @author: ananta """ from abc import ABC,abstractmethod # a = np.array([1,2,3,4]) # len(a) #answer = 4 # list(a).index(a[-1]) # answer is 3 # this is to print the values # print(a) # print(a[1]) # a=1 # print(a) # a+=1 # prin...
3278f7051b1b30930f7d8e90339aa3d25433d7fe
thcipriani/dotfiles
/bin/santa.py
1,071
3.9375
4
#!/usr/bin/env python from __future__ import print_function import random DONT_PAIR = [('blazey', 'tyler')] EVERYONE = ['tyler', 'shawnie', 'lillian', 'mike', 'blazey'] MATCHES = EVERYONE[:] def find_match(person, dont_match): """Match a person with another person.""" match = random.choice(MATCHES) ...
a9a1fce118793f090a1cd00ddf622ee262b34190
martin235/Fractal-drawing
/fractal1.py
722
3.84375
4
import turtle as t t.speed(100) def Triangles(longueur,n): if n==0: t.color("black") t.begin_fill() for i in range(3): t.forward(longueur) t.left(120) t.end_fill() else: Triangles(longueur//2,n-1) t.forward(longueur//2) Triangles(l...
61c9a78b94553b8ee064a94a9f0553a4a1c85add
ricoreisser/MeinStudium
/Seitenhalbiernde_bla.py
382
3.84375
4
from math import pow,sqrt def num(s): try: return float(s) except ValueError: return False a=False while(a==False): a=num(input('a eingeben:')) b=False while(b==False): b=num(input('b eingeben:')) c=False while(c==False): c=num(input('c eingeben:')) res=0.5*sqrt((2*(pow(b,2)+pow(c,2...
e849691ce706ddffc5ceb3e4dd822eade8142172
felipefonsecadev/fsnd-movie-trailer-website
/media.py
602
3.796875
4
class Movie: """Class to store information about one movie Attributes: title: a string containig the title of a movie overview: a string containing the overview of a movie poster_image_url: a string contaning the url to the poster of a movie trailer_youtube_url: a string contain...
46ca0843a6e2b7a7273b10aa3cbc2baf3fe5f59f
AbhishekHP2016/009_016_LLP_Solutions
/SOL_012.py
853
3.96875
4
#!/usr/bin/env python from abc import ABCMeta, abstractmethod # class Human(metaclass=ABCMeta): ## python 3.x class Human(object): ## remove for python 3.x __metaclass__ = ABCMeta ## remove for python 3.x @abstractmethod def __init__(self): pass def run(self): print ('running!') # class Robot(metaclass=A...
c2bbe5fb1ea3b8cafb1c2e0f0c4a0d26692b363b
sherifessawy/Track-Simulation-Tool
/Solver.py
4,789
4.125
4
def simulator(vi, track): #vi is initial velocity at the beginning of the simulation, track is a dictionary of form {1:['s', lenght], 2:['c', length, raduis]} """ simulates the track calling the three main functions(straight line, corner, brake) appropriately """ i = 0 #ends the simulation whe...
99c209f6b19cf57ef4797164f6e0fa23391f0e62
kwonj1234/todo_list
/app/views.py
847
3.65625
4
def main_menu(): print("1. Adjust incomplete items") print("2. Adjust completed items") print("3. Show all items") print("4. Add new item") print("5. Delete items") print("6. Exit") return input("Pick one") def show_item(item): print(item) def select_item(): return input("Select th...
0e78f1d1b2832fa898dc9a922011c3e0322757b2
talrab/python_excercises
/bdays_3.py
1,869
4.09375
4
import json from collections import Counter with open("Bdays_3.json",'r') as f: bdays_dictionary = json.load(f) print (bdays_dictionary) print(bdays_dictionary["Romi"]) print(bdays_dictionary["Romi"]["Day"]) print('Welcome to the birthday dictionary. We know the birthdays of:\n') for name in bdays_dictionary.key...
a9842c9896f227bb707b36906ec06f6fe93c0fc2
talrab/python_excercises
/fibonacci.py
707
4.3125
4
run_loop = True num_elements = int(input("Please enter the number of elements: ")) if num_elements < 0: run_loop = False while (run_loop): answer = [] for x in range(num_elements): print( "X=" + str(x)) if (x+1==1): answer.append(1) elif (x+1==2): answer.ap...
be8e2034214c422bf9be242911b01ad877e8a23b
JasonQVan/Self-Taught-Assignments
/Inheritance.py
417
3.765625
4
class Shape(): def what_am_i(self): print("I am a shape") class Rectangle(Shape): def __init__(self, w, l): self.width = w self.length = l def calculate_perimeter(self): return (self.width*2 + self.length*2) class Square(Shape): def __init__(self, s): self.s1 = s def calculate_perimet...
5ecc9a206a36401a31124acf585a4a121a98291b
Pectin-eng/Lesson-6-Python
/lesson_6_task_4.py
2,301
4.3125
4
print('Задача 4.') # Пользователь вводит атрибуты всего класса: class Car: speed = int(input('Введите вашу скорость: ')) color = input('Введите цвет машины: ') name = input('Введите марку машины: ') is_police = input('У вас полицейская машина? да/нет ') def go(self, color, name): print(f'...
681c7a89b82985cccb13d5479df94fdef2b1b272
vpc20/python-dynamic-programming
/CoinChange/CoinChangeCombinations/CoinChangeDynamic.py
2,544
3.578125
4
# def coin_change_dyna_iter(coin_list, change): # arr = [[1] + [0] * change for _ in range(len(coin_list) + 1)] # for i in range(1, len(coin_list) + 1): # for j in range(1, change + 1): # if j >= coin_list[i-1]: # arr[i][j] = arr[i - 1][j] + arr[i][j - coin_list[i-1]] # ...
48165199811b9e2b45ca0ec0c02258b485d855d5
vpc20/python-dynamic-programming
/CoinChange2.py
2,466
3.75
4
# You are given coins of different denominations and a total amount of money.Write a function to compute the number # of combinations that make up that amount.You may assume that you have infinite number of each kind of coin. # # Example 1: # Input: amount = 5, coins = [1, 2, 5] # Output: 4 # Explanation: there are fou...
ce7a64d55874aaa041c6d5742575d8e7cac427e4
vpc20/python-dynamic-programming
/MinPathSum.py
2,348
3.875
4
# Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right # which minimizes the sum of all numbers along its path. # Note: You can only move either down or right at any point in time. # # Example: # Input: # [ # [1,3,1], # [1,5,1], # [4,2,1] # ] # Output: 7 # Explanation: Be...
664482f70bebbf7966edfcbbe0d170bccc4472a6
vpc20/python-dynamic-programming
/CoinChange/CoinChangeCombinations/CoinChangeRecursive.py
3,365
3.796875
4
# Given a value N, if we want to make change for N cents, and we have infinite supply # of each of S = { S1, S2, .. , Sm} valued coins, how many ways can we make the change? # The order of coins doesn’t matter. # # For example, for N = 4 and S = {1,2,3}, # there are four solutions: {1,1,1,1},{1,1,2},{2,2},{1,3}. So out...
d91a1e26ffb811eb4f2473998ba2bd262ee7d98a
fausecteam/ctf-gameserver
/src/ctf_gameserver/lib/database.py
3,323
3.671875
4
from contextlib import contextmanager import sqlite3 @contextmanager def transaction_cursor(db_conn, always_rollback=False): """ Context Manager providing a cursor within a database transaction for any PEP 249-compliant database connection (with support for transactions). The transaction will be committed...
25b7118a0861272081137dcc956e5c9d18fe1546
urmilashinde/python
/Chapter_6.py
359
3.890625
4
fruit = "Urmila is the best" print 'best' in fruit word1 = "Umang" word2 = "Urmila" if word1 < word2: print "Umang is less than Urmila" else: print "Urmila is less than Umang" name = "SOHUM PAREKH" print "Before: ", name print "After: ", name.lower() data = "mnfrhfiufksdk@gmail.com njkdsfkjf" pos1 = data.find...
1d84ea6245f8bc466144f54cf18d169f8434c29f
AaronCHH/PG_TOOL
/PYTHON/listfile/listfile.py
216
3.53125
4
''' use file ext for searching ''' import os, sys path = '.' fileType = sys.argv[1] for root, dirs, files in os.walk(path): for file in files: if file.endswith(fileType): print(os.path.join(root, file))
65795c7a1288d0bdc37e65dec07e029a6814d33a
frankness/MPyWE
/gradient_check.py
928
3.734375
4
from __future__ import division import numpy as np def f(x): b = np.ones_like(x) return x * x + b def eval_numerical_gradient(f, x): """ a naive implementation of numerical gradient of f at x - f should be a function that takes a single argument - x is the point (numpy array) to evaluate the g...
482592fb052760a597b76096b08d052a22b0d164
pbrus/variability-analyser
/varana/varana/phase.py
7,572
3.546875
4
""" Phase a light curve with a specific frequency. """ from copy import deepcopy from os.path import basename, splitext, dirname, join from typing import Tuple, Callable import matplotlib.pyplot as plt import numpy as np from numpy import ndarray from scipy.optimize import curve_fit def read_lightcurve(filename: st...
ff1f788be7fe1b4353527e72132137e8d7ea7958
ajbolous/FirstHand
/controller/handControl/gui/control.py
1,023
3.5625
4
import Tkinter as tk from handControl.hand import hand def onKeyPress(event): if event.char == 'w': hand.move_axis(0,hand._axis[0].angle+5) if event.char == 's': hand.move_axis(0,hand._axis[0].angle-5) if event.char == 'a': hand.move_axis(1,hand._axis[1].angle+5) if event.char =...
3044717df743d8338bf520a47cf30e1c3c87335b
pulak-chandan/ds-algorithms
/datastructures/trees/src/bst.py
5,053
3.90625
4
# Recursive import queue class Node: def __init__(self, data): self.data = data self.leftChild = None self.rightChild = None # HAS A Relationship # BinarySearchTree has a NODE class Tree: def __init__(self): self.root = None def insert(self, data): if not self.ro...
34d5bb5773af03db6f3b5145abbfa9c62e7386b3
pulak-chandan/ds-algorithms
/datastructures/trees/invertBST.py
511
3.53125
4
import datastructures.trees.src.bst as bst def invertRec(node): if node.leftChild: invertRec(node.leftChild) if node.rightChild: invertRec(node.rightChild) temp = node.leftChild node.leftChild = node.rightChild node.rightChild = temp def invertTree(): if tree.root: in...
473cb9abf886f8611d99c4ba051cece1a009a9a9
pulak-chandan/ds-algorithms
/algorithms/optimalMergePattern.py
1,215
4.0625
4
from queue import PriorityQueue def insert_to_maintain_sorting(x, list): count = 0 for val in list: if val < x: count += 1 else: list.insert(count, x) break if count == len(list): list.append(x) return list def findOptimalMergingCost(filesSi...
910b662b24c0aa529204ba85ef1d1f0898fd81fc
zhangchenghao0617/Learn
/day 04/第一次大作业.py
1,196
4.09375
4
# # 1. 如何实现字符串的反转?如: name = "wupeiqi" 请反转为 name ="iqiepuw" # name = "wupeiqi" # name2 = name[::-1] # print(name2) # 2. 如何实现 “1,2,3” 变成 [‘1’,’2’,’3’] # str ='1,2,3' # li = [] # for i in str: # if i != ',': # li.append(i) # print(li) # # 3. 如何实现[‘1’,’2’,’3’]变成[1,2,3] # li = ['1','2','3'] # li2 = [] # for i i...
d24840795d6920c92e3b5d07858cec726035d2fc
zhangchenghao0617/Learn
/day 02/课上练习.py
1,001
3.71875
4
# #练习1:输出1~100所有的数字 # i=1 # while i<= 100: # print(i) # i = i+1 # #练习2:使用while循环求出1-100所有数的和. # i =1 # s = 0 # while i<=100: # s = s + i # i = i + 1 # print(s) # #练习3:打印1~100所有的偶数 # i = 2 # while i <= 100: # print(i) # i = i + 2 # #练习4: 使用while循环打印 1 2 3 4 5 6 8 9 10 # i = 0 # while i < ...
71d04e6f0a4b82bd5b5e67453c1e99204f30cc1c
zhangchenghao0617/Learn
/day 03/for 循环.py
135
3.515625
4
s1 = '老男孩教育最好的讲师:太白' # i = 0 # while i < len(s1): # print(s1[i]) # i += 1 # for i in s1: print(i)
640091e3bafa1f9f917c120fad5fdd2bfdfd9a4b
ibra1010/TransactionsAggregator
/Common/Transaction.py
974
3.65625
4
class Transaction: def __init__(self, way, amount, toAccount, fromAccount): self.way = way self.amount = amount self.toAccount = toAccount class TransactionHistoryInput: def __init__(self, bank, transactions): self.bank = bank self.transactions = transactions class Trans...
3f847de107575a61a89468c9df97569b58edbf65
yukie7/Python
/MyLibrary.py
1,183
3.578125
4
# coding: utf-8 import sys # 入力(改行アリ)を終わりまで(EOF)まで読み込み # a b c d ... a = [] for line in sys.stdin: line = line.replace('\n','') #改行文字を除去(空文字に置き換え) a.append(line) # 配列aの1文字目を除去 del a[0] # 小文字→大文字 # a = "abc" → a = "ABC" a.upper() # 大文字→小文字 # a = "ABC" → a = "abc" a.lower() # split # ...
d372618a4ffe17664744553d17593c64bcb86868
Hemanth0798/Begginer__Friendly_Problems
/PYTHON/2NDOct_Githubname (2).py
201
3.546875
4
l1=eval(input("Enter first list:")) l2=eval(input("Enter Second list:")) c=l1.copy() for i in l2: d=0 for j in l1: if(i==j): d+=1 if(d==0): c.append(i) print(c)
51a4bcb49223b93ebc60b0cce21f4cbde2c5b8da
yankwong/python_quiz_3
/question_1.py
506
4.25
4
# create a list of number from 1 to 10 one_to_ten = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] # using list comprehension, generate a new list with only even numbers even_from_one_to_ten = [num for num in one_to_ten if (num % 2 == 0)] # using list comprehension, generate a new list with only odd numbers odd_from_one_to_ten = [num...
3c1521bb65889c3ba7eb374e8a215cee618b4c5d
bdaumit/Quest_Test
/classes_and_attacks.py
885
3.671875
4
#player_name = input("Enter your name: ") print(""" Class List: 1. Rogue 2. Knight 3. Ranger 4. Mage 5. Palidan 6. Priest 7. Barbarian""") print("") #player_class = input("Choose you class: ") #attributes are capitalized because str = string in python Hp = 0 Mp = 0 Dex = 0 Str = 0 Mag = 0 Def = 0 Spr = 0 def ranged_...
b029c7f65f2e653c9fa8048bf76512a5793629ef
srijaniintm/Code-Combat
/Python/04-Word-without-Vowels.py
165
4.21875
4
s = input() # Taking Input for i in s: # Traversing the String if i not in "AEIOUaeiou": print(i,end='') # Printing the character if it is not a vowel.
d1032c31cbfe6997d73dcdf99ea06ee1ee74a1c8
KeiichiroTokita/BDM
/se10-led.py
751
3.515625
4
import RPi.GPIO as GPIO from time import sleep # GPIOポートの設定 --- (*1) SENSOR_PORT = 27 LED_PORT = 21 GPIO.setmode(GPIO.BCM) GPIO.setup(SENSOR_PORT, GPIO.IN) GPIO.setup(LED_PORT, GPIO.OUT) try: ntime = 0 # LED点灯時間を管理する変数 --- (*2) # 繰り返しセンサーの値を得る --- (*3) while True: v = GPIO.input(SENSOR_PORT) ...
421ce0dabf326248c65348bd3506e5596570730a
pnthairu/module7_Arrays
/sort_and_search_array.py
2,039
4.3125
4
from array import array as arr from filecmp import cmp # Start Program """ Program: sort_and_Search_array.py Author: Paul Thairu Last date modified: 06/23/2020 You can make a new files test_sort_and_search_array.py and sort_and_search_array.py. In the appropriate directories. For this assignment, you can...
c9ecff97df0ed0bb5ddef01fade7d18d4322b44b
hayc09/automatic-engine
/Lab1/gcd.py
1,085
3.921875
4
#!/usr/bin/env python3 from math import gcd as denom, isclose from random import randrange def gcd(a, b): """Function takes in two values, compares them, setting largest value to a, and smallest to b, performs Euclid's algorithm until the remainder is zero, returning the largest common denominator""" ...
e1d4a9e2300b7d9bc5e1b27eb5303f6d43fafce7
juliomejia97/DSA-Python
/Exercises/Remove k-th Last Element From Linked List/RLE.py
866
3.8125
4
class ListNode: def __init__(self, value, next=None): self.value = value self.next = next def __str__(self): current_node = self result = [] while current_node: result.append(current_node.value) current_node = current_node.next return str(...
82bd4e75a478c60c6004a41a01644cc7f7b3ce46
juliomejia97/DSA-Python
/Exercises/Contiguous Subarray with Maximum Sum/kadane.py
306
3.578125
4
import math def max_sub_array_sum(arr): maxSum = -math.inf maxHere = 0 for i in range(len(arr)): maxHere += arr[i] if maxHere > maxSum: maxSum = maxHere if maxHere < 0: maxHere = 0 return maxSum print(max_sub_array_sum([1, 2, 3, -2, 5]))
d59b29ec8a9edc6ca4d1d03c176a603e43d87dcf
juliomejia97/DSA-Python
/Exercises/Zig Zag Conversion/ZZC.py
588
3.5625
4
from collections import defaultdict def convert(s: str, numRows: int) -> str: rows = [[] for i in range(numRows)] currentRow = 0 if currentRow == numRows - 1: return s goingDown = True for c in s: rows[currentRow].append(c) if currentRow == 0: goingDown = True ...
11e98cd1ea10071310ed7050b84dd885c6904a8e
juliomejia97/DSA-Python
/Exercises/Word Search/WS.py
1,111
3.6875
4
class Solution: def exist(self, board: list[list[str]], word: str) -> bool: for i in range(len(board)): for j in range(len(board[i])): if word[0] == board[i][j] and self.dfs(self, board, i, j, 0, word): return True return False def dfs(self, board...
a85625519a33692aac27146fdafe8d5e8c819fed
juliomejia97/DSA-Python
/Data Structures/Graphs/Topological Sort/TopologicalSortDFS.py
1,436
3.609375
4
from collections import defaultdict from collections import deque class Graph: def __init__(self, V): self.V = V self.graph = defaultdict(list) def addEdge(self, v, u): self.graph[v].append(u) def topologicalSort(self): res = [] visited, cycle = set(), set() ...
12cece78f29c77c42f47635632083bb1afcd5a21
juliomejia97/DSA-Python
/Exercises/Reverse Integer/RI.py
626
3.71875
4
class Solution: def reverse(self, x): res = 0 # TODO: Analizar si es positivo o negativo negativeFlag = False if x < 0: negativeFlag = True x = x*-1 while x > 0: val = x % 10 res = res*10 + val x = x//10 if ...
52d8c2ba6204aec8b1a1083515bffe1f267fb860
Ayush-co/python-practice
/Day-1/Sum of two numbers.py
121
4.09375
4
x=int(input("Enter The number x")) y=int(input("Enter the number y")) z=x+y print("The sum of two numbers is : " ,z)
a7be99cad8701343f5ab0e720e5655312d42924c
amitmeel/Machine_Learning
/Part 2 - Regression/Section 6 - Polynomial Regression/my_practice.py
1,546
3.90625
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('C:\\Users\\IBM_ADMIN\Desktop\\Machine_Learning_AZ\\Part 2 - Regression\\Section 6 - Polynomial Regression\\Polynomial_Regression\\Position_Salaries.csv') X = dataset.iloc[:, 1:-1].values y = dataset.il...
c3e2f31d7850b5056c5eb7974b8778523d2dad6e
dianamicru99/dianaLenguaje
/Ejercicios While/Ejercicio4.py
458
4.03125
4
while True: print("Opción 1 - comenzar programa") print("Opción 2 - imprimir listado") print("Opción 3 - finalizar programa") opcion=int(input("Opción elegida: ")) if opcion==1: print("¡Comenzamos!") elif opcion==2: print("Listado:") print("Diana, Erika, Bea, Jess") e...
d7741681127802ad16ddecda7632126cc3dd7bb1
SylarK/HarvardX
/03. cs50w - flask (2019)/dictionaries.py
97
3.609375
4
ages = {"Alice": 25, "Bob":35, "Charlie":34} ages["Charlie"] = 40 ages["Alice"] += 1 print(ages)
43c829f3c0cf27194fbeffcb11cc067992549ea2
tejaspant390/-python_assignment_dec8
/password.py
228
4.09375
4
#A program to check the password. password= "tejas" def word(value): if(value == password): print("Password match") else: print("Password is wrong") value=input("Enter the password: ") word(value)
7ba7f11dba93592769e4ff414f4a456980ec0cd2
josemfche/matplotplotly
/Others/scatter_squares.py
541
3.6875
4
import matplotlib.pyplot as plt x_values = range(1, 5001) y_values = [x**3 for x in x_values] plt.style.use('seaborn') fig, ax = plt.subplots() ax.scatter(x_values, y_values, s=10, c='Red') #Set chart title and label axes. ax.set_title("Square Numbers", fontsize=24) ax.set_xlabel("Value", fontsize=1...
0d7b86cad05e0a7391f3eb150175446a58f20c6b
ratneshgujarathi/Encryptor-GUI-
/encrypt_try.py
1,299
4.4375
4
#ceasor cipher method encryption #this is trial module to easy encrypyt the message #c=(x-n)%26 we are ging to follow this equation for encrytion #c is encryted text x is the char n is the shifting key that should be in numbers % is modulus 26 is total alphabets #function for encrytion def encryption(string...
0b3f7ea565bfe307be90b70e2b2ba9c8b5aa0779
WaitBright/Algorithm
/tips/common.py
2,564
3.53125
4
import sys class Solution1: """ 矩阵旋转 逆时针旋转矩阵90度,但是不能利用额外的空间,只能使用本矩阵操作。 逆时针旋转矩阵90度等于 对角线对称交换再i行与n-1-i行交换 对角线对称元素关系: nums[i][j], nums[j][i] i行与n-1-i行元素关系: nums[i][j], nums[n-1-i][j] 反对角线对称元素关系: nums[i][j], nums[n-1-j][n-1-i] """ def transpose(self, nums): n = l...
fdabe04d854a4ec4ca379be0a0860d83598e9291
WaitBright/Algorithm
/tips/graphDemo.py
626
3.71875
4
""" python 表示图结构 A -> B A -> C B -> C B -> D C -> D D -> C E -> F F -> C """ def find_path(graph, start, end, path=[]): path = path + [start] if start == end: return path if not graph. if __name__ == '__main__': # 未知不带权用字典+数组表示 # 带权用字典+字典表示 # graph...
5524c6ee4d3cba89166ab96fc0be4c4697b2c796
doomseur/Student
/rsa_level/rsa_level_9.py
3,778
3.9375
4
#!/usr/bin/python2 # # A weakness of the RSA is Small encryption exponent. Described here : https://www.di-mgt.com.au/rsa_alg.html#weaknesses # Small encryption exponent # If you use a small exponent like e=3 and send the same message to different recipients and # just use the RSA algorithm without adding rando...
c73e6703a75b91b64e3b46fb1c1f82b42e5160b5
lukewheless/numpy
/myarrays2.py
794
3.796875
4
import numpy as np grades = np.array([[87,96,70], [100,87,99], [100,81,72]]) #name = ["Brad","Chad", "Bob"] print(grades.sum()) print(grades.min()) print(grades.mean()) print(grades.var()) print(grades.std()) #for i in name: #print(i) m = grades.mean(axis = 1) print(m,...
0eb094aab33e8eeac43fabc63435bf8b683e4bc4
YangSSo51/honeypolicy
/mydb.py
1,651
3.515625
4
import csv, sqlite3 import psycopg2 import random import time def strTimeProp(start, end, format, prop): """Get a time at a proportion of a range of two formatted times. start and end should be strings specifying times formated in the given format (strftime-style), giving an interval [start, end]. pro...
ced4b430f7a3f5f0ba5ffd663319d7925b26afad
robotech412/ITESCAM-ISC
/Segundo-Semestre/Algebra Lineal/Identificación de matrices/matrices.py
505
3.5625
4
print ("arreglo 1\n") print ("tipo de arreglo: matriz cuadrada") A=[[1,2,3],[4,5,6]] a="" for k in range(2): for j in range(2): # imprime(A[k][j]) a+=str(A[k][j])+'\t' print (a) a="" B=[[1,2,3],[4,5,6]] a="" print("") print ("arreglo 2\n") print ("tipo de arreglo: matriz rectangula...
97f7f68e6ca0e01ef6fa2ac64ea0ecfc19438cb6
m-okhravi/Neural-network
/simple node with 3weights.py
421
3.671875
4
import matplotlib.pylab as plt import numpy as np # this example show output of sigmoid function for network with one node and 3input(x) with their 3weights x = np.arange(-8, 8, 0.1) w1 = 0.5 w2 = 1.0 w3 = 2.0 l1 = 'w = 0.5' l2 = 'w = 1.0' l3 = 'w = 2.0' for w, l in [(w1, l1), (w2, l2), (w3, l3)]: f = 1/(1+np.exp(...
8837865ab2c24ca61457d6a2f02e7855d0661b65
imd93shk/Learning-Python
/E11_Check_Primality_Functions.py
720
4.09375
4
# -*- coding: utf-8 -*- """ www.practicepython.org Exercise 11: Check Primality functions Created on Sat Sep 15 17:08:27 2018 @author: Imaad Shaik """ print("This program is to check wether the given number is prime or not") def get_number(): return int(input("Enter a number:\n")) def primality(number): j =...
0505914172cbc2bd8013b23c3a6120b6bcb56262
jsimkoff/DataStructures
/Module6/tree_orders.py
771
3.5625
4
class TreeOrders: def read_tree(self): self.n = int(raw_input()) self.key = [0 for i in range(self.n)] self.left = [0 for i in range(self.n)] self.right = [0 for i in range(self.n)] for i in range(self.n): [a, b, c] = map(int, raw_input().split()) ...
08af43272ea9611fe8abb72f05c23c229ab87979
jsimkoff/DataStructures
/Module1/packet_processing/process_packages.py
2,531
3.5625
4
# python2 from collections import namedtuple, deque Request = namedtuple("Request", ["arrived_at", "time_to_process"]) Response = namedtuple("Response", ["was_dropped", "started_at"]) class Buffer: def __init__(self, size): self.size = size self.finish_time = deque() def proces...
7826baf60abf84bd84357e0c293979432cef930e
Khosiyat/algorithm_task
/matrix_ROTATION.py
2,900
3.53125
4
# SHART-3: Matritsa elementlarini soat strelkasi bo'yicha 1dan n*n gacha chiqaruvchi dastur. #EN|BUTTONS ARE CREATED THOSE MOVE THE DATA STORED BOTH HORIZONTALLY AND VERTICALLY #UZ| ENIGA VA BO'YOIGA TIZILGAN DATALARNI HARAKATLANTIRUVCHI TUGMALARNI YARATAMIZ tuneButton=1 startButton=0 #EN| A: FIRST FUNCTION IS TO SE...
a50d4a6e710c004fe9e2d4d08378d40ab3b1a4c1
cherryVsV/2laba
/5.py
858
3.984375
4
'''Введите с клавиатуры текст. Программно найдите в нем и выведите отдельно все слова, которые начинаются с большого латинского символа (от A до Z) и заканчиваются 2 или 4 цифрами, например «Petr93», «Johnny70», «Service2002». Используйте регулярные выражения.''' import re def search(Vvod): text = '' splitText ...
bd8747ce4c21bb8f3ee943f2895230567caf6343
agrzybkowska/Data8Project
/Talent_Team.py
980
3.5625
4
from files_to_dataframe import FileToDF from sklearn.preprocessing import LabelEncoder import pandas as pd def talentteammatcher(): # this function generates a table which is suitable for doing the merge based on name file= FileToDF('data8-engineering-project', 'Talent') df = file.dataframecsv() df = df[...
a7ca5c75d43d8fbdb082f89d549b1db9959e101a
praveendareddy21/ProjectEulerSolutions
/src/project_euler/problem4/problem4.py
2,395
4.21875
4
''' A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99. Find the largest palindrome made from the product of two 3-digit numbers. Created on Feb 18, 2012 @author: aparkin ''' from project_euler.timing import timeruns, format...
023fe6292fbcc9232c346861a8a39702dd2fe4c0
praveendareddy21/ProjectEulerSolutions
/src/project_euler/timing.py
1,716
3.578125
4
''' Created on 2012-02-07 @author: aparkin ''' from timeit import Timer def timeruns(runs, num_iterations = 100): ''' Time a series of code snippets, running each num_iterations times. The snippets are passed via the runs parameter, which is a list of tuples, each tuple containing 1) the snippe...
5ce5a95bf5c71581eeb16d9219f1d5550035bf9f
Archan2607/Python_Programming
/GeekForGeeks/Max_Interval_Overlap.py
752
3.671875
4
""" Problem Link: - https://practice.geeksforgeeks.org/problems/maximum-intervals-overlap/0 """ from collections import Counter def algo(starts, ends): times = sorted(set(start + end)) c = 0 max_c = 0 max_t = None starts_by_time = Counter(starts) ends_by_time = Counter(e + 1 for e in e...
2eaf76003a6f036082a580896883c97076207458
Archan2607/Python_Programming
/GeekForGeeks/Search_in_matrix.py
317
3.578125
4
""" Question Link: - https://practice.geeksforgeeks.org/problems/search-in-a-matrix/0 """ t=int(input()) for i in range(t): temp=list(map(int,input().split())) ele=list(map(int,input().split())) k=int(input()) ele=set(ele) print(1) if k in ele else print(0)
1d376d91ebcd7a717005451d2741b17d339fc097
Archan2607/Python_Programming
/GeekForGeeks/Largest_ZigZag_Sequence.py
690
3.546875
4
""" Question Link: - https://practice.geeksforgeeks.org/problems/largest-zigzag-sequence/0 """ def larZigZagSumInMatrix(i,j): if dp[i][j] != -1: return dp[i][j] if i == n-1: dp[i][j] = a[i*n+j] return dp[i][j] zzs = 0 for k in range(n): if k!=j: zzs = max(zz...
1872133d092181f1d3a3fab736483b91f28b15f4
HannibalXZX/LearnPython
/自学是门手艺/class.py
1,137
3.71875
4
# -*- coding:utf-8 -*- #@Time : 2020/3/11 17:54 #@Author: Shaw #@mail : shaw@bupt.edu.cn #@File : class.py #@Description: class Counter(object): def __init__(self, start, stop): self.current = start self.stop = stop def __iter__(self): return self def __next__(self): ...
27d79b97b7092fdd28ac27249567e8414a35e565
seanybaggins/MatrixAlgebra
/book/sources/03-Linear_Equations_in-class-assignment.py
7,564
4.21875
4
# --- # jupyter: # jupytext: # text_representation: # extension: .py # format_name: light # format_version: '1.5' # jupytext_version: 1.10.3 # kernelspec: # display_name: Python 3 (ipykernel) # language: python # name: python3 # --- # # # # 03 In-Class Assignment: Solving ...
2a37380e4bdddd4ef8150ead3eca9cade91578df
seanybaggins/MatrixAlgebra
/book/sources/09-Determinats_in-class-assignment.py
6,242
3.703125
4
# --- # jupyter: # jupytext: # text_representation: # extension: .py # format_name: light # format_version: '1.5' # jupytext_version: 1.10.3 # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- # # # 09 In-Class Assignment: Determinants # # <img s...
1ff64de9934c840e397cc2a3b07690cae8566481
Diksha-11/OOPM-C-Notes
/python all sheets (Saurabh Shukla)/python ass 2/ass2.7.py
485
4.1875
4
print("Form of Quadratic Equation is :- ax^2+bx+c") a=int(input("Enter 'a' of an quadratic question: ")) b=int(input("Enter 'b' of an quadratic question: ")) c=int(input("Enter 'c' of an quadratic question: ")) D=(b*b)-(4*a*c) if (D<0): print("Nature is unequal and imaginary") elif(D==0): print("Nat...
55206cfeeb0b83bd8a2b7384a25615171bbf0e79
Diksha-11/OOPM-C-Notes
/python all sheets (Saurabh Shukla)/python prac/8.py
108
4
4
x=int(input("Enter a number")) n=x%10 print("Last digit of the number is",n) input("Enter any keyword")
ec2e7ba2171b749d3418acb847592ee2a1267afb
Diksha-11/OOPM-C-Notes
/python all sheets (Saurabh Shukla)/python prac/4.py
398
3.890625
4
sc=int(input("Enter science number") u=int(input("Enter maths marks")) h=int(input("Enter hindi marks")) ev=int(input("Enter enviornment studies marks")) en=int(input("Eneter english marks")) sum=sc+u+h+ev+en per=sum/5 print(per) input("Enter any key") ...
b0cdb0ec92e3674e079c761330cdedb4cde51e3c
Diksha-11/OOPM-C-Notes
/python all sheets (Saurabh Shukla)/python prac/10.py
132
3.75
4
x=int(input("Enter hindi number")) y=int(input("Enter science number")) sum=x+y av=sum/2.0 print(av) input("Enter any key")
3168a4c1ca45ebd2e0e3a8b7dd7084783c71d3f4
JingYiTeo/Python-Practical-1
/Converting to upper case.py
138
4.21875
4
#Converting phrase or words to upper case Word = input("Enter a Word/Phrase: ") #Convert it to upper case: print(Word.upper())
51ba0a467b225507dba691f0b75f1a1948128dc8
jwroche/adventOfCode
/2019/Day1.py
572
3.5625
4
import math def calcFuel(mass): val = mass final_fuel = 0 while val > 0: val = math.floor(val/3.0)-2 if val > 0: final_fuel += val return final_fuel def main(): file_name='Day1Input.txt' module_masses=[] # Save off the masses with open(file_...
81674c5c2563fb9914e7d8c3c9a591be23d92582
stochastic-thread/elasticgraph
/core/graph.py
2,602
3.578125
4
class Graph(): def __init__(self): self.vertices = {} # maps (vk) -> dict, which contains properties self.edges = {} # maps (vk1, vk2) -> dict, which may contain any # number of prop label to prop value pairs def __str__(self): retval = "" for index, label in enumerate(self...
f01515226d8402d5ba3e9ed87e7810448a9829ca
twagener/prg_tkinter
/layout_demos/09_grid.py
256
3.515625
4
from tkinter import * colours = ['red','green','orange','white','yellow','blue'] r = 0 for c in colours: Label(text=c, relief=RIDGE,width=15).grid(row=r,column=0) Entry(bg=c, relief=SUNKEN,width=10).grid(row=r,column=1) r = r + 1 mainloop()
78c11d7e9aca108d2e7564bfd66027dd8d57be2d
liam9/spamegg_DRAW265
/generate_dragon.py
2,848
3.703125
4
import sys import math import Line_Point ''' purpose write to stdout a dragon curve with i iterations, line length l, and colour c preconditions i and l are positive non-zero ints and floats (respectively) c is a string ''' def next_line(root, i, turn): # copy root new_line = Line_Point.Line(root.point0...
185712e8ab34237708d805dafd53788747aff5c7
mkung8889/python-challenge
/PyBank/main.py
1,445
3.578125
4
import os import csv csvpath = os.path.join('Resources','budget_data.csv') with open(csvpath,newline="") as csvfile: csvreader = csv.reader(csvfile,delimiter= ",") rows = [] totalnet = 0 months=[] pl=[] change = [] totalchange = 0 for i, row in enumerate(csvreader): if i...
fd764dfa38a486be87b2e9c86a2b01ff21d44c19
victorianorton/team-five
/db_round_zero/Address.py
2,523
3.515625
4
__author__ = 'Victoria' import sqlite3 class AddressTable(object): def __init__(self, db): self.db_name = db def insert_address(self): with sqlite3.connect(self.db_name) as conn: conn.cursor() user_in_id = raw_input("Input unique_id: ") user_in_adnum ...
abbff4221376635e0816f893d55b485f277dc3ba
froginafog/data_analysis
/0004/main.py
3,492
3.6875
4
def remove_repeated_data(data): num_elements_in_data = len(data) if(num_elements_in_data == 0): return data unique_data = [] unique_data.append(data[0]) for i in range(1, num_elements_in_data): num_elements_in_unique_data = len(unique_data) data_is_unique = True for j...
eea1a67f02c852cd6ca7b2997c9bb7ffdff4e7ba
coomanky/game-v1
/main.py
2,848
4.3125
4
#user information print("hello and welcome to (game v2) , in this game you will be answering a series of questions to help inprove your knowledge of global warming ") print (" ") name = input ("What is your name? ") print ("Hello " + name) print(" ") # tutorial def yes_no(question): valid = False while no...
5937b535876cc94a8f30f534ae26553694c1f23d
sahilm89/rusmalai-ncbs
/packages/examples/test_data.py
768
3.65625
4
import ANN import matplotlib.pyplot as plt from sklearn.datasets import load_digits data = load_digits() input = data.data target = data.target numLayers = 5 iterations = 20000 #input = [[0,0],[0,1],[1,0],[1,1]] #target = [0,1,1,0] nn1 = ANN.FNN(numLayers, input, target, eta=0.05 ) e = nn1.train(iterations) achi...
04e011d640b201dff0ac58326a7c601a94dc4a3c
davidlopez/cpe1040pa2
/project2/pa2_main.py
549
3.828125
4
# Solution 1 # names = [] # def cap_join(names): # names2 = " ".join(names).title() # return names2 # if __name__ == '__main__': # names = ["calvin", "and", "hobbes", "are", "the", "first", "spacemen", "on", "mars"] # print(cap_join(names)) # Solution 2 def cap_join(list1): names = [] for index1 in...
445f0f524e1813dea78a79603ef97b0b647cbda6
andesviktor/Python_adv_lessons
/homeworks/homework_library/book.py
628
3.6875
4
class Book: """ Класс книги и действий с ней """ def __init__(self, book_id: int, book_name: str, book_author: str, book_year: int, book_available: bool): """ :param book_id: ID книги :param book_name: Имя книги :param book_author: Автор книги :param book_year: Год выпус...
9a53f4bb434de3e7294ad40eb24942455c6b9e25
andesviktor/Python_adv_lessons
/homeworks/homework_2/library.py
4,071
4.15625
4
""" Создать три класса: 1. Класс библиотека Поля: - список книг (list Books) - список читателей (list Readers) Методы: - Добавить книгу - Удалить книгу - Отдать книгу читателю - Принять книгу от читателя - Вывести список всех книг - Вывести списо...
29f35c12c8f6a2ffed6e4987a41c70c7c0d998b6
MattCocci/ReusableCode
/CompSci/bisect.py
293
3.65625
4
# Bisection for root-finding def bisect(f, lower, upper, tol=10e-5): middle = 0.5 * (upper + lower) print "Middle " + str(middle) if upper - lower >= tol: if f(middle) > 0: bisect(f, lower, middle, tol) else: bisect(f, middle, upper, tol) else: return middle
52dad76686a481f7218cc435f240c3086897bc37
DesignisOrion/DIO-Tkinter-Notes
/grid.py
467
4.40625
4
from tkinter import * root = Tk() # Creating Labels label1 = Label(root, text="Firstname") label2 = Label(root, text="Lastname") # Creating Text fields entry1 = Entry(root) entry2 = Entry(root) # Arrange in the grid format label1.grid(row=0, column=0) label2.grid(row=1, column=0) # Want to have...
fa5cdbad427a59b56aedf23a00a36b3dfc8dee2e
hubbm-bbm101/lab5-exercise-solution-b2200765016
/Exercise 1.py
307
4.21875
4
number = int(input("Welcome, enter a number: " )) sum = 0 if number % 2 == 0 : for i in range(1, number + 1): sum = sum +i print("the sum is: ", sum) else: for i in range(1, number + 1, 2): sum = sum +i average = sum / number print("The average is: ", average)
08fafdc6d416a5c794b80c1fbff111dc88215e47
ataidekaroline/tbfamazonpy
/TrabalhoFinalAmazon.py
10,821
3.9375
4
#1 - Cadastrar novos clientes class cliente: nome:None cpf:None senha:None email:None limite_credito:None #lista para armazenar as variáveis 'cliente' clientes = [] #1ª função do menu def cadastro(): global clienteN clienteN = cliente() clienteN.nome = input("Nome : ") clienteN.cp...
46be042e32cc83189d965a2efe92a07fb300be11
paull87/PasswordGenerator
/passwordGenerator.py
1,710
3.796875
4
# PasswordGenerator.py - This script will generate a password that meets all # of the following criteria - # At least one upper and lowercase character # At least one number # At least one special character/symbol # Is at least 10 characters long import re, pyperclip as pc, random as r # Random lengt...
bff8437e4bec2513047633377eb41a21999a886c
fernandojsmelo/curso-python-e-django-senac
/exercicio2.py
347
3.890625
4
idade = int(input("Informe sua Idade :")) if idade >= 18: print("Pode entrar na Festa") elif idade >= 16: atuldo = input("Você esta acompanhado de um Adulto? \n" "S=SIM N=NAO : ") if atuldo == "S": print("Pode entrar na Festa") else: print("Lamento deve ir para casa") else: print("Idade inverio...
3be2a6617a2b500e73091f6fbafad444e834e740
maryheng/CT_project
/utility.py
4,987
3.96875
4
# utility.py v1.0 import csv # reads a CSV file and returns every line as a list # e.g. for a CSV file with the following 2 lines: # apple, orange # banana, durian # this function will return this list: [['apple', ' orange'], ['banana', ' durian']] def list_reader(csv_file): the_list = [] with open(csv_file, ...
39d2367ba2910304e1e50724783ffbd3ece60b0f
divyakelaskar/Guess-the-number
/Guess the number .py
1,862
4.25
4
import random while True: print("\nN U M B E R G U E S S I N G G A M E") print("\nYou have 10 chances to guess the number.") # randint function to generate the random number between 1 to 100 number = random.randint(1, 100) """ number of chances to be given to the user t...
2d131fb9f3e64ed522bb1256b83e007fc8d7622f
AbishekNanjappa/MyPythonCode
/first_N_natural_numbers/utility.py
222
3.734375
4
def first_N_numbers(N): num = 1 List = [] while num <= N: List.append(num) num += 1 if num <= N: List.append("#") else: continue return List