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
03e31c06cd8e42fd8228b365914067dbd12a89a3
arnavakula/basic-python
/basics/string_type.py
365
3.875
4
#string writing, splicing, stripping s = " You ar e awesome" print(s, type(s)) s1 = """You are awesome """ print(s1) print(s[0]) print(s * 2) print(len(s)) print(s[0:5]) print(s[:8]) print(s[8:]) print(s[-10:-1]) print(s[::-1]) print(s.strip()) print(s.find("awe", 0, 8)) print(s.find("awe", 0, len(s))) print(s.coun...
08d9301029c0f319d56d0ab2c66eab72c35c6de6
arnavakula/basic-python
/lambdas/dec_challenge.py
198
3.53125
4
def decor(fun): def inner(name): result = fun(name) + ", how are you?" return result return inner @decor def hello(name): return ("Hello " + name) print(hello("Arnav"))
2d1b153d48feb7a25ddc7b4ce051ccadde63bfe7
arnavakula/basic-python
/basicprograms/grade_calculator.py
374
4.0625
4
m, p, c = [int(x) for x in input("Enter your math, physics, and chemistry score: ").split(', ')] low = min(m, p, c) avg = float((m + p + c)/3) if low < 35: print("You have failed at least one exam") else: if avg <= 59: print("You got a C average") elif avg <= 69: print("You got a B grade") ...
f8bf287a27a6bbd68667bc29415650967c042be4
alexandrhnatenko/Test_birthday
/app.py
2,891
3.609375
4
import json import sys HELP = """ Script has 3 arguments to calculating First: Number of days per year, type integer, must be greater than zero. Second: Number of peoples in the room, type integer, must be greater than one. Third: Range of days, type integer, must be greater than zero. """ ERROR_MESSAGE = "ERROR: {...
70a8d59cf77d8622b6b3376970fe1a0f2add2747
mattbruv/project-euler
/src/problem052.py
556
3.5625
4
def numToList(n): ns = [int(x) for x in str(n)] ns.sort() return ns def sameDigits(x, curX, maxX, compareList): testList = numToList(x * curX) if testList == compareList: if curX == maxX: return True return sameDigits(x, curX + 1, maxX, compareList) else: ret...
6eb10956d11db56a0a73933a018c6193d2461c4c
mattbruv/project-euler
/src/problem054.py
2,961
3.5
4
JACK = 11 QUEEN = 12 KING = 13 ACE = 14 CARD_DICT = {'T': 10, 'J': JACK, 'Q': QUEEN, 'K': KING, 'A': ACE } def parseCardNumber(number): try: return int(number) except: return CARD_DICT[number.upper()] def parseCard(card): return (parseCardNumber(card[0]), card[1].upper()) def parseHand(h...
fe1e1462b6384f0c1b76a23945aab1a6ceac45cd
mattbruv/project-euler
/src/problem034.py
228
3.671875
4
import math def factSum(n): return sum([math.factorial(int(n)) for n in str(n)]) def problem34(): total = 0 for i in range(3, int(1e6)): if factSum(i) == i: total += i print(total) # 40730
e10c80db050dea4ac14ad5e7c513c16bc105ae90
GokulAB17/-Basic-Python-Codes-
/python regular expressions (3) (1).py
5,080
4.28125
4
# Regular expressions are essentially a tiny,highly specialized programming language # which embedded inside pythopn and model available through(re). # used for searching text string which is in proper formate. # Regular expressions is a special sequence of characters that help you match # or find other st...
4e0b8e90cad657eaa1b2ddc18d4aa4f4cbfe9c63
Avanii0809/C-97
/guessingGame.py
249
3.78125
4
import random num = random.randint(1, 9) print(num) for i in range(0, 5): xyz = int(input("Enter your guess: ")) if num == xyz: print("Congrats! You got that right.") break else: print("Oops, try again.")
68412a070237c225261a457a5b58926c9ad192b9
phamtony/arcade-ping-pong
/scoreboard.py
802
3.640625
4
from turtle import Turtle ALIGNMENT = "center" FONT = ("Arial", 40, "normal") PLAYER_ONE_CORD = (-100, 200) PLAYER_TWO_CORD = (100, 200) class Scoreboard(Turtle): def __init__(self): super().__init__() self.hideturtle() self.penup() self.color("white") self.l_score = 0 ...
090c06ea28c07c3adee6b2b8a3d7a1fcdec0ef82
rameshrameshrum/python-repository
/sum of n no.py
112
3.65625
4
n=int(input("enter the no:\n")) ''' x=n*(n+1)/2 print x ''' sum=0 for i in range (n+1): sum=sum+i print sum
340051a4d5cdf2517736da58cfe7d785984cc448
rameshrameshrum/python-repository
/print odd no bt 2 no.py
95
3.671875
4
f=int(input("f=")) l=int(input("l=")) for i in range (f,l): k=i%2 if(k==1): print i
803f6284cdf48b1ed75ff948d6f3a4d4cb326714
AkhtarZainab/Python_Programming
/pi_value.py
625
3.765625
4
import math def fact(k): if k == 0: return 1 if k == 1: return 1 k = k * fact(k-1) print(k) return k def estimate_pi(): k=0 sum_factor=0 while True: # for i in range(5): a = (fact(4*k)) * (1103+(26390*k)) / ((fact(k)**4) * (396**(4*k))) ...
83933bd8086ea8e720d49fa65d55d52378bedb0b
NicolasMatton/structure-study-of-trees-and-heap
/AVL.py
6,798
3.5625
4
#-*- coding: utf-8 -*- """ Created on Sat Dec 15 14:42:43 2018 @author: utilisateur """ """Un Noeud possède une clefs, et deux fils qui sont des Noeuds""" class Arbre: def __init__(self): self.val = None self.filsG = None self.filsD = None self.pere = None ...
f7a7262ef01aa126a6952db66142efcce12d140e
anshnagrath/grade8.py
/bonus.py
594
3.78125
4
def cal_bonus(): try: salary = input("Please provide your salary amount :") years = input("Please enter the year of service :") if years>5: bonusAmount = 5/float(100) *salary netamount = salary + bonusAmount print("Your bonus Ammount {}".format(bonusAmount...
a029e3145d63c3a302832fdb8387d0fea9c1b2cc
ethanttlee/Rotten-Tomatoes
/text_gen_streamlit.py
1,823
3.921875
4
import streamlit as st from aitextgen import aitextgen temperatures = [0.2,0.5,1.0,1.2] st.title("Text Generator") description='Utilizing both GPT-2 as well as aitextgen, the text generation model is trained on the critic reviews from the top four most popular genres. The model then takes in a prompt inputted by ...
af10a0225c7d05e41d41968ba47d47f830d5087b
mahralkh/python-fundamental-stmiksz
/convert_bilangan.py
1,580
3.71875
4
def genConverter(angka, pembilang): result = [] hasilAngka = "" loop = True while loop: if angka >= pembilang: result.append(angka) sisa = angka % pembilang angka = angka // pembilang if sisa > 9: huruf = libChar(sisa) ...
991733cbd4e77adeb5744915dfe9611d30cf2a56
tyMarking/NEAT
/evaluate.py
1,433
3.515625
4
# -*- coding: utf-8 -*- """ Created on Mon Mar 26 10:31:40 2018 @author: Ty Marking """ """ use dynamic programming, start from end and recursion down? or start from begining and keep lookping through each layer? what about loops? """ import math def sigmoid(x): return 1 / (1 + math.exp(-x)) #for dynamic progra...
c0c11b9715ea7856fc4773f1001de99b9ee91fd9
jjlogu/blackboard
/interview/ibm/student_cholate_prob.py
682
3.515625
4
# find repeated letters in a given strings # str= input() # res = { # a:1, # } # 5 students sitting in a circular fashion # -> s1 -> s2 -> s3 -> s4 -> s5 # input: number students # student to begin with: int # number of choclate # return last person to hold choclate num_students = int(input()) begin = int(...
6ba3a552604c3bc210d7643ef593ba625afc6c75
jjlogu/blackboard
/hackerrank/dict_hashmap/substrin.py
866
3.65625
4
#!/bin/python3 import math import os import random import re import sys # Complete the twoStrings function below. def twoStrings1(s1, s2): arr ={} for i in range(len(s1)): arr[s1[i]] = 1 for i in range(len(s2)): if arr.get(s2[i]): return("YES") return("NO") # Complete the ...
404b0425fb71b9a4acf85be7f9650fab69b75663
jjlogu/blackboard
/hackerrank/arrays/n_rotation.py
781
3.671875
4
#!/bin/python3 # problem statement: https://www.hackerrank.com/rest/contests/master/challenges/ctci-array-left-rotation/download_pdf?language=English import math import os import random import re import sys # Complete the rotLeft function below. def rotLeft(a, d): """ if len(a) == d: return a for ...
1c7ec94f523960baac57264a0bf9697c2201427f
kmconnors/python-challenge
/PyBank/main.py
1,324
3.546875
4
import os import csv csvpath = os.path.join("..", 'PyBank', 'budget_data.csv') with open(csvpath, newline='') as csvfile: csvreader = csv.reader(csvfile, delimiter=',') row_count = (sum(1 for row in csvreader) - 1) print(row_count) import os import csv csvpath = os.path.join("..", 'PyBank', 'budget_data.cs...
b222f10f4728d84ca2d8c0c0c9db5eab00ea1f92
penroselearning/pystart_code_samples
/20 Date and Time - strptime.py
249
3.953125
4
from datetime import datetime random_date = '22-Oct-1983' print(f'Provided Date in String Format: {random_date}') # Print the String in Date Format new_date=datetime.strptime(random_date,'%d-%b-%Y') print(f'Converted into Date Format: {new_date}')
e1b2d3b0e6ef46e6555a5dc701d8d42894849bfa
penroselearning/pystart_code_samples
/19 Date and Time - Leap Year.py
131
3.75
4
import calendar year=2040 if calendar.isleap(year): print(f'{year} is a leap year') else: print(f'{year} is not a leap year')
b9435e4e72c911c2cbab2c94c347651e9fbabec2
penroselearning/pystart_code_samples
/17 Tuples - Random Coordinates.py
1,005
4.09375
4
# Using a Tuple to Store Random X and Y Coordinates to Draw 200 Circles on the Canvas import turtle import random window = turtle.Screen() window.bgcolor("black") # Stores the Height and Width of the Window in different variables width = window.window_width() height = window.window_height() pen = turtle.Turtle() pe...
7d946c451a2c515b92c6658d33d4d5902899caf6
penroselearning/pystart_code_samples
/05 String Formatting - C Style Formatting.py
99
3.796875
4
name = "Jane" age = 17 print("%s is %d years old." % (name, age)) x = 1 # int y = 2.8 # float
fddfb938c79e24c33f05236862143bd0f8ed96d2
penroselearning/pystart_code_samples
/12 Break and Continue - Fantasy Boxing League.py
406
3.578125
4
import random fantasy_boxers = ['Floyd Mayweather', 'Muhammad Ali', 'Manny Pacquiao', 'Mike Tyson', 'George Freeman', 'Amir Khan', 'Vijender Singh'] matches = 6 print(f'Fantasy Boxing Matches') print('-' * 30) while matches > 0: boxer1 = random.choice(fantasy_boxers) boxer2 = random.choice...
603eca56497eacb11201e688b496dc85e92f3c81
penroselearning/pystart_code_samples
/Student Submission Isha Reddy.py
1,061
4.125
4
print('Student Grade Calculator') student_scores = [] try: student_scores = [input("Enter Student Name: "), (int(input("Enter English Score (Max 100): \n")), int(input("Enter Math Score (Max 100): \n")), int(input("Enter Chemistry Score (Max 100): \n")), ...
156cbc3db9c6c23edd71f39adf382afe76081a53
penroselearning/pystart_code_samples
/07 If Statements - Positive Negative or Zero.py
179
4.15625
4
n1 = int(input("Enter a Number of your Choice: ")) if n1 > 0: print("The Number is Positive") elif n1 < 0: print("The Number is Negative") else: print("The Number is Zero")
765d21e3ef208f0a197c71a5b1543f71fd7aa4dc
penroselearning/pystart_code_samples
/16 Try and Except - Division.py
415
4.125
4
print('Division') print('-'*30) while True: try: dividend = int(input("Enter a Dividend:\n")) divisor = int(input("Enter a Divisor:\n")) except ValueError: print("Sorry! You have not entered a Number") else: try: result = dividend/divisor except ZeroDivisionError: print("Division ...
0eec4387f90fb8d72b831e464724eda81ad56251
penroselearning/pystart_code_samples
/04 Strings - Joining Strings.py
73
3.703125
4
## Joining Strings with a Character name='David' print('-'.join(name))
4c95d508fe4cbcdd35f32a1c7fd10ff63315a2d0
penroselearning/pystart_code_samples
/10 For Loop - Remove Vowels from a Word.py
297
4.3125
4
longest_word='pneumonoultramicroscopicsilicovolcanoconiosis' new_word_without_vowels='' vowels=['a','e','i','o','u'] for letter in longest_word: if letter not in vowels : new_word_without_vowels += letter print(f'The worlds longest word without vowels - {new_word_without_vowels.upper()}')
6d4a9045fcefcbb1985354888f52f7bedea9f3b5
sandromelobrazil/YELLOW_aula1
/AULA8/exercicios/geralista.py
142
3.5625
4
#!/usr/bin/python for _ip in range(1,255): print('192.168.0.' + str(_ip)) for _ip in range(1,255): print('192.168.100.' + str(_ip))
d58080ec7fbc9725bfeca7469ec336d85b8b167c
Amanda-Bishop/dice-game
/inputbox.py
2,809
3.640625
4
# A simple module to get user input allowing for backspace but not arrow keys or delete key # Shown in a box in the middle of the screen,Only near the center of the screen is blitted to # Called by: # import inputbox # answer = inputbox.ask(screen, "Your name") # colors and valid keys can be changed by changing the co...
687b06c2106c6e512b1bdc138872d670b4a5463b
jakeherp/cs50
/pset6/mario/more/mario.py
647
4.0625
4
from cs50 import get_int def mario(): # prompt user to input desired height height = get_int('Height: ') # if height is smaller than 1 or larger than 8 reprompt if height < 1 or height > 8: mario() else: for blocks in range(1, height + 1): spaces = height - blocks ...
96123c9dd37ce68d6803dfad8371c28c7edf3c4a
AdamK-PXU/advent-2018
/2018-12-01/p2/puzzle.py
696
3.625
4
import string filename = "input.txt" class Counter(dict): def __missing__(self, key): return 0 def duplicateFrequency(frequencyChanges): frequency = 0 frequencyChangeIndex = 0 counter = Counter() while counter[frequency] < 2: frequency += frequencyChanges[frequencyChangeIndex] ...
97e07a7ebe6d47fa6ea96711bb64d12f6c0e8a9a
richmr/CTF
/crypto/vignere.py
1,457
3.625
4
def vignere_decode(ciphertext, key): plaintext = "" posn = 0 ciphertext = ciphertext.upper() key = key.upper() base = ord('A') for letter in ciphertext: Ci = ord(letter) - base Ki = ord(key[posn % len(key)]) - base Mi = (Ci - Ki) + base plaintext += chr(Mi) ...
2b9b267d4f023451b2e41a16c502e483de54ca7e
monuelo/skin-cancer-classifier
/helpers/data_conversion.py
351
3.921875
4
import pandas as pd def create_csv(file, extension): """Create a CSV file from a xls Args: file: The file path that will be converted without the extension extension: The file extension """ data_xls = pd.read_excel(f"{file}.{extension}", index_col=None) data_xls.to_csv(f...
6716efaf012f7ed75775f9dca8dad3593c5a4773
venkatakaturi94/DataStructuresWeek1
/Task4.py
1,271
4.21875
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. """ import csv list_tele_marketers=[] with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) list_from =[] list_to =[] for to in texts: list_from.append(to[0]) list_to.append(to...
262410cb93feac66e6f14e66d10270ca09ee2eba
ParulProgrammingHub/assignment-1-Bunnyyash
/Q8.py
216
3.96875
4
b=input("enter the base of the triangle :") h=input("enter the height of the triangle :") area=0.5*(b*h) print "Area of the triangle for %d base and %d height is %d" %(b,h,area) n=raw_input("press any to exit")
a0a7615387d99b5fd2d320817eb5e3400ffcb1df
DerrickStuckey/census-predictor
/code/analysis/create_threezip_aggregates.py
1,486
3.65625
4
# -*- coding: utf-8 -*- """ Practicum Find 3-digit zipcode counts of relevant count variables @author: Kit """ import csv from itertools import groupby ########################################################### # INPUT: select relevant columns from dataset columns = [31,33,35,37,44,46] columns.extend(range(48,63)) ...
4c4be2d605ec6deb84c9e3e812e9140d6164f1a8
JakobLyon/canasta
/player.py
4,454
3.75
4
import cfg import cards import sys #human player module class Player(): def __init__(self, team): self.hand = [] self.team = team self.score = 0 def draw(self): self.hand.append(cfg.gamedeck.draw()) def firstCheck(self,play): return None def checkPlay(self, play): return True def checkforr...
c4c760f5840cd67678114569f3fe0cc890f501ac
codeguru132/pythoning-python
/basics_lists.py
526
4.34375
4
hat_list = [1, 2, 3, 4, 5] # This is an existing list of numbers hidden in the hat. # Step 1: write a line of code that prompts the user # to replace the middle number with an integer number entered by the user.li hat_list[2] = int(input("ENter a number here: ...")) # Step 2: write a line of code that removes...
1f2c6eb5610ff3cec20b91f6c73aadf146b6c5ca
codeguru132/pythoning-python
/for_And_else.py
207
4.09375
4
for i in range(5): print(i) else: # i retains its last value print("else:", i) # here the for is not even executed j = 111 for j in range(2,1): print(j) else: print("else:", j)
b1348b814ee55483f4fc6d1daffe3e2c684e85d8
jdiego/pycpfcnpj
/pycpfcnpj/cpf.py
1,024
4
4
from . import calculation as calc from . import compatible as compat def validate(cpf_number): """This function validates a CPF number. This function uses calculation package to calculate both digits and then validates the number. :param cpf_number: a CPF number to be validated. Only numbers. :...
85bce9d83471bc5e254ddfb29f89b032d3561210
akulahemasanthoshidaughterofmurty/MountBlue-Job-Challenge
/#!/bin/Migratory Birds.py
794
3.625
4
#!/bin/python3 import math import os import random import re import sys # # Complete the 'migratoryBirds' function below. # # The function is expected to return an INTEGER. # The function accepts INTEGER_ARRAY arr as parameter. # def migratoryBirds(arr): # Write your code here d={} for i in arr: ...
90238138775dc9a02b59188c1199fd7d0e3a709a
anniecee/cs50
/pset7/houses/import.py
1,577
3.96875
4
import sys import csv import cs50 # Error message for incorrect number of command lines if len(sys.argv) != 2: print("Error! Usage: python import.py characters.csv") exit(1) #Set up database connection db = cs50.SQL("sqlite:///students.db") #Open csv file to read with open(sys.argv[1], "r") as input_file: ...
857232ba914c700e3a3c62ba8d8c441f1f683eef
FabianNet/pySalamander
/Giraffe/app.py
224
3.78125
4
from math import * print("Hello janni") character_name = "abc" print(" /") print(" /") print(" \\") print(" \\") print(character_name[1].upper().isupper()) def hiii(name): print("huhu " + name) hiii("ssss")
3565e9290a2b2fc1425358e94bab917e549548d9
ryanbie/Python-Automation
/Chapter 3/globalStatement.py
329
3.9375
4
def spam(): global eggs #global tells Python don't create a local variable with this name. eggs = 'spam' eggs = 'global' spam() print(eggs) #output is spam beecause eggs is declared global at the top of spam, so when eggs is set to 'spam', this assignment is done to the globally scoped eggs. (replacing global...
838102f69eb37b2e27d16c7bb002048369523e65
ryanbie/Python-Automation
/Chapter 3/localandglobalvariables.py
1,029
4.09375
4
def spam(): eggs = 99 bacon() print(eggs) def bacon(): ham = 101 eggs = 0 spam() #eggs will still print 99 because eggs is a local variable in the local scope #parameters and variables that are assigned in a called function are said to exist in that function's local scope. #variables that are ass...
3520177d9f769ce8fd9997dc8e283f93e5cfd099
arcarchit/mit-ds-algo
/dsalgo/cs/tree/airplane_scheduling.py
3,309
3.609375
4
# Airplane scheduling problem # Mainly 2 API # 1) schedule new arrival # 2) Get no of arrivals before time t class TreeNode: def __init__(self, name, time): self.left, self.right = None, None self.name, self.time = name, time self.smaller, self.larger = 0, 0 class AirplanScheduler: # This will be tree and wi...
19889ba9f9642dc99a3ebad82a9774b68d501ae0
arcarchit/mit-ds-algo
/dsalgo/cs/dp/edit_distance.py
1,721
3.859375
4
def edit_distance(strA, strB): # insert A, insert B, delete A, delete B, update A, update B, same # In case of longest common sub-sequence problem would be different. It always helps to right recurrence relation # It is not important to get answers, more important is understand complexity , starting from br...
fa51134b87683e210866a1dd7f16067607c35ce2
arcarchit/mit-ds-algo
/dsalgo/cs/interviewbit_mock/majority_element.py
2,154
4.09375
4
def say_hello(): print 'Hello, World' for i in xrange(5): say_hello() def majority_element(arr): """ Test Case : [1 1 2 3 1 1] i=0 k=5, i=0 k=4, i=0, k=3 [1 3 2 1 1 1] i=2, k=5 [1 3 2 1 1 1] i=4 k=5 , i=4 k=4 Edge Case : [1 1 2] i=0,j=2,k=2 [1 2 1] i=2,k=2 Complexity Input : array O...
7c3d9408890a34b8a87ca19a40427d85da455270
arcarchit/mit-ds-algo
/dsalgo/cs/interviewbit_mock/buy_sell_stock.py
2,630
3.609375
4
# https://www.interviewbit.com/mock-interview/36d122ce/problem/?origin=past&problem_id=11 # https://www.interviewbit.com/problems/best-time-to-buy-and-sell-stocks-ii/ def buy_sell_once(arr): """ Time Complexity : O(N) Space Complexity : O(1) """ MIN_INT = -1e10 MAX_INT = 1e10 profit = MIN...
3833f1a85d4a46fb3574997f2bbef11ac9ccf85a
arcarchit/mit-ds-algo
/dsalgo/cs/tree/avl_practice.py
3,191
3.625
4
class TreeNode: def __init__(self, val): self.left, self.right = None, None self.val = val self.height = 1 # Root has height of 1 self.parent = None def __str__(self, depth): ret = "" if self.right: ret += self.right.__str__(depth + 1) ret += "\n" + (" "* depth) + str(self.val) if self.left: ...
21ec38ab4ac4988d00f266fcabf45268a32adb1e
arcarchit/mit-ds-algo
/dsalgo/cs/tree/binary_search_tree.py
5,247
3.859375
4
class Tree: def __init__(self, val): self.left, self.right, self.val = None, None, val class BST: def __init__(self): self.tree = None def insert(self, a): if not self.tree: self.tree = Tree(a) return parent = self.tree while True: ...
32e14721978cac96a0e1c7fe96d1e7088f928658
rciorba/plp-cosmin
/old/p1.py
1,246
4.21875
4
#!/usr/bin/python # Problem 1: # Write a program which will find all such numbers which are divisible by 7 but # are not a multiple of 5, between 2000 and 3200 (both included). # The numbers obtained should be printed in a comma-separated sequence on a # single line. # to nitpick: min and max are builtin functions...
ddf62a91fe35a8fb1381398bd7cbb26887fcbb7d
EstephaniaCalvoC/CityWeatherAPI
/app/weather/serializer.py
1,117
3.578125
4
"""Define a serializer class to encode the weather object to JSON""" import json from app.utils.utils import get_hour_from_uts, get_wind_descr, get_wind_direction def get_weather_dict_to_serilize(weather): """Return a dictionary to serilize a Weather object""" wind_desc = get_wind_descr(weather.wind_speed) ...
ec0c358abec2cdce08062ddc45075e1aa20f8e4d
sswang923/interview-questions
/solution.py
228
3.921875
4
def compare(x,y): if str(x) + str(y) > str(y) + str(x): return -1 else: if str(x) + str(y) == str(y) + str(x): return 0 else: return 1 print sorted([1, 2, 3], cmp=compare)
6554c79d7e74e841fb897ca17d92b82031c1cbe1
jonsnowduhhh/10Days
/characters.py
2,193
3.5625
4
from locations import * class Character: def __init__(self, name, str, dex, con, int, wis, cha, location, backpack): self.name = name self.str = str self.dex = dex self.con = con self.int = int self.wis = wis self.cha = cha self.location = ...
a57e1fe462002e2797275191cba5b2ebd0d2cfc5
ak45440/Python
/Replace_String.py
667
4.1875
4
# Write a Python program to find the first appearance of the substring 'not' and 'poor' from a given string, # if 'not' follows the 'poor', replace the whole 'not'...'poor' substring with 'good'. Return the resulting string. # Sample String : 'The lyrics is not that poor!' # 'The lyrics is poor!' # Expected Result :...
abefbf336a312d7cc1b83ad3b3dff2f49e493533
zezOtik/Home_tusk
/Мусорка тестов/test5.py
764
3.765625
4
# -*- coding: utf-8 -*- from Main_algoritm import randomstep from Main_algoritm import if_I def main(): size_n = 4 size_m = 5 i1 = 7 i2 = 1 hashtable = dict([(2,1),(6,3),(8,1)]) (i1,j) = randomstep(hashtable,i1,size_n,size_m) if i1 == 12 and j == 4: print('Test5 is co...
55ce803bd9272354d37b9adb0398bfa6abcf0bd5
ChennakeshavaNT/Python-Programming
/Turtle_Graphics/ChessBoard/chessboard.py
1,676
4.21875
4
#this code prints a chessboard using turtle graphics #Input: No Input #output: Chessboard representaion import turtle ck = turtle.Turtle() #Creation of a turtle named ck ck.clear() ck.forward(80) ck.left(180) ck.forward(80) ck.right(180) #iterative Approach is used for a in range(4): ck.pendown() for i in rang...
e1c33d6939639083426e0b9d8622d8f93bb5a5e8
valentine909/codewars
/test/codewars/3_kyu_Make_a_spiral.py
1,447
3.625
4
""" https://www.codewars.com/kata/make-a-spiral/train/python """ def is_out(position, size): return any(x > (size - 1) or x < 0 for x in position) def is_one(position, matrix): return not is_out(position, len(matrix)) and matrix[position[0]][position[1]] == 1 def sum_coordinates(position, direction): ...
734843fee7d18fe4a3830bb60c8aced6cb18a52e
valentine909/codewars
/test/codewars/4_kyu_most_frequent_words.py
1,125
3.78125
4
""" https://www.codewars.com/kata/51e056fe544cf36c410000fb/train/python """ from collections import Counter import re def top_3_words(text): return [x[0] for x in Counter(re.findall(r"'*[a-z][a-z']*", text.lower())).most_common(3)] assert top_3_words("""In a village of La'Mancha, the name of which I have no des...
fdd0879eb287d55ca61a31bfb08a89434aa9f123
valentine909/codewars
/test/codewars/3_kyu_battleship_field_validator.py
2,739
3.859375
4
""" https://www.codewars.com/kata/52bb6539a4cf1b12d90005b7/train/python """ def validate_battlefield(field): ships = [] for i, row in enumerate(field): for j, cell in enumerate(row): if cell == 1: # Ship first met if _connected_diagonals(i, j, field): r...
ab407193dc72bc7ee95a918fe81786fcedc2449c
AIHackerTest/tinshelly_Py101-004
/Chap0/project/random_number_basic.py
607
4.03125
4
import random correct_number = random.randint (0,20) i = 0 while i < 10: print ("Pls input an integral number between 0 and 20: ", end = ' ') input_number = int(input()) if input_number == correct_number: print ("Congratulations! You are correct!") exit (0) elif input_numb...
f647476c36493730c112fa107e290b163e458a71
greusor2003/2DConvex-Hull
/convex_hull.py
6,701
4
4
# -*- coding: utf-8 -*- """ Algorithm for finding the convex hull of a list of points. The set of points is implemented as a (2,) ndarray (numpy type), each column representing the (x,y) coordinates of a point. Step 0: The functions scatter_points() and no_dupli() generate L, the list of distinct point...
b98764d6b4ec74e94a69e6a491e0fd064d673615
abhilshmohan93/Luminar-Python
/languagefundamentals/swapping.py
561
3.953125
4
print("case 1") print("case 1 before swapping") no1=10 no2=20 print("no1=",no1,"no2=",no2) temp=no1+no2 no1=temp-no1 no2=temp-no2 print("case 1 after swapping") print("no1=",no1,"no2=",no2) print("\ncase 2") no1=10 no2=20 print("case 2 before swapping") print("no1=",no1,"no2=",no2) no1=no1+no2 no2=no1-no2 no1=no1-no2...
fb397c976c3f4c310a1de9bae96060e5be01bf64
k8isdead/codewars
/python/6kyu-DefaultList.py
2,180
4.09375
4
class DefaultList: ''' The collections module has defaultdict, which gives you a default value for trying to get the value of a key which does not exist in the dictionary instead of raising an error. Why not do this for a list? Your job is to create a class (or a function which returns an object)...
eb9e192a80cc39d34fbccba7328ca22888a577d6
rwoblesky/py
/split.py
406
4.03125
4
def split_word(word): place = 0 split = [] while place < len(word): split.append(word[place]) place += 1 return split def sort_split(a): a.sort() return a split = split_word(raw_input("What would you like to split?")) print split print "Would you like to sort?" response = raw_input("Y or N") if response ...
59da38cb2247d811ce5124618f0eb6289e0ef219
rwoblesky/py
/ex12.py
220
3.96875
4
age = raw_input("How old are you? ") height = raw_input("How tall are you? ") weight = int(raw_input("How much to you weigh? ")) if weight > 200: print "Wow, you're fat and old!" else: print "Wow, you're fit and old!"
a0910051a6e6a497fca7edd491be29f07dc3d622
wootkarawoot/PYTHON.py
/Exercise5_1_Surinthon_K.py
359
3.734375
4
InputOne = int(input('1โปรดระบุตัวเลข')) InputTwo = int(input('2โปรดระบุตัวเลข')) print(InputOne,"+", InputTwo ,"=", InputOne+ InputTwo) print(InputOne,"-", InputTwo ,"=", InputOne- InputTwo) print(InputOne,"*", InputTwo ,"=", InputOne* InputTwo) print(InputOne,"/", InputTwo ,"=", InputOne/ InputTwo)
8a9cdfc75a61fe187a0747f64555089602709abe
HanyangTechAI/2020_RL_Team01
/chess/hai.py
894
3.59375
4
from random import choice from piece import Bishop, King, Knight, Pawn, Queen, Rook class Hai: def __init__(self): self.playersturn = None self.gameboard = None self.Color = None def autoInput(self, Color): piecelist = [] for position, piece in self.gameboard.items(): ...
9a2a9686bc20414385d093545dae41f449ad7bbb
shivathudi/nosql
/postrgeSQL/test_files.py
1,206
3.546875
4
import json def count_data(data, key): return len(data[key]) def get_data_value(data,key): return data[key] input_file_name = 'walmart_search_san_francisco.json' with open(input_file_name, 'r') as input_file: data = json.load(input_file) #Q1 # print(get_data_value(data, "totalResults")) #Q2 ...
bf1ddb812830daa6886923b1c2020741d9cea660
BarY7/k_intervals_ex2
/assignment2.py
16,261
3.71875
4
################################# # Your name: ################################# from os.path import sameopenfile import numpy as np import matplotlib.pyplot as plt from numpy.lib.nanfunctions import nanmedian import intervals class Assignment2(object): """Assignment 2 skeleton. Please use these function si...
3854e9f4fdf2ec37dfd89f064c05ba7d1200f054
schwancr/schwancr_bin
/scripts/genPts.py
2,694
3.734375
4
#!/usr/bin/python2.6 -tt import sys from numpy import * import re from random import * ''' This script will generate a grid of points given two initial points. It will draw a line between the given points, then produce a vector perpindicular to that, and then another vector perpindicular to both. This defines the gr...
409bc028f40f0ccf0f8364293540e550a44e59b8
ningke/dec2bin
/dec2bin.py
3,891
4.625
5
# # Convert a decimal number (whole and fraction) to its binary representation. # ## # Algorithm: # A decimal number is a number represented as multiples of 10s. So for example 53.72 is # exponent of 10: 1 0 -1 -2 # multiples: 10 1 .1 .01 # 5 3. 7 2 # # Bin...
4c8aeb3d021f2e38803164bc6e123a2ccc077011
jsmzdf/EjerciciosDeBasica
/E11.py
99
3.625
4
import math r=input("ingrese radio") print("el volumen de la esfera es: ",(3/4)*math.pi*int(r)**3)
9df652f4d39064aa5642fb330cee991e2a713b79
rainbowrun/jump_pussy
/eval.py
6,481
4.03125
4
#!/usr/bin/python3 """Find an expression to use source numbers to get a target number. For example: $ eval.py 5 6 7 8 24 (5 + 7) * (8 - 6) = 24 $ eval.py 5 2 7 (5 + 2) = 7 """ import argparse import itertools import math import sys parser = argparse.ArgumentParser(usage=__doc__) # # 6 - (7! / (8 - 5!))...
7dbb3890411625acb1a1037b75d2bacffa41b943
vsarode/pract_python_prog
/leet/longest_substring_without_repeating_characters.py
1,287
3.96875
4
''' Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1. Example 3: Input: "pwwkew" Output: 3 Explanation: The answer is "wke", with the length of 3. Note that the answer m...
f1245bf3146680be1be9c93edc4fe968ad852aee
vsarode/pract_python_prog
/DS/DLinkedList.py
897
3.84375
4
class Node: def __init__(self, data): self.prev = None self.data = data self.next = None class DLinkedList: def __init__(self): self.head = None def append(self, data): t_head = self.head if not t_head: new_node = Node(data) new_node...
d2eaca3b3c6e3e07536e5217e141807d831e2a1e
vsarode/pract_python_prog
/add.py
307
4
4
def addition(): ''' :return: ''' choice = input("1) Addition 2) Substraction \n Enter your choice: ") val1 = input("Enter number 1:") val2 = input("Enter number 2:") def substraction(): """ :return: """ return input("Enter first no:") - input("Enter second number:")
d4386e9d7ad31fceadb491be070b5b22abb0ffbe
vsarode/pract_python_prog
/tax.py
455
3.53125
4
# you can write to stdout for debugging purposes, e.g. # print("this is a debug message") def solution(A): A= sorted(A) print A l = len(A) if A[0] > 0: for i in range(l - 1): print A[i], i print A[i + 1], A[i] + 1 if A[i] != A[i + 1] and A[i] + 1 != A[i + 1]...
e7a25711ca64ca4df97f1b344d345febc6429dc7
vsarode/pract_python_prog
/array/max_subarray_sum_with_k.py
388
3.5
4
def get_sum_with_subarray_of_size_k(arr, k): max_sum = arr[0] i, j = 0, 1 while j < len(arr)+1: if j - i > k: i += 1 if max_sum < sum(arr[i: j]): max_sum = sum(arr[i: j]) j += 1 return max_sum if __name__ == '__main__': arr = [1, 4, 2, 10, 23, 3, 1, ...
41126620e671d2c5298381eeda1f0a67b8f6a560
Wei-Mao/Assignments-for-Algorithmic-Toolbox
/Divide-and-Conquer/Improving QuickSort/quicksort.py
2,645
4.5
4
# python3 from random import randint from typing import List, Union def swap_in_list(array, a, b): array[a], array[b] = array[b], array[a] def partition3(array: List[Union[float, int]] , left: [int], right: [int]) -> int: """ Partition the subarray array[left,right] into three parts such that: array[...
c970dd4e69416a05fd9d26c16ac79dc0d882be56
Wei-Mao/Assignments-for-Algorithmic-Toolbox
/Greedy Algorithms/Car Fueling/car_fueling.py
1,234
3.546875
4
# python3 def compute_min_number_of_refills(d: int, m: int, stops: list): """ O(n) with n as the number of the gas stations. """ assert 1 <= d <= 10 ** 5 assert 1 <= m <= 400 assert 1 <= len(stops) <= 300 assert 0 < stops[0] and all(stops[i] < stops[i + 1] for i in range(len(stops) - 1)) an...
499b5c18b63ef19a66444a7149bbd7d817c8e7b4
DeepFriedCyber/DeepFriedCyber
/DataQuest tutorial - Classify Text Using SpaCy.py
6,879
3.703125
4
#!/usr/bin/env python # coding: utf-8 # In[1]: get_ipython().system('pip install spacy') get_ipython().system('python -m spacy download en') # In[2]: # Word toeknization from spacy.lang.en import English # Load English tokenizer, tagger, parser, NER and word vectors nlp = English() text = """When learning dat...
b4a1d078479cd256c641dda0381656169469fc2a
JayKay24/Office_Space_Allocation
/dojo.py
418
3.59375
4
class Dojo: """ This class accepts a list of offices and living spaces objects and initializes Dojo objects. """ def __init__(self, offices, living_spaces): self.__offices = offices self.__living_spaces = living_spaces @property def offices(self): return len(self.__o...
ad8925d35a38c094ab50be4058a9e253eee341a6
JayKay24/Office_Space_Allocation
/view.py
5,796
3.546875
4
""" This example uses docopt with the built in cmd module to demonstrate an interactive command application. Usage: view create_room <room_type> <room_name>... view add_person <fname> <lname> <person_job> [<accom>] view display_all_offices view display_greeting view print_room <room_name> view p...
6dfcacd1c1659c5bae68bd061024256bc034aeeb
BondarevDV/useful_scripts
/Lessons_OOP/decorators.py
653
3.640625
4
import time import functools def testTime(fn): #@functools.wraps(fn) def wrapped(*args, **kwargs): st = time.time() result = fn(*args) dt = time.time() -st print(f"Время работы: {dt} сек") return result return wrapped @testTime def node1(a, b): while a != b: ...
95a0e46490008fdf5b5a8c9af785080cd862ba4c
Bharti20/python_function_questions
/calculator.py
393
4.09375
4
def calculator(number_x,number_y,operation): if operation=="add": return number_x + number_y elif operation=="substract": print(number_x-number_y) elif operation=="multiply": print(number_x*number_y) else: print( number_x/number_y) calculator (20,25,"add") calculator(40,...
972e7c1ae5a3fd9b2538cdb9aba9e41838115918
Bharti20/python_function_questions
/nested_function.py
177
4
4
def outer_function(num1,num2): def inner_function(num1,num2): return num1+num2 add=inner_function(num1,num2) return add+5 res=outer_function(10,5) print(res)
d1d6453aff61c30f6dd18abe5dd11140c70b80ce
Bharti20/python_function_questions
/sum_list_argument.py
194
3.609375
4
def add_number(List1,List2): i=0 while i<1: j=0 while j<len(List1): print(List1[j]+List2[j]) j=j+1 i=i+1 add_number([50,60,10],[10,20,13])
c1cbc48357131c9cf7866d82079e9fb1715abe0b
Bharti20/python_function_questions
/calculator_using_return.py
497
3.984375
4
def calculator(number_x,number_y,operation): if operation=="add": return number_x + number_y elif operation=="substract": return (number_x-number_y) elif operation=="multiply": return (number_x*number_y) else: return( number_x/number_y) number_1=calculator (20,25,"add") ...
9f6119fc436d8c2c5bd40cdb20823398d8ca1960
Bharti20/python_function_questions
/functionQuetion.py
193
4
4
def my_function(num1,num2): res=num1*num2 return res i=1 while i<5: i=i+1 a=int(input("enter fisrt number")) b=int(input("enter second number")) print(my_function(a,b))
d61e8cc4d38bcfe6575e72fb48697e670d3a057b
VertikaD/HackerRank
/Practice/Problem Solving/TimeConversion.py
1,124
4.0625
4
# Complete the timeConversion function below. # code by Vertika Dhingra. def timeConversion(s): # Write your code here. # There are no changes to be done in seconds and minutes. # converting 12 hour to 24 hour clock. # if last two elements is PM and first two elements are not '12', # then a...
a5ebafdc54890ba2f9ac6af370482aef11c6205d
VertikaD/HackerRank
/Practice/30 Days Of Code/Day10.py
1,065
4.03125
4
# Binary Numbers if __name__ == '__main__': # Code by Vertika Dhingra n = int(input()) Binary_list = [] def DecimaltoBinary(num): if num >= 1: # we are dividing num by 2 until quotient is >= 1. # recursive function because it is repetitive process. # calling itself...
f09f8b5f03d314c1e5135fea46d6c88785fcc0d6
VertikaD/HackerRank
/Practice/30 Days Of Code/Day8.py
923
3.859375
4
# Dictionaries and Maps if __name__ == '__main__': # Code by Vertika Dhingra. n = int(input()) # Input1: no. of entries in the phonebook. # Input2: names and phonenumber using dictionary comprehension. phonebook = {name: int(phonenumber) for name, phonenumber in ( input().split() for _ in r...
1503167fc239a999b55b18bb7e04889d4698a927
Stml89/merge2dict
/main.py
763
3.875
4
#__author__ = 'stml' #!/usr/bin/env python a = { 'a': 1, 'b': 2, 'c': 3 } b = { 'c': 3, 'd': 4, 'e': 5 } class Dict: def check_rezult(self, dict_for_check): ab = {'a': [1, None], 'b': [2, None], \ 'c': [3, 3], 'd': [None, 4], 'e': [None, 5]} if (d...