blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
b5fd2a7bd444226c4e206495a4c96d337ca89964
BYY2100/xopy
/X-O..py
4,097
3.890625
4
#X O Game #BY: BYY2100 import random from os import system, name from time import sleep def clear(): if name == 'nt': _ = system('cls') else: _ = system('clear') def display_board(board): #print("\n"*100) clear() #sleep(1.5) print(board[7] + '...
0d6bb920163638dd85b7e2c3eaddef0f9aa5f3a0
cajun-code/dice_py
/question1/rectangle.py
937
4.09375
4
""" Author : Allan Davis Answer to question 1 for CCP Games To Run the test the test just type: python -m doctest rectangle.py """ class Point(object): """ A point class """ def __init__(self, x, y): self.x = x self.y = y class Rectangle(object): def __init__(self, x, y, width...
d2e44cc77b11217c7c006f00b4d87553916afb08
sanoojps/coding-interview-bootcamp-algorithms-and-data-structure
/array_chunks.py
888
3.8125
4
# Give an array and chunk size # divide the array into many sub arrays where # each subarray is of length size def slices_array(array: list, size:int): list_of_slices = [] slice = list() for element in array: if len(slice) < size: slice.append(element) if len(slice) == size:...
5532ec790ee43867f1b147341348d8e5f499c226
orionmind/practice
/fibonacci.py
637
4.09375
4
def fibonacci(n): if n == 0: print "0" return 0 elif n == 1: a = 1 print a return a elif n == 2: b = 1 print b return b else: c = store_nminus1 + store_nminus2 print c return c def close(number, num_to_quit): if ...
62f646bb0bc9ebe21047375ffe71dcee5f9a594c
bishalkunwar/Random_practics_Python
/oddEvenChecking.py
828
4.09375
4
#WAP to take two input value # from user and check the value is odd or even # if even then add the 5 multiple until its sum being 100. #Solution: input1 = int(input("Enter first number: ")) input2 = int(input("Enter second number: ")) #Global variables declaration: sum = 0 remainder = 0 c = 5 #Check...
65e3be5647b35e5d1e1d5cdf458df9d26812fd97
ingridavis/FSDI-114
/assignment1.py
1,612
4.4375
4
# Create a function that checks whether two words are anagrams of each other. # Two words are anagrams of each other if they are of the same length (number of letters) and use all of the same letters. # For example: star and rats are anagrams of each other because they are of the same length and use all the same ...
053195f1359a6578e51479e9d4f21377dc1404ec
ingridavis/FSDI-114
/CR_singly_linked.py
1,518
4
4
# Competency Report # Singly Linked List implementation # class representing my node class Node: data = None next_node = None #points to next node in the list def __init__(self, data): self.data = data def __repr__(self): return "<Node data: %s>" % self.data ...
bad988ad65d2feb0a80a898a7c2fc97e6966de91
MohiniMohiniMohini/headFirstPython
/chptr3_dict_tups_sets/vowels4.py
434
3.890625
4
vowels = ['a', 'e', 'i', 'o', 'u'] word = input("Provide a word to search for vowels: ") found = {} #initialize found dict. #for letter in vowels: # found[letter] = 0 for letter in word: if letter in vowels: found.setdefault(letter, 0) found[letter] += 1 for k, v in sorted(found.items()): ...
5a49b41622687da54a0ab1ecd4f2616c813dc059
farhadmpr/enfaConverter
/enfaConvertor.py
1,102
3.71875
4
import keyboard import pyperclip en = "qwertyuiop[]\\asdfghjkl;'zxcvbnm,.?" fa = "ضصثقفغعهخحجچپشسیبلاتنمکگظطزرذدئو.؟" def Handle(): print('key pressed') keyboard.send('ctrl+c') text = pyperclip.paste() pyperclip.copy(Conver(text)) keyboard.send('ctrl+v') def GetLang(text): if te...
8e0aec190bdd803c713090448c423855e3df0e26
shadowvrs/BackwardsText
/BackwardsText.py
726
3.65625
4
#run in terminal: python3 BackwardsText.py from tkinter import * root = Tk() root.title("BackwardsText") root.geometry("420x150") entre = Entry(root, width = 50) outcome = Entry(root, width = 50) text = Label(root, text = "Text to drawkcaB, Backward ot txeT") text.place(relx = 0.5, rely = 0.05, anchor = "center") en...
21e02fda88eb0115dc455537bb904d3618f6055f
jn417/ca_three
/weather_update.py
1,275
4.125
4
""" Module to extract local weather data from the api stated in the config file """ import requests,json from configparser import ConfigParser def kelvin_to_celsius( arg1 ): """ Function to convert kelvin to celsius. Takes a single flaot as an argument and returns a float itself. """ celsius = (arg1 ...
47236ed18df2602865decea85d732fd86423c185
LogeshRe/Python-Utilities
/List_of_EXCEL_Files.py
1,108
3.84375
4
# This program prints the list of all Excel files in a choosen directory and all its sub-directory's. # Run the program and choose the folder. It will print out all .xls files in the choosen folder and all its sub_folders from os import listdir import os def Readpath(): from tkinter.filedialog import askdi...
4883a110462d490e95cffe2df62495b214faa1ff
mohamed-abdo/algorthims-toolbox
/assignment_pkg/week01/a_plus_b.py
218
3.6875
4
import sys def calc_sum(str_input): print(int(str_input[0])+ int(str_input[1])) if __name__ == "__main__": str_input= input("please inter the input numbers: ") #sys.stdin.read() calc_sum(str_input.split())
7df5ce4b9ee0cedf5e4ead94d127fd5317cc807c
lingsitu1290/code-challenges
/stack_and_queue_implementation.py
2,514
4.5
4
# Implementation of abstract data types Stack and Queue # Stack - LIFO # Queue - FIFO class Stack: """ >>> s = Stack() >>> print s.size() 0 >>> s = Stack() >>> s.push('hello') >>> s.push('true') >>> s.peek() 'true' >>> s = Stack() >>> s.isEmpty() True >>> s = S...
30d9fb7b07a2ec3ecf1920e5d6bf8ac201dd8c96
lingsitu1290/code-challenges
/diagonal_difference.py
321
3.75
4
# Hacker Rank Diagonal Difference # Grab matrix size N = int(raw_input()) difference = 0 for i in xrange(N): row = raw_input().split() # difference will be the addition of the difference of the matrix difference += (int(row[i]) - int(row[N-1-i])) # Print absolute of the difference print abs(difference)...
055e5d2625255f142e616c9b153291d621a6a542
lingsitu1290/code-challenges
/plus_one_sum.py
616
4.0625
4
""" Write a function that takes an array of integers and returns the sum of the integers after adding 1 to each. """ def plus_one_sum(lst): """ >>> plus_one_sum([1, 2, 3, 4]) 14 >>> plus_one_sum([4, 5, 6, 7]) 26 """ # Add 1 to each number in the list in place then sum new list for i, nu...
b4ceb17505d429fda140afe0bb72c07c7d05142d
lingsitu1290/code-challenges
/group_anagrams.py
1,638
4.1875
4
def group_anagrams(lst): """ Given a list of strings, group the strings that are anagrams of each other together. >>> group_anagrams(["cat", "dog", "god", "banana", "odg"]) [['banana'], ['dog', 'god', 'odg'], ['cat']] >>> group_anagrams(["tire", "iret", "sam", "ams", "car"]) [['tire', 'iret'], [...
c2f89538905e35bd88aba4434e544bff22c792e9
lingsitu1290/code-challenges
/show_even_numbers.py
978
4.3125
4
def show_even_numbers(lst): """Given a list of even and odd numbers, return a list of the indices at which the original number is an even number. >>> show_even_numbers([1,2,3,4,5,6,7,8,9]) [1, 3, 5, 7] Time: O(n) Space: O(n) """ even_index_list = [] for i, val in enumerate(lst...
06729dd726cba9a6eda5b29b9a8855fd1a0caf6b
lingsitu1290/code-challenges
/substring_in_string.py
1,228
4.25
4
def substring_in_string(string, substring): """ Returns index of the first occurrence of substring within string If substring is not in string, return -1 >>> substring_in_string('hello world', 'hello') 0 >>> substring_in_string('hot potato', 'tao') -1 """ index = string.find(substr...
2e050e2b9a5a73152357a0f72c192f27f28f2397
suzanrodrigues/Curso-em-Video
/#028 - Jogo de adivinhação v1.0.py
1,150
4.1875
4
'''Escreva um programa que faça o computador "pensar" em um número inteiro entre 0 e 5 e peça para o usuário tentar descobrir qual foi o número escolhido pelo computador. O programa deverá escrever na tela se usuário venceu ou perdeu''' import random, time #Poderia usar o ra...
5ba688c4517db80c40f128dd0b6f7505bf9955d7
suzanrodrigues/Curso-em-Video
/#034 - Aumentos múltiplos.py
531
3.90625
4
'''Escreva um programa que pergunte o salário de um funcionário e calcule o valor do seu aumento. Para salários superiores a RS1500,00, calcule um aumento de 10%. Para os inferiores ou iguais, o aumento é de 15%''' salario = int(input('Qual o salário do funcionário? R$')) if salario <= 1500: print('O aumento do s...
8e0d232e6675e973485bbb095bacaad5f713c2c5
svijay87/Learning-Program-python
/multithreading-process-pool.py
1,038
3.515625
4
import multiprocessing as mp import time def test(fname): with open(fname,"w") as f: f.write("Hi") f.write("Hi 1") f.write("Hi 2") f.write("Hi 3") f.write("Hi 4") def process_performance(filename): start_time = time.time() # filename = "text.txt" ...
36ee82817ec964058915e794c04dee530a790fe7
svijay87/Learning-Program-python
/threading-example-2.py
790
3.625
4
from threading import Thread from threading import Event import time class Connection(Thread): StopEvent = 0 def __init__(self,args): Thread.__init__(self) self.StopEvent = args def run(self): for i in range(1,10): if(self.StopEvent.wait(0)): ...
d027146e85b8b80f2c0b77afe94fd6eeee12257b
hanshnnn/Simple_Banking_System
/banking.py
5,750
3.578125
4
import random import sqlite3 # Connect to a database conn = sqlite3.connect('card.s3db') # Creates a cursor cur = conn.cursor() # Creates table cur.execute(""" CREATE TABLE IF NOT EXISTS card( id INTEGER PRIMARY KEY AUTOINCREMENT, number TEXT, pin TEXT, balance INTEGER DEFAULT 0 ) """) conn.com...
af99a2c56f416a73d9e3ef1061da89a86ef0fead
gkirchhoff32/Computational_Imaging_Lab
/Documents/Internships_Research/Waller_Lab/scripts/mirror_array_diameter.py
4,366
3.625
4
# Calculate maximum diameter given mirror dimensions # # Output: Estimates of number of mirrors for array import numpy as np # Calculate mirror coordinates and plot mirror array. # # Computational Imaging Lab # University of California, Berkeley # Copyright 2019 Grant J. Kirchhoff # gkirchhoff32@berkeley.edu # # Input...
6668dfce129448d18b68f0c579ddf610a684bc61
LuckyLi0n/prog_golius
/Turtle/turtle_4good.py
105
3.78125
4
import turtle t = turtle.Turtle() t.shape("turtle") for i in range(360): t.forward(1) t.left(1)
5a10b83ff08b7fddcd38be660cbb9f38b8df608f
LuckyLi0n/prog_golius
/Turtle/turtle_12.py
215
3.734375
4
import turtle t = turtle.Turtle() t.shape("turtle") t.left(90) for i in range(5): for j in range(180): t.forward(1) t.right(1) for k in range(180): t.forward(0.2) t.right(1)
8e7f9adbe40f9f484d018e61c175bb41f779abd8
LuckyLi0n/prog_golius
/Turtle/turtle_9.py
277
3.578125
4
import turtle t = turtle.Turtle() t.shape("turtle") x = 0 y = 0 a = 50 k = 3 o = 18 for aa in range(11): t.penup() t.goto(x, y) t.pendown() for i in range(k): t.forward(a) t.left(360/k) a += 20 k += 1 y -= o o += 7 x -= 10
6b721e97f99f360eb87ecea006eaee39b28f256d
LuckyLi0n/prog_golius
/Turtle/turtle_11.py
232
3.578125
4
import turtle t = turtle.Turtle() t.shape("turtle") n = 1 t.left(90) for k in range(6): for i in range(360): t.forward(n) t.left(1) for l in range(360): t.forward(n) t.right(1) n += 0.2
d88b43cfad6fb262466095f622455f5387254032
DrRenuwa/MIT-Course
/Lessons/Unit 2 GCD Iterative.py
277
3.828125
4
def gcdIter(a, b): ''' a, b: positive integers returns: a positive integer, the greatest common divisor of a & b. ''' for i in range(a, 0, -1): if a%i == 0 and b%i == 0: return i break print(gcdIter(210,180))
ae3d1c9400873f65a2c371f49e70869984518bab
AriRosell/CYPAriadnaGG
/libro/problemas_resueltos/problema3_9.py
229
3.921875
4
print("Calcula la serie") N=int(input("Ingresa N: ")) I=int(1) SERIE=float(0) for I in range(I,N,1): SERIE=SERIE+(I**I) print(int(SERIE)) I=I+1 print("El total de la serie es:",int(SERIE)) WAIT=input("FIN")
7730124b7db9286896d2e9727513a3f03d986d45
AriRosell/CYPAriadnaGG
/libro/problemas_resueltos/problema3_6.py
398
3.953125
4
print("Calcular el numero mayor y el menor") MAY=int(-100000) MEN=int(100000) N=int(input("Ingrese la cantidad de numeros a ingresar: ")) I=int(1) for I in range(0,N,1): NUM=int(input("Ingrese un numero: ")) if NUM>MAY: MAY=NUM if NUM<MEN: MEN=NUM I=I+1 print("El numero mayor...
28eb5837697a075b0fc9b2330522e8d212b788fc
AriRosell/CYPAriadnaGG
/libro/ejemplo2_1.py
140
3.859375
4
CAL=float(input("Ingrese la calificacion")) if CAL > 8: print("La calificacion es aprobatoria (0 NO / 1 SI)") print("fin del programa")
6139d725906b85179f2b4b12fbfc096ba77b13d6
AriRosell/CYPAriadnaGG
/libro/problemas_resueltos/capitulo2/problema2_13.py
674
4.03125
4
print("Determinar si es apto para una carrera") MAT=int(input("Ingrese la Matricula del alumno: ")) CARR=str(input("Ingrese la carrera a la que aspira el alumno (en minusculas sin acentos): ")) SEM=int(input("Ingrese el semestre del alumno: ")) PROM=float(input("Ingrese el promedio del alumno: ")) PROMCARR={'econo...
524bf86c45435337978bcc5ae8af223e337a34ad
agravitybrain/A-DS_Lab_1
/main.py
8,900
4.125
4
""" main.py module for experiments """ import time import random import copy def selection_sort(list_sort: list) -> (list): """ Implements a selection sorting algorithm Return sorted list >>> selection_sort([4,5,3,2,1,0]) [0, 1, 2, 3, 4, 5] """ global selection_c for i in range(len(li...
90f13324abee19ce18842462fdd9efd3bff9c083
ARUN14PALANI/Python
/Trurtle_Race/main.py
1,076
4.21875
4
from turtle import Turtle, Screen import random screen = Screen() screen.setup(500, 400) turtle_colors = ["red", "blue", "green", "yellow", "orange", "violet"] turtle_position= [-90, -60, -30, 0, 30, 60] new_turtles = [] for turtle_index in range(6): current_turtle = Turtle(shape="turtle") current_turtle.co...
61122fd01a60eba7640db10051d65dcad0bc4288
ChiragTutlani/DSA-and-common-problems
/Algorithms/quicksort.py
536
3.984375
4
def quicksort(arr): if len(arr) < 2: return arr else: pivot = arr[0] smallThanPivot = [] greatThanPivot = [] for x in arr[1:]: if x<=pivot: smallThanPivot = smallThanPivot + [x] else: greatThanPivot = grea...
8ebb91848db9ce11bc14ec0875905d0aa39ad9fb
mjuniper685/LPTHW
/Practice/ex20Prac.py
1,057
4.25
4
#LPTHW Exercise 20 Functions and Files #import argv module from sys import argv #unpack argv into variables script_name, input_file = argv #define a function to print the whole file def print_all(f): print(f.read()) #define a function to rewind to the first line of the file def rewind(f): f.seek(0) #define a...
d44a7a2c2135f45fd32e76f63482d35d6056bb23
angelika22/problemele_1-12
/problema 11.py
329
3.515625
4
nr_la_inceput=int(input("numarul iepurilor la inceput de luna:")) nr_de_nascuti=int(input("numar iepurilor nascuti in timpul lunii:")) nr_de_morti=int(input("numar iepurilor de morti la sfirsitul lunii:")) nr_la_sfirsit=nr_la_inceput+nr_de_nascuti-nr_de_morti print("numarul de iepuri la sfirsit de luna este", nr_la...
93aa0e3b42593469594fcc0820894d8cc93b641d
litchixie/UIlearn
/shicaoti/__init__.py
762
3.515625
4
# coding:utf-8 # int类型信息,为整型,没有带小数点 a = 22222222 print(type(a)) # float浮点数类型信息 b = 12.33 print(type(b)) # str字符串类型 c = "sd552fsf三分少" # 使用单引号或者双引号包围 print(type(c)) # list列表类型,使用中括号包围 d = [1,4,58,5,5,8,"dsf",12.22,[2,"sdf"]] # 队列 print(type(d)) # tuple元组类型,小括号包围,内容不可更改 e = (1,2,3,5,"ds","第三方") print(type(e)) ...
c0c7031436170ace9df3187d55f9dc706aa45340
christiangalleisky/DailyCodingProblem_380_through_400
/DCP_Number_386.py
1,468
3.8125
4
class CharacterFrequency: def __init__(self): self.sentence = "" self.char_blocks = [] self.charLink = "" self.sortedSentence = "" self.frequencyList= [] def collect_Sentence(self): print("Enter a sentence!") self.sentence = input() def...
c17c90b72707589e53302b7584019d3ded524ca6
Erritro/zadania_p
/zadanie09.py
701
3.8125
4
#Utwórz macierz (3x5) losowych liczb rzeczywistych. #Usuń jej trzeci wiersz. import random macierz = [] wiersz = [] for wiersze in range(3): for kolumny in range(5): wiersz.append(random.uniform(1,10)) macierz.append(wiersz) wiersz =[] print("Macierz tabelarycznie") for wiersz...
3da86d09dbc1751c57b90c0613809b3e75730e59
Escarzaga/guess-secret-number-functions
/main.py
2,840
3.84375
4
import random import json import datetime #funcion para jugar desde el inicio sin tener que correr el juego de nuevo def play_game(level="easy"): secret = random.randint(1, 30) attempts = 0 wrong_guesses = [] score_list = get_score_list() name = input("What's your name?: ") while True: ...
8bcd78a63fbcf26e6ed85d56718327d55e6a633c
henriqueotogami/microsoft-learn-studies
/Composição - Aula 43/classes.py
639
3.90625
4
class Cliente: def __init__(self, nome, idade): self.nome = nome self.idade = idade self.enderecos = [] def insere_endereco(self, cidade, estado): self.enderecos.append(Endereco(cidade, estado)) def lista_enderecos(self): for endereco in self.enderecos: ...
f8ba08d04939015e5f203b019ecce5f09e49d154
namecoin/namecoin-core
/contrib/namecoin/convertAddress.py
1,651
3.5
4
#!/usr/bin/env python3 # Convert Address - convert Bitcoin to Namecoin addresses # Copyright (C) 2016-2019 Daniel Kraft <d@domob.eu> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foun...
026db375c01c7d28ba63cd856e4e2310537b5e5f
Oskorbin99/Learn_Python
/Other/Decorator.py
1,807
3.546875
4
from random import randrange # Simple decorator def pidor_decorator(func): def wrapper(): if randrange(2) == 1: zrada = func() + " You is pidor!" else: zrada = func() + " Very cool! You is idiot!" return zrada return wrapper @pidor_decorator def...
accf88ddac848f153213d33b60fcf41d0a9c70c2
barmalejka/Advanced_Python
/hw3/simple_calc/dates.py
1,313
3.96875
4
import operator from datetime import datetime, timedelta def count_entries(): while True: try: counter = int(input("Enter number of terms: ")) except ValueError: print('Should be a positive integer number. Please try again.') continue if counter < 2: ...
caae11b7c34a275d669dacbdcaeade10e71d4ce6
LaVlad/Algosi
/lab1/HashTable.py
1,786
3.59375
4
class HashTable: def __init__(self): self.capacity = 28800 self.table = [None] * self.capacity self._collision_count = 0 self._comp_count = 0 self._search_count = 0 def _hash_func(self, value): return sum([(ord(c) - 32) for c in (value[0:2] + value[-1])]) de...
46256d40468cc1af78e9982e32c039a3b4706133
deepanshusingh1209/cuddly-disco
/PRACTICE/practice_01.py
104
3.921875
4
a=int(input("Give a number :--")) b=int(input("Give a number you want to add in 'a' :-- ")) print(a+b)
b1a39da7550b611f2196e6b2427a3357903959b4
deepanshusingh1209/cuddly-disco
/ASCII value.py
215
3.859375
4
#print(ord("s")) #print(chr(122)) ''' a="sangam" c="d" b=(ord(c)-3) print(b) c=97 d=chr(c) print(d) ''' str1 = str(input("dedo :-- ")) print() list1 = list(str1) #print(list1) #print(len(list1))
3ea0f2ae48ba0919cf2e3828cbbaa5463a807a82
deepanshusingh1209/cuddly-disco
/questionBykrihsna02.py
454
3.828125
4
your_salary=int(input("enter your salary (in rupees) :--")) years_of_service=int(input("enter your years of service (in years) :--")) if years_of_service>5: new_salary= your_salary + your_salary*5/100 your_bonus=your_salary*5/100 print("your net bonus amount is", your_bonus) print("Your Salary inc...
1a3dd622cff426b2343cce1f36b132a2a641c231
armandiito/ejercicios_python
/armando hoja de trabajo/ejercicio_2.py
324
3.859375
4
#armando sequen #0901-19-1801 #Escribir un programa en Python que pregunte el username en la consola y #después de que el usuario lo ingrese muestre en consola: ¡Hola <username>!, #donde <username> es el nombre que el usuario haya introducido. usuario=input("ingrese su nombre de usuario: ") print("Hola ", us...
6287ad79b8e10f8ded6d6d5f02e1642ac0b373bb
RemonIbrahimNashed/CeaserCipher
/task_1_ceaserCipher.py
3,563
3.84375
4
from collections import Counter import numpy as np import matplotlib.pyplot as plt import string import operator #encryption function def encrypt(line , key ): line = line.upper() alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" result = "" for letter in line: if letter in alpha: letter_index = (alpha.find(letter) - key...
901f20d4c6ed0763952c9db7f9d8df0c1ada5d9b
LCCrun/ACAutomation
/utils/DropStropWords.py
695
3.828125
4
#去除停用词 #传入的数据需为contents:list of list | stopwords:list #传出的数据为contents_clean:list of list | all_words:list def drop_stopwords(contents, stopwords): contents_clean = [] all_words = [] for line in contents: line_clean = [] for word in line: if word in stopwords: ...
9b289a59ea5ad651b140f6b0469b25b1a1c59147
LowWeiLin/asteroids
/renderer.py
3,103
3.71875
4
""" Renderer to render asteroids game using pygame """ import sys import time import pygame import numpy as np from asteroids_game import AsteroidsGame BLACK = (0, 0, 0) WHITE = (255, 255, 255) class Renderer: """ Renderer to render asteroids game using pygame """ def __init__(self): self....
1078e80154bcc01ca6fae94fc73923dc62681b12
morganjk/parglare
/parglare/errors.py
1,393
3.640625
4
from __future__ import unicode_literals def expected_symbols_str(symbols): return " or ".join([s.name for s in symbols]) class Error(object): """ Instances of this class are used for error reporting in the context of error recovery. """ def __init__(self, position, length, message=None, inpu...
998f823750f995de04670fb9d3ed9c5d82b08ae7
OindrilaNath/Practice-Python
/2.Operators.py
129
3.78125
4
''' This script is to practice different types of operators used in python ''' a=10 b=a+10 b-=10 print('\nthe result:',b)
a370d1af7897343bd57cc33fb9c669a0ed988250
ghager93/ConcaveCurveShortening
/old/Vector2D.py
938
3.75
4
from collections import namedtuple from math import hypot class Vector2D(namedtuple('Vector2D', ('x', 'y'))): def __abs__(self): return type(self)(abs(self.x), abs(self.y)) def __int__(self): return type(self)(int(self.x), int(self.y)) def __add__(self, other): if type(other) is t...
aab824b479dd525926b65ba6f5ef69f67d228d1b
JessicaAndrew/EEE3097S-Group-3
/Combined/CompressEncrypt.py
2,309
3.5625
4
# note this encryption code was adapted for use from the code on the website: https://kentjuno.com/learning/python/encrypt-file-with-aes-in-python/?__cf_chl_managed_tk__=pmd_hlkUY4MSLokfXLP0W7X5pldoV.w7AWDdhgcb_gkkEJM-1633346584-0-gqNtZGzNAuWjcnBszROl from Crypto import Random from Crypto.Cipher import AES from Cryp...
c3bbdb946dac14bd7cecb89d39b257fa3dde847f
info-edu/info-edu.github.io
/python/site/cesar/3_piratage.py
1,431
3.59375
4
## Piratage Maintenant nous sommmes un pirate Premiers pas vers le déchiffrement sans la clef Comment faire: en français il y a plus de *e*. => va suffir d'analyser un message chiffré pour trouver quelle est la lettre la plus fréquente. Il faudra alors décaler le message pour que cette lettre devienne un *e*. ```py ...
75d502fb3bdd87ecede8ffe6f22dc54911b4b505
Bimal-Sethi/Sorting_Visualizer
/main.py
3,103
3.6875
4
from tkinter import * from tkinter import ttk import random from Sorting_Algorithms import bubble_sort from Sorting_Algorithms import merge_sort ### Making a window for the app ### root = Tk() root.title("Sorting Algorithm Visualisation") root.maxsize(height=540, width=810) root.config(bg='black') ### Partioning the ...
4592b70d445e50f36d44bf71438ca9b1b58f5cb4
C-CCM-TC1028-111-2113/homework-2-SofiaaMas
/assignments/02Licencia/src/exercise.py
656
4.03125
4
def main(): #Escribe tu código debajo de esta línea edad=int(input('Coloca tu edad')) id_oficial=str(input('Cuentas con identificación oficial? (si/no):')) if edad<0: print('Respuesta incorrecta') elif edad>=18 and id_oficial == 'si': print('Trámite de licencia concedido') elif edad<=18 and id_oficial...
b3bf09944017694b362ef5dcdbeab68bafdd2eeb
sanjanprakash/Hackerrank
/Cracking The Coding Interview/recursion_fibonaccinumbers.py
152
4.15625
4
def fibonacci(n): if (n == 1 or n == 2) : return 1 return fibonacci(n - 1) + fibonacci(n - 2) n = int(raw_input()) print(fibonacci(n))
ee70a7f62690d1a97d8a6ff6af5ca4c9202a690e
sanjanprakash/Hackerrank
/Languages/Python/Strings/validators.py
336
3.59375
4
string = raw_input() l = list(string) a, b, c, d, e = False, False, False, False, False for i in l : if i.isalnum () : a = True if i.isalpha () : b = True if i.isdigit () : c = True if i.islower () : d = True if i.isupper () : e = True print a print b print c ...
1d11e37f4d531b075babc71f313bcc3c0fee1816
sanjanprakash/Hackerrank
/Algorithms/Recursion/thepowersum.py
358
3.578125
4
def Power(base,exp) : ans = 1 for i in range(exp) : ans *= base return ans def Check(x,n,base) : num = Power(base,n) rem_x = x - num if (rem_x < 0) : return 0 if (rem_x == 0) : return 1 return Check(x,n,base + 1) + Check(rem_x,n,base + 1) x = int(raw_input()) n ...
3e56ce92ac5ca65112d29b30ff62c115ebb53160
sanjanprakash/Hackerrank
/Languages/Python/Strings/findastring.py
138
3.59375
4
Str, key, count = raw_input(), raw_input(), 0 for c in range(len(Str)): if Str[c:c + len(key)] == key: count += 1 print count
90d880603957ce93191862c24b131069f0114187
arrayoutofbounds/stack_dispatcher
/dispatcher.py
11,330
3.6875
4
# A1 for COMPSCI340/SOFTENG370 2015 # Prepared by Robert Sheehan # Modified by Anmol Desai # You are not allowed to use any sleep calls. from threading import Lock, Event from process import State class Dispatcher(): """The dispatcher.""" MAX_PROCESSES = 8 def __init__(self): """Constr...
4fbb219f7b99d1fa6a14ae6b1b04ae89afb46939
corey-marchand/pythonisms
/itterator.py
2,455
4.0625
4
class Linked_list(): def __init__(self, collection=None): self.head = None if collection: for item in reversed(collection): # [a,b,c] => [a] > [b] > [c] > None self.insert(item) def insert(self, value): """adds node to head of new linked list""" ...
560fca21dd0b05700ef5dfdcc1fca08494615e1e
nana1243/Algorithm
/python/BOJ/수학2/2581.소수찾기2.py
377
3.734375
4
n=int(input()) m=int(input()) def isPrime(x): if x<=1: return False else: for i in range(2, x): if x%i==0: return False return True answer1=[] for i in range(n,m+1): if isPrime(i)==True: answer1.append(i) print(answer1) if len(answer1)==0: print(...
3bd13546c6baee5a0dbff41e1c254614a0b3f2ad
nana1243/Algorithm
/python/programmers/Brute-Force-Search/소수찾기.py
620
3.703125
4
def solution(numbers): import math def isPrime(num): if num == 1 or num==0: return False n = int(math.sqrt(num)) for k in range(2, n+1): if num % k == 0: return False return True from itertools import permutations def sol(numbers): ...
a11afd04175e1f895ab02cb751453bf153ea0878
jwsander/CS112-Spring2012
/classcode/day07--debugging/02_syntax.py
94
3.953125
4
#!/usr/bin/env python n = int(raw_input("Enter a number: ")) print n, "squared is", n ** 2
cc78076efdca6d1d8f1aafdf40815d8799f53315
jwsander/CS112-Spring2012
/hw05/tictactoe.py
7,575
4.03125
4
#!/usr/bin/env python """tictactoe.py A simple Tic-Tac-Toe game for two players. The Keypad is used. "Fill" means the area (corresponding to 1-9 on the keypad) is full with something, either an X or an O. X(1-9) and O(1-9) relate to the same thing. """ ##Initialization settings import pygame from pygame.locals impo...
95d4b98f4b1addebc07a90700e01affb7200f7a9
VladMak/leetcode
/tests.py
5,074
4.125
4
import unittest from main import Solution from ListNode import ListNode class TestSolution(unittest.TestCase): def setUp(self): self.solution = Solution() def test_twoSum(self): """Example 1: Input: nums = [2,7,11,15], target = 9 Output: [0,1] Output: Because nums[0] ...
7cda74f33cb4c8a462d9ba8ff16961a830aa5e64
yangyang0106/study
/Day_20201201.py
340
3.796875
4
# i = 0 # while i <= 30: # if i % 3 == 0: # print(i) # i +=1 # i = 0 # while i <=30: # if i % 3 == 0 and i % 5==0: # print(i) # i +=1 # sum=0 # i = 0 # while i <= 20: # sum+=i # i+=1 # print(sum) i=0 while i<=10: print(i*'*') i+=1 while i<=11 and i != 0: print(...
78b2cac62b59afcb96a123e58eb68127f34227f4
caijinxu/python
/S12/day3/copy.py
371
3.796875
4
import copy # #浅拷贝 # copy.copy() # #深拷贝 # copy.deepcopy() # #赋值 # # a1 = 123123 # # a2 = 123123 # # a2 = a1 # # print(id(a1)) # # print(id(a2)) # a3 = copy.deepcopy(a1) # print(id(a1)) # print(id(a3)) dic = { "cpu":[80,], "men":[80,], "disk":[80,] } print('befor',dic) new_dic = copy.copy(dic) new_dic["new"...
1b93e610bb3a647fcaf794bb83f399377a0c50f6
EthanOtholvinBrown/Objects-Falling-and-Half-Life
/Object Falling and Half Life/Object Falling and Half Life.py
6,115
3.859375
4
# -*- coding: utf-8 -*- """ Created on Mon Mar 9 10:33:23 2020 @author: Ethan """ import math def main(): userChoice = -1 while (userChoice != 0): print("Welcome to assignment 2!") userChoice = int(input("Enter which part you would like to do[1 or 2, 0 to exit]: ")) if(user...
5bc289e8526c9ad2103edc1f7908020f2a498e5c
N3K0521/FIT1045
/Exam revision.py
3,516
4.03125
4
#Searching: def find(word, letter): index = 0 while index < len(word): if word[index] == letter: return index index = index + 1 return -1 """ find -> inverse of the [] operator takes a character and finds the index where that character appears f not found, returns -1 """ #loopin...
6480f036b932e36a647113701426d5c944c125d8
N3K0521/FIT1045
/Tutorial 4.py
2,068
3.890625
4
# Tutorial 4 # Prepared Question ''' Your phone (likely) knows you who your most-used contacts are so they can be displayed on the speed-dial page. Here are two different ways we could implement this functionality in Python. ''' def speed_dial_v1(contact_list): sd_name, sd_number, sd_freq = contact_list.pop() ...
8a8875c20ebe529d493c2e81c80adc5f18fc07a5
DankiLiu/Way-to-Python
/python_crash_course/data_visualization/random_walk.py
1,202
4.25
4
from random import choice class RandomWalk: '''A class to generate random walk.''' def __init__(self, num_points=5000): '''Initialize attributes of a walk.''' self.num_points = num_points # All walks start at (0, 0) self.x_value = [0] self.y_value = [0] def fill_w...
e7bb75abb2b02e8f6c06f24b7a8775d014c601ed
jonaskrogell/adventofcode2017
/23b-optimized.py
316
3.5625
4
h = 0 b_s = 93 * 100 + 100000 c = b_s + 17000 def isPrime(number): for x in range(2, int(number/2)+1): if number % x == 0: return False return True for b in range(b_s, c + 1, 17): print(b) if not isPrime(b): print(b, 'prime') h = h + 1 print('finished, h:', h)
5c55755817d3a297c069254a2d34500c4700d990
jonaskrogell/adventofcode2017
/4.py
280
3.640625
4
import sys valid = 0 for passphrase in sys.stdin.read().strip().split('\n'): words = set() for password in passphrase.split(' '): if password not in words: words.add(password) else: break else: valid += 1 print(valid)
550b7f8fcdecbfd7c11897990eb6ab91fb9ffe3d
render3d/sudoku-solver
/sudoku.py
13,775
4
4
import numpy as np from itertools import chain import time def displayGrid(sudoku): """Prints the sudoku in a more readable format Args: sudoku (<class 'numpy.ndarray'>): the puzzle in any state Returns: <class 'NoneType'>: Just prints the grid """ for row in range(...
c387e301bcdd8523f8e9b719f92ffc973894f0f3
everttonbs/CursoPy
/Desafios/emprensado.py
730
3.828125
4
import random num_aleatorio = random.randint(1, 100) lista_ten = [0, 101] while(True): ten_usuario = int(input("Digite um numero: ")) lista_ten.append(ten_usuario) lista_ten.sort() a = lista_ten.index(ten_usuario) #print(f"Index {a}") if(ten_usuario > num_aleatorio): print("Tente...
10bf3fc22ab3f30d2fe0e4998eb974c3ebbcaed8
everttonbs/CursoPy
/Listas/usoFor.py
581
4.25
4
palavra = "Huppermago" for letra in palavra: print("Letra: {}" . format(letra), end = ' ') #print("Letra: {}" . format(letra)) print(); #Mostra na tela as letras fora de ordem for letra in set("Hello World!"): print (f'Letra -> {letra}') listaNomes = ["Maria", "Jose"] for nome in listaNomes: pr...
d7e3b24cdf9ca78616cb084c5b82da4995472b60
fintak23/Collaborative-Programming
/Game.py
5,103
3.578125
4
import os import time batteryimg=""" ╔══════════════════════╗ ║╔════════════════════╗╚╗ ║║████████████████████╚╗╚╗ ║║███████Full Battery ║║║ ║║████████████████████╔╝╔╝ ║╚════════════════════╝╔╝ ╚══════════════════════╝""" sfpercent=""" ╔══════════════════════╗ ║╔════════════════════╗╚╗ ║║████████████████\\\\\\\\╚╗╚╗ ║...
55dccdc6ee1856a3d976bae7e524b1549cf275b1
adamjoshuagray/BloomMap
/BloomMap.py
3,174
3.5
4
# file: BloomMap.py # Written by Adam J. Gray 2015. # This file contains a quick and dirty implementation of # a Bloom-filtered map. # Obviously this could be implemented more efficiently. # # More info on Bloom filters can be obtained at: # https://en.wikipedia.org/wiki/Bloom_filter from random import * # This is th...
6f5beb049c449649149d2a5474260717689e43c5
radhamohanparashar/Dynamic_programming
/inorder.py
2,434
4
4
class Node: def __init__(self, data): self.left = None self.right = None self.data = data # Insert Node def insert(self, data): if self.data: if data < self.data: if self.left is None: self.left = Node(data) else:...
6d41b1cece8deb36245b93e9ea90034153205122
colingdc/project-euler
/10.py
469
3.546875
4
# The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. # Find the sum of all the primes below two million. import math import sys def erathostenes_crib(n): numbers = range(2, n) candidates = [2] + [x for x in range(2, int(math.sqrt(n)) + 1) if x % 2] for candidate in candidates: numbers = [numbe...
59f0eab87556831d370d8cdb008c0b490d2662ae
colingdc/project-euler
/40.py
526
3.640625
4
# coding: utf-8 # An irrational decimal fraction is created by concatenating the positive integers: # 0.123456789101112131415161718192021... # It can be seen that the 12th digit of the fractional part is 1. # If dn represents the nth digit of the fractional part, find the value of the following expression. # d1 × d10 ...
8425e108215885fa0480d399ee98fc0f6395b27a
colingdc/project-euler
/38.py
1,272
4.15625
4
# coding: utf-8 # Take the number 192 and multiply it by each of 1, 2, and 3: # 192 × 1 = 192 # 192 × 2 = 384 # 192 × 3 = 576 # By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1,2,3) # The same can be achieved by starting with 9 and m...
11ca7dc139f3004c053bd1054079c6d45fcbcff5
florisvb/PyNumDiff
/pynumdiff/utils/_pi_cruise_control.py
2,106
3.734375
4
import numpy as _np def run(timeseries_length=4, dt=0.01): """ Simulate proportional integral control of a car attempting to maintain constant velocity while going up and down hills. This function is used for testing differentiation methods. This is a linear interpretation of something similar to what...
96e2fef64ced0aac4c6a263a3939984d31a7eb0f
j-gilkey/NYC_property_val_and_community_gardens
/garden_locator.py
1,110
3.75
4
import pandas as pd import seaborn as sns import numpy as np import matplotlib.pyplot as plt from sklearn.neighbors import NearestNeighbors def find_nearby_gardens(lots_df): #takes in a dataframe that contains 'lat' and 'lng' columns representing lattitude and longitude coordinates #for each of those points th...
4d7568a8fdb9729d9ff34e0bae70597e6430e2e2
Indi44137/Functions
/Revision 3.py
365
4.09375
4
#Indi Knighton #03/12/2014 #Revision task 3 number1 = int(input("Please enter a number here: ")) number2 = int(input("Please enter a number here: ")) def sort(number1, number2): if number1 > number2: print("{0}, {1}".format(number2, number1)) else: print("{0}, {1}".format(number1, n...
90034df440b186dcb1f2e168864717f06f5c86d7
kunsir111/deeplearning
/xixixi/tensor的基本用法.py
2,009
3.59375
4
# 在PyTorch中, torch.Tensor 是存储和变换数据的主要⼯具。如果你之前⽤过NumPy,你会发现 # Tensor 和NumPy的多维数组⾮常类似。然⽽, Tensor 提供GPU计算和⾃动求梯度等更多功能,这 # 些使 Tensor 更加适合深度学习。 import numpy as np import torch # 创建⼀个5x3的未初始化的 Tensor : x = torch.empty(5, 3) print(x) # 创建⼀个5x3的随机初始化的 Tensor : x = torch.rand(5, 3) print(x) #创建⼀个5x3的long型全0的 Tensor : x = torch...
bcb5d2898fdca66e4f997135c19e2f3b74da4e8b
catonis/Numerical-Methods
/palindromics.py
4,288
3.71875
4
# -*- coding: utf-8 -*- """ Created on Mon Jul 8 21:54:53 2019 @author: Chris Mitchell """ class PalindromicInteger(int): _palindrome = 0 _pLen = 0 _pSplitIndex = 0 _pIsLenEven = False _pSplits = [] def __init__(self, n): self._palindrome = n self._pLen = len(str(self._pa...
9bbbec4e8227e586d1b3423a78b35ec28c267da8
catonis/Numerical-Methods
/continued_fractions.py
2,481
3.984375
4
# -*- coding: utf-8 -*- """ Created on Thu Jul 12 20:55:39 2018 @author: Chris Mitchell """ from reduce import reduce def unpack_cont(cont_frac): """Take a continued fraction and expand it to a rational number. The function takes a continued fraction as a list and unpacks the fraction which is ret...
570b7e7bf94f8ca520c568db53f5182b8a38c936
Fantasya/GUI_Ramanfit
/grid_layout.py
531
3.515625
4
from tkinter import * root = Tk() Button1 = Button(root, text="Button1", fg="red") label_1 = Label(root, text="Name") label_2 = Label(root, text="Password") entry_1 = Entry(root) # Ask for a blank field. Il faut ensuite préciser où est-ce qu'on le met. entry_2 = Entry(root) label_1.grid(row=0, sticky=E) label_2.gri...
65b581798980749909efe07bb15d80203f6c3ffb
pedemonte96/TFG_physics_2019
/gradient_descent/grad_descent.py
1,725
3.546875
4
def gradient_descent(f, gradient, x, j_real, eps=1e-6, max_iter=100, initial_alpha=0.1): """ Aquesta funci implementa l'algorisme de descens pel gradient. :param f: Funci a minimitzar :param x: Punt inicial :param eps: Moviment mnim realitzat abans de parar :param max_iter: Iteracions mxime...
8e78e86e40646158b0d146d7adea73c1bf710f5f
payalaharikrishna/demomarch
/pyth/queue.py
542
3.71875
4
from threading import * from time import * from queue import * class Produre: def __init__(self): self.q=Queue() def produre(self): for i in range(1,11): print('item produced',i) self.q.put(i) sleep(1) class Consumer: def __init__(self,prod): self.prod=pr...
2faf7f05bf4eab93eec96ae80e3d800deca61843
payalaharikrishna/demomarch
/pyth/abs.py
350
3.8125
4
from abc import ABC , abstractmethod class Pawan(ABC): def display(self): print('this is concrete method') @abstractmethod def cal(self,a): pass class Suresh(Pawan): def cal(self,a): print('square=',a*a) class Hari(Pawan): def cal(self,a): print('cube=',a*3) h=Hari()...