blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
8bd00712b24a79e31acbac79fb3e31a12985fbe7 | x19154992/PythonLab4 | /RegExMesser.py | 367 | 3.5 | 4 | import re
string = """Mary had a little lamb,
And everywhere that Mary,
went, the lamb as sure
to go"""
# print(re.compile(pat, re.M).sub("{\g<0>}", s.strip()))
pattern = r"lamb"
prog = re.compile(pattern)
prog.sub("a","c")
result = prog.match(string)
# result = re.match(pattern, string)
print(result)
print(type(p... |
a905311c816909f6899782a7adfd7f18aba5b5c8 | ngotiendat8795/Ngo.T.Dat-C4E28-Fundamentals | /Session 2/ex4_ss2.py | 564 | 3.5 | 4 | #1
# q = int(input("Nhap so sao muon ve: "))
# for i in range(q):
# print("* ", end='', flush=True)
# #2
# t = int(input("Nhap tong so * va x: "))
# if t%2 == 0:
# for i in range(t//2):
# print("X * ", end='', flush=True)
# else:
# k = (t-1)//2
# for i in range(k):
# print("X * ",... |
01ba24a685b896f3bf25e6964e2804516898a352 | ngotiendat8795/Ngo.T.Dat-C4E28-Fundamentals | /Session 3/list_intro.py | 1,507 | 3.703125 | 4 | #list/array
#CRUD creat read update delete
# menu = ["COM", "PHO", "BUN DAU", "MAM TOM"]
# print(" Nha tao co những món sau:", *menu,sep=", ")
# a = input("May muon an them cai gì: ")
# menu.append (a)
# print(*menu,sep='\n')
menu = ["COM", "PHO", "BUN DAU", "MAM TOM"]
# count = 0
# a = menu[-1]
# id = menu.index(a... |
2996b5291a3fd078208aca2bbf55679441830bd3 | ngotiendat8795/Ngo.T.Dat-C4E28-Fundamentals | /Session 1/turtle_ex4.py | 122 | 3.796875 | 4 | from turtle import *
speed(0)
shape('arrow')
color("green")
for i in range(200):
circle(100)
left(5)
mainloop()
|
15c0c3d19bd800f9960b55c769a1ba623efa5862 | mixer/interactive-python | /examples/engine.py | 4,193 | 3.875 | 4 | """This is the core of the pong example. You can read through it if you'd
like, but it's pretty boring. I try to shove as much boring game logic into
here so that the interactive demos can focus on what matters--interactive!
"""
import curses
import random
import math
import asyncio
class Sprite:
def __init__(se... |
087c88107f73f48b4c2ffdcde67d2be0d09acb08 | utsavlamgade1/Python_Task | /Assignment2.py | 3,279 | 3.9375 | 4 | # Task Two
# Question1
x = 52
if x%3==0 and x%5==0:
print ("Consultadd Python Training")
elif x%3==0:
print("Consultadd")
elif x%5==0:
print('c')
else:
print('Sorry You got the wrong number!!')
# Question2
choice = input("Pick any one of among 1, 2, 3, 4 or 5: ")
if choice in ('1','2','3','4','5... |
0e202b55217c67216e5965791f048c37fa12b3bb | deibylugo14/Ahorcado | /juego.py | 1,656 | 3.609375 | 4 | from tkinter import *
import tkinter as tk
import random as rm
from nivelD import *
class juego (niveles):
def __init__(self):
self.ventanaPrincipal()
def ventanaPrincipal(self):
self.raiz =tk.Tk()#ventana principal
#nombre tamaño y color
self.raiz.title("juego ahorcado")
... |
557e19101872bd90128b326189858af9c55d1c91 | stefanklut/musicprediction | /read_data.py | 3,630 | 3.703125 | 4 | '''
Filename: read_data.py
Reads the data from a csv file into a dataframe for further uses.
'''
import numpy as np
class response_data:
''' Implements data class that saves participant data. '''
def __init__(self, filename, good_file_ids, dl=';'):
'''
Inits the response_data class.
I... |
09030b98e6a5b7531d7b1ce795cdfd515b36d0f2 | karas639/darkweb_study | /utils.py | 959 | 3.546875 | 4 | import cv2
import numpy as np
#openCV 에서는 BGR 순으로 채널 지정
BLUE = 0
GREEN = 1
RED = 2
# 특정한 색상의 모든 단어가 포함된 이미지를 추출합니다.
def get_chars(image, color):
other_1 = (color + 1) % 3
other_2 = (color + 2) % 3
c = image[:, :, other_1] == 255
image[c] = [0, 0, 0]
c = image[:, :, other_2] == 255
... |
647f106fe1dbb20b0616a58288d85dec4c4b0684 | bomcon123456/30Days_Leetcode | /day9.py | 1,332 | 3.90625 | 4 | import itertools
class Solution:
def backspaceCompare(self, S: str, T: str) -> bool:
def get_char_backward(s):
deleted_char = 0
for c in reversed(s):
# If we delete a char, increment counter
if c == '#':
deleted_char += 1
... |
f308bb31891af410bec34cbfec86997556d66c8a | XXXXLM/python_fluent | /python_fluent/p2/2_2.py | 782 | 3.859375 | 4 | # -*- coding:utf-8 -*-
color = ['red','green']
size = ['s','m','l']
# 列表生成式
cloths_1 = [(c,s)for c in color for s in size]
print cloths_1
'''
Python 2.x 中,在列表推导中 for 关键词之后的赋值操作可能会影响列表推导上下文中的同名变量,
但是这种情况在 Python 3 中是不会出现的。
'''
# 生成器表达式
for cloths in ((c,s) for c in color for s in size):
print cloths
'''
用到生成器表达... |
a455d3530a27aeb23d33dca3247a2fb8f838c284 | XXXXLM/python_fluent | /python_fluent/p2/2_6.py | 1,085 | 3.5625 | 4 | # -*- coding:utf-8 -*-
'''
+= 调用的是__iadd__方法,如果一个类没有实现这个方法,
呢么就会调用__add__方法。
如果这个类实现了__iadd__方法,同时他是一个可变序列,调用这个方法,
他本身就会发生改变,如果没有__iadd__方法,会得到一个新的对象。
总的来说,可变序列一般都实现了__iadd__方法,因此+=就是就地加法,
不可变序列根本不支持这个操作,对这个方法的实现也就无从谈起。
+=所适用的感念也适用与*=,后者相应的是__imul__方法。
'''
l = [1,2,3]
print(id(l))
l *= 2
print(id(l))
... |
a3ca7614a3745cc69e84e908e6e78d04df5c8dbf | gadereshma5/FirstProject | /Return_val_FromFunction_10April18.py | 169 | 3.640625 | 4 | # Return value from function
def do_math(num1,num2):
return num1+num2
math1=do_math(2,5)
math2=do_math(5,6)
print("The first sum is",math1,"second sum is",math2) |
0294f304151da51745ca4d7eeb69f7f57fa84c8f | gadereshma5/FirstProject | /Default_Argument_10April18.py | 196 | 3.65625 | 4 | # Default argument
def fun(name="nick", age=27):
print("my name is", name, "age is", age)
fun()
def fun1(name="nick", age=27):
print("my name is", name, "age is", age)
fun1("Jack") |
4126831bcd81a46e8c46c458e7dcc14fc4041831 | gadereshma5/FirstProject | /Built_In_Functions.py | 637 | 4.0625 | 4 | # Built in functions are str,int,float,bool,len,sorted
print(str("6"))
print(int("5")) # convert string to integer
print(float("1.3")) # convert string to float
print(bool("True")) # convert string to boolean
print("Length of the string is "+str((len("Hello")))) # calculate Length of the string
print("length of... |
e550ba32364726b1c013041277aaf2ae9295b83a | batherk/monte-carlo-tree-search | /Functions.py | 498 | 3.75 | 4 | import re
def get_user_input(message, regex=None, legal_values=[], set_type=str):
"""Method for getting correct user input using regex"""
user_input = input(message)
if regex:
pattern = re.compile(regex)
while not pattern.match(user_input):
user_input = input(f'Regex: "{regex}":... |
4d5163d9a6a86f41fc330b548bf50ae6ba805cf6 | SaadShabir/Unit0-03 | /hello_world_button.py | 343 | 3.65625 | 4 | # Created by: Saad Shabir
# Created on: Aug 2017
# Created for: IC3U
# Daily Assignment - Unit 0-03
# This program displays Hello World through a click of a button
import ui
def hello_world_touch_up_inside(sender):
#print ('Hello, World!')
view['hello_world_label'].text = ("Hello, World!")
view = ui.load_vie... |
379fdee9978994c73483c4f9e72a27aded0d3fbc | pdecks/tree-LCA-edges | /amazon-exercise.py | 3,879 | 4.09375 | 4 | class BinaryTreeNode:
def __init__(self, value, parent):
self.value = value
self.left = None
self.right = None
self.parent = None
def insert_left(self, value):
self.left = BinaryTreeNode(value)
return self.left
def insert_right(self, value):
self.r... |
ee0ee9692a8e144b55dc98b18765a1fad05bc498 | githajime/git_develop | /search2.py | 252 | 3.875 | 4 | str1 = "月火水木金土"
str2 = input("検索文字列を入力:")
index = str1.find(str2)
if index != -1:
print(str2 + " が見つかりました")
print("Index:", index)
else:
print(str2 + " が見つかりませんでした")
|
9e0a810a881feab77fee09ed5f27c6500dbff16e | githajime/git_develop | /exception1.py | 223 | 3.5 | 4 | import sys
try:
score = int(input("Input your score:"))
except:
print("*Input number")
sys.exit()
else:
print("Your Score:", score)
if score >= 80:
print("Pass")
else:
print("Fail")
|
d1ec9438f4dd04ec232f50de0ff6eafc6c9a66c9 | githajime/git_develop | /if7.py | 155 | 3.90625 | 4 | num = int(input("数値を入力:"))
if (num % 3 == 0 or num % 5 == 0) and (num >=100):
print("100以上の3もしくは5の倍数です")
|
c69561a1e02bc85f3a747a0b7e6ebc48f64efc39 | SmischenkoB/campus_2018_python | /Viktor_Miroshnychenko/2/Array difference.py | 311 | 3.828125 | 4 | def list_difference1(filter_list, target):
for lvalue in filter_list:
if lvalue in target:
target.remove(lvalue)
return target
input_list = list(input("Enter target list \n"))
filter_list = list(input("Enter filter list \n"))
print(list_difference1(filter_list, input_list))
|
069fb2f6adf80062d539ee28d9709381ed5c2042 | SmischenkoB/campus_2018_python | /Lilia_Panchenko/1/Task6.py | 216 | 3.71875 | 4 | input_str = input('Please, input PIN to validate:\n')
is_pin_valid = True
len_str = len(input_str)
if not (len_str == 4 or len_str == 6) or not input_str.isnumeric():
is_pin_valid = False
print (is_pin_valid)
|
15e7c739bd58aef889c90dadc601196e2b0b417e | SmischenkoB/campus_2018_python | /Tihran_Katolikian/8/CannotSaveGameError.py | 699 | 3.6875 | 4 | class CannotSaveGameError(Exception):
def __init__(self, save_data_file_address, causing_exception):
'''
Constructor of file data was being attempted to save to.
:param save_data_file_address: an address of file when data saved.
:param causing_exception: an exception that caused the... |
ce51c27893b378bd6abb314ad4926e17637c6228 | SmischenkoB/campus_2018_python | /Dmytro_Shalimov/1/9.py | 2,110 | 4.3125 | 4 | <<<<<<< HEAD
print("Convert a 24-hour time to a 12-hour time.")
print("Time must be validated.")
user_input = input("Enter time: ")
formatted_time = str()
if len(user_input) != 5:
print("not valid time")
hours = user_input[:2]
minutes = user_input[3:]
if hours.isnumeric() and minutes.isnumeric():
hou... |
425c4137611ae13aee9d24a486040bc9e565edd8 | SmischenkoB/campus_2018_python | /Dmytro_Skorobohatskyi/batch_3/verify_brackets.py | 1,004 | 4.3125 | 4 | def verify_brackets(string):
""" Function verify closing of brackets, parentheses, braces.
Args:
string(str): a string containing brackets [], braces {},
parentheses (), or any combination thereof
Returns:
bool: Return True if all brackets are closed, otherwise... |
bb423915ec72d508a8f7ff84bbc904cd2d3285ad | SmischenkoB/campus_2018_python | /Serhii_Oliinyk/3/spell_number.py | 2,641 | 3.71875 | 4 | def spell_number(number):
"""Function convert number in word phrase.
Args:
number: type integer.
Returns:
Return string.
"""
dict_number = {
0: "zero",
1: "one",
2: "two",
3: "tree",
4: "for",
5: "five",
6: "six",
7: ... |
5a8071026e6bb38c39495b65a8673d83a78777f8 | SmischenkoB/campus_2018_python | /Masha_Mumrenko/1/pythontask8.py | 391 | 3.671875 | 4 | def validate_24_hour(hour_string):
validation_list = [24,60]
answer = True
string_parts = hour_string.split(':')
if len(string_parts) != 2:
answer = False
else:
for i in range(len(string_parts)):
if int(string_parts[i]) >= validation_list[i] or int(string_parts[i]) < 0:
... |
5cfb9aa9dd222d9f2b2f55ce0ee10a6153528040 | SmischenkoB/campus_2018_python | /Yurii_Smazhnyi/1/1.ExesAndOhx.py | 191 | 3.734375 | 4 | string = input("input your string: ")
x_сount = 0
o_сount = 0
for i in string:
if i == 'x':
x_сount += 1
elif i == 'o':
o_сount += 1
print(x_сount == o_сount)
|
9d0cb1ba82a9af6b200669d3460b249d6fa26504 | SmischenkoB/campus_2018_python | /Oleksandr_Kotov/3/rock_paper_scissors.py | 1,908 | 4.09375 | 4 | from random import choice
WEAPONS = ["scissors", "rock", "paper"]
def is_confusion(choices):
"""define if more than 2 types of
weapon is chosen and confuse happened"""
confusion = len(set(choices)) == 3 or len(set(choices)) == 1
return confusion
answer = 'y'
while answer == 'y':
num_of_pla... |
92cbac43042872e865e36942ce164e1d5fdb0d40 | SmischenkoB/campus_2018_python | /Kyrylo_Yeremenko/2/task7.py | 2,517 | 4.21875 | 4 | """
This script solves task 2.7 from Coding Campus 2018 Python course
(Run length encoding)
"""
def write_char_to_list(last_character, character_count):
"""
Convenience function to form character and count pairs for RLE encode
:param last_character: Character occurred on previous iteration
:... |
5bd8e8535a49baaf74310bbfd088695c4812e6fb | SmischenkoB/campus_2018_python | /Denys_Miroshnyk/3/Spell number.py | 4,170 | 3.96875 | 4 | input_number = input("enter a number to spell \n")
def speller(number):
"""this function spells the passed number
Arguments:
number {int} -- a number that needs to be spelled
Returns:
str -- spelled number
"""
spelled_number = ""
temp_number = list(number)
spe... |
8833b9d9d455b9a11585582cb1a07494cbe61dd3 | SmischenkoB/campus_2018_python | /Dmytro_Shalimov/3/3.6.py | 5,771 | 3.953125 | 4 | from random import choice
from collections import Counter
import sys
print("Rock, paper, scissors game")
WEAPON_ID = {'rock': 0, 'paper': 1, 'scissors': 2}
WEAPON_TYPE_BY_ID = {0: "rock", 1: "paper", 2: "scissors"}
# see get_winner function for details
WEAPON_EFFECT_BY_ID = [[0, 2, 1],
... |
ca083750d217b37cec619a44a1cec9d2f8f9e911 | SmischenkoB/campus_2018_python | /Dmytro_Skorobohatskyi/1/task6.py | 178 | 3.890625 | 4 | string = input('enter the string\n')
length = len(string)
is_lenght_right = length == 4 or length == 6
is_pin_valid = is_lenght_right and string.isdigit()
print(is_pin_valid)
|
c1ea2fc8c755e9ca87fb78c8938a01c82d1e302c | SmischenkoB/campus_2018_python | /Kyrylo_Yeremenko/3/task1.py | 2,019 | 4.1875 | 4 | """
This script solves task 3.1 from Coding Campus 2018 Python course
(Spell number)
"""
NUM_POWS_OF_TEN = {100: 'Hundred', 1000: 'Thousand', 1000000: 'Million'}
NUMS = \
{
0: "Zero",
1: "One",
2: "Two",
3: "Three",
4: "Four",
5: "Five",
6: "Six... |
651fa6304d193b702589c974183c6549e9d030ef | SmischenkoB/campus_2018_python | /Yurii_Smazhnyi/4/DungeonGame/map_generator.py | 1,033 | 3.6875 | 4 | import random
GROUND_SYMBOL = 'O'
TRAP_SYMBOL = 'X'
PLAYER_SYMBOL = 'T'
TREASURE_SYMBOL = '='
TRAP_MODIFIER = 10
TREASURE_MODIFIER = 20
def create_map(map_size):
"""
Create Map for Dungeon Game.
:param map_size: size of map.
:map_size type: int.
:returns: created map with traps and treasures.
... |
dd5d4fec5d79053c12dd4880f7abbe30f3b9bace | SmischenkoB/campus_2018_python | /Mykola_Horetskyi/1/Reverse String.py | 80 | 3.78125 | 4 | text = input('input text:\n')
reversed_text = text[::-1]
print(reversed_text)
|
ef12252832676f4dff5894ce32ec703369148221 | SmischenkoB/campus_2018_python | /Ruslan_Neshta/2/LengthEncoding.py | 1,551 | 4.0625 | 4 | def compress(string):
"""
Does length encoding on given string.
:param string: string to encode
:return: encoded list of strings
:rtype: list
"""
res = []
index = 0
while index < len(string):
current = string[index]
counter = 0
while index < len(string) an... |
c955386992b1cf118dd6b8c1ffb792c98a12012e | SmischenkoB/campus_2018_python | /Dmytro_Shalimov/1/8.py | 1,062 | 4.125 | 4 | <<<<<<< HEAD
print("Validate a 24 hours time string.")
user_input = input("Enter time: ")
if len(user_input) != 5:
print(False)
hours = user_input[:2]
minutes = user_input[3:]
if hours.isnumeric() and minutes.isnumeric():
hours_in_int = int(hours)
minutes_in_int = int(minutes)
if hours_in_... |
92295f2ad2b0ed8ff4d35474780dba9dc88e16e5 | SmischenkoB/campus_2018_python | /Kateryna_Liukina/3/3.5 Verify brackets.py | 766 | 4.25 | 4 | def verify_brackets(string):
"""
Function verify brackets
Args:
string(str): string to verify brackets
Returns:
bool: return true if all brackets are closed and are in right order
"""
brackets_opening = ('(', '[', '{')
brackets_closing = (')', ']', '}')
brackets_dict = di... |
2d9d5ecb3a53c62da62052da5f849c71384a0300 | SmischenkoB/campus_2018_python | /Mykola_Horetskyi/3/Crypto Square.py | 1,074 | 4.125 | 4 | import math
def encode(string):
"""
Encodes string with crypto square method
Args:
string (str) string to be encoded
Returns:
(str) encoded string
"""
encoded_string = "".join([character.lower() for character in string
if character.isalpha()])
... |
0fc832fbb9323145a330bae524ff5d09d069630b | SmischenkoB/campus_2018_python | /Yehor_Dzhurynskyi/2/task5.py | 591 | 3.5625 | 4 | def custom_filter(func, items):
"""
keeps the elements in collection which satisfied a condition supplied by `func`
:param func: function or None
if it's function, then keep elements which returns True on this param
else if it's None, then keep elements which could be interpreted... |
26de00b1491dcd0c7abb0a587115f59de63bcb07 | SmischenkoB/campus_2018_python | /Kostiantyn_Nifantiev/1/TimeValidator.py | 494 | 3.921875 | 4 | while True:
time_to_validate = input('Enter time to validate: ')
time_to_validate = time_to_validate.strip()
tokens = time_to_validate.split(':')
if len(tokens) == 2 and tokens[0].isnumeric() and tokens[1].isnumeric():
hours = int(tokens[0])
minutes = int(tokens[1])
... |
fbb6d6bd9456607b4734de4a6e30c0caf132bec8 | SmischenkoB/campus_2018_python | /Viktor_Miroshnychenko/1/MiddleLetters.py | 210 | 3.96875 | 4 | input_string = input("Enter string \n")
odd = bool(len(input_string) % 2)
mid = int(len(input_string) / 2)
if odd == True:
print(input_string[mid] )
else:
mid -= 1
print(input_string[mid:-mid] )
|
e63105840c53f6e3ea05835cb8a67afe38e741cc | SmischenkoB/campus_2018_python | /Lilia_Panchenko/1/Task7.py | 643 | 4.25 | 4 | import string
input_str = input('Your message: ')
for_question = 'Sure.'
for_yelling = 'Whoa, chill out!'
for_yelling_question = "Calm down, I know what I'm doing!"
for_saying_anything = 'Fine. Be that way!'
whatever = 'Whatever.'
is_question = False
if ('?' in input_str):
is_question = True
is_yelling = True
ha... |
8e61bf171d79e30b60e6bcd6755e3c0bc5578494 | SmischenkoB/campus_2018_python | /Oleksandr_Kotov/10/game_package_okotov/game_package_okotov/player.py | 711 | 3.6875 | 4 |
import decorators
import creature
class Player(creature.Creature):
"""defines game player
"""
def __init__(self, row, col, health):
"""initialzie player instance
Arguments:
row {int} -- row on game map
col {int} -- column on game map
health {int} -- p... |
3dc064cc783775e22eace280876c670234069ee1 | SmischenkoB/campus_2018_python | /Taras_Martyniuk/1/xo_count.py | 348 | 3.703125 | 4 |
def main():
print(quicker(input()))
def quicker (string):
x_count = o_count = 0
for ch in string:
if ch == 'x':
x_count += 1
elif ch == 'o':
o_count += 1
return x_count == o_count
def nicer (string):
return string.count('x') == string.count('o')
if __name... |
f851617f767b8b34095205f0f4a9fbddabcaef63 | SmischenkoB/campus_2018_python | /Ruslan_Neshta/1/TimeValidation.py | 458 | 4.0625 | 4 | def is_time_valid(string):
numbers = string.split(':')
is_valid = False
if len(numbers) == 2 and numbers[0].isdigit() and numbers[1].isdigit():
hours = int(numbers[0])
minutes = int(numbers[1])
if 0 <= hours <= 24 and 0 <= minutes <= 59:
is_valid = True
return is_v... |
c8e414ffc62e0ba9a25bf800a5b359af1853f068 | SmischenkoB/campus_2018_python | /Lilia_Panchenko/1/Task4.py | 353 | 4.0625 | 4 | input_str = input('Please, input some phrase to check if it is an isogram:\n')
len_input = len(input_str)
letters = ''
for i in range(len_input):
char = input_str[i]
is_alpha = char.isalpha()
is_in_letters = char in letters
if (not is_in_letters and is_alpha):
letters = letters + char
if is_in_letters:
... |
b0962f37a7f8a9a1e97606e1c4dc6e33ebe12553 | SmischenkoB/campus_2018_python | /Kateryna_Liukina/1/Rotational Cipher.py | 531 | 4.0625 | 4 | key_str = input("Enter a key\n")
if not key_str.isnumeric():
print("Wrong key")
quit()
key = int(key_str)
input_string = input('Enter a string\n')
numbers = [ord(ch) for ch in input_string]
for i in range(len(numbers)):
if ord('a') <= numbers[i] < ord('a') + 27:
numbers[i] = ord('a') + (numbers... |
52ec2c3441265cd275e5f82172befe26fa0e9639 | SmischenkoB/campus_2018_python | /Tihran_Katolikian/3/SpellNumber/main.py | 129 | 3.59375 | 4 | from SpellNumber import say_number
while True:
number = int(input('Input number to spell: '))
print(say_number(number))
|
166f06183b0ca2b310d3d969ef44d1bf187a203a | SmischenkoB/campus_2018_python | /Oleksandr_Mykhailovskyi/2/ArrayDiff2.py | 361 | 3.640625 | 4 |
def array_diff(sequenceA, sequenceB):
"""
Set difference.
Args:
sequenceA (iterable): set A.
sequenceB (iterable): set B.
Returns:
Set difference A / B as set.
"""
setA, setB = set(sequenceA), set(sequenceB)
return setA - setB
A = [1, 2, 3, 4, 1, 1, 4]
B = [2, 3,... |
3f2039d4698f8b153ef13deaee6ec80e266dae3c | SmischenkoB/campus_2018_python | /Yurii_Smazhnyi/2/FindTheOddInt.py | 402 | 4.21875 | 4 | def find_odd_int(sequence):
"""
Finds and returns first number that entries odd count of times
@param sequence: sequnce to search in
@returns: first number that entries odd count of times
"""
for i in sequence:
int_count = sequence.count(i)
if int_count % 2:
retu... |
5fbf80dd6b1bc1268272eb9e79c6c6e792dcc680 | SmischenkoB/campus_2018_python | /Tihran_Katolikian/2/CustomMap.py | 606 | 4.3125 | 4 | def custom_map(func, *iterables):
"""
Invokes func passing as arguments tuples made from *iterables argument.
:param func: a function which expects len(*iterables) number of arguments
:param *iterables: any number of iterables
:return: list filled with results returned by func argument. length of l... |
a44c77f696ab1687d02cdc5f2e7bef800a8fcad7 | SmischenkoB/campus_2018_python | /Taras_Martyniuk/3/poker_hands.py | 2,976 | 3.890625 | 4 | from itertools import groupby
from collections import Counter
"""
poker hand types
"""
HighCard, Pair, TwoPair, Three, Straight, Flush, FullHouse, Four, StraightFlush, RoyalFlush = range(10)
high_ranks = {
'J' : 11,
'Q' : 12,
'K' : 13,
'A' : 14
}
suits = {'D', 'S', 'C', 'H'}
HAND_SIZE = 5
def ... |
8ef1c43ecfb5b822471bbbd4502a6ffb84ab03d3 | SmischenkoB/campus_2018_python | /Denys_Miroshnyk/4/Game_loop.py | 2,073 | 4 | 4 | import Map_generator
player_position = (-1, -1)
player_moves = {1: 'up', 2: 'down', 3: 'right', 4: 'left'}
player_actions = {
1: lambda point: [point[0], point[1] + 1],
2: lambda point: [point[0], point[1] - 1],
3: lambda point: [point[0] + 1, point[1]],
4: lambda point: [point[0] - 1, point[1]]}
d... |
49a34fd0c622e4feda0f385d2115fc988a848b3b | SmischenkoB/campus_2018_python | /Kostiantyn_Nifantiev/4/Dungeon_GameV1/DungeonGame.py | 206 | 3.71875 | 4 | from game_functions import game_loop
while True:
game_loop()
decision = input('Do you want to play again? y/n:\n')
if decision == 'y':
continue
else:
break
|
8b4e88df052850d51cc6541535b0d4dddcdf2a0a | SmischenkoB/campus_2018_python | /Lilia_Panchenko/2/Allergies.py | 1,075 | 4.21875 | 4 | def two_pow(pow):
"""
two_pow(pow)
This function returns 2 in pow 'pow'
Args:
pow (int): pow to perform
Returns:
int: result of performing pow 'pow' on base 2
"""
return 2**pow
def allergies(score):
"""
allergies(score)
This function returns list of person's allergies
Args:
... |
03cd271429808ad9cf1ca520f8463a99e91c9321 | SmischenkoB/campus_2018_python | /Tihran_Katolikian/2/FindTheOddInt.py | 1,183 | 4.375 | 4 | def find_odd_in_one_way(list_of_numbers):
"""
Finds an integer that present in the list_of_number odd number of times
This function works as efficient as possible for this task
:param list_of_numbers: a list of integers in which must be at least one integer
which has odd number of copies there
... |
f2732235d40cac588ed3540afb2148bb97949807 | SmischenkoB/campus_2018_python | /Kyrylo_Yeremenko/1/task2.py | 183 | 3.703125 | 4 | """
This script solves task 2 from Coding Campus 2018 Python course
(Jaden Casing Strings)
"""
import string
userString = input("Input string: ")
print(string.capwords(userString))
|
a19c8d2bf61250e9789f95a202f86dafbe371166 | SmischenkoB/campus_2018_python | /Ruslan_Neshta/3/VerifyBrackets.py | 897 | 4.3125 | 4 | def verify(string):
"""
Verifies brackets, braces and parentheses
:param string: text
:return: is brackets/braces/parentheses matched
:rtype: bool
"""
stack = []
is_valid = True
for ch in string:
if ch == '(' or ch == '[' or ch == '{':
stack.append(ch)
... |
1c9d6a6fa5cf6afb82ba33f97e3be544985781fe | SmischenkoB/campus_2018_python | /Masha_Mumrenko/3/square_cypher.py | 566 | 3.703125 | 4 | import string
from math import ceil,sqrt,floor
def crypto_square(input_string):
new_string = ''.join(el for el in input_string if el.isalnum()).lower()
number_of_rows = int(ceil(sqrt(len(new_string))))
encoded_string = ''.join(new_string[row::number_of_rows] for row in range(number_of_rows))
re... |
e1874b8aa84ea7d09e17e0f10491e0a288de0773 | SmischenkoB/campus_2018_python | /Mykola_Horetskyi/1/Isogram.py | 264 | 4.09375 | 4 | text = input('input text:\n')
isIsogram = True
text = text.lower()
for character in text:
if character == ' ' or character == '-':
continue
if text.count(character) != 1:
isIsogram = False
break
print(isIsogram)
|
afcde2b727325a21965a6f2c16ec75ec24dc44bb | SmischenkoB/campus_2018_python | /Volodymyr_Kuksa/1/GetTheMiddleCharacter.py | 256 | 4.09375 | 4 | input_string = input("input the string to find out it's middle character(s): ")
center_index = (len(input_string) - 1) // 2
if len(input_string) % 2 != 0:
print(input_string[center_index])
else:
print(input_string[center_index:center_index + 2])
|
72b9064fbe4b62e843ac13b7a3e5300b8e5f5c58 | SmischenkoB/campus_2018_python | /Yurii_Smazhnyi/1/8.ValidationTime.py | 177 | 3.59375 | 4 | import re
string = input("input your string: ")
valid_time = re.compile('([01]?[0-9]|2[0-3]):[0-5][0-9]')
if valid_time.match(string):
print(True)
else:
print(False)
|
1a4a3d8881462bae39e713cfbeb531eb6e572485 | SmischenkoB/campus_2018_python | /Serhii_Oliinyk/2/amstrong_number.py | 556 | 4.0625 | 4 | def is_amstrong_number(value):
"""Function check if digit is Amstrong number.
Args:
value: type integer.
Returns:
Return true if number is Amstrong number anf false if not.
"""
string = str(value)
array = list(string)
sum = 0
for i in array:
number = int(i) **... |
6855d88767abbe577f76e8263f5b1ec6aa9a6dee | SmischenkoB/campus_2018_python | /Dmytro_Skorobohatskyi/2/armstrong_numbers.py | 917 | 4.125 | 4 | def amount_digits(number):
""" Function recognize amount of digit in number.
Args:
number(int): specified number
Returns:
int: amount of digits in number
"""
counter = 0
while number != 0:
counter += 1
number //= 10
return counter
def chec... |
05cbb9c991b61b3ad9fbe22fff411cb2ff6bba81 | SmischenkoB/campus_2018_python | /Mykola_Horetskyi/2/Run length encoding.py | 1,459 | 4.4375 | 4 | def rle_encode(original_string):
"""
Encodes string using run-length encoding
Args:
original_string (str) string to encode
Returns:
(str) encoded string
"""
encoded_string = ''
current_character = ''
character_count = 0
for character in original_string:
if char... |
9879e700bccb8329e9a1b5e5ddca71abfb0aa7ba | SmischenkoB/campus_2018_python | /Dmytro_Shalimov/2/1.py | 1,338 | 4.4375 | 4 | from collections import Counter
print("Given an array, find the int that appears an odd number of times.")
print("There will always be only one integer that appears an odd number of times.")
print("Do it in 3 different ways (create a separate function for each solution).")
def find_odd_number_1(sequence):
... |
9d3fbc554c6ecccafa6736a422667b651808716f | SmischenkoB/campus_2018_python | /Taras_Martyniuk/1/24to12.py | 462 | 4 | 4 | from validate_24h import is_valid_24h
def main():
time_24h = input('enter time in 24h format:\n')
if not is_valid_24h(time_24h):
print('not valid')
return
hours = int(time_24h[:2])
minutes = int(time_24h[3:])
is_am = hours <= 11
if not is_am: hours -= 12
am_pm_str = ... |
c4f36eeccb641d34218f23e888e1ff82d42249e3 | SmischenkoB/campus_2018_python | /Masha_Mumrenko/4-5/map_creator.py | 2,636 | 3.75 | 4 | from random import shuffle
from random import randint
game_entities = {'cell': '-', 'trap': '#', 'treasure':'X', 'player':'I', 'path':'+'}
treasure_inverse_rate = 20
trap_inverse_rate = 10
generated_map = []
def generate_characters_list(map_square):
"""
generates list of characters except player in random o... |
31a53e4953f7fb4705357bdb9cffbde81514c52e | SmischenkoB/campus_2018_python | /Dmytro_Skorobohatskyi/batch_10/dungeon_game_stereotype_pkg/dungeon_game_stereotype_pkg/level_map.py | 2,148 | 3.5 | 4 | from random import shuffle, randint
from .decorators import DebugDecorator
class LevelMap:
TRAP = '#'
TREASURE = '$'
LIMIT = '?'
FREE = '.'
PLAYER = 'P'
ENEMY = 'E'
def __init__(self, size_of_side):
amount_cells = size_of_side ** 2
amount_traps = amount_cells // 10
... |
4bbbf35b2d634a6704ed8a97e72c3470e85d78d0 | SmischenkoB/campus_2018_python | /Kostiantyn_Nifantiev/3/PockerHand/hand_shuffle.py | 519 | 3.796875 | 4 | from random import shuffle
suits = ['S', 'H', 'C', 'D']
card_values = ['A', 'K', 'Q', 'J', '10', '9', '8', '7', '6', '5', '4', '3', '2']
pocker_deque = []
for suit in suits:
pocker_deque += [''.join([value, suit]) for value in card_values]
def get_suffled_hands(how_many):
"""
This func... |
54336b1cbb8ee0608db2196d12f7f8ea8335ffc8 | SmischenkoB/campus_2018_python | /Oleksandr_Mykhailovskyi/1/PINValidation.py | 753 | 3.921875 | 4 | import string
pin = "0000"
# Checks if PIN 6/4 digits
def ValidatePINStructure(inputPIN):
if type(inputPIN) != str:
raise TypeError("Validate PIN accepts string")
else :
if len(inputPIN) != 6 and len(inputPIN) != 4:
print("PIN has to be 4 or 6 digits long")
return False... |
40e3c22ece7f9643706c6969a7e637b0b0b3230e | SmischenkoB/campus_2018_python | /Mykola_Horetskyi/7/utils.py | 2,378 | 3.859375 | 4 | from random import randint, choice
from decorator import debug_decorator
from game_logger import logger
from text import wrong_y_n_input
class Position:
@debug_decorator
def __init__(self, x, y):
"""
Constructor of Position class
"""
self.x = x
self.y = y... |
6ce5f8489ceaa2d469a3c7c5bbcb250e505eeddd | SmischenkoB/campus_2018_python | /Denys_Miroshnyk/1/Validation of 24 hours time.py | 520 | 3.75 | 4 | time = input("enter time in 24 format\n")
numbers = time.split(":")
number_set = set(("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"))
is_time = True
if len(numbers) != 2:
is_time = False
else:
for number in numbers:
for i in number:
if i not in number_set:
is_time = Fals... |
82719506ef19c361a15f701dd99e2fec74b6d939 | SmischenkoB/campus_2018_python | /Viktor_Miroshnychenko/3/spelling_numbers.py | 2,450 | 3.71875 | 4 | DIGIT_SPELLING = {0:"", 1:"one", 2:"two", 3:"three", 4:"four", 5:"five", 6:"six", 7:"seven", 8:"eight", 9:"nine"}
DECADES_SPELLING = {2:"twenty", 3:"thirty", 4:"forty", 5:"fifty", 6:"sixty", 7:"seventy", 8:"eighty", 9:"ninety"}
SECOND_DECADE = {10:"ten", 11:"eleven", 12:"twelve", 13:"thirteen", 14:"forteen", 15:"fiftee... |
acd345d1dd89c828cfa6dcf6f3b892862137b768 | SmischenkoB/campus_2018_python | /Yehor_Dzhurynskyi/11/character.py | 1,010 | 3.734375 | 4 | class Character:
"""
class which represents moveable entity
"""
def __init__(self):
self._health = 3
self._bag = 0
def input(self):
"""
getting input from stdin
"""
raise NotImplementedError
def on_location_changed(self, new_cell):
""... |
8edfea8932b2bd28fcd1aa3a1b8ac51341467462 | SmischenkoB/campus_2018_python | /Oleksandr_Mykhailovskyi/10/dungeon_game_mykhailovskyi/dungeon_game_mykhailovskyi/game_map.py | 6,102 | 3.53125 | 4 | from map_generator import generate_random_map
from .logging_utility import logger
from .logging_utility import logging_debug_decorator
from .logging_utility import logging_info_decorator
from .game_exceptions import LogicalError
class Position:
"""
Wrapper for 2D coordinates.
"""
def __init__(self, ... |
10899716cf8c7a3d3a572e1d86d2ec293800844a | SmischenkoB/campus_2018_python | /Oleksandr_Kotov/2/array_difference.py | 280 | 3.75 | 4 | def array_diff1(lhs, rhs):
"""return the difference of lists"""
for val in rhs:
[lhs.remove(val) for i in range(lhs.count(val))]
return lhs
def array_diff2(lhs, rhs):
"""return the difference of lists"""
return [val for val in lhs if val not in rhs]
|
3c2510888352bd0867e04bf557b473af4b4ecfa9 | SmischenkoB/campus_2018_python | /Kyrylo_Yeremenko/3/task5.py | 858 | 4.46875 | 4 | """
This script solves task 3.5 from Coding Campus 2018 Python course
(Verify brackets)
"""
brackets = \
{
'{': '}',
'[': ']',
'(': ')'
}
def verify_brackets(string):
"""
Verify that all brackets in string are paired and matched correctly
:param string: Inp... |
6557983112c09f41b0c1729848bd691cefac309f | SmischenkoB/campus_2018_python | /Lilia_Panchenko/11/player.py | 2,948 | 3.640625 | 4 | from logger import my_logger
from random import choice
import logging
from custom_exception import PlayerInputError
class Player:
"""
Player class. Responsible for spawn player on map, input player's choices, regulate player's hp and bag
"""
def __init__(self):
"""
Constructor for Pl... |
93b9e752cadcad8af303a7f8fdfbc690c74a94af | SmischenkoB/campus_2018_python | /Lilia_Panchenko/2/Custom_filter.py | 554 | 3.890625 | 4 | def m_filter (func, sequence):
"""
m_filter (func, sequence)
It's a custom filter fuction. Filter out all the elements of a sequence "sequence", for which the function 'function' returns True.
Args:
func (function): Function to use as filter.
sequence (list): List to perform function at.
... |
4222ba910ee8de47457a20b7107c45fb8fe85691 | SmischenkoB/campus_2018_python | /Dmytro_Skorobohatskyi/2/mapping_functions_list.py | 459 | 3.96875 | 4 | def map_functions(value, *functions):
""" Function apply functions to value and return list of result values.
Args:
value(float): value for applying of functions
functions(tuple): tuple of variadic function's amount.
Returns:
list: new list with values of function's applying to va... |
7d3693bb3830cb0adf487d378d01a2ce88b8c1ba | SmischenkoB/campus_2018_python | /Viktor_Miroshnychenko/2/Find the odd int.py | 400 | 3.96875 | 4 | input_list = input("Enter list of integers \n")
def find_odd_1(string):
for char in string:
if string.count(char) % 2 == 1:
return char
def find_odd_2(string):
list_of_odds = list(map(lambda char: string.count(char) % 2, string))
odd_char = string[list_of_odds.index(1)]
... |
b757eaad491e54b2741260843776ec194092a7e1 | SmischenkoB/campus_2018_python | /Tihran_Katolikian/2/Allergies.py | 527 | 4.0625 | 4 | def determine_allergies(score):
"""
Method helps to find a list of dangerous food for Tom according to an allergic score
:param score: an allergic score
:return: the list of dangerous products for Tom according to score
"""
allergic_map = {
'eggs': 1,
'peanuts' : 2,
'she... |
3ddfb02da9a1d28f5e2a9c0fa634b20e21f0e5ac | SmischenkoB/campus_2018_python | /Vadym_Bilestkyi/2/Task3.py | 156 | 3.65625 | 4 | def custom_map(func, iterable):
result = (func(element) for element in iterable)
return result
print(list(custom_map(lambda x: x**2, [1, 2, 3])))
|
457243172b6951a110c90271af29da9027b3857a | SmischenkoB/campus_2018_python | /Denys_Miroshnyk/3/Crypto Square.py | 1,382 | 3.90625 | 4 | from math import sqrt
def encode(sentence):
"""encodes passed sentence
Arguments:
sentence {str} -- sentence to encode
Returns:
str -- encoded sentence
"""
normalized_sentence = ''.join(
[ch for ch in sentence if ch.isalpha()]).casefold()
columns = int(sqrt(len(norma... |
c967a89546576e37862ed208446a05d39588f4da | SmischenkoB/campus_2018_python | /Vadym_Bilestkyi/1/Task8.py | 413 | 3.6875 | 4 | def is_valid_time(time):
time_parts = time.split(':')
if len(time_parts) != 2:
return False
hours, minutes = time_parts
validation_condition = (0 <= int(hours) < 24 and 0 <= int(minutes) < 60)
return validation_condition
if __name__ == '__main__':
print(is_valid_time('13:58'))
p... |
b2a74e49729af05e8e8bf6930fd7cfcede6d842b | kverma17/auth_system | /user_module.py | 1,024 | 3.78125 | 4 | import database as db
class User():
def __init__(self):
pass
def create_user(self):
print("enter user's name")
name = str(input())
print("enter user's role(for multiple roles give comma seperated roles).")
role = str(input()).upper().split(',')
db.data[name] = ... |
f828ad14c79d92b92b349277b29bbcc3f6432553 | ElliotW1999/Part-IV-Project | /_TiRakauDrive/RL/archive/RLv11/initDatabase.py | 1,253 | 3.9375 | 4 | import sqlite3
from sqlite3 import Error
import os
def create_connection(db_file):
""" create a database connection to a SQLite database """
conn = None
try:
conn = sqlite3.connect(db_file)
cursor = conn.cursor()
for p in range(0, 9):
for o in range(0, 5):
... |
3b9d41b56405cd2fc334be9f65d98e2c064dc8d5 | JulieDaniel/python_assignments | /hospital.py | 2,330 | 3.65625 | 4 | class patient(object):
nextid=0
def __init__(self, name, allergies, bed = 0):
patient.nextid = patient.nextid + 1
self.id = patient.nextid
self.name = name
self.allergies = allergies
self.bed_number = bed
def displayinfo(self):
print "Patient Name:", self.na... |
a1580ffae099ab814ecff195ce50dc2b00b2afa4 | JulieDaniel/python_assignments | /coin_tosses.py | 440 | 3.703125 | 4 | def cointoss():
headcount = 0
tailcount = 0
import random
for n in range(0, 5001, 1):
toss = random.randint(1, 2)
if toss==1:
headcount+=1
print "Attempt number:", n, "It's heads.", "So far there are", headcount, "heads."
else:
tail... |
09961a4ee12f660aaff4e9ced835801f21b47d47 | JulieDaniel/python_assignments | /dictionary_basics.py | 210 | 3.765625 | 4 | myself={
'name': 'Julie',
'age': '38',
'country of birth': 'United States',
'favorite language': 'Python'
}
for key, data in myself.items():
print ("My "+ key + " is "+ str(data))
|
8762ed93d84ec52c67b07aee1b19803314f53d2e | xiaohaiguicc/CS534-machine_learning | /Project3/source_code/1conv1pool.py | 6,095 | 3.53125 | 4 | import tensorflow as tf
import numpy as np
# Parameters
# Default: list all the default variables that need to tune
# Adjust: put the parameter that need to be adjusted
learning_rate = 1E-3
# Save dir:
save_dir = 'tensorboard/1conv1pool/lr=1E-3'
#This is to list all INFO
tf.logging.set_verbosity(tf.logging.INF... |
266af67cb93a3e8ece35d1684879d2f29e31d315 | KirillShakhov/vafel6_py | /main.py | 1,021 | 3.765625 | 4 | import math
import matplotlib.pyplot as plt
import numpy as np
print("Введите промежуток (x1, x2) через пробел")
x1, x2 = 0.0, 1.0
y1, y2 = 1.0, 2.0
n = 5
h = (x2 - x1) / n
D0, D1 = y1 + h, h
y = [[y1, D0], [0, D1]]
def p(x): return 1
def q(x): return 1
def f(x): return 3 * (np.e ** x)
def get_c1():
... |
debf04e0309f785153e865bfc80b463ca399eb45 | funaska/lesson2 | /for.py | 1,121 | 3.765625 | 4 | # Оценки
# Создать список с оценками учеников разных классов школы вида [{'school_class': '4a', 'scores': [3,4,4,5,2]}, ...]
# Посчитать и вывести средний балл по всей школе.
# Посчитать и вывести средний балл по каждому классу.
def avg_grade(grades_dict,is_whole=False):
all_grade = 0
all_length = 0
for cur_class i... |
910ac1e9f0b5aa6ec80e92e4a15919de3dbd6ee8 | Harumi-spec/fs-ranking-prediction | /project/utils/comparable_mixin.py | 1,293 | 3.671875 | 4 | """
Compara dos objetos a partir del valor que genere el método _cmpkey()
Uso:
# Hacer que la clase a comparar herede de ComparableMixin
class Foo(ComparableMixin):
...
# Implementar un método _cmpkey() que retorne el elemento a usar para comparar.
def _cmpkey():
return se... |
227a7ec09a872e24acda319bda4a321dfe7cb145 | tsujimon1216/fighter-saga | /monster.py | 3,147 | 3.953125 | 4 | # coding=utf-8
import random
class Monster:
def __init__(self, name="", hp=0, attack=0, defence=0):
self.name = name
self.hp = hp
self.attack = attack
self.defence = defence
self.max_hp = hp
self.origin_attack = attack
self.origin_defence = defence
def ... |
4a3bc5a3ded654941a4c4b08a0591898c76e850b | WarrenWeckesser/numpngw | /pngscan.py | 8,860 | 3.53125 | 4 | """
The function pngscan reads a PNG file and prints some of the information
in the file to stdout. It is used for testing and debugging.
"""
from __future__ import print_function, division
import struct
import zlib
color_types = {0: "grayscale",
2: "RGB",
3: "indexed color",
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.