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
2b7afbda40cae062fb728648eeb1f7f45c0e9bc5
AP-MI-2021/lab-2-CarnuStefan
/main.py
3,609
3.8125
4
''' 6. Determină dacă un număr este superprim: dacă toate prefixele sale sunt prime. De exemplu, `233` este superprim, deoarece `2`, `23` și `233` sunt toate prime, dar `237` nu este superprim, deoarece `237` nu este prim. - Funcția principală: `is_superprime(n) -> bool` - Funcția de test: `test_is_superprime...
4c71d1fa592e3c54844946aa62e8eb4f7c69f95f
Aravindan-C/LearningPython
/LearnSet.py
535
4.3125
4
__author__ = 'aravindan' """A set is used to contain an unordered collection of objects,To create a set use the set() function and supply a sequence of items such as follows""" s= set([3,5,9,10,10,11]) # create a set of unique numbers t=set("Hello") # create a set of unique characters u=set("abcde") """set...
06623bd65d8ba4d62713be768697929943c83e61
Aravindan-C/LearningPython
/LearnIterationAndLooping.py
640
4.15625
4
__author__ = 'aravindan' for n in [1,2,3,4,5,6,7,8,9,0]: print "2 to the %d power is %d" % (n,2**n) for n in range(1,10) : print "2 to the %d power is %d" % (n,2**n) a= range(5) b=range(1,8) c=range(0,14,3) d=range(8,1,-1) print a,b,c,d a= "Hello World" # print out the individual characters in a for c in a : ...
0804378fa0c7cbc3f256161e17bef3564748e38e
Icheka/web-scraping-challenges-and-solutions-in-python
/02.py
1,726
4
4
from urllib.request import urlopen from urllib.error import URLError from urllib.error import HTTPError from bs4 import BeautifulSoup ''' 02: Write a Python program to download and display the contens of robots.txt for https://en.wikipedia.org ''' class Scraper: ''' Loads any webpage and returns an exit code ...
0fb0931988a35f8b48cc8e4f3d43f7c921b7614e
suribe06/Scientific_Computing
/Laboratorio 3/interpo_lagrange.py
777
3.703125
4
from pypoly import X import numpy as np def lagrange(datos): """ Entrada: Un conjunto de datos (ti, yi) Salida: Polinomio interpolante del conjunto de datos con metodo de Lagrange """ n, pol = len(datos), 0 for j in range(n): y = datos[j][1] prod1, prod2 = 1, 1 for k in ...
77bcb095ae5683e04de0a41047e6b1a218890bf7
Casper-V/Oefening
/user_input.py
270
3.953125
4
# vraag bij restaurant of er plek is number_of_seats = int(input("How many seats do you want to reserve? ")) if number_of_seats <= 8: print (f"No problem. We have a table for {number_of_seats} seats ready for you.") else: print ("Sorry, you will have to wait.")
908ff1d7ed7b294b3bef209c6ca6ffbf43851ba8
loc-dev/CursoEmVideo-Python-Exercicios
/Exercicio_008/desafio_008.py
598
4.15625
4
# Desafio 008 - Referente aula Fase07 # Escreva um programa que leia um valor em metros # e o exiba em outras unidades de medidas de comprimento. # Versão 01 valor_m = float(input('Digite um valor em metros: ')) print(' ') print('A medida de {}m corresponde a: '.format(valor_m)) print('{}km (Quilômetro)'.format(valo...
b692aeb005cd6da9ae2b4759d75c482f7fdc56a8
loc-dev/CursoEmVideo-Python-Exercicios
/Exercicio_017/desafio_017_03.py
445
3.9375
4
# Desafio 017 - Referente aula Fase08 # Faça um programa que leia o comprimento do cateto oposto # e do cateto adjacente de um triângulo retângulo, # calcule e mostre o comprimento da hipotenusa. # Versão 03 from math import hypot cat_op = float(input('Digite o valor do cateto oposto: ')) cat_adj = float(input('Digi...
6743e75e9566149e149f565f5e07b09ac843f17c
loc-dev/CursoEmVideo-Python-Exercicios
/Exercicio_021/desafio_021.py
413
3.734375
4
# Desafio 021 - Referente aula Fase08 # Faça um programa em Python que abra # e reproduza o áudio de um arquivo MP3. # Versão 01 from pygame import mixer # Iniciando o funcionalidade 'mixer' mixer.init() # Carregar a música mixer.music.load("music.mp3") # Configuração do Volume mixer.music.set_volume(0.7) # Inici...
b8d2af50ed4f13924ac7edde21e43a48599b56f7
loc-dev/CursoEmVideo-Python-Exercicios
/Exercicio_034/desafio_034.py
529
3.875
4
# Desafio 034 - Referente aula Fase10 # Escreva um programa que pergunte o salário de um funcionário # e calcule o valor do seu aumento. # Para salários superiores a R$ 1250,00, calcule um aumento de 10% # Para salários inferiores ou iguais, o aumento é de 15%. salario = float(input('Qual é o salário do funcionário? R...
37e9ec85ea551c5a0f77ba61a24f955da77d0426
loc-dev/CursoEmVideo-Python-Exercicios
/Exercicio_022/desafio_022.py
662
4.375
4
# Desafio 022 - Referente aula Fase09 # Crie um programa que leia o nome completo de uma pessoa # e mostre: # - O nome com todas as letras maiúsculas e minúsculas. # - Quantas letras no total (sem considerar espaços). # - Quantas letras tem o primeiro nome. nome = input("Digite o seu nome completo: ") print('') print...
c21762ec2545a3836c039837ec782c8828044fca
jkusita/Python3-Practice-Projects
/count_vowels.py
1,833
4.25
4
# Count Vowels – Enter a string and the program counts the number of vowels in the text. For added complexity have it report a sum of each vowel found. vowel_list = ["a", "e", "i", "o", "u"] vowel_count = 0 # Change this so it adds all the values of the keys in the new dictionary. vowel_count_found = {"a": 0, "e": 0, ...
554fd5879f4e8613e342f6c76be58e0a21065611
Chicpork/TIL
/CleanCodePython/ch2/iterables.py
1,241
3.9375
4
# %% from datetime import date, timedelta class DateRangeIterable: """An iterable that contains its own iterator object.""" def __init__(self, start_date, end_date): self.start_date = start_date self.end_date = end_date self._present_day = start_date def __iter__(self): r...
d05b098ece960a4d10b4058ccf2b8d7629520ad8
easykatka04/easy_strr
/ft_count_char_in_str.py
109
3.546875
4
def ft_count_char_in_str(a, b): c = 0 for i in a: if i == b: c += 1 return c
15311589d1122ea69e7e73f9a16d2d4bd121eaf8
RDelg/rl-book
/chapter3/learner.py
3,053
3.65625
4
import numpy as np import matplotlib.pyplot as plt from matplotlib.table import Table from .maze import Enviroment class ValueLearner(object): """Value learner for a 2D grid world. Parameters ---------- maze : Enviroment Maze enviroment to work with. discount : float Discount fa...
f0d24ad8911754befad8e7824332714ec16a7fb8
Melina-Zh/M_L
/nn1.py
1,036
3.640625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Sep 28 16:59:28 2018 @author: Melina """ #感知器 import numpy as np class Perceptron: def __init__(self,eta=0.01,iter=10):#学习率和迭代次数 self.eta=eta self.iter=iter def fit(self,x,y): self.w=np.zeros(1+x.shape[1]) ...
3fd0827e2c0bb92ed205f23420c7c3534951a5fb
jb892/cruw-devkit
/cruw/visualization/draw_rf.py
1,741
3.5625
4
import numpy as np def magnitude(chirp, radar_data_type): """ Calculate magnitude of a chirp :param chirp: radar data of one chirp (w x h x 2) or (2 x w x h) :param radar_data_type: current available types include 'RI', 'RISEP', 'AP', 'APSEP' :return: magnitude map for the input chirp (w x h) ...
8c6fc2d2ebb468e9841e5931bb3a157a6ab9ed97
testroute/HogwartsLG5
/test_things/test_get_param/testlist.py
833
3.96875
4
#列表推导式 import datetime import os import time # list3=[i**2 for i in range(1,4) if i !=1] # print(list3) # list4=[i*j for i in range(1,4) for j in range(1,5)] # print(list4.sort()) # tuple1 =1,2,4 # print(type(tuple1)) # list4.pop(2) # print(list4) # set1 =set() # print(set1,type(set1)) # print(os.getcwd()) # # os.pat...
2487fdd78e971f078f6844a2fa5bb0cd031b0d71
Dunkaburk/gruprog_1
/grundlaggande_programvareutveckling/week2/src/samples/MathMethods.py
751
4.25
4
# package samples # math is the python API for numerical calculations from math import * def math_program(): f_val = 2.1 print(f"Square root {sqrt(f_val)}") print(f"Square {pow(f_val, 2)}") print(f"Floor {floor(f_val)}") print(f"Ceil {ceil(f_val)}") print(f"Round {round(f_val)}") # etc. ...
b4074fc9f325a68ee850c734eb9d7d8814c46a65
Dunkaburk/gruprog_1
/grundlaggande_programvareutveckling/Week1Exercises/Week1Exercises/week1/src/samples/MethodsBasics.py
3,542
4.40625
4
# package samples # To structure the program and to help solving specific tasks we use methods. # Methods, are smaller parts of a program (subprograms) # - The ideal method returns a calculated value given some input values (similar to a mathematical function) # - But not all are: Some methods don't take any input...
a1b609ad8fdc417762f0a8dde352e952751c9672
Dunkaburk/gruprog_1
/grundlaggande_programvareutveckling/Week1Exercises/Week1Exercises/week1/src/samples/PrimitiveVariables.py
3,071
4
4
# package samples # Types, literals and primitive variables # # The primitive (built in) types (sets of values) in Python are # Numeric types: # - int, integers # - float, real numbers. # - complex, complex numbers. # - bool, truth values (are actually considered numeric) # Sequence types: # - list, mutable i...
dc51ac0d58866248ae815122aed9640c4bce9d94
Dunkaburk/gruprog_1
/grundlaggande_programvareutveckling/Week1Exercises/Week1Exercises/week1/src/exercises/Ex7RPS.py
1,083
4.0625
4
# package exercises from random import random # /* # * The Rock, paper, scissor game. # * See https://en.wikipedia.org/wiki/Rock%E2%80%93paper%E2%80%93scissors # * # * This is exercising smallest step programming (no methods needed) # * # * Rules: # * # * ----------- Beats ------------- # * | ...
1b54c0d17ea896a12aa2a20779416e0bac85d066
Dunkaburk/gruprog_1
/grundlaggande_programvareutveckling/week3_tantan/src/exercises/Ex4MedianKthSmallest.py
901
4.15625
4
# package exercises # # Even more list methods, possibly even trickier # def median_kth_smallest_program(): list1 = [9, 3, 0, 1, 3, -2] # print(not is_sorted(list1)) # Is sorted in increasing order? No not yet! # sort(list1) # Sort in increasing order, original order lost! print(list1 == [-2, 0...
16acd854ef3b668e05578fd5efff2b5c2a6f88f4
Dunkaburk/gruprog_1
/grundlaggande_programvareutveckling/Week1Exercises/Week1Exercises/week1/src/exercises/Ex2EasterSunday.py
1,705
4.3125
4
# package exercises # Program to calculate easter Sunday for some year (1900-2099) # https://en.wikipedia.org/wiki/Computus (we use a variation of # Gauss algorithm, scroll down article, don't need to understand in detail) # # To check your result: http://www.wheniseastersunday.com/ # # See: # - LogicalAnd...
98f95c15adc57a9ecc6153fb8834e239a4b47465
aneekdas96/MIT_6034_Lab
/lab8/lab8/lab8.py
9,289
3.5625
4
# MIT 6.034 Lab 8: Bayesian Inference from nets import * #### Part 1: Warm-up; Ancestors, Descendents, and Non-descendents ############## def get_ancestors(net, var): "Return a set containing the ancestors of var" ancestors = set() list_of_vars = [var] while list_of_vars != []: current_var = li...
721f17df884a01ef034deabcb6a71030f44bc438
wll1014/KKB
/beforeClass/KKB1.py
1,442
3.859375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Sep 15 06:32:28 2019 @author: llwu """ import math num_str = input("请输入整数:"); num = int(num_str) num_n = math.sqrt(num) n = math.floor(num_n) left_min = n*n mid_value = n*n + n+1 right_max = (n+1)*(n+1) def getLeftRightSteps(input_num): ...
9108f6979c6c6626061dc6331eaf870058ba1ff0
SpyderXu/coding
/template/Prim最小生成树.py
1,420
3.5
4
class edge: def __init__(self, u, v, w): self.u = u self.v = v self.w = w def either(self, ): return self.u def other(self, p): if self.u == p: return self.v else: return self.u def __lt__(self, other): return...
db73fa6e98d9f30aba22d3c4be6be39f7a1529ea
FightingTigers/tic-tac-toe
/student1.py
2,100
3.953125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu May 23 07:13:26 2019 @author: chaninlaohaphan """ from player import MachinePlayer import random class RandomBot(MachinePlayer): def make_move(self, board): x = random.randrange(3) y = random.randrange(3) ...
516bb485b9f00ac390e40581cb3c508b54ffbc48
justPerson787/Volcanoes-Webmap
/app.py
1,007
3.515625
4
import folium import pandas #to load csv file with data data = pandas.read_csv("Volcanoes.txt") lat = list(data["LAT"]) lon = list(data["LON"]) elevation = list(data["ELEV"]) def marker_color(elevation): if elevation < 1000: return 'green' elif 1000 <= elevation < 3000: return 'orange' els...
35cdae6706209bde1e562dd18200d9d7c6825e78
Momemo/PortScanner
/portScanner.py
1,534
3.609375
4
import socket import threading from queue import Queue open_ports = [] # list for open ports queue = Queue() # empty queue target = '' # IP address to scan # This function creates a socket and attempts to connect with given port and IP # Connection is only sucessful if the port is open # returns true or false d...
3652541c2e8a1fde2e8924b18df74bdb508c739c
nicky1211/DSALabAssignments
/StackExceptionImplement.py
1,479
3.859375
4
class Error(Exception): """Base class for other exceptions""" pass class ArrayFullException(Error): """Raised when elements are tried to be added when the size if full""" pass class ArrayStack: """ LIFO stack implementation usinng Python list as underlying storage """ def __init__ (self,MAX_LEN = 1): ...
bb15f7b01e6cdd880a79d1febaa15a8d94efe4a8
davidich/ucla_ml
/Week 04 (hw3)/Homework 03/utils_linear_regression.py
583
3.546875
4
import numpy as np def h(x: np.ndarray, theta: np.ndarray): """ Linear regression hypothesis function. :param x: Features. N*M matrix. N-instances, M-features :param theta: Bias + Weights; M*1 column vector :return: Prediction (y_hat). N*1 column vector """ return np.array(x @ theta, dtype...
ea93754a85444bff205ca1803dc04a38f26c0035
lihalyf/Python
/Restore_IP_Address.py
1,316
3.84375
4
""" 426. Restore IP Addresses Given a string containing only digits, restore it by returning all possible valid IP address combinations. Example Given "25525511135", return [ "255.255.11.135", "255.255.111.35" ] Order does not matter. """ class Solution: """ @param s: the IP string @return: All possi...
f6d7ce480778d230d09d31e6b0c53fdbb96a9cca
anthonysim/Python
/Intro_to_Programming_Python/supremeCourt2.py
649
3.703125
4
""" Supreme Court A program that requests the name of a president as input and then displays the names and years of the justices appointed by that president. """ import pickle def main(): dicLst = createDictFromBinaryFile("JusticesDict.dat") president = input("Enter a president: ") getJustice(dicLst, ...
45d7b3ced0aafd996aeb5d6cb41fbc96e222a75f
anthonysim/Python
/Intro_to_Programming_Python/min.py
437
4.09375
4
""" Min Function A function that returns the minimum value in a list of numbers. """ def main(): min_number = min() print("Your minimum number is:", min_number) def min(): count = int(input("How many numbers in your list?: ")) numbers = [] for number in range(count): number = int(input("Enter...
fd550e115ac526fe5ac6bc9543278a7d852325b6
anthonysim/Python
/Intro_to_Programming_Python/pres.py
444
4.5
4
""" US Presidents Takes the names, sorts the order by first name, then by last name. From there, the last name is placed in front of the first name, then printed """ def main(): names = [("Lyndon, Johnson"), ("John, Kennedy"), ("Andrew, Johnson")] names.sort(key=lambda name: name.split()[0]) names.sor...
25259da4f2ae15d1aa7abbbcb774ea7e55aaee46
anthonysim/Python
/Intro_to_Programming_Python/oscars.py
882
3.84375
4
""" Academy Awards A program that displays the different film genres, requests a genre as input, and then diplays the Oscar-winning films of that genre. Use Oscars.txt """ def main(): oscars = getData("Oscars.txt") print() genre = input("Enter a genre: ") genre = genre.lower() winners(os...
339ab46faa86b3adc7d9408ee33f796937b6b5a0
anthonysim/Python
/Exercises/showStars.py
204
3.703125
4
# A function that forms a "tree" based on # the amount of rows specified. def showStars(row): for i in range(1, row + 1): stars = '*' * i print(stars) showStars(5)
500d87f1048fe284c7eb13320e401a0482430cfb
LachezarStoev/Programming-101
/sum_of_divisors/solution.py
271
3.75
4
def sum_of_divisors(n): sum=0 for div in range(1,n+1): if(n%div==0): sum+=div return sum def main(): print(sum_of_divisors(8)) print(sum_of_divisors(7)) print(sum_of_divisors(1)) print(sum_of_divisors(1000)) if __name__ == '__main__': main()
3325f75a27d76e34d2c5b22f74ae4a1840f42f2a
LachezarStoev/Programming-101
/sudoku_solved/solution.py
660
3.6875
4
def column(matrix, i): return [row[i] for row in matrix] def row(matrix,i): return matrix[i] def take_submatrix_3x3(matrix,p,q): return [matrix[i][j] for i in range(p,p+3) for j in range(q,q+3)] def is_array_solved(arr): unique_numbers=set(arr) restricted_numbers=[x for x in unique_numbers if x in range(1,10)] ...
2922ae993bbebccd772d493f79c9a56e7934cccc
LachezarStoev/Programming-101
/prime_factiorization/solution.py
594
3.8125
4
from itertools import dropwhile, takewhile def prime_factorization(n): divs=[] while(n>1): for div in range(2,n+1): if(n%div==0): divs.append(div) n//=div break result=[] while(divs != []): countOfDiv=list(takewhile(lambda x: x==divs[0], divs)) result.append((countOfDiv[0],len(countOfDiv))) d...
64d3df0e9550e9f1d1c424ef215675a3251b05b1
LachezarStoev/Programming-101
/contains_digits/solution.py
417
3.828125
4
def contains_digits(number, digits): digitsOfNumber=[] while number!=0: digitsOfNumber.append(number%10) number//=10 for digit in digits: if(not digit in digitsOfNumber): return False return True def main(): print(contains_digits(402123, [0, 3, 4])) print(contains_digits(666, [6,4])) print(contains_di...
024b941a6ea2e4efae5ac689a96c2feeaa2b257f
LachezarStoev/Programming-101
/sum_of_min_and_max/solution.py
279
3.671875
4
def sum_of_min_and_max(arr): maxElem=max(arr) minElem=min(arr) return maxElem+minElem def main(): print(sum_of_min_and_max([1,2,3,4,5,6,8,9])) print(sum_of_min_and_max([-10,5,10,100])) print(sum_of_min_and_max([1])) if __name__ == '__main__': main()
73e7c59448d7646c76286b13dc3d3db3a3dae71d
LachezarStoev/Programming-101
/sevens_in_a_row/solution.py
329
3.734375
4
def sevens_in_a_row(arr, n): if( len([x for x in arr if x==7]) >= n): return True return False def main(): print(sevens_in_a_row([10,8,7,6,7,7,7,20,-7], 3)) print(sevens_in_a_row([1,7,1,7,7], 4)) print(sevens_in_a_row([7,7,7,1,1,1,7,7,7,7], 3)) print(sevens_in_a_row([7,2,1,6,2], 1)) if __name__ == '__main__'...
8195e2ea8fcf12229f2ae307020c1fb1b4d21f59
andrevalasco/ex_python
/ex011.py
289
3.890625
4
l = float(input('Digite a largura da parede: ')) h = float(input('Digite a altura da parede: ')) a = l * h tinta = a / 2 print('Sua parede tem dimensão {}X{} e sua área é de {} m²'.format(l, h, a)) print('Será necessário {:.2f} l de tinta para pintar esta parede'.format(tinta))
b7982e3ed0c4eb5735965df136f16e630ab0fcea
tomasolodun/lab10
/1.4.1.py
1,870
3.765625
4
"""Сформувати функцію для введення з клавіатури послідовності чисел і виведення її на екран у зворотному порядку (завершаючий символ послідовності – крапка)""" import timeit def reverse(n): if len(n) == 1: return n[0] else: return (n[len(n) - 1] + reverse(n[0:len(n) - 1])) # Поки не з...
b2bc221c2df88427fc52958cdd5276a219422dc1
acbalanza/PythonDoesWhat
/pdw_019_the_confusingly_named_setdefault.py
978
3.8125
4
pdw_id = 19 title = "The confusingly named setdefault" pub_date = (2010, 12, 28, 11, 42) author = "Kurt" tags = ("dict", "setdefault", "collections", "defaultdict") """ dict.setdefault(key[, default]) returns the key's value if the key is in the dict. If it's not, it inserts the default and returns that val...
378cf33e916102adad2d424f85c24484bebfd4f2
vibin000/twitter-automation-follower-ing-list
/example.py
1,523
3.859375
4
#This is an example which demonstrates how to call the class defined earlier ("twitterBot") and store different calls with different list based on the call to different variables as desired. #First run the scripts in twitter_automate.py file ,and after defining the class in it ,run the below code. #For storing the fo...
b47b32ce3cbfeb871e32b807b85662f46fa26b65
bobradov/Neuromorphic
/mlp2.py
5,189
4.3125
4
""" Multilayer Perceptron. A Multilayer Perceptron (Neural Network) implementation example using TensorFlow library. This example is using the MNIST database of handwritten digits (http://yann.lecun.com/exdb/mnist/). Links: [MNIST Dataset](http://yann.lecun.com/exdb/mnist/). Project: https://github.com/aymericdamie...
0d1aa02446e1cde49c7a26e347924cf4a24eea36
antondelchev/For-Loop---Lab
/11. Clever Lily.py
824
3.84375
4
age = int(input()) washing_machine_price = float(input()) single_toy_price = int(input()) toys_number = 0 money_as_a_gift_each_birthday = 0 money_collected_as_gift = 0 money_total = 0 for i in range(1, age + 1): if i % 2 == 0: money_as_a_gift_each_birthday += 10 money_collected_as_gift...
bb7aae8701b531bbb2f0f460f4eed3b7f87ae312
josephduarte104/data-science-exercises
/py4e/helper11.py
509
4.0625
4
import re x = "Why should you learn to write programs? 7746 12 1929 8827 Writing programs (or programming) is a very creative \ 7 and rewarding activity. You can write programs for many reasons, ranging from making your living to solving \ 8837 a difficult data analysis problem to having fun to helping 128s...
fbd7c968c49807581dd0b51b1bc2e5be7c18e29a
GolanSho/HomeWork
/HM3.py
1,456
3.984375
4
def sumarry(): array = [17, 1, 12, 54, 23, 9, 21] sumarray = [] for i in array: if i >= 3 and i <= 20: sumarray.append(i) print(sum(sumarray)) sumarry() def sumval(): val1 = 0 val2 = 0 integ = [] while True: num = int(input("Enter a Number: ")) in...
aaccb7f0df1646691c4f6621236618b831437e7d
bayukrs/logika-test-BGM
/main.py
306
3.640625
4
def print_hi(N): for i in range(1, N): j = i if i % 3 == 0: j = "Frontend" if i % 5 == 0: j = "Backend" if i % 5 == 0 and i % 3 == 0: j = "Frontend Backend" print(j, ",", end="") if __name__ == '__main__': print_hi(50)
fc010fd5893b9a047a9c52816b7adaf869ce1498
sam1037/mini_python_games
/sudoku_backup.py
3,304
3.734375
4
import random # make a board which you can display number # player can enter number, undo and get hint # create list coords_list = [] y = 0 x = 0 for a in range(81): coords_list.append((x,y)) x += 1 x %= 9 if len(coords_list) > 8 and x == 0: y+=1 coords_list = {a:[b for b in range(1,10)] for ...
34a4437906dda2944ba8211b5193b9de0f8780ce
Dantera/Imgen
/jsoner.py
723
3.6875
4
#!usr/bin/py """ """ import json def load_from_file(file): """ Args: file (): Returns: (Dictionary): the data from the file """ with open(file) as json_data: return json.load(json_data) def save_to_file(data, file, pretty_print=False): """ Args: da...
41af2c86866f2008093c06a98750c54b43dea176
icnp2017/submission
/p4_impl/p4t/p4t/utils.py
1,310
3.78125
4
from itertools import count class Namespace(object): """ Namespace that provide easy nesting and collision avoidance. String can be retrieved by means of a standard `str` built-in. """ def __init__(self, name='', parent=None): self._name = name self._parent = parent self._chi...
be0eaa8ec23bcdc70ee5813849f58ff1687dfa0c
leurekay/Python-Scripts
/plot_arrow/try1.py
890
3.53125
4
# -*- coding: utf-8 -*- """ Created on Sat Jan 14 19:56:09 2017 @author: aa """ from math import * import matplotlib.pyplot as plt class Point: def __init__(self,x,y): self.x=x self.y=y p1=Point(0,0) def arrow(f,p,angle): A=Point(p.x+0.5*cos(pi+angle),p.y+0.5*sin(pi+angle)) B=Point(p.x+0.5...
58f26e0f54950f42887d710779fa2bc57dc6fcda
sahasradude/Language-processors
/line no/linecountstop.py
616
3.75
4
file = open(raw_input("Enter filename\n")) #neededword = raw_input("Enter the word to be searched\n") i = 1 wordslist = [] text = "" for line in file: line = line.strip("\n")+ " " text += line i = 1 wordslist = text.split(" ") print "\n",i,".", i+=1 for word in wordslist: print word, if word.find(".") ...
bcb8466d7fee03394321cf066b232233769826a2
DiamondLightSource/auto_tomo_calibration-experimental
/old_code_scripts/harris_edge.py
6,612
3.59375
4
from scipy.ndimage import filters import numpy as np import pylab as pl def compute_harris_response(im, sigma=3): """ Compute the Harris corner detector response function for each pixel in a graylevel image. This indicator function allows to distinguish different eigenvalue relative sizes without ...
8ad39ace6b0a1df63ec3e11546646180aaa08485
jaffarabbas/Assignment_python-1
/Assignment 2/pythonassignment2/task3.py
127
3.59375
4
a = [] a.append("Hello") a.append("Geeks") a.append("For") a.append("Geeks") print("The length of list is: ", len(a))
97ef3b39b97918b53050ebfdfb884c311d281770
jaffarabbas/Assignment_python-1
/Assignment 2/pythonassignment2/task4.py
211
4.09375
4
lst = [] num = int(input('Enter how many items in list: ')) for n in range(num): numbers = int(input('Enter cost of item ')) lst.append(numbers) print("Sum of elements in given list is :", sum(lst))
6badd68a3e7616d18ae577008dde2efc0dbad8fe
biroc/algs
/test.py
2,593
3.65625
4
# import unittest # # def max_heapify(array,i,heapsize): # left = 2 * i + 1 # right = left + 1 # largest = i # # if left < heapsize and array[left] > array[largest]: # largest = left # # if right < heapsize and array[right] > array[largest]: # largest = right # # if largest != i:...
c1dceb57ede0b3eb1f1fe5fe658fe283116d68f3
pythonic-shk/Euler-Problems
/euler1.py
229
4.34375
4
n = input("Enter n: ") multiples = [] for i in range(int(n)): if i%3 == 0 or i%5 == 0: multiples.append(i) print("Multiples of 3 or 5 or both are ",multiples) print("Sum of Multiples of ",n," Numbers is ",sum(multiples))
ff547f2b78a5a972a7526e75402c00796f5d78fc
yashin0993/NeuralNetwork
/study_of_DL/02_NeuralNetwork/two_layer_net1.py
732
3.5625
4
import numpy as np from activation import activation act = activation() def init_network(): network = {} network['w1'] = np.array([[0.1, 0.3, 0.5], [0.2, 0.4, 0.6]]) network['b1'] = np.array([0.1, 0.2, 0.3]) network['w2'] = np.array([[0.1, 0.4], [0.2, 0.5], [0.3, 0.6]]) network['b2'] = n...
a570599cce87b3a8ce25ff8d7d55b528e73325b0
acorned/Python_lessons_basic
/lesson02/home_work/hw02_easy.py
1,425
3.8125
4
# Задача-1: # Дан список фруктов. Напишите программу, выводящую фрукты в виде нумерованного списка выровненного по правой сторне # Пример: # Дано: ["яблоко", "банан", "киви", "арбуз"] # Вывод: # 1. яблоко # 2. банан # 3. киви # 4. арбуз arr = ["яблоко", "банан", "киви", "арбуз"] for num in...
7468f255b87e3b4aa495e372b44aba87ff2928d1
tengrommel/go_live
/machine_learning_go/01_gathering_and_organizating_data/gopher_style/python_ex/myprogram.py
449
4.3125
4
import pandas as pd ''' It is true that, very quickly, we can write some Python code to parse this CSV and output the maximum value from the integer column without even knowing what types are in the data: ''' # Define column names cols = [ 'integercolumn', 'stringcolumn' ] # Read in the CSV with pandas. data...
8c2ababb93198e7acae72e46d896a5d2fe257d8d
DanieleSiri/Sudoku
/sudoku_generator.py
1,513
3.765625
4
import random import sudoku_class def randomize_position(): random_x = random.randint(0, 8) random_y = random.randint(0, 8) return random_x, random_y def randomize_first_box(): """used to break most easy patterns in the first box""" random_x = random.randint(0, 3) random_y = random.randint(0...
df200bb09f51b22be14c48d88517d24675893940
aiguang11211/gitskills
/py/简单tkinter例子.py
460
3.6875
4
from tkinter import * def resize(ev=None): label.config(font='Helvetica -%d bold'%scale.get()) top=Tk() top.geometry('250x150') label=Label(top,text='Hello World',font='Helvetica -12 bold') label.pack(fill=Y,expand=1) scale=Scale(top,from_=10,to=40, orient=HORIZONTAL,command=resize) scale.set(12) scal...
e863fd0cfe96478d6550b426d675de6cfc84c08a
kami71539/Python-programs-4
/Program 19 Printing even and odd number in the given range.py
515
4.28125
4
#To print even numbers from low to high number. low=int(input("Enter the lower limit: ")) high=int(input("ENter the higher limit: ")) for i in range(low,high): if(i%2==0): print(i,end=" ") print("") for i in range(low,high): if(i%2!=0): print(i,end=" ") #Printing odd numbers ...
61bef90211ffd18868427d3059e8ab8dee3fefde
kami71539/Python-programs-4
/Program 25 Printing text after specific lines.py
303
4.15625
4
#Printing text after specific lines. text=str(input("Enter Text: ")) text_number=int(input("Enter number of text you'd like to print; ")) line_number=1 for i in range(0,text_number): print(text) for j in range(0,line_number): print("1") line_number=line_number+1 print(text)
968098b3815c914233cb9c0632c921b2ef27a589
kami71539/Python-programs-4
/Program 12 Dictionary.py
459
3.546875
4
monthconversion={ "Jan":"January", "Feb":"February", "Mar":"March", "Apr":"April", "May":"May", 6:"June", "Jul":"July", "Aug":"August", "Sep":"September", "Oct":"October", "Nov":"November", "Dec":"December" } print(monthconversion.get("Mar")) print(monthconversion["Jul"]) print(monthconversion[6]) prin...
799c2d124d6c7dc11779fa3a6c6e1f3a36980a96
kami71539/Python-programs-4
/Program 16 Nested loops.py
315
3.859375
4
#Nested Loops for i in range(10): for j in range(10): print(j,end="") print("") print(i) number_grid=[ [1,2,3], [4,5,6], [7,8,9], [0] ] print(number_grid[1][2]) for row in number_grid: print (row) for coloumn in row: print(coloumn)
38658702ed937a7ba65fd1d478a371e4c6d5e789
kami71539/Python-programs-4
/Program 42 Finding LCM and HCF using recursion.py
259
4.25
4
#To find the HCF and LCM of a number using recursion. def HCF(x,y): if x%y==0: return y else: return HCF(y,x%y) x=int(input("")) y=int(input("")) hcf=HCF(x,y) lcm=(x*y)/hcf print("The HCF is",hcf,". The LCM is",lcm)
6f2ac1ae18a208e032f7f1db77f64710f3b9bd00
kami71539/Python-programs-4
/Program 15 Exponents.py
221
4.375
4
print(2**3) def exponents(base,power): i=1 for index in range(power): i=i*base return i a=int(input("")) b=int(input("")) print(a, "raised to the power of" ,b,"would give us", exponents(a,b))
e80d7d475ddcf65eddd08d77aa4c2c03f965dfb9
kami71539/Python-programs-4
/Program 35 To count the uppercase and lowercase characters in the given string. unresolved.py
458
4.125
4
#To count the uppercase and lowercase characters in the given string. string=input("") j='a' lower=0 upper=0 space=0 for i in string: for j in range(65,92): if chr(j) in i: upper=upper+1 elif j==" ": space=space+1 for j in range(97,123): if chr(j) in ...
2afd84914e4120cc7e233dce0b7779a9654318c9
alexvydrin/gb_course_python_clientserver
/lesson_1/task_1_4.py
1,283
3.921875
4
""" 4. Преобразовать слова «разработка», «администрирование», «protocol», «standard» из строкового представления в байтовое и выполнить обратное преобразование (используя методы encode и decode). Подсказки: --- используйте списки и циклы, не дублируйте функции """ WORDS = ['разработка', 'администрирование', 'protocol...
9c975a67d5bb4c12d08f6aaf58866b15974b22f3
xinyuan-Winter2021-Cmput291/291A5
/A5T5SQLite.py
986
3.5625
4
# 291 A5 Task5 SQLite import sqlite3 import sys def task5_sql(cursor): print("Task 5 SQLite") if len(sys.argv) > 1: neighbourhood = str(sys.argv[1]) else: neighbourhood = input("Please enter a neighbourhood: ") try: sql = ''' SELECT avg(price) as average_rental FROM li...
9e802716623c03946cee8eddebab2f158da3a15b
stanley-c-yu/mathematics-for-machine-learning
/pca/pca.py
4,610
3.734375
4
import numpy as np class PCA: ''' Refactored submission for the PCA Course by the Imperial College of London on Coursera. Many thanks to the fellow students who completed this course and provided useful tips and guidance on the forums. None of this would have been possible without you. ...
452058865789c23530d5c33c7f063c2f9c0399f3
lauux/AlgorithmQIUZHAO
/Week_03/127.单词接龙.py
1,075
3.515625
4
# # @lc app=leetcode.cn id=127 lang=python3 # # [127] 单词接龙 # # @lc code=start class Solution: def ladderLength(self, beginWord: str, endWord: str, wordList: List[str]) -> int: if not endWord or not wordList or endWord not in wordList: return 0 L = len(endWord) newWordL...
5ed3de8cc08fe52d61aafac5556b4d7f148cfae3
lauux/AlgorithmQIUZHAO
/Week_06/205.同构字符串.py
478
3.5
4
# # @lc app=leetcode.cn id=205 lang=python3 # # [205] 同构字符串 # # @lc code=start class Solution: def isIsomorphic(self, s: str, t: str) -> bool: maps = {} for i in range(len(s)): if s[i] in maps and maps[s[i]] != t[i]: return False elif s[i] not in maps: ...
04ae7c06f98e112a0e7fb4f4f1319acb022d8b5f
LEEHOONY/my-project
/week01/company.py
733
3.859375
4
# 회사 조직도 만들기 # 사람 클래스를 만든다(사람의 기본요소는 이름, 나이, 성별로 한다) # 직장 동료 클래스를 사람 클래스를 이용하여 만든다.(사람 기본 요소 외 직급을 추가한다.) ## Human class class Human: company = "Python" def __init__(self, name, age, sex): self.name = name self.age = age self.sex = sex human1 = Human("홍길동", "23", "M") human2 = Human("...
06991835059e7a626be65079c8b85c7e0a93a06b
joshunov/SYNCSHACK_2021
/Main.py
10,287
3.609375
4
import Horse_racing.horse_racing_2 as horse import fTheBus_fn as ftb import trivia1 as triv import kings_cup as king import random import time import os os.system("pip install pydealer") os.system("pip install termcolor") def letter_by_letter(string): for i in string: print(i, end= (''), flush= True) ...
870b35565e3ae8e46a0e2a12179675a20825f5c4
targupt/projects
/project -1 calculator.py
325
4.3125
4
num1 = int(input("1st number ")) num2 = int(input("2nd number ")) sign = input("which sign(+,-,/,x or *)") if sign == "+": print(num1+num2) elif sign == "-": print(num1-num2) elif sign == "/": print(num1/num2) elif sign == "x" or sign == "X": print(num1*num2) else: print("wrong input please try aga...
b37131762f81e96b6122212f27e2265d9ba00ef4
yana5k/amis
/km-82/Burlachenko_Yana/workshop1/source/The First/Function.py
286
3.78125
4
n = int(input("n = "))#введення даних def f(n):#рекурсивна функція if n < 3:#блок перевірки кінця рекурсії return if n == 3:#блок перевірки кінця рекурсії return 4 print(f(n)/f(n - 1) print(f(n))
a1133186f694fb020ebdf74dfb0ee53fa2da721b
waviq/PythonLatihan
/strings.py
454
3.890625
4
nama = 'Waviq Subhi'; print(nama[0]) print(nama[3]) print(nama[-1]) print(nama[0:5:2]) number = "1, 2, 3, 4, 5, 6" print(number[0::3]) print("Waviq "*2) print("Waviq "*(3+2)) # #in = digunakan untuk membandingin isi variabel, apakah memiliki nilai # yang sama atau memiliki isi yang mirip dg variabel yang di ban...
8c97900b4ac05dcbfb345d5f6ded07e9cccb823f
ljxgit/DataStructure
/SortAlgorithm/MergeSort.py
1,058
4.03125
4
# -*- coding:utf-8 -*- # Python实现归并排序(稳定排序),主要思想是合并两个有序数组,如果是一个无序的数组,则首先拆分成单个元素,然后两两合并成有序数组,时间复杂度是O(nlogn) def merge_sort(lists): # 递归,先拆分,再合并 if len(lists) <= 1: return lists mid = len(lists)>>1 # 切分到left和right都只有一个元素时,开始合并 left = merge_sort(lists[:mid]) right = merge_sort(lists[mid:]) ...
01c172d4c6c6b4d9714c2aca9b9d4b425a3933d3
lexjox777/Python-conditional
/main.py
838
4.21875
4
# x=5 # y=6 # if x<y: # print('Yes') #========== # if 'Hello' in 'Hello World!': # print('Yes') #================== # x=7 # y=6 # if x > y: # print('yes it is greater') # elif x < y: # print('no it is less') # else: # print('Neither') #================== # ''' # Nested if statement # ''' # num...
789c16069aa84901e4bbe995d13018a0ed4c11ff
urashimaeffect0083/GovLens
/readSQLite.py
1,808
3.578125
4
''' Reference URLs: https://sqlite.org/cli.html ''' import sqlite3 import argparse from os.path import exists, join from os import makedirs import pandas as pd def showSQLite3TblToCSV(inputDFPath, outputDirPath): # connect database file conn = sqlite3.connect(inputDFPath) # set SQL connection and cur...
84650242ab531d3a0755452b8c6eb4476e0a710c
dncnwtts/project-euler
/1.py
582
4.21875
4
# If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these # multiples is 23. # # Find the sum of all the multiples of 3 or 5 below 1000. def multiples(n,k): multiples = [] i = 1 while i < n: if k*i < n: multiples.append(k*i) i += 1 else: return m...
61c34a415f86f857f22136416b3c7f7a29385617
dncnwtts/project-euler
/20.py
561
3.859375
4
# 10! = 3628800 and the sum of these digits is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. # Find the sum of the digits in the number 100!. def fact(n): if n == 1: return n else: return n*fact(n-1) def count(n): numdigs = len(str(n)) val = 0 for i in range(numdigs)[::-1]: dig = n/10**i val += dig n -= dig*10**i ...
a82a468fb42aefca02bb7c6978bbc29e9a77ee05
dncnwtts/project-euler
/19.py
1,799
3.953125
4
# You are given the following information, but you may prefer to do some research for yourself. # # 1 Jan 1900 was a Monday. # Thirty days has September, # April, June and November. # All the rest have thirty-one, # Saving February alone, # Which has twenty-eight, rain or shine. # ...
d23f970f82d5cf0b3ebccdde733bec17201a980c
dmonyei/Python-Blackjack
/Blackjack(Beta).py
6,424
3.875
4
import random deck = {"Ace of Diamonds": 11, "Two of Diamonds" : 2, "Three of Diamonds": 3 , "Four of Diamonds": 4 , "Five of Diamonds" : 5, "Six of Diamonds": 6, "Seven of Diamonds": 7, "Eight of Diamonds": 8, "Nine of Diamonds": 9, "Ten of Diamonds": 10, "Jack of Diamonds" :10,"Queen of Diamonds"...
1d355fa0dce229a7c480bf4043aef3a54c235ba2
FabijanC/aoc2017
/day13/13_2.py
2,113
3.609375
4
def move(): global curr, direction, range_ for scanner in curr: if curr[scanner] == range_[scanner]: curr[scanner] -= 1 direction[scanner] = "up" elif curr[scanner] == 1: curr[scanner] = 2 direction[scanner] = ...
fe2170c700f47a0ddf827508b17d62bebaadd9df
rookie1020/Recommendation-System
/mf_sgd.py
4,460
3.53125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Apr 28 01:48:05 2018 @author: J Rishabh Kumar @content: matrix factorization using gradient descent """ import numpy as np import matplotlib.pyplot as plt class MF(): def __init__(self, R, K, alpha, beta, iterations): """ Pe...
30f24e310183f61b552192a91064c2149d705f07
clayton-halim/claybotics
/MotorManager.py
2,273
3.75
4
import Motor from MotorState import MotorState class MotorManager(): def __init__(self, motorLeft, motorRight): self.mLeft = motorLeft self.mRight = motorRight self.state = MotorState.CENTER def setDirection(self, horizontal, depth): if horizontal == "left": if depth == "forward": print("forward left...
e2acccf7ef01ce3f9ee40ffb75f55e502a4c8984
jhuntley97/Python-Level-2
/Lab activity 2.py problem 1.py
90
3.609375
4
#Jwaun Huntley #4/16/19 d={'a':5, 'b':10,'c':15} for x, y in d.items(): print(x, y)
80edc85c156a001668382fe7fe3c1eff3e92617f
Aathish04/Old-Python-Game-Projects
/AdventureTrail/AdventureTrail.py
14,043
3.9375
4
#This game was developed in joint by Rhys Van Der Kruk and Aathish Sivasubrahmanian #Shoutout to Matthew Riedel, a classmate of mine. #All My Imports import time print("Welcome to Adventure Trail. The Word Game where what you do affects your rate of survival.") time.sleep(0.5) playername =(input("Now, What is the name ...
26da6bf89f628c85fe288a0f0e229c8a0772b3b6
arunravi74/Edyoda_Python_Quiz_App
/database.py
2,326
3.734375
4
import sqlite3 from IPython.display import clear_output """connection=sqlite3.connect("Info.db") sql=\"""CREATE TABLE if not EXISTS questions( Question VARCHAR(50), Topic VARCHAR(20), difficulty_level VARCHAR(20), Option_A VARCHAR(20), Option_B VARCHAR(20), Option_...
ff5952abf7de4d60b3123551f4bf05466f67b620
ankittrehan2000/RockPaperScissors
/RockPaperScissors.py
270
3.71875
4
import random def RockPaperScissor(): number = random.randint(1,3) #1 - Rock #2 - Paper #3 - Scissors if (number == 1): return 'rock' elif (number == 2): return 'paper' elif (number == 3): return 'scissors' else: return 'Facing errors'
73c582cbae91273375e9d1964873a193a88d19d6
awanjila/python_play_ground
/roll_dice.py
298
4.0625
4
import random def roll_the_dice(): max=8 min=1 roll_dice="yes" while roll_dice =="yes" or roll_dice=="y": print("rolling the dice...") print("The values are...") print random.randint(min,max) print random.randint(min,max) roll_dice=raw_input("roll the dices again?") roll_the_dice()