blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
c4f58d8b4ef849c8a4cdd2a2ec05dda41dc637a8
mjoze/kurs_python
/codewars/Primes_in_numbers.py
328
3.859375
4
"""Given a positive number n > 1 find the prime factor decomposition of n. The result will be a string with the following form : "(p1**n1)(p2**n2)...(pk**nk)" with the p(i) in increasing order and n(i) empty if n(i) is 1. Example: n = 86240 should return "(2**5)(5)(7**2)(11)""" def primeFactors(n): pass num ...
f23bb998e51343b9730a7670a000c8d16501e0ab
mjoze/kurs_python
/codewars/consecutive_strings.py
579
4
4
"""You are given an array strarr of strings and an integer k. Your task is to return the first longest string consisting of k consecutive strings taken in the array. Example: longest_consec(["zone", "abigail", "theta", "form", "libe", "zas", "theta", "abigail"], 2) --> "abigailtheta" n being the length of the string ...
bf02ddbeba64ab81c0e3621c6d267aa54ca97a38
mjoze/kurs_python
/kurs/04_funkcje/zadania/zadanie6.py
847
3.671875
4
""" Napisz grę kamień-papier-nożyce tak, aby korzystać z funkcji.""" import random # loss : win rules = { 'n': 'k', 'k': 'p', 'p': 'n', } def declare_winner(user, ai, ): return (user, ai) if user == ai else (ai if (user in rules.keys() and ai == rules[user]) else user) def game(n): result = { ...
4e5a6bdf913e0aa7823bcb7cb1ffcfa06478b9dd
mjoze/kurs_python
/codewars/sum_of_digits_digital_roots.py
879
4.28125
4
"""In this kata, you must create a digital root function. A digital root is the recursive sum of all the digits in a number. Given n, take the sum of the digits of n. If that value has more than one digit, continue reducing in this way until a single-digit number is produced. This is only applicable to the natural num...
60f5347ac87880bd4ee4fe767ee73a2b0ef7deba
mjoze/kurs_python
/kurs/01_zmienne_i_typy/zadanie3.py
304
3.765625
4
#3 quote = 'Honesty is the first chapter in the book of wisdom.' # a print(len(quote)) # b print(quote[-7:-1]) # c middle = len(quote)//2 print(quote[:middle]) # d print(quote[-1]) # e print(quote[middle::3]) # f print(quote[::2]) # g print(quote[::-1]) # h print(quote.replace('wisdom', 'friendship'))
ac94e379d53ec067f6295c4a2d5072786dacc43e
mjoze/kurs_python
/kurs/06_operacje_na_plikach/zadanie4.py
518
3.78125
4
import random def random_quote(words): quote_for_today = random.choice(words).strip('') return quote_for_today.split(' - ') def show(quote): print("Quote of day is:") print("*" * 150) print(quote[0].center(150)) print(quote[1].center(150)) print("*" * 150) filename = 'quotes.txt ' # i...
f4c5b0d3065008b4693bfb2db77121dce2655d8b
mjoze/kurs_python
/kurs/03_kolekcje/zadania/ex10.py
369
3.6875
4
"""Użytkownik podaje dowolną liczbę N. Napisz, który wygeneruje słownik, wg zasady, że każdej liczbie przyporządkowany jest jej kwadrat (n : n * n). Załóżmy, że użytkownik podał N = 8 Wynik: {1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64}""" sq = {} n = int(input('Podaj dowolną liczbę')) for i in range(1, (n+...
cc46d7f8f550b29e878e70a43eea4e9d5a19641c
mjoze/kurs_python
/kurs/02_instrukcje_sterujace/if/if2.py
329
3.578125
4
"""Pobierz dwie liczby całkowite od użytkownika i oblicz ich sumę. Jeśli suma jest większa niż 100, wyświetl wynik, w przeciwnym wypadku wyświetl “Koniec”.""" a = int(input("Podaj liczbę")) b = int(input("Podaj drugą liczbę")) sum = a + b if sum > 100: print("twój wynik to", sum) else: print('koniec')
a329c5fae652985ed6e672c7170d0783d1069e10
mjoze/kurs_python
/dodatkowe/script.py
104
3.546875
4
a = ['23', '100'] actual_temp = 25 for i in range(int(a[0]), int(a[1])+1): print(i == actual_temp)
b78c793942d48bfb2586fc2690722de9a706d4e1
mjoze/kurs_python
/hackaton_2/01_generator_nauczyciela/create_data.py
366
3.59375
4
import csv def open_csv_file(file): with open(file + '.csv', 'r') as f: reader = csv.reader(f) students = list(reader) return students def create_students_dict(lista): students = {} for element in lista: students[element[0] + element[1] + element[2]] = [element[1], element[2]...
0c5c73d72c9e7872fc33199fe9f244bc7715f6f3
mjoze/kurs_python
/codewars/iq_test.py
1,149
4.5625
5
""" Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given numbers finds one that is...
9a922c6a2b13830a5c2597d0879e6262ae1e45c0
mjoze/kurs_python
/kurs/12_OOP/alien.py
1,018
3.671875
4
import random class Player: """ Gracz w grze strzelance. """ def blast(self, enemy): shoot = random.randint(1, 10) print("Wróg ma 3 punkty życia") print('Gracz razi wroga trafiając: {}\n'.format(shoot)) if shoot >= 3: enemy.die() else: enemy.win...
667762cb32910c8de75ae695c2b68f6c6ca6a11f
mjoze/kurs_python
/kurs/03_kolekcje/discard_remove_set.py
215
3.84375
4
txt = {'d', 'r', 'a', 'b', 'k'} txt.discard('q') print(txt) "KeyError if elem is not contained in the set." txt.remove('b') print(txt) "Remove element from the set if it is present." "remove - error. discard - not"
6e476e766491bbce4693c7be8856424a46052d51
mjoze/kurs_python
/kurs/08_wyjatki/zadanie4.py
874
3.90625
4
""" Oblicz średnią arymetyczną z kilku liczb. Liczby będą podane przez użytkownika po przecinku. Napisz funkcję, która przyjmie wartości i wyświetli średnią. Program powinen być odporny na błędy użytkownika. Błędów nie wyświetlaj, ale rodzaj błędu zapisz do pliku.""" numbers = input("liczby") numbers = numbers.split(',...
0645e3a47c686c71b303221a5b773fbb5f2ade7e
rpachauri/connect4
/connect_four/evaluation/victor/rules/threat_combination.py
14,253
3.65625
4
from collections import namedtuple from enum import Enum from typing import Optional, Set, List from connect_four.evaluation.victor.rules import Rule, Vertical, Baseinverse, Claimeven from connect_four.game import Square from connect_four.problem import Group from connect_four.evaluation.board import Board class Thr...
d7dcb31923dec95886a9ad872afa73dc4387b8ed
rpachauri/connect4
/connect_four/envs/connect_utils.py
2,256
3.84375
4
def connected(state, num_to_connect, player, row, col): """ Args: state (np.ndarray): a numpy ndarray of shape (2, M, N), where M and N are > 0. num_to_connect (int): num_to_connect > 0. player (int): 0 or 1. The player we are checking. row (int): the starting row col (in...
91dfaee18068ce48f55c9c5a58f81046da74aa16
shchoice0812/TIL
/Python Advanced/05. Special_Metho(slots).py
1,227
3.53125
4
""" slots의 개념 - 파이선 인터프리터에게 통보 - 해당 클래스가 가지는 속성을 제한 - __dict__는 hash table 사용으로 메모리 사용이 많음, 따라서 __slots를 사용하며 다수의 객체 생성 에는 메모리 사용(공간) 대폭 감소 효과 - 해당 클래스에 만들어진 인스턴스 속성 관리에 dictionary 대신 Set 형태를 사용 - 대용량 데이터 처리를 위해 ML, DL 모델에는 대부분 slots를 사용 """ # __slot__, __dict__ 성능 비교 (클래스 2개...
6bd47a1774df3150faf8915c27156b93b08069a5
thinkreed/python-algo
/e3_longest_substring.py
726
3.9375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ __title__ = '' __author__ = 'thinkreed' __mtime__ = '17/3/3' """ class Solution: def longest_substring(self, str): start = max_length = 0 # 已出现过的字符字典, char -> index usedChar = {} for i in range(len(str)): # 如果出现重复,从当...
acd5d5c8da57bc27a960ec5f3bff6f56b8331451
iwuji1/try_pong
/game_trial.py
6,507
3.53125
4
import pygame import time import random pygame.init() #defining colors white = (255,255,255) black = (0,0,0) blue = (35,41,207) red = (227,23,0) green = (2,227,55) #Display size and settings display_width = 800 display_height = 600 gameDisplay = pygame.display.set_mode((display_width,display_height)) pygame.display...
a5be0c5a7e7a677e061f19b0b247070a92eae056
adqn/split-file
/filesplit.py
1,200
3.53125
4
def splitparts(filearr, div): filelen = len(filearr) divsize = filelen / div remainder = filelen % div fileparts = [] divstart = 0 for i in range(1, div+1): fileslice = filearr[divstart * divsize : i * divsize] fileparts.append(fileslice) divstart += 1 if remainder > 0: count...
3996092b93d6916f38041c072f39e36969712774
lxmambo/hangman
/hangman.py
1,522
3.9375
4
import random import hangman_art as ha import hangman_words as hw import os def clear(): os.system('cls') #on Windows System chosen_word = random.choice(hw.word_list) word_length = len(chosen_word) end_of_game = False lives = 6 already_guessed_msg = False congrats = False #hangman logo print(ha.logo) #testing ...
3c29330075a94eae596807d866b77009943b34eb
raffipython/bike
/Calculator_static.py
493
3.78125
4
# -*- coding: utf-8 -*- class Calculator(): def __init__(self): self.result = 0 @staticmethod def addition(number1, number2): result = number1 + number2 print("{} + {} \t= {}".format(number1, number2, result)) @staticmethod def substraction(number1, number...
4c222721bf2eb390f94cc8dc8a537cad406244fb
Nehanavgurukul/list
/mainstr_bonus_part.py
675
3.640625
4
# mainStr = "the quick brown fox jumped over the lazy dog. the dog slept over the verandah." # subStr = "over" # replacementStr = "on" # list1=mainStr.split() # new_list=list(mainStr) # print(new_list) # i=0 # while(i<len(new_list)): # if( new_list[i]==subStr): # new_list[i].replacementStr("on") # i=i...
e731c888648c57e82b066b11c15a8f0af1c4767d
Nehanavgurukul/list
/removing_list.py
161
3.875
4
names_list = ["annu", "shivam", "deepa", "pooja", "rupa", "dhruv", "alok"] names_list.pop(3) print ("length of the list is ", len(names_list)) print (names_list)
7e1bf8ced55312d987b87c316ff68d3647457e8f
Nehanavgurukul/list
/palindrome1.py
227
4.03125
4
first_list=[1,2,3,4,5,4,3,2,1] last_list=[] i=len(first_list)-1 while(i>=0): last_list.append(first_list[i]) i=i-1 if(first_list==last_list): print("it is palindrome") else: print("it is not palindrome")
11a895aa45b73ceda7605306c7427f8be71df9dc
ianfoo/advent-of-code-2020
/puzzles/2020/day-13/crt.py
1,763
3.703125
4
# A Python 3program to demonstrate # working of Chinise remainder # Theorem # Returns modulo inverse of a with # respect to m using extended # Euclid Algorithm. Refer below # post for details: # https://www.geeksforgeeks.org/multiplicative-inverse-under-modulo-m/ import sys def inv(a, m): m0 = m x0 = 0 ...
7ec024911edc71d7ea3c54ee6bbb5a112014811e
Dharm3438/Problem-Solving
/1.DSA/Implementation/3.LL/2.gfg_implementation.py
1,665
3.96875
4
MOD = 10**9+7 # your task is to complete this function # Function should return an integer value # head1 denotes head node of 1st list # head2 denotes head node of 2nd list ''' class node: def __init__(self): self.data = None self.next = None ''' ''' 1 4 1 2 3 4 5 1 2 3 4 5 ''' def multiplyTwoLis...
36744fe94f45b7361685d6930a796e8928b6f188
Dharm3438/Problem-Solving
/1.DSA/new_solving/45_search_mat.py
376
3.546875
4
mat = [] for i in range(int(input('Col: '))): m = list(map(int, input().split())) mat.append(m) x=int(input('x: ')) n=len(mat[0]) m=len(mat) i = 0 j = m-1 fg=0 while(i<n and j>=0 and fg==0): if(mat[i][j]==x): fg=1 print(f"val found at {i},{j}") elif(mat[i][j]>x): j-=1 els...
51a233205822d09e27302f910a24926aa9744b57
Dharm3438/Problem-Solving
/1.DSA/Implementation/1.Recurssion/4.fibonacci.py
144
3.609375
4
def fib(n): if(n==1 or n==0): return n return fib(n-1) + fib(n-2) print(fib(1)) print(fib(2)) print(fib(5)) print(fib(6))
15cb85dbc16b3e686c7ffc51a6ad857441892809
Dharm3438/Problem-Solving
/4.Leetcode/contest 258/1_reverse_prefix.py
673
4.21875
4
''' 2000. Reverse Prefix of Word Given a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inclusive). If the character ch does not exist in word, do nothing. For example, if word = "abcdefd" and ch = "d", then you should ...
4bab8294fa204dae11831dc0e637444e4cb62111
Dharm3438/Problem-Solving
/1.DSA/36_three_way_partition.py
1,672
3.5
4
#User function template for Python class Solution: def threeWayPartition(self, array, a, b): # code here i = 0 l = 0 r = len(array)-1 while(i<=r): if(array[i]<a): array[i],array[l] = array[l],array[i] l+=1 i+=1 elif(array[i]...
e9d65df010b0982067b5cba41a3f6cb9e7c5b9ac
Dharm3438/Problem-Solving
/3.Codeforces/word_capitalization.py
170
3.859375
4
name = input() first_letter = name[0] #print(first_letter) first_letter = first_letter.upper() #print(first_letter) final_str = first_letter + name[1:] print(final_str)
81e4c2c98ebc7ef11463db6cabed26115010e225
Dharm3438/Problem-Solving
/1.DSA/recurssion/1_factorial.py
249
4.15625
4
def factorial(n): #Base Case if(n==1): return 1 #Recursive assumption tmp = n*factorial(n-1) #Self work return tmp if __name__ == "__main__": n = int(input('Enter a number: ')) print(factorial(n))
743e7d80f9241d933393285d6ecb6c0823aaa2a7
Dharm3438/Problem-Solving
/1.DSA/link_list.py
2,567
3.890625
4
class Node: def __init__(self, data=None, next=None): self.data = data self.next = next class LinkedList: def __init__(self): self.head=None def print(self): if(self.head == None): print('LL is Empty') return itr = self.head ...
8ae2bbdd4719de113dde9e8bfb3baa72dc95cdf6
Dharm3438/Problem-Solving
/1.DSA/46_median_row_wise.py
1,103
3.515625
4
#User function Template for python3 class Solution: def median(self, matrix, r, c): #code here arr=[] for i in range(0,r): for j in range(0,c): arr.append(matrix[i][j]) #print(arr) arr.sort() #prin...
97339a5b6cb1bb21c108887fa1d18b6aa56e4672
Dharm3438/Problem-Solving
/1.DSA/Implementation/2.Array/4.pairsum.py
528
3.53125
4
def pair(arr,x): arr.sort() i=0 j=len(arr)-1 ct = 0 while(i<j): if(arr[i]+arr[j]==x): #code for handling dupliation while(i<j and arr[i]==arr[i+1]): i+=1 ct+=1 while(i<j and arr[j]==arr[j-1]): j-=1 ...
4a11ce8c992bb2e390dbfa8c537009d98bb5cba1
mwall-dev/chessAI
/state.py
562
3.5625
4
""" Wrapper class for chess board (Good for extendability). """ import chess class State: def __init__(self, fen=None): if fen is None: self.board = chess.Board() else: # Careful of shallow copies. Come back later and check docs. self.board = chess.Boa...
9cd777ca096d9458430b5bfcf38d44bc55ecfdb8
amssdias/python-pong
/pong.py
4,065
3.625
4
import pygame import random def ball_animation(): global ball_speed_x, ball_speed_y global player_1_score, player_2_score global score_time ball.x += ball_speed_x ball.y += ball_speed_y if ball.y >= screen_height or ball.y <= 0: ball_speed_y *= -1 if ball.right >= screen_width: ...
99e9ff8a73b393b39ad5972d41328b51d4b915b3
ingliscj/NCL-MSc-PORTFOLIO
/Python/TicTacToeProject.py
3,666
4.125
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: from IPython.display import clear_output import random print('Welcome to Tic-Tac-Toe!') board_floor = '----------' test_board = ['X','O','X','O','X','O','X','O','X'] board = [' ']*9 # function that neatly displays dynamic game board def display_board(board): cle...
a5ccb9fddffff976b18747020557846adb476d36
Nothrazim/arbetsprov
/card.py
8,596
3.59375
4
import random class Card: def __init__(self, name, cost, card_type, effects=[]): self.name = name self.cost = cost self.card_type = card_type self.effects = effects def shuffle_deck(deck): print("I have now shuffled the deck.") random.shuffle(deck) def draw_card(hand, d...
bfc0aa771330e30017daa3d982a1ebce5a43598d
bcfurtado/exercism
/python/rotational-cipher/rotational_cipher.py
373
3.8125
4
from string import ascii_lowercase, ascii_uppercase, maketrans, translate def rotate(text, key): to_lowercase = ascii_lowercase[key:] + ascii_lowercase[:key] to_uppercase = ascii_uppercase[key:] + ascii_uppercase[:key] translation_table = maketrans(ascii_lowercase + ascii_uppercase, to_lowercase + to_uppe...
1763f8acbb6e3e08522f5bfd17aea18b59d8de05
marcos-mendez/Image-coin-counter
/coin counter.py
864
3.734375
4
# Rhys Dunn - 2015 # Learning image vision/OpenCV # import libraries import numpy as np import cv2 # load image img = cv2.imread("money.jpg") # prep image - blur and convert to grey scale grey = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) blurred = cv2.GaussianBlur(grey, (17, 17), 0) # show blurred image and grey sca...
2796d438c6db90d0569988d04c6f0ccecb874763
shiladityab/Python-Games
/guess number game_while loop.py
367
4.1875
4
print("Guess a Number between ZERO to TEN Game") import random number = random.randint(0,10) guess = int(input("I am thinking about the number : ")) while True : if guess == number : break else : guess = int(input("NOPE ... !!! Try Again with a different number now : ")) print("You are RIG...
095293ed24900fd1a767a7f9f8bf1df01de1e088
Hemvati/31-May
/sort.py
223
3.765625
4
l1=[] l2=[] a=[] s=int(input("Enter the size of list:")) for i in range(s): e=int(input("Enter element:")) a.append(e) print(a) for num in a: if (num%2==0): l1.append(num) else: l2.append(num) print(l1) print(l2)
ff0540620d7df7ea0bd8603080849efefe466dad
xlistarer/homework4
/main.py
3,033
4.46875
4
# This is a sample Python script. # Press Shift+F10 to execute it or replace it with your code. # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. '''Task 1 The Guessing Game. Write a program that generates a random number between 1 and 10 and lets the user guess what ...
5052f1973a5a2b9665f31f088f84a1901da6f2ad
scirelli/dailycodingproblem.com
/problem_9/main.py
2,177
4
4
#!/usr/bin/env python3 """ This problem was asked by Airbnb. Given a list of integers, write a function that returns the largest sum of non-adjacent numbers. Numbers can be 0 or negative. For example, [2, 4, 6, 2, 5] should return 13, since we pick 2, 6, and 5. [5, 1, 1, 5] should return 10, since we pick 5 and 5. F...
7fecb144a0ad62af2dda06db76705cc524ff6e21
scirelli/dailycodingproblem.com
/problem_296/tests/utils/test_decorators.py
420
3.65625
4
""" Simple decorator to print a function doc string. """ import functools def it(func): """ Prints the doc string for you """ @functools.wraps(func) def wrapper_print_doc_str(*args, **kwargs): print(func.__doc__) return func(*args, **kwargs) return wrapper_print_doc_str def d...
b858f9aeb248371530150a04156ebb59b6f2fd69
Botagoz-Ahm/Task-2
/korobki.py
505
3.90625
4
l1 = int(input()) w1 = int(input()) h1 = int(input()) l2 = int(input()) w2 = int(input()) h2 = int(input()) Area1 = (((((2 ** l1) ** w1) + (2 ** l1) ** h1) + (2 ** w1) ** h1)) Area2 = (((((2 ** l2) ** w2) + (2 ** l2) ** h2) + (2 ** w2) ** h2)) if Area1 == Area2: print('Boxes are equal') elif Area1 < Area2...
e80a1bd8f9c24902ffd99810a97716de9acd09c4
pchg/config
/bin/crocetcions_ohrgrauqitophes.py
1,713
4.09375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """Un programme mettant en evidence l'inutilite de l'orthographe pour la comprehension d'un texte""" from random import * import string, sys def scramble_text(text): mots = text.split(" ") textout = [] mot = "" for mot in mots: mott = [] ...
05fad0b60728a5934c5b13a0d5f151fbd65a51be
sushi-irc/nigiri
/helper/code.py
774
3.703125
4
""" Misc. code helper """ def _generate_unique_attribute(fun): return "__init_%s_%s" % (fun.func_name, str(id(fun))) def init_function_attrs(fun, **vars): """ Add the variables with values as attributes to the function fun if they do not exist and return the function. Usage: self = init_function_attr(myFun, a...
a32cadd0c965c2f038aa3c95490a5094be52aea6
gulshan-mittal/bomberman-game
/enemy.py
1,643
3.5
4
#!/usr/bin/python # -*- coding: utf-8 -*- import random from person import Person from gameConfig import global_arr class Enemy(Person): # inherit class of Person # This Class is making Enemy randomly def __init__(self): self.lives = 1 self.shape = [['E', 'E', 'E', 'E'], ['E', 'E', 'E', 'E'...
aec37c09ccb507432e0a177ef1480dbbcc26e708
Dmmc123/ds_lab_8
/vector_clock.py
3,546
3.734375
4
# importing all the needed libraries # Process and Pipe - for implementing multiprocess communicationg # datetime to see the real time of process execution from multiprocessing import Process, Pipe from datetime import datetime # function to represent the real and Lamport times # in a more visual way def local_time...
d062c72303388d20602b3a1906f64a6c6b9a475b
InnaKlabukova/InnaKlabukova
/hw6.py
241
4.15625
4
distance = float(input("Дистанция в первый день: ")) goal = float(input("Цель: ")) days = 1 while distance < goal: distance *= 1.1 days += 1 print(f"Требуемое количество дней - {days}")
6689c9c52f9154f33ae64efdd926982ecc12cfe1
belgort-clark/ctec-121-module-7-skill-building
/exercise06/module-7-skill-building-exercise-6-solution.py
563
3.90625
4
# Module 7 - Skill Building Exercise No. 6 Solution # Author: Bruce Elgort # Date: July 22, 2017 def main(): print("This program computes the 'number value' of a name") print() # get a name (multiple words) names = input("Enter a name: ") # Create a string of all the letters -- avoids nested loop...
1696cf6474c5d59f7771574aa299442b3364763e
psyworld/numerical_methods
/nonlinear/gradient.py
746
3.71875
4
from numpy import * from math import * def gradient(X0, eps, F2, F_d): print("Solving system by Gradient descent") X0 = array(X0) X1 = X0.copy() while True: X0 = X1.copy() W = array([ [F_d[0][0](*X0), F_d[0][1](*X0)], [F_d[1][0](*X0), F_d[1][1](*X0)] ]) F = array([F2[0](*X0), F2[1](*X0)]) W_ ...
4dce1c2df962482d83b79b82c420527129fdf4c1
damienyf/lxf-python
/lxf-python-basic/oop_adv3.py
7,019
3.9375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 为这样的枚举类型定义一个class类型,然后,每个常量都是class的一个唯一实例。 # Enum from enum import Enum Month = Enum('Month', ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')) for name, member in Month.__members__.items(): print(name, '=>', member, ',', member...
bac0c1aba7f3368ab307fb4fca068b15e17ad6c8
Sam-Garcon/ICS3U-Unit-2-05-phyton
/local_and_global_variable_program.py
880
4.4375
4
#!/usr/bin/env python3 # Created by: Sam. Garcon # Created on: June 2021 # This program shows how local and global variables work # global variable # global variable variableX = 25; def local_variable(): # this shows what happens with local variables variable_X = 10 variable_Y = 30 variable_Z = variabl...
ac51d66b5733fabc09720b44dc0e0f56af081f90
bfl2/OitoRainhas
/oitoRainhasv1.py
8,462
3.5
4
import operator import random import numpy from numpy import sum import pygame, sys from pygame.locals import * # ------# Variaveis Globais numAvalFitness = 0 # condicao de parada, 10.000 avaliacoes de fitness ou individuo com fitness 1 encontrado maxFitness =0 def bin3Gen(num): bin3 = [] while num > ...
a2185e30cf6cc8ff5ac60242dd7bb928150a290b
JSmalley1/ProjectEuler
/Problems41_50/Problem41.py
354
3.890625
4
def is_pan_digital(val): string = str(val) return set(string) == set(map(str, range(1, len(string)+1))) def is_prime(val): for y in xrange(2, 100000): if not val % y: return False return True # any number using the digits 1-8 or 1-9 are divisible by 3 for x in xrange(7654321, 1, -1): if is_pan_digital(x) an...
d4276d80eac9b920c0b3505a350adbcc44e0444b
soundaraj/practicepython.org
/rock paper scissor.py
1,099
3.859375
4
import random while True: dic = {1:'rock', 2:'scissor', 3:'paper'} print("enter the key to play",dic) a = input() b = random.choice(dic.keys()) if a == dic.keys()[0]: if b == dic.keys()[1]: print "you win" else: print "you l...
6e794df692dd6d5eec3ee168dad507e960bdc640
manuelahebel/participants-signup
/gui_windowOne.py
5,232
3.71875
4
''' User Interfaces: Window 1: Shows all different course types and offers a button to proceed to the next window. Window 2: Shows all courses of a course type, showing start and end date as well as trainer name. With a button the course choice can be selected. Next window opens. Window 3: Sign-Up Wind...
3f95e9e935d9ee16fccd5dc2742bda4818f1f708
neHek/homework1
/Кратность пяти.py
160
3.71875
4
#!/usr/bin/python a=int(input('Первое число: ')) b=int(input('Второе число: ')) for i in range(a, b+1): if i%5==0: print(i)
d22e17419eefc509c9a83524b514837d97b89710
A01378889/Trabajos-en-clase
/PruebaCero/Hola.py
174
3.828125
4
distancia = int(input("¿Cual es la distancia?: ")) tiempo = int(input("¿Cuanto tiempo fue?: ")) velocidad = distancia/tiempo print ("La velocidad fue: ",velocidad,"KM2")
92bfdf682172f49b145440b4650099477d325523
A01378889/Trabajos-en-clase
/Clase Dos/AreaTrapezio.py
392
4.03125
4
#Autores: Jossian Abimelec García Quijano, Felipe Gomez Portugal #Calcula el area y precio de un terreno, dado su altura y bases, al igual que el precio por metro cuadrado. a = int(input("Cual es la base de abajo: ")) b = int(input("Cual es la altura: ")) c = int(input("Cual es la base de arriba: ")) formula =...
4be3a9ae5f79370c179af08b363acfd07a1caced
A01378889/Trabajos-en-clase
/PruebaCero/IMC.py
217
3.796875
4
#Autor: Felipe Gomez Portugal Trueba #Calcular el IMC; dado el peso y estatura peso = int(input("Cual es tu peso: ")) estatura = float(input("Cual es tu estatura: ")) imc = peso / estatura**2 print ("Este es tu IMC: %.2f " %imc)
32373dc64e6c63cfad7d2a0562c36c9e83d2d4b5
JunYe1993/Python-Starter
/Python3/LeetCode/0002-Add Two Numbers/UnitTest.py
2,004
3.9375
4
import unittest import Solution from typing import List class ListNode: def __init__(self, x): self.val = x self.next = None class ListNodes: def __init__(self, nums: List[int]): root = n = ListNode(0) for i in range(len(nums)): n.next = ListNode(nums[i...
dc5c24148531710df1ab89bc4feea75ad4190dcc
JunYe1993/Python-Starter
/Learning/DataType.py
826
3.796875
4
# coding=utf-8 print type(1) print type(1L) print type(3.14) print type(True) print type(3 + 4j) print 2 ** 100 print 10 / 3 print 10 // 3 print 10 / 3.0 print repr(1.0 - 0.8) print str(1.0 - 0.8) print "c:\\toDaniel" print "c:\toDaniel" print r"c:\toDaniel" name = "Daniel" for ch in name: print ch print name...
52c11d7bc2f0bf5ebc60283d598f3d16a09dcd57
JunYe1993/Python-Starter
/Python3/LeetCodePremium/Google_Interview/Interview_Process/Odd_Even_Jump.py
5,591
3.96875
4
# You are given an integer array A. From some starting index, you can make a series of jumps. The (1st, 3rd, 5th, ...) jumps in the series are called odd-numbered jumps, and the (2nd, 4th, 6th, ...) jumps in the series are called even-numbered jumps. Note that the jumps are numbered, not the indices. # # You may jump ...
09d395c636d79f1e43dc0d128ba265822ccba351
JunYe1993/Python-Starter
/Python3/LeetCode/TestingModule/ListNode.py
652
3.890625
4
from typing import List class ListNode: def __init__(self, x): self.val = x self.next = None class ListNodes: def __init__(self, nums: List[int]): root = n = ListNode(0) for i in range(len(nums)): n.next = ListNode(nums[i]) n = n.next self.v...
b33878ca74c61155ad2ac80945132851fdc4417b
ThejakaSEP/StockPrediction-
/Home.py
2,801
3.828125
4
#importing necessary librabries import pandas as pd import numpy as np from sklearn.tree import DecisionTreeRegressor from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split import matplotlib.pyplot as plt #Setting a style to the plot ( styles are available in the documen...
119563e52546759abf4b09c6b18938b822402728
markrichardson/pyalgds
/4-4 linked list for levels of BST.py
438
3.765625
4
# -*- coding: utf-8 -*- """ Created on Sun Dec 07 18:17:57 2014 @author: Mark """ from data_structures import BinarySearchTree, Queue, LinkedList # initialise the BST B = BinarySearchTree() for k in [7,3,11,1,5,9,13,0,2,4,6,8,10,12,14]: B.insert(k) # breadth first search Q = Queue() Q.enqueue(B.root) whi...
1323033602b5444b5b2d8127daade1d86345591c
bu1der/python
/for2.py
104
4.15625
4
name = raw_input("What is your name?") print "Hellow" for letter in name: print letter print "!"
20c9d8a7ead9a7c098371f5832cfd782b2a37a12
KrishnaRavula162/Python
/org/aztechs/learning/Print down.py
73
3.84375
4
n = int(input("Enter A Number: ")) a=1 while a<=n: print(n) n=n-1
bdb6582ec0343d5aa744a4ea26f2e480471c59da
Anjalipatil18/Hackerrank-And-Codesignle-Questions
/rectangle.py
215
4
4
length_input=input("enter the length of rectangle..") bredth_input=input("enter the bredth of rectangle..") if length_input==bredth_input: print "Yes, it is square.." else: print "No, it is only rectengle.."
a611dd60af21db0c322a8fd886385b26aa96ae40
carlsverre/Project-Euler
/005/problem_005.py
227
4.0625
4
#!/usr/bin/python def lcm(x,y): return x*y/gcd(x,y) def gcd(x,y): while y != 0: (x, y) = (y, x%y) return x final = 2 for num in range(3,21): final = lcm(final,num) print "Solution 005: " + str(final)
a25f9d98fac90ab3d92fae519f5a77a5fcf02705
ramprasad-mondal/Patterns
/Solid diamond.py
159
3.84375
4
a = int(input('Enter the no of rows: ')) for row in range(a): print(' '*(a-row-1)+'* '*(row+1)) for row in range(a,0,-1): print(' '*(a-row)+'* '*(row))
3ea4a8f226a3ff2ac0f32c64eeebb87345c435ef
ramprasad-mondal/Patterns
/Solid half diamond.py
135
3.890625
4
a = int(input('Enter the no of rows: ')) for row in range(a): print('* '*(row+1)) for row in range(a-1,0,-1): print('* '*(row))
25667443884c92a5d06900b1d77875b26a2b5238
altanai/cirq_quantum_programming
/simulators/simulator_invertible.py
809
4.15625
4
# Invertible gates and operations # cirq.inverse has a default parameter used as a fallback when value isn’t invertable. # cirq.inverse(value, default=None) returns the inverse of value, or else returns None if value isn’t invertable. import cirq def main(): # Pick a qubit. qubit = cirq.GridQubit(0, 0) #...
fff27642afb0273f7b453517143f1660fc70ba03
aa-ag/pylexa
/soundtotext.py
689
3.6875
4
import speech_recognition ''' Documentation: https://pypi.org/project/SpeechRecognition/ ''' file = "test.wav" # "I believe you're just talking nonsense" # initialize recognizer r = speech_recognition.Recognizer() # open file # with speech_recognition.AudioFile(file) as src: # # listen for data / load audio to ...
17905ac47d8bccf0b0d9b37475608c5adc944ba4
huiyuandiknow/Cracking_the_coding_interview
/array/rotateImage.py
336
3.671875
4
# Given a n x n 2D matrix that represents an image. Rotate the image # by 90 degree clockwise. def rotateImage(a): overall = [] for i in range(len(a)): current = [] n = len(a) while n!= 0: current.append(a[n-1][i]) n-= 1 overall.append(current) ...
baa4094a5b32b43d16242023e5032ffd69ac5b8a
ninadpathak/Python-Projects
/Lists.py
639
4.46875
4
# we can create an iterative list by using for loop while defining the list end = int(input("Enter an ending number: ")) list = [x for x in range(0, end + 1)] squares = [] square_root = [] cube_root = [] print("\n\nSquares from 0 to ", end) for i in list: print(i ** 2) squares.append(i ** 2) pri...
15583dc994303c1fb4b60d55884c3e3e46482950
yyuvraj54/Bmax
/self/placeholder.py
1,263
3.546875
4
import tkinter as tk from tkinter import * from tkinter.constants import * class Entry1(tk.Entry,Widget, XView): """Entry widget which allows displaying simple text.""" def __init__(self, master=None, placeholder="", color='grey',cnf={}, **kw): super().__init__(master) Widget.__init__...
6d50b8ebe4c82149bf9d9269a1dc96dca45b4713
soblin/algorithm_list
/sort/bubble_sort/main.py
752
4.21875
4
# -*- coding: utf-8 -*- import sys def print_array(array, size): ret = "" for i in range(size): ret += str(array[i]) + ' ' print(ret) def bubble_sort(array, size): reverse_num = 0 upper = size-2 while upper >= 0: for i in range(0, upper+1): if array[i] > array[i+1...
e2601e195eb3a9a1809b2b0c9d9d94e40dcec142
soblin/algorithm_list
/tree/binary_tree_walk/main.py
1,221
3.96875
4
# -*- coding: utf-8 -*- import sys input = sys.stdin.readline def print_tree(root, left, right, order): if root == -1: return l = left[root]; r = right[root]; if order == "Preorder": print(' ' + str(root), end="") if l != -1: print_tree(l, left, right, order) ...
1cc82c4d5b1483f8b09519d543dfac3154cc0298
MilesL19/Display-Portfolio
/Camera Project/working_camera.py
1,530
3.5
4
import RPi.GPIO as GPIO from picamera import PiCamera import time import datetime GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) #Setting up the camera lights blueLight = 27 GPIO.setup(blueLight, GPIO.OUT) redLight = 17 GPIO.setup(redLight, GPIO.OUT) #Setting up the buttons startButton = 24 GPIO.setup(startButton, G...
48a6e6e1a0a502a75194b6c8f7420a834515ac42
lly102799-git/python-cookbook
/第1章 数据结构和算法/1.16 筛选序列中的元素/list_generator_comprehension.py
1,218
3.6875
4
# -*- coding: utf-8 -*- """ @project: Python Cookbook @date: 2020-10-20 14:41 @author: Li Luyao """ import math from itertools import compress mylist = [1, 4, -5, 10, -7, 2, 3, -1] # 列表推导式 print([n for n in mylist if n > 0]) print([n for n in mylist if n < 0]) # 生成器表达式,处理原始输入很大的情况 pos = (n for n in mylist if n > 0)...
77beb3fc834151eded83a4bccc4fd13d5a980c44
lly102799-git/python-cookbook
/第1章 数据结构和算法/1.11对切片命名/create_slice_object.py
705
3.84375
4
# -*- coding: utf-8 -*- """ Project: python-cookbook Create Time: 2020/10/17 15:01 Author: Li Luyao """ # Create a slice object record = '.........100 ........513.25 ........' # 创建切片对象、对切片对象进行命名的目的是:对代码的功能有更清晰的认识 SHARES = slice(20, 32) PRICE = slice(40, 48) cost = int(record[SHARES]) * float(record[PRICE]) # slice...
730bf62ee356a617f02d57f46b1ec1769ce69174
lly102799-git/python-cookbook
/第2章 字符串和文本/2.15 给字符串中的变量名做插值处理/insert_in_text.py
1,031
3.765625
4
# -*- coding: utf-8 -*- """ @project: Python Cookbook @date: 2020-10-27 19:20 @author: Li Luyao """ # 使用format()方法 s = '{name} has {n} messages.' print(s.format(name='Guido', n=37)) # 使用format_map()和vars()联合 name = 'Guido' n = 37 print(s.format_map(vars())) # vars(): without argument equivalent to locals() # vars()可...
d21f51a418044e3de1c93a90d107c2d0313e2b0e
lly102799-git/python-cookbook
/第8章 类与对象/8.10 惰性属性.py
1,089
3.96875
4
# -*- coding: utf-8 -*- """ @project: python-cookbook @date: 2021-01-26 14:31 @author: Li Luyao """ # 定义一个惰性属性的最好方法是使用描述符 class Lazyproperty: def __init__(self, func): self.func = func def __get__(self, instance, cls): if instance is None: return self else: valu...
89682023982e4a90e4fed13cb9da454fdd582f83
lly102799-git/python-cookbook
/第1章 数据结构和算法/1.15 根据字段将记录分组/some_factory_function.py
526
3.59375
4
# -*- coding: utf-8 -*- """ @project: Python Cookbook @date: 2020-10-20 14:12 @author: Li Luyao """ def maker(n): # 内嵌函数和闭包 k = 8 def action(x): return x ** n + k return action f = maker(2) print(f(4)) def test(num): in_num = num def nested(label): nonlocal in_num # 内嵌函数内部...
ae70c85bf523523049c3d0bb478954331c2a4ba8
lly102799-git/python-cookbook
/第4章 迭代器和生成器/4.10 以索引-值对的形式迭代序列/iter_with_index_value_pair.py
1,269
3.65625
4
# -*- coding: utf-8 -*- """ @project: python-cookbook @date: 2020-11-20 14:34 @author: Li Luyao """ # enumerate()返回索引-值对 my_list = ['a', 'b', 'c'] for idx, val in enumerate(my_list): print(idx, val) for idx, val in enumerate(my_list, start=1): print(idx, val) # 适用于记跟踪记录文件中的行号,当想在错误信息中加上行号时就特别有用 def parse_dat...
61e62770bb50a89871c80e73d9b15aae02802e25
MarkovAlexandr/Snake
/Sergei_part/Sergei_part_of_the_prj.py
4,566
3.53125
4
import pygame as pg import random import sys # Main constants of the game size = width, height = 500, 500 border_size = 10 color = 180, 212, 101 border_color = 99, 136, 64 size_rec = 25 # Game functions of its rules def rand_color(count): return random.randint(count, 255), random.randint(count, 255), random...
c8b1409a56eb00715b53d78087dde46186bc57df
nsfcac/Automating-the-scale-up-process-in-OpenHPC
/Codes/displayInfoIPMI.py
1,693
3.59375
4
#This code is for displaying network discovery data in a nice format (for IPMI Discovery). #Part1: This Function is for have a nice print of nodes information #---------------------------------------------------------------------------------------------------------------------- def printNetDiscoveryInfo(dicSysInfoLis...
ce2da8a4eb1372d420d04ca50b119ff4be2e2765
GabrielCarmoSilva/URI
/2410.py
144
3.59375
4
lista = [] N = int(input()) i = 0 while (i < N): lista.append(int(input())) i += 1 nova_lista = list(set(lista)) print(len(nova_lista))
72b8449af43e14a0f935559b6dd94959f3c8d736
LaurentStar/ultimate-tic-tac-toe
/ultimatetictactoe/game/players/ai/heuristics.py
5,420
3.703125
4
from copy import deepcopy from ...boards import Square, State def deepcopy_board(function): def with_copied_board(macroboard, *args): return function(deepcopy(macroboard), *args) return with_copied_board @deepcopy_board def winning_move(macroboard): """ Returns a valid winning move for the m...
a5794b4c755ddd724a430f1c3275b684f2913556
sen-sourav/common-framework
/Framework/TTHbbAnalysis/TTHbbLeptonic/python/dsidmap.py
2,062
3.65625
4
# Small class to load the map text file and create objects to hold this # We can then use that in our download scripts # Author: Ian Connelly # 07 Feb 2018 class Sample(object): def __init__(self): self.Name = "" self.Comment = "" self.DSIDList = set() def setSampleName(self, name...
c0f5e4d98c3fc58c2a8a8f1846002dfb3e75775a
kumikoda/cryptopals-python
/crypto/hamming.py
773
3.578125
4
def bit_distance(b1: bytes, b2: bytes) -> int: assert len(b1) == len(b2) distance = 0 for i in range(0, len(b1)): for j in range(0, len(b1)): bit1 = (b1[i] >> j) % 2 bit2 = (b2[i] >> j) % 2 if bit1 != bit2: distance += 1 return distance def n...
1b9d4345c31e40cff723d5bb00f423045ef4f6b3
tomzx/decision-trees
/memory.py
1,091
3.78125
4
from typing import Any, Dict class Memory: def __init__(self, memories: Dict[str, Any]): self.__dict__["memory"] = memories def recall(self, fact: str) -> Any: return self.memory.get(fact) def remember(self, fact: str, value: Any = True) -> None: self.memory[fact] = value de...
7f10ca9eaccd703b0e5f981aec0967fdcb36a3a3
XGWang0/Suse_testsuite
/tests/qa_test_stress/stress.py
484
3.59375
4
#!/usr/bin/python import os def count_cpus(): """number of CPUs in the local machine according to /proc/cpuinfo cpus = lines starting with 'processor' in /proc/cpuinfo""" f = file('/proc/cpuinfo', 'r') cpus = 0 for line in f.readlines(): if line.startswith('processor'): cpus += 1 return cpus if __name__...
84248dcd913dbf727afaf19fed4a8872b952992d
Torresplays/wordguesinggame
/word_game.py
3,755
4.125
4
""" File: word_guess.py ------------------- Fill in this comment. """ import random global e LEXICON_FILE = "Lexicon.txt" # File to read word list from INITIAL_GUESSES = 8 # Initial number of guesses player starts with def play_game(secret_word): """ Add yur code (remember to delete the "pas...