blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
f308ebab881b043b38953f111ec5d01d68b84fe2
iDneprov/university
/NM/3/task4.py
863
3.609375
4
statement = {"x*": 1.0, "x": [0.0, 0.5, 1.0, 1.5, 2.0], "y": [0.0, 0.97943, 1.8415, 2.4975, 2.9093]} def GetDerivativesValues(x, y, dot): i = 0 while x[i + 1] < dot: i += 1 while i + 1 > len(x) + 1: i -= 1 firstDerivative = (y[i+1] - y[i])/(x[i+1] - x[i]) + ((y[i+2] - y[i+1])/(x[i+2] ...
ce981daae2eeda0038941778658b09ced578538b
kelv-yap/sp_dsai_python
/ca3_prac1_tasks/section_2/sec2_task4_submission.py
780
4.3125
4
number_of_months = 6 title = "Calculate the average of your last " + str(number_of_months) + "-months electricity bill" print("*" * len(title)) print(title) print("*" * len(title)) print() bills = [] bill_number = 1 while bill_number <= number_of_months: try: input_bill = float(input("Enter Bill #{}: ".for...
32fa594d52303002349c2e360568102da9476bb2
ingrid-wu/CS170
/skeleton/solver.py
7,484
3.515625
4
import networkx as nx import numpy as np import math import os import random ########################################### # Change this variable to the path to # the folder containing all three input # size category folders ########################################### path_to_inputs = "/home/justinwei/cs170/inputs" ###...
8e4bfbf02e1ff7009cfa156cf08427cf0b49caca
jessica156/NFA-to-DFA-Converter
/NFAtoDFA_Converter.py
4,288
4.125
4
from typing import NamedTuple # A Data Structure that holds information about finite automatas class Finite_Automata(NamedTuple): list_of_states: list variables: list start_state: int final_states: list transitions: list final_dfa_states: list # A class that converts files to NFA and NFA to DF...
e3ac44b37f2f78dac95229051386a20881b61009
Afraysse/practice_problems
/missing_num.py
1,173
4.125
4
""" SOLUTION 1: Simple Solution - O(N) keep track of what you've seen in a seperate list. """ def find_missing_num(nums, max_num): # find what number is missing from the list and return it # there's a way of solving in O(n), but can also solve in O(log N) # list may be in any order seen = [Fals...
22ce5573bfb99f17627e24f90206b52968b5ecc0
samuelfujie/LintCode
/973_1-bit_and_2-bit_Characters/solution.py
371
3.890625
4
class Solution: """ @param bits: a array represented by several bits. @return: whether the last character must be a one-bit character or not """ def isOneBitCharacter(self, bits): if not bits: return False i = 0 while i < len(bits) - 1: i += 1 if bits...
555b8028b194953d3b6759bbbbe0b32e19f4ca29
samuelfujie/LintCode
/797_Reach_a_Number/solution.py
432
3.671875
4
class Solution: """ @param target: the destination @return: the minimum number of steps """ def reachNumber(self, target): target = abs(target) n = 0 while target > 0: n += 1 target -= n diff = abs(target) if diff ...
89a11e5a500ca9618ea95e7dc3bdd40c6675b2bf
samuelfujie/LintCode
/362_Sliding_Window_Maximum/solution.py
1,123
3.703125
4
class Solution: """ @param nums: A list of integers. @param k: An integer @return: The maximum number inside the window at each moving. """ def maxSlidingWindow(self, nums, k): if not nums: return [] if len(nums) <= k: return [max(nums)] ...
b5316056c302236f7e9a208aa21b71272b01dfc3
samuelfujie/LintCode
/57_3Sum/solution.py
1,057
3.546875
4
class Solution: """ @param numbers: Give an array numbers of n integer @return: Find all unique triplets in the array which gives the sum of zero. """ def threeSum(self, numbers): numbers.sort() results = [] for i in range(len(numbers) - 2): if i > 0 and ...
b5b947f9a0f83a0086b422031693613d9724cfa5
samuelfujie/LintCode
/685_First_Unique_Number_in_Data_Stream/solution.py
582
3.53125
4
import collections class Solution: """ @param nums: a continuous stream of numbers @param number: a number @return: returns the first unique number """ def firstUniqueNumber(self, nums, number): num_counter = collections.defaultdict(int) for num in nums: num_counte...
7169e95f7c0428f04db6c3704da8208c473da7d5
samuelfujie/LintCode
/1351_Fraction_to_Recurring_Decimal/solution.py
1,700
3.953125
4
class Solution: """ @param numerator: a integer @param denominator: a integer @return: return a string """ def fractionToDecimal(self, numerator, denominator): if numerator == 0: return '0' negative = False if (numerator < 0 and denominator > 0) or (d...
0def714111e48ba4b5ec247086b08780c053c0bb
samuelfujie/LintCode
/134_LRU_Cache/solution.py
1,872
3.5625
4
class LinkedNode: def __init__(self, key=None, value=None, prev=None, next=None): self.key = key self.val = value self.prev = prev self.next = next class LRUCache: """ @param: capacity: An integer """ def __init__(self, capacity): self.max_capacity = capacity...
8082068ef255b601febec4722ca8292cb4de4594
mishashahab/left_leaning_red_black_tree
/LLRBT (19B-004-CS)(19B-043-CS).py
16,254
3.84375
4
# Creating a public class of RBTNode class RBTNode: # This constructor takes one argument data key i.e. data to set the elements def __init__(self, key): self.key = key # Initialize Node pointers left and right self.left = None self.right = None # New node is al...
be539a08cd8c4261a9764967596fb16a26756e12
Kai-Chen/the-lambda-club
/python/basic.py
213
3.625
4
def max2(a,b): return a if a > b else b def max3(a,b,c): return max2(max2(a,b),c) def reverse(s): return s if len(s) <= 1 else reverse(s[1:]) + s[0] def reverse2(s): return ''.join(reversed(s))
355ee501441d3fea748bee9e288d2466fba17afb
alexweee/learn-homework-2_my
/my_date_and_time.py
1,490
4.15625
4
from datetime import datetime, date, timedelta import datedelta """ Домашнее задание №2 Дата и время * Напечатайте в консоль даты: вчера, сегодня, месяц назад * Превратите строку "01/01/17 12:10:03.234567" в объект datetime """ def split_myday(day): #day_split = str(day).split() #yesterday_final = day....
d172c5f1c365dea3a6a8688d35dde1f5026db073
DomWat/udemy-projects
/hundred-days-python/week2/day8.py
7,342
4.125
4
# functions with inputs, difference between arguments & parameters # # FUNCTIONS # # add a variable to ino can be passed # def greet(): # print('Hello') # print('Hello') # print('Hello') # # pass info when called to replace the variable # greet() # name = input('What is your name?\n') # # ('paramete...
45fee82fdf3e8296572b97c10b6011301d3dbd85
gabits/training
/python/data_structures/subarrays.py
1,992
4
4
""" 3 Subarray problem Consider the following task given two arrays A and B without repetitions (that is, no double occurrences of the same element). Tha task is to check whether each element of B is also an element of A without regard of the order. For instance if A = [1, 2, 3, 4] and B = [2, 3, 1] then the answer is ...
8323a3ce2b1462ad00b30aa433c84a89ce5cd1cb
gabits/training
/python/algorithms/longest_common_string.py
316
3.96875
4
"""Given strings s1 and s2, find the longest string s such that s1 = s + u1 and s2 = s + u2, e.g. s1 = ’catch’ s2 = ‘cart’ u1 = ‘tch’ u2 = ‘rt’ comparison = ’t’ > ‘r’ order = s1 > s2 """ # Is is to find the longest between both?
ffb6de3f41339998133918774bfc824673bbb9dd
marchello-bit/geekbrains
/les_1/les_1_task_8.py
411
3.765625
4
#Определить, является ли год, который ввел пользователь, високосным или не високосным. #https://drive.google.com/file/d/1rMFGA4gKeUYoIXjR8GYV-ttVT4-hQJMv/view?usp=sharing N = int(input('Введите год N:')) if N%4==0 and N%100!=0 or N%400==0: print('Год високосный') else: print('Год не високосный')
06f9566a0d1c51fc9caf5b7279b9b16cfb907f99
marchello-bit/geekbrains
/les_2/les_2_task_2.py
726
4.09375
4
#Посчитать четные и нечетные цифры введенного натурального числа. Например, если введено число 34560, то у него 3 четные цифры (4, 6 и 0) и 2 нечетные (3 и 5). #https://drive.google.com/file/d/1rMFGA4gKeUYoIXjR8GYV-ttVT4-hQJMv/view?usp=sharing n = int(input('Введите натуральное число число:')) chet=0 ne_chet=0 while n ...
e1771a8446c03835dda14e0f77a779a5c8451ae2
LPisano721/color_picker
/colorpicker.py
1,767
4.21875
4
""" Program: colorpicker.py Author: Luigi Pisano 10/14/20 example from page 287-288 Simple python GUI based program that showcases the color chooser widget """ from breezypythongui import EasyFrame import tkinter.colorchooser class ColorPicker(EasyFrame): """Displays the result of picking a color.""" ...
0bc381a2bfabd0717afc100ac74f3fd36dbd871f
prasadwrites/algorithms
/palindrom_linkedlist.py
1,349
3.640625
4
from collections import deque # 1->2->3->4->4->3->2->1 # b b b b # f f f b # 1->2->3->4->5->4->3->2->1 # b b b b b # f f f f f # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class...
5881a51204c3f71d260f2650146d8eb781166b9c
Curtis-S/td-project-two
/main.py
5,453
4.15625
4
import keywordCypher import atbash import polybiussquare if __name__ == "__main__": print("Hello and welcome to my cipher program where" "you can encrypt and decrypt your words with well known ciphers") while True: first_response = input("please type a number to select what option\n\n" ...
1c454e7aeca39c00c44d7941d004b1a5665aec10
fordfishman/16SEvoSim
/code/python/Strain.py
3,059
3.671875
4
## Ford Fishman # class for strain, defined here by differences in protein coding genes # import modules import rRNA import Gene import Error as er class Strain: """ Constructor ----------- name (str) - name of strain ssu (rRNA) - represents rRNA of strain ssuLength (int) - how long rRNA will...
70c68e870d0be107e02cbef05a20f99193d13054
youngjos/ATBS_ws
/10_scope.py
543
3.796875
4
spam = 42 # global scope ham = 32 def eggs(): spam = 24 # local scope to eggs, wont exist after function return def bacon(): print(ham) # will use the global ham variable so 32 def baconButLocal(): ham = 64 print(ham) # will use the local ham variable so 64 def baconButLocalButUsingGlobal(): glo...
ac67a506fe6faa79d486c4dccac785fa06d68dfd
Sushantghorpade72/EM-624---Infomatics-for-engineering-management
/EX 02/EM624A_EX02_SushantGhorpade.py
1,489
4.09375
4
#Author: Sushant Ghorpade #Description: # Write the program as a loop to prompt the user for input and print the input, until the user inputs ‘done’ (without quotes). #The user should be prompted for a price in cents. They will enter the word ‘done’ (no quotes) to finish. # Enter the price as cents, a multiple of ...
d5a32a5ddac2767db1582f26b895b4e4cde8ce9f
souravs17031999/HacktoberFestContribute
/Algorithms/Cryptography/Rsa.py
1,123
3.96875
4
#!/usr/bin/env python3 from math import gcd import gmpy2 from Crypto.PublicKey import RSA from Crypto.Util.number import * '''RSA Implementation in python 3.6 ''' # Two random prime numbers are chosen p=2 q=7 n=p*q phi=(p-1)*(q-1) print("Choosen primes:") print("p=",p, ", q =",q) print("Modulus or n =",n) print("Euler...
5a08c851b80ca886e0bbae186a68c096de3fdf7d
annamiklewska/KnapsackProblemGA
/GeneticAlgorithm/problem_generator.py
2,348
3.53125
4
import csv import logging import random as r from structs import Item logging.basicConfig(level=logging.INFO) def _generate_items(n, w, s): """ :param n: number of objects to choose :param w: maximum carrying capacity of the backpack :param s: maximum backpack size :return: list of items; Item(w...
3011731db670688f250340be1d79d960d6f55bb1
VinoyKoshyThomas/NewOne
/string.py
166
3.875
4
var1='hello' var2="World" var3='hai' #Concat print(var1+var2) #Repeatation print(var3 *3) #slice print(var1[1:3]) print(max(var1)) print(min(var1)) print(len(var1))
f4fc11022326dc492769e266e8c91918d60ce30f
toan-lee/loopring-quant
/src/market/__init__.py
1,756
3.671875
4
import abc class MarketException(Exception): """ Custom Market Exception """ def __init__(self, msg): super(MarketException, self).__init__(msg) self.__msg = msg class Market(object): """ abstract Market class """ __metaclass__ = abc.ABCMeta def __init__(...
2da51b497199b3dd5b65dcf8b63eb1443965f169
Harmonylm/Pandas-Challenge
/budget_v1.py
2,831
4.1875
4
# Budget: version 1 # Run with: python3 budget_v1.py import csv BUDGET_FILE="budget_data.csv" month_count = 0 # number of months read total_pl = 0 # total profit less all losses max_profit = 0 # largest profit increase seen max_profit_month = "" # month string with maximum profi...
0c4c21e8e8acf9787d3cf0455ca741688b2e32c7
satyajeetdeshmukh/Python-OpenCV
/learning basics/if elif else.py
132
3.703125
4
name = "Rohan" if name is "Rohan": print("Maa Chuda") elif name is "Satyajeet": print("Bhsdk") else: print("Bhen k Lund")
aed1f4263ce2f6d1e726ffdf7e0a918715e2bd66
satyajeetdeshmukh/Python-OpenCV
/learning gui/5.py
602
3.5625
4
# gui with classes from tkinter import * class BuckyButtons: def __init__(self, master): # when object is created this function will initialize, master means the main window frame = Frame(master) frame.pack() self.printButton = Button(frame, text="Chello", command = self.printMessage) ...
b935d8751aed1c64a752bd36bd42cc71eaf9e5cc
stcchau/cube_solver
/cube_solver.py
7,570
3.53125
4
import queue import time import random class Cube: def __init__(self, board): self.board = board self.solution = [[('w', 'r', 'g'), ('w', 'g'), ('w', 'g', 'o'), ('w', 'o'), ('w', 'o', 'b'), ('w', 'b'), ('w', 'b', 'r'), ('w', 'r')], [('y', 'o'), ('y', 'o', 'g'), ('y...
a67c1e64e1b30ac113ec21f81ab1c3e1c0c51c8a
ahmedbahaaeldin/MNIST-Data-Set-Deep-learning-Practice
/Code.py
2,368
3.546875
4
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("C:\\Users\\BIKAA\\Desktop\\AhmedBahaa\\New folder",one_hot=True) n_nodes_h1=500 n_nodes_h2=500 n_nodes_h3=600 n_classes=10 batch_size=100 x=tf.placeholder('float',[None,784]) y=tf.placeholder('float') ...
47855b6fd8f1449aaace6f48061bcf56a76b9226
KashifNiaz59/image_processing
/1_basics.py
706
3.859375
4
# ********** some basics of the image ****************** # i have an image " imageProcessing.jpg " # using opencv library # import it import cv2 # **** READ IMAGE ----> imread() img=cv2.imread("imageProcessing") # to display image in 2-D array # check the type of the array print(type(img)) print(img) # **** SHOW...
3a2401fc3c06626e7ce21471e347956a0e1c140f
ErikWeisz5/digitalSolutions2020
/Classwork/Test1.py
97
3.734375
4
num1 = int(input('Enter the first number: ')) print(num1 // 2) print(num1 % 2) print((5 + 2) / 4)
3cc259f575598bc6585577eeb9edfa2576b41555
SrCervantes/Mision-05
/Mision05.py
10,259
3.84375
4
# Autor: Luis Ricardo Chagala Cervantes # Mediante ciclos for se realizaran diversas funciones muestrando en una pantalla seleccionable una figura o un valor numerico. import pygame # Librería de pygame. import random # Librería random. # Dimensiones de la pantalla ANCHO = 800 ALTO = 800 # Colores BLANC...
aaf3c788b2619bb800995d43a9b80d4f5b13a10b
Sharan-Lobana/Cryptography
/cipherfeedbackmode.py
1,891
3.546875
4
import random #Convert string initialization vector to stream of bits #Each character represented by 8 bits def generate_IV(initialization_vector): x = [ord(i) for i in initialization_vector] return ''.join('{0:08b}'.format(i) for i in x) #Generate a key of random ordering of 8 bit numbers def generate_key(blocksiz...
5ce7fde9fe6605344ebc0581bef6df15d3a9e939
Sharan-Lobana/Cryptography
/transposition.py
1,996
3.84375
4
#Implementation of transposition block cipher from utils import generate_key_transposition,generate_random_string #Block size = 25 def transpose(block_array,key): string ='' for i in range(5): for j in range(5): string += block_array[j][int(key[i])] return string def encipher(message,key=None): supplied = ...
57b57fc2c25a5fed061a5bbd7d046d234469e6c3
max-web-developer/python-homework-1
/home.py
1,411
4.125
4
# total = int(input("введите количество квартир!: ")) # floors = int(input("введите количество этажей: ")) # apartment = int(input("номер кв вашего друга? ")) # p = (total/floors) # if total % floors > 0 or apartment <= 0 or total < apartment: # print("кол-во квартир не делится на кол-во этажей!") # if total % flo...
05c2a991b646c6cc5e6b260e7c2b20b132a258f8
samfernandss/curso_python
/br/com/sammyfckr/aula04_tipos_dados/tipo_dados.py
355
3.875
4
#int num = 1_000_000 print(num) #float valor = 1.4 #boolean (inicial maiúscula sempre) ativo = True print(not ativo) #string "isso é" 'isso é' '''isso é''' """isso é. (acho)""" nome = "Sam Fernandes" print(nome.upper()) print(nome[0:3]) #nome[::-1] -> Do primeiro ao último elemento e inverter (inversão de string) ...
17d9c674c716fe57317cac123fecd1df07ee1c35
martinalee94/2019-1-OSS-L1
/ex10_martina.py
177
3.953125
4
def RectangleArea(width, height): return width*height width=float(input("Width: ")) height=float(input("Height: ")) Area=RectangleArea(width,height) print(Area)
aa0cf1b1fc24755457d2f656ceb98ba36ab51ff6
davidossa/Datacademy
/semana1/cal_volumen.py
262
3.703125
4
def run(): radio= int(input('Cual es el radio de tu cilindro: ')) altura= int(input('Cual es la altura de tu cilindro: ')) volumen= 3.1416*(radio**2)*altura print(f'El volumen de tu cilindri es {volumen}') if __name__ == '__main__': run()
339e46b9d60ecc8c4241afd603f0c2cb2a50eec9
mehdiebrahim/Stanford-Algorithms---Coursera
/Divide and Conquer, Sorting and Searching, and Randomized Algorithms/Week 3/quicksort.py
3,882
3.96875
4
import pandas as pd import sys import os os.chdir('/Users/mehdiebrahim/Desktop/Coding/Stanford Algorithms - Data') data = pd.read_csv('QuickSort.txt',sep=' ',header=None) data.columns = ['a'] L = list(data['a']) n = len(L) count= 0 def find_middle(a,b): '''Finds the middle element between a and b ''' if abs...
1eca3b4a68f798fe401da75f89df4749e9cd62fd
oba2311/UrbanModelling-Segragation
/D3-Jerusalem/Scrapers/TableGeneralScraper.py
511
3.625
4
import requests import lxml.html as lh import pandas as pd url='https://www.btselem.org/hebrew/jerusalem/building_starts_statistics' #Create a handle, page, to handle the contents of the website page = requests.get(url) #Store the contents of the website under doc doc = lh.fromstring(page.content) #Parse data that are...
bb2d48d0d644ef6e80e13741ff71cc31966e2266
Ga3ta/maindgueims
/math_set.py
956
4.0625
4
''' Importamos la función randint del módulo random y la función sqrt del módulo math para nuestro generador de cuadráticas ''' from random import randint from math import sqrt ''' En esta función, generamos tres números para nuestras constantes de la función cuadrática, checamos la discriminante y con base en su valo...
7d44a24b40ff2163e3d5819235a8cdbc399a8921
Ga3ta/maindgueims
/display_math_problems.py
2,440
3.5
4
import pygame from random import randint from box import * from screen_text_chemistry import * import math_set #Esta clase maneja los elementos que se deben mostrar en la pantalla de los problemas de matematicas class DisplayMath: # La función con la que se instancia el objeto def __init__(self, size, screen)...
a286155c30ca510b30626717275ddf71d9d35455
wfelipe3/KnowBag
/python/bus-stop/datatypes.py
471
3.640625
4
tuple = (12, "test", True) age, name, male = tuple assert age is 12 assert name is "test" assert male is True list = [1, 2, 3, 4, 5] list.append(6) assert 6 in list disctint_values = {1, 2, 3, 2, 5} assert len(disctint_values) is 4 assert len(set(list)) is 6 assert 2 in disctint_values assert 10 not in disctint_...
898a4b983ac42313214af8538e6705b181ec0884
wfelipe3/KnowBag
/python/bus-stop/portafolio.py
829
3.6875
4
f = open("data.csv", mode='r') data = f.read() print(data) f.close() def openData(file="data.csv", mode='r', error="warn"): if error not in {"warn", "silent", "raise"}: raise ValueError("Error must be warn, silent or raise") try: return open(file, mode) except FileNotFoundError as e: ...
27f0bc7810fa55cee7ff04e24ac3950dd94c2137
ronidad/prep_group_project
/functions.py
289
3.796875
4
def greet(who_to_greet): greetings = "Hello " + str(who_to_greet) return greetings print(greet("Ronnie")) def mean(value): if type(value) == dict: the_mean = sum(value.values()) / len(value) else: the_mean = sum(value) / len(value) return the_mean
b107cf5cf5f3ab6c4c18fc32fecdc83ab128d6e7
varshini-07/python
/series.py
820
4.1875
4
#sum of series def factorial(num): fact=1 for i in range(1,num+1): fact=fact*i return fact num=int(input("enter the number: ")) sum=0 for i in range(1,num+1): sum=sum+(i/factorial(i)) print("the sum of series: ",sum) #sum of odd n series def factorial(num): fact=1 for...
eebb8eaa4391d0b4e47a4ac4c02d53b83333da48
varshini-07/python
/switcher.py
844
3.625
4
def zero(): return 'zero' def one(): return 'one' def indirect(i): switcher={ 0:zero, 1:one, 2:lambda:'two' } func=switcher.get(i,lambda :'Invalid') return func() print(indirect(4)) print(indirect(2)) print(indirect(1)) ============================================...
3c95524aa0f0006d74e2913f5c5bd889aec11cb6
diver-gent/python_classes
/class_project/my_class_file.py
788
3.734375
4
class Test: def __init__(self, a): self._a = a self._b = "instance_variable_b" @property def a(self): print("getter of a") return self._a @a.setter def a(self, value): print("setter of a") self._a = value @a.deleter def a(self): pri...
86244c7def2259a4afcf30c27ef5d7bbaed088dc
rafasapiens/learning
/Frame input.py
543
3.8125
4
from tkinter import * root = Tk() Label(root, text='Click em diferentes\n locais na tela abaixo').pack() def callback(event): dir(event) ['__doc__', '__module__', 'char', 'delta', 'height', 'keycode', 'keysym', 'keysym_num', 'num', 'send_event', 'serial', 'state', 'time', 'type', 'widget', 'width', 'x', ...
c66d440ace31329638495fedd9c17b1f6caf4e3c
rafasapiens/learning
/Dormir.py
606
3.8125
4
nome=str(input('Olá amigo, qual seu nome? \n')) print ("Prazer", nome,'!'"""\nEu sou o computador, \nmas pode me chamar de Amigãozãoku. \nAdoro quando me chamam assim! ;)\n""" ) idade = int(input('Qual sua idade? \n')) print ('Muito jovem ainda! \nTemos muito o que viver juntos!') sono=(input("Você es...
1696343cf400d655d6e5680a88e550334764cf75
yeutterg/beautiful-photometry
/src/load_spd_to_csv.py
2,195
3.59375
4
""" This script is used to load spectral data files (CSVs) into a basic spectral database, for example source_illuminants.csv The script is run as follows: python load_spd_to_csv.py target_database.csv file_to_import.csv name For example: python load_spd_to_csv.py source_illuminants.csv CSVs/melanopic_spd.csv Melanop...
d137bb1a2509bd2ab60f39943673485b1e57489f
owili1/BOOTCAMP
/Hello world.py
210
4.125
4
print("Hello World\n"*10) #modifying hello world to prinT nmaes in reverse name1=(input("Enter name")) name2=(input("Enter name")) name3=(input("Enter name")) print("Hi "+name3+","+name2+","+name1+".")
916837c875ff973dce15ced21f0d1e1ac39eeb7e
ahmadatallah/rosalind-problems
/Textbook_BA1A.py
1,198
3.921875
4
#!/usr/bin/env python ''' A solution to a code challenges that accompanies Bioinformatics Algorithms: An Active-Learning Approach by Phillip Compeau & Pavel Pevzner. The textbook is hosted on Stepic and the problem is listed on ROSALIND under the Textbook Track. Problem Title: Compute the Number of Times a Patter...
fb93bc746877017821ac227b857696962603634d
ahmadatallah/rosalind-problems
/Textbook_BA1N.py
1,512
3.8125
4
#!/usr/bin/env python ''' A solution to a code challenges that accompanies Bioinformatics Algorithms: An Active-Learning Approach by Phillip Compeau & Pavel Pevzner. The textbook is hosted on Stepic and the problem is listed on ROSALIND under the Textbook Track. Problem Title: Generate the d-Neighborhood of a String C...
2f1392acbb42d0b1a81749756b379cd938c1a025
nordox/Project_Euler
/euler5.py
1,225
4.09375
4
# Program to find the smallest positive number # that is evenly divisible by all the numbers # from 1 to 20 # ## Old way of doing it (working) ## Takes a long time # def divider( x ): # i = 1 # while i < 20: # if x%i == 0: # i = i + 1 # else: # i = 1 # x = x...
ff7473cc0816f458a629f50a07e6321a12423a32
doleksiyenko/Maze-Generation
/prim_maze_generator.py
3,602
4.28125
4
import numpy as np import random from typing import Tuple, List from PIL import Image def generate_maze(size: int) -> np.array: """ Return a numpy array that represents a maze. The maze is generated using 'Prim's Algorithm'. <size> : An integer representing the size of the maze to be generated, i.e s...
669721ef23f36b105d2a64864f7af0aedc565e54
melissah1993/database-tracker-python
/tracker.py
1,665
3.6875
4
#Melissa Hardware. import sqlite3 >>> def connect(sqlite_file): conn = sqlite3.connect(sqlite_file) c = conn.cursor() return conn, c >>> def close(conn): # conn.commit() conn.close() >>> def total_rows(cursor, table_name, print_out=False): c.execute('SELECT COUNT(*) FROM {}'.format(table_name)) count = c.f...
04de961947211d4d3402fb09d597845f8d020f11
AlexandruCabac/Instructiunea-FOR
/For4.py
144
3.828125
4
a=int(input()) b=int(input()) if(a%2==0): for i in range(a+1,b,2): print(i) else: for i in range(a,b,2): print(i)
e771d5d422e0b9570b60ef9f6d35612ead5c23fd
xiulonghan/wordSeg
/leftRightEntropy.py
879
3.734375
4
# -*- coding:utf-8 -*- """ Algorithms about calculate the information entropy of left and right list. Author:aluka.han Email:aluka_hxl@gmail.com Reference: https://github.com/Moonshile/ChineseWordSegmentation http://www.matrix67.com/blog/archives/5044 https://zlc1994.com/2017/01/04/ """ import mat...
3c5be2dde0b5fee7c9f3305e6b46b66f7a275817
AntonChernichkin/Probe
/hw2/04_my_family.py
1,574
4
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Создайте списки: # моя семья (минимум 3 элемента, есть еще дедушки и бабушки, если что) my_family = ["Антон", "Варя", "Леброн", "Элвуня"] # список списков приблизителного роста членов вашей семьи my_family_height = [ # ['имя', рост], ] my_family_height.append(["...
474f8dd05fc042e65867e54ddd35ef7afda185d1
indranilsinharoy/iutils
/cg/rigidbody.py
25,824
3.546875
4
# -*- coding: utf-8 -*- #----------------------------------------------------------------------------------------- # Name: rigidbody.py # Purpose: Utility functions useful for computer graphics, especially related to # rigid body transformations # # Author: Indranil Sinharoy # # Created: ...
58d2bc9660b52b0eaeed197441b98d0cc1a11986
SkinFart/takeaway
/phone.py
464
3.984375
4
def phone(): # Tested, this is better than using try/except, better formatting for user keep_going = True while keep_going: phone = input("Enter contact number: > ") if phone == '': print("Contact number cannont be blank. ") elif all(x.isnumeric() or x.isspace() for x in pho...
3ad5ba06dd3e950ba6b912ff8ac20ecbe6dbd170
opheliaynyn/procon_library
/BIT.py
510
3.65625
4
#--------------------------------------------------------------- #BIT(Bynary Indeked Tree, Fenwick Tree) class BIT(object): def __init__(self, size): self.size = size self.bit = [0] * (self.size + 1) def sum(self, i): s = 0 while i > 0: s += self.bit[i] i...
d033dd48d414b0daaf537e2d6336e32715029b80
tlevine/namamamonom
/namamamonom/main.py
558
3.640625
4
import argparse from namamamonom.columns import read from namamamonom.name import is_name parser = argparse.ArgumentParser() parser.add_argument('filename', nargs = '+') def main(): args = parser.parse_args() import sys, csv writer = csv.writer(sys.stdout) writer.writerow(('filename', 'name', 'is_na...
c3ab3341eb1b2060d2a1fd48da8828cd3172453a
jstutul/Jugulbondi
/designcsv.py
489
3.53125
4
from csv import writer def tutul(p): return p def Createcsv(data): with open('dataset.csv','w') as file: csv_writer=writer(file,lineterminator='\n') header=('age','height','weight','city','education','income','gender','body_type','complexin','drinking','smoking','religion','family_status','ma...
9f8f75dd4a487388bef412fa748403abbbfa0076
csmatic/xBombs
/mapGrid.py
1,462
3.515625
4
''' Created on 11 Apr. 2018 @author: bob ''' from terrain import * class MapGrid(object): ''' classdocs ''' def __init__(self): ''' Constructor ''' # initiate grid via list of lists self.myboard = [] for numLoop in range(10): ...
db665202fccf5aef49ee276732e2050ffde1306f
thiamsantos/python-labs
/src/list_ends.py
416
4.1875
4
""" Write a program that takes a list of numbers (for example, a = [5, 10, 15, 20, 25]) and makes a new list of only the first and last elements of the given list. For practice, write this code inside a function. """ def get_list_start_end(initial_list): return [initial_list[0], initial_list[-1]] def main(): ...
9993766594dea8835043ca71a5e058d4dc8796bf
thiamsantos/python-labs
/src/odd_even.py
525
4.40625
4
"""Ask the user for a number. Depending on whether the number is even or odd, print out an appropriate message to the user. Hint: how does an even / odd number react differently when divided by 2? """ def is_odd(number): return number % 2 == 1 def main(): number = int(input("Type a number: ")) number_is_o...
0c9e3663676c47f6df1dc219c27003d950d36a65
adelinmihoc/University
/Fundamentals of Programming/Laboratories/Lab 5/DomainBook.py
1,818
3.828125
4
#Domanain Module class Book: def __init__(self, isbn, author, title): self.isbn = isbn self.author = author self.title = title def getIsbn(self): ''' Function that gets the isbn of a book input: output: self.isbn - the isbn of a book ''' ...
db5adcbd59dbda7b271cc51c39a05985a033010f
adelinmihoc/University
/Fundamentals of Programming/Laboratories/Lab 11/domain/validators.py
999
3.53125
4
from errors.exceptions import ValidationError class ValidateStudent: def validate_student(self, student): errors = "" if student.get_stud_id() < 0: errors += "Invalid student id!\n" if student.get_stud_name() == "": errors += "Invalid student name!\n" i...
0487c1552665c0312a2af134d425d045d82aec8d
ebamberger1/BiasInData
/preprocess_compas.py
5,844
3.5625
4
# Preprocesses the adult dataset in preparation for one-hot encoding and # scaling import pandas as pd import numpy as np from csv import writer #pd.set_option("display.max_rows", None, "display.max_columns", None) # Replaces all values of an attribute with specified values. # df is a dataframe, attr is ...
59c403dc437d169f3221cd169eb386aa72374c92
nemonat/Testing
/Sky.py
750
3.890625
4
my_number = 5 + 5 x = "Einat" y = "0533341128" z = 41 print(x) print(y) print(x + " " + y) print (x + " " +str(z)) t = 12 s = 13 #First project print ( 12 +13) print (12*13) print(13-12) print (13/12) if (t> s): print ("t is bigger") if (s>t): print ("s is bigger") if s>t: print ("Good") elif s==t: ...
b4c162543b31a9dd7bd698fb105fa66c7684d341
nemonat/Testing
/Buyme.py
3,590
3.5
4
# A. # Enter the website from selenium import webdriver driver = webdriver.Chrome('C:/Users/Rikman/Documents/Devops/chromedriver.exe') driver.get("https://buyme.co.il/") # Enter הרשמה subscribe = driver.find_element_by_class_name("seperator-link") subscribe.click() # Press button "להרשמה" subscribe2 = driver.find_...
4956c92527f892b1662be74cf1a84939442427d0
python-practice-b02-006/tambovtsev
/lab8/body.py
4,451
3.53125
4
import pygame import numpy as np G = 1 class Body(pygame.sprite.Sprite): """ Represents a planet or a star. """ def __init__(self, group, mass, pos, vel, radius, color="#2aff00"): """ Creates a body with given parameters, adds it to the group of bodies. """ self.mass ...
01efdde0ac87f3142f526a09e51c922559ffbe69
edusidsan/Kali-Linux
/KaliLinuxCourse/Week2/python101.py
3,444
4.25
4
#!/bin/python3 #Print string print("Strings and things:") print('Hello, world') print("""Hello this is a multi-line string!""") print("This is"+" a string") print('\n') #new line #Math print("Math time:") print(50 + 50) #add print(50 - 50) #sub print(50 * 50) #mult print(50 / 50) #div print(50 ** 2) #exp print(50...
65c038f2df7f62a8533e78f185137c602eac861f
arbazkhan971/Robotics-pracs-exam-code
/fundamental_rotation.py
630
3.5
4
import numpy as np import math x = int(input("Enter the X axis:")) y = int(input("Enter the y axis:")) z = int(input("Enter the X axis:")) axis = int(input("enter axis of rotations")) r = int(input("Enter angle of rotations")) a = r * math.pi/180 p = np.array([[x],[y],[z]]) r1 = np.array([[1,0,0],[0,math.cos(a),-mat...
2b8829210bb2c376dd02e9d6587d65c80c79866f
gmongaras/Salary_Predictor
/complete.py
7,543
3.578125
4
import matplotlib.pyplot as plt #Used to create graphs import seaborn as sns #Also used to create graphs import numpy as np #Used for working with arrays which will be #useful when working with the data import pandas as pd #Used to open CSV files from sklearn.preprocessing import LabelEncoder, O...
fc5124440d1ff4f21e6fc89ec236cb13893b65cb
Blaxon/2048-Xanai
/move_table.py
2,341
3.859375
4
""" Author Xander Hang this is 2048 game. a table storage move """ import game UP_TABLE = {} DOWN_TABLE = {} LEFT_TABLE = {} RIGHT_TABLE = {} HITS = 0 def move_up(matrix): if matrix in UP_TABLE: global HITS HITS += 1 return UP_TABLE[matrix] else: UP_TABLE[matrix] = game.mo...
fcd64f80a0bce7785044d71c65221e1d4dd13df1
arsengizatov/hello-world
/Project_python.py
2,344
3.609375
4
import random import os class Project: def __init__(self, file): self.fileName = file def open_file(self): file = open(self.fileName, "r") return file def read_file(self): descriptions = self.open_file().read().split("\n\n") each_descriptions = list() for each in descriptions: each_descriptions....
6c62612a0270be0ff45c0a9d678ceb1d25781a3b
CrazyC33/00_Python_Basics
/input.py
368
4.09375
4
username = input("What is your name? ") fav_num = int(input("Favourite Number? ")) double = fav_num * 2 half = fav_num / 2 squared = fav_num * fav_num print("Hi {}, your favourite number is {}".format(username, fav_num)) print("double {} is {}".format(fav_num, double)) print("half {} is {}".format(fav_num, half)) pr...
ba69cc116365bdbebba27f8b2e6fc14030f7a6ec
slawomirgicala/compilers
/ast.py
1,432
3.5
4
class Node: pass class Program(Node): def __init__(self, program): self.type = "program" self.program = program class Statement(Node): def __init__(self, this_stmt, other_stmts): self.type = "statement" self.this_stmt = this_stmt self.other_stmts = other_stmts c...
098375b970a69f17f60d267a26b5806c319cc8a3
kacox/data-structures-practice
/graphs/graph_weighted_undirected.py
4,746
3.8125
4
""" Implementation for an undirected, weighted graph data structure. Very similar to `graph_undirected.py` implementation. (0)---7---(1) / \ 1 2 / \ (4)-------4--------(2)----3----(3)---2---(5) """ import random # adjacency list representation of above graph # {...
b68b9b215454a269d225e56aa9b1cfc8225633aa
bobbyisac/S1-microProject
/pong1.py
5,459
3.9375
4
# Implementation of classic arcade game Pong #import simplegui import simpleguitk as simplegui #import SimpleGUICS2Pygame.simpleguics2pygame as simplegui import random # initialize globals - pos and vel encode vertical info for paddles global ball_pos, ball_vel WIDTH = 600 HEIGHT = 400 BALL_RADIUS = 10 PAD_WIDTH = 8 P...
4f5f0d208acedbdb28f7ef6e058fcdaf3719fcb7
tgalloway00/python-challenge
/pybank.py
2,218
3.984375
4
import os import csv total_months = [] profit_losses = [] average_change = [] # pull data from particular csv csvpath = os.path.join('budget_data.csv') with open(csvpath) as budget_data: budget_reader = csv.reader(budget_data, delimiter=',') # skip over header next(budget_reader) # start for loop to get ...
517b4338cc412f923d5a7dbb8d5a891f6800eb3e
bella013/Python.questions.repeat
/questao8.py
161
3.9375
4
soma = 0 media = 0 for i in range (5): num = int(input("Insira un número: ")) soma = soma+num media = soma/5 print("A média dos números é: ", media)
9000434610d7911ec457c2e81bcbdf58d4f54e9d
Rosthouse/AdventOfCode2019
/challenge7_part1.py
2,214
3.78125
4
# Advent of Code 2019: Day 7, Part 1 # https://adventofcode.com/2019/day/7 from processor import Processor import itertools def run_settings(settings: [int], code: [int]) -> int: out = 0 current = 0 processors: [Processor] = [Processor(code.copy()) for x in range(5)] while current < 5: proce...
144192ef48f9da6751a542c84ddb6ef2fb0aff6c
Rosthouse/AdventOfCode2019
/challenge6_part1.py
1,500
3.90625
4
# Advent of Code 2019: Day 6, Part 1 # https://adventofcode.com/2019/day/6 from anytree import Node, RenderTree, AsciiStyle, search, PreOrderIter def create_orbit_tree(orbits: [str]) -> Node: root = Node("COM") for orbit in orbits: planets = orbit.strip().split(")") parent = search.find(root, ...
5eb4fd9955c959eb3c858b7130eca4d6abc95f89
Rosthouse/AdventOfCode2019
/challenge4_part1.py
846
4
4
# Advent of Code 2019: Day 4, Part 1 # https://adventofcode.com/2019/day/4 def verify_pw(pw: int) -> bool: elements: [int] = list(map(lambda digit: int(digit), str(pw))) double: bool = False ascending: bool = True for i in range(0, len(elements)-1, 1): if elements[i] == elements[i+1]: ...
dad4ab8086b8f40a69170a208beb9abe1e28b5d0
rosemaryrose/Newprojectforyandex
/final_game_classes.py
6,545
3.515625
4
import pygame import random from copy import deepcopy import os import sys def terminate(n=None): if n is None: pygame.quit() sys.exit() else: pygame.quit() sys.exit(n) class ILoveHueGame: def __init__(self, corner_colors, numbers_of_cells): self.width = numbers_o...
3725e038bf16b455286757d0725f448b992601ef
gKlocek/political-party-management-system
/political-party-management-system/connection.py
860
3.84375
4
#!/usr/bin/python hostname = 'localhost' username = 'init' password = 'qwerty' database = 'projekt' # Simple routine to run a query on a database and print the results: def doQuery( conn ) : cur = conn.cursor() cur.execute('CREATE TABLE Member (id int PRIMARY KEY,is_leader bool,password text,last_action_time ...
e23747a0ad7fc597c82b1ec6bb689237bc0d360c
yonima/python-source-code-of-my-book
/第五章/5.8 input_python3.py
456
3.640625
4
# -*- coding: utf-8 -*- """ python 用户交互:input() 需求: 请模拟微博登陆程序 1、用户名 2、密码 """ # 微博系统记录我的账号信息如下 username = 'Tfboy' password = '123456' user = input('请您输入您的账号:') passw = input('请输入您的密码:') if user == username and passw == password: print('欢迎回来,请开始您的微博之旅!') else: print('请输入正确的账号和密码!')
6438a3b1e130991201426fba939cbd32936d0292
yonima/python-source-code-of-my-book
/第六章/6.8_map().py
333
3.890625
4
# -*- coding: utf-8 -*- """ map(函数,可迭代对象)的用法 """ # 需求: 使用内建函数把浮点数变成整数 int() list_float = [6.78, 25.6, 80, 97.4] # Python3 与 2不同 list_int = list(map(int, list_float)) print(list_int) # 如果参数位置错了呢? list_int = list(map(list_float, int)) print(list_int)
7263531032116a06858adba2550e537c40a2a0bc
yonima/python-source-code-of-my-book
/第四章/4.3 list_basic_op.py
3,197
3.53125
4
# -*- coding: utf-8 -*- """ 列表基本操作知识点(五大基本操作): 1、访问列表元素 2、 添加列表元素 2、补充知识点:从空列表构建新列表 3、修改列表元素 4、删除列表元素 5、列表排序及其他 """ # 定义列表 -- Python实战圈成员列表 names_python_pc = ['陈升','刘德华','杨幂','TFboys'] ''' 1、访问列表元素 ''' # 根据索引访问列表元素--访问杨幂 yangmi = names_python_pc[2] print('Python实战圈成员列表种第三个是:',yangmi) # 两种方法...
dc2af4a6ee2218a71b3ff1701745dbf4a78e2d9e
yonima/python-source-code-of-my-book
/第五章/5.6 列表解析式.py
5,216
4
4
# -*- coding: utf-8 -*- """ 列表解析式: 1、指定条件的列表解析式: if if--else 两种 2、无条件列表解析式 3、嵌套for循环列表解析式 """ ''' 1、指定 if 条件的列表解析式 ''' # 需求:求10以内的奇数 odds = [] # 使用range(10)生成数字 for n in range(10): # 如果数字除以2的余数为 1 则为奇数 if n % 2 == 1: odds.append(n) print(f'使用 for 循环求10以内的奇数有: {odds}') ''' 把上面的代码转化为列表解析式的步骤为: 1、复制 o...