blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
34532ac30fa5d8856773db419309191cb5c9bbd0
TimRock23/Codewars-solutions
/6-kyu/Consecutive strings.py
257
3.515625
4
def longest_consec(strarr, k): n = len(strarr) max_str = '' if n >= k > 0: for i in range(n-k+1): string = ''.join(strarr[i:i+k]) if len(string) > len(max_str): max_str = string return max_str
f95fed910f0b7332153211a53e3346eae480571b
TimRock23/Codewars-solutions
/7-kyu/Find the divisors!.py
196
3.828125
4
def divisors(integer): result = [] for i in range(2, integer//2 + 1): if integer % i == 0: result.append(i) return result if len(result) else f'{integer} is prime'
5c015718390f96cb80bca237873460ca0a0c1766
TheUncertaintim/NatureWithKivy
/0_Introduction/Exercise_0-6.py
1,914
3.65625
4
""" Exercise 0.6 Use a custom probability distribution to vary the size of a step taken by the random walker. The step size can be determined by influencing the range of values picked. Can you map the probability exponentially — i.e. making the likelihood that a value is picked equal to the value squared? """ from kivy...
1d88356f25150fecc41125dcf4f7fedfed227bbf
TheUncertaintim/NatureWithKivy
/3_Oscillation/Exercise_3-12.py
2,570
3.921875
4
""" String together a series of pendulums so that the endpoint of one is the origin point of another. Note that doing this may produce intriguing results but will be wildly inaccurate physically. Simulating an actual double pendulum involves sophisticated equations, which you can read about here: http://scienceworld.wo...
12741cfe6d861a590bf2f4bca5a3b5b035ad62dc
TheUncertaintim/NatureWithKivy
/3_Oscillation/Exercise_3-4.py
1,319
3.71875
4
""" Using Example 3.4 as a basis, draw a spiral path. Start in the center and move outwards. Note that this can be done by only changing one line of code and adding one line of code! """ from kivy.app import App from kivy.uix.widget import Widget from kivy.core.window import Window from kivy.clock import Clock from ki...
cde9d641697d10399a10a21592c4d9ea04737dba
TheUncertaintim/NatureWithKivy
/2_Forces/Exercise_2-4.py
3,784
3.5
4
""" Create pockets of friction in a Processing sketch so that objects only experience friction when crossing over those pockets. What if you vary the strength (friction coefficient) of each area? What if you make some pockets feature the opposite of friction—i.e., when you enter a given pocket you actually speed up ins...
3c819089ef007419ee8df2bf18d404cd68ff1463
TheUncertaintim/NatureWithKivy
/2_Forces/Exercise_2-3.py
2,733
3.84375
4
""" Instead of objects bouncing off the edge of the wall, create an example in which an invisible force pushes back on the objects to keep them in the window. Can you weight the force according to how far the object is from an edge — i.e., the closer it is, the stronger the force? """ from kivy.app import App from ki...
3b83afc7c7fcd86e6ccc97f37f4f7e89e18b46de
jeffb4real/scripts
/anagrams2.py
170
3.796875
4
#!/usr/bin/env python use string a = square_root(14.999) print a def square_root(x): y = x / x if y.search(r/('\d+)\.'), str(y)): z = $1 return z
3661ccbc9d6499a0d7f44ce5c8e764c1cba14228
jeffb4real/scripts
/mbyn.py
1,171
4.1875
4
#!/usr/bin/env python # There is a grid of size M x N. The top left corner is (0,0) and the bottom right is (m-1,n-1). # Write a function to print all the paths from (0,0) to (m-1,n-1), where you can only move right or down, no backtracking. # For example, in a 2x2 grid, the function should print "D,R" and "R,D" b...
3bcdb171266418dda075b311fb5ea9517263081c
jeffb4real/scripts
/mbyn_terse.py
1,483
3.875
4
#!/usr/bin/python # There is a grid of size M x N. The top left corner is (0,0) and the bottom right is (m-1,n-1). # Write a function to print all the paths from (0,0) to (m-1,n-1), where you can only move right or down, no backtracking. # For example, in a 2x2 grid, the function should print "D,R" and "R,D" becau...
c488e0d3cfcc1e3382282ab455b4e7122b0fe4eb
jeffb4real/scripts
/fibonacci.py
156
3.53125
4
#!/usr/bin/python # Fibonacci sequence a, b = 0, 1 for i in xrange(0, 10): print a a_tmp = a a = b b = a_tmp + b #a, b = b, a + b
654029cdcda935b92230a4f9b7adc159dda852db
T2D24/Tower_Defence
/enemy.py
2,056
3.5
4
import pygame import random from config import * from levels import * from animation import Animation class Enemy(pygame.sprite.Sprite): def __init__(self, x, y): super(Enemy, self).__init__() if random.randint(0, 1) == 1: self.anim = Animation(ENEMY_2_WALK, x, y, (SIZE[0] + 25, SIZE[1...
abfef6f846c4ab8e7191bb5fe397830a3b766cb7
vizhka/newbie-files
/list.py
347
3.734375
4
mylist = [1, 2, 3] mylist1 =[] mylist2 =['z'] l3 = ['test', 10, True, [1, 2, 3]] print(l3) print(list('Lists')) print(len(l3)) print(l3[3]) l4 = ['test', 14, False, [1, 3, 4, 5], 'friday'] print(l4[3]) l4[0] = 'new item' #добавление нового элемента в начало списка print(l4) l4.append('last item')# print(l4)
6ff7b83a5ee3b8a80599a003c37962edcba0ca13
Lock1/IF1210-Daspro
/tools/csvtohashedcsv.py
1,255
3.609375
4
from pandas import * from hashlib import * # Random number generator sederhana dengan definisi fungsi def lcg(m,a,b,s): if a: s = (a * s + b) % m else: return s return lcg(m,a-1,b,s) # st1 dan st2 tidak komutatif def hash(st1,st2): hashedst1 = sha512(str(st1).encode('utf-8')).hexdigest...
24378a16568316a96f702bfec8469c0c9d03ba49
elroyvargas/vargasmamani
/EstCondicional.py
797
3.9375
4
def estCondicional01(): #Definir variables y otros print("Ejemplo estructura Condicional en Python") montoP=0 #Datos de entrada cantidadX=int(input("Ingrese la cantidad de lapices:")) #Proceso if cantidadX>=1000: montoP=cantidadX*0.80 else: montoP=cantidadX*0.90 #Datos de salida print("El mo...
b704e5fac1c2be142ea8668dc4e5a3a9b6172d05
BaksiLi/CW-Baksi-Ryu
/Python/5kyu/calculating_with_function.py
1,579
3.6875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Calculating with Functions # https://www.codewars.com/kata/525f3eda17c7cd9f9e000b39/ import operator as op op_curried = lambda f: lambda y: lambda x: f(x, y) plus = op_curried(op.add) minus = op_curried(op.sub) times = op_curried(op.mul) divided_by = op_curried(op.flo...
1bc5658d862da835ace35996c71508a5caecf2f8
sarahannali/pythoncourse
/Challenges/remove_every_other.py
385
3.828125
4
def remove_every_other(givenList): for item in givenList: indexofItem = givenList.index(item) if not indexofItem%2 == 0: givenList[indexofItem] = "" ansList = [i for i in givenList if i != ""] return ansList print(remove_every_other([1,2,3,4,5])) # [1,3,5] print(remove_every_ot...
ba518bec2ca6eefb6bc687ace562a4aa47db9bc4
sarahannali/pythoncourse
/Challenges/valid_parentheses.py
807
4.25
4
''' valid_parentheses("()") # True valid_parentheses(")(()))") # False valid_parentheses("(") # False valid_parentheses("(())((()())())") # True valid_parentheses('))((') # False valid_parentheses('())(') # False valid_parentheses('()()()()())()(') # False ''' def valid_parentheses(givenString): ans = True ...
7be031768e903d47c8ec1a4ce2833f0b377f8361
sarahannali/pythoncourse
/Practice_Projects/calculator_practice.py
939
4.0625
4
floatChoice = input("Would you like to make your result a float? (Y/N) ").lower() if floatChoice == "Y": ans1 = True else: ans1 = False ans2 = input("What operation would you like to use? (add, multiply, divide, subtract) ").lower() ans3 = input("What's your first input? ") ans4 = input("What's your second in...
c7bce34317359de82c7e9e6be9cd81a6dff6e893
sarahannali/pythoncourse
/Challenges/vowel_count.py
471
4.03125
4
def vowel_count(word): vowelDict = {} vowels = ["a", "e", "i", "o", "u"] for letter in word: letter = letter.lower() if letter in vowels: if letter not in vowelDict: vowelDict[letter] = 1 else: vowelDict[letter] += 1 return vowelDic...
9796aaef0d7cef7229a47e7adfa4fa258bb77797
sarahannali/pythoncourse
/FileIO_Practice/fileio_practice.py
1,192
3.625
4
def copy(original, copyfile): with open(original) as ogFile: ogFiletxt = ogFile.read() with open(copyfile,"w") as copyFile: copyFile.write(ogFiletxt) copy("story.txt","story_copy.txt") def copy_and_reverse(original, copyfile): with open(original) as ogFile: reverseFile = ogFile.rea...
0db68f3f401213c38ba50a44bcb3cbb064806333
sarahannali/pythoncourse
/FileIO_Practice/csvfile_practice.py
2,143
3.6875
4
from csv import writer, DictReader, reader def add_user(First, Last): with open("file.csv", "a", newline="") as File: csv_writer = writer(File) csv_writer.writerow([First, Last]) add_user("Dwayne", "Johnson") def print_users(): with open("file.csv", "r") as File: csv_reader = DictRe...
86f119f3c06334d7d4c74fcd0006ee043416006e
mojtabadsh/Document
/python-excercize/odd-number.py
96
3.78125
4
n = int(input("enter a number")) while n >= 1: if (n % 2) != 0: print(n) n -= 1
0035f78c305fec2098fb4314fd97d01e8ae2fe16
alexgdav/python-practice
/guessnum.py
343
4.0625
4
import random chosen = random.randint(1, 20) n = input("Guess what number between 1 & 20 I'm thinking of") n = int(n) if n == chosen: print(f"You got it, I'm thinking of {n}") elif n > chosen: print(f"You guessed too high! I was thinking of {chosen}") elif n < chosen: print(f"You guessed too low! I was ...
555691ef4314996aa97af9c4291036c17ba7681a
flourishshade/classwork
/Listrangetuple.py
554
3.5625
4
import csv # List_1={'beacon', 'butter', 'egg','spams'} # List_1.sort() # print(List_1) # first_100_numbers = list(range(1,101)) # for num in first_100_numbers: # if num % 7 ==0: # seven.append(num) # elif num % 8 == 0: # eights.append (num) # elif num % 5 == 0: # fives.append (nu...
63391e1778a32dc4399f7916a3dadc70145eadad
mjm159/StudyProblems
/linked_lists/linked_list_addition_2.py
999
4.0625
4
#!/usr/bin/python ''' You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in forward order, such that the 1's digit is at the tail of the list. Write a function that adds the two numbers and returns the sum as a linked list. ex) input: (6 -> 1 -> 7) + (2...
d4de7747750653007cb16d249b149623725b34d9
horiwooooo/AtCoder
/ABC088C/Takahashi'sInformation.py
2,452
3.609375
4
import pandas as pd import sys # make dataframe to store the value of each coordinate c = pd.DataFrame(index=[1, 2, 3], columns=[1, 2, 3]) # enter values for each coordinate print("Enter the value c for each coordinate in row 1.") c.iloc[0, 0], c.iloc[0, 1], c.iloc[0, 2] = (int(x) for x in input().split()) if sum(c.il...
36985ccc8ca73d6d27719c5576aca3b9c200f414
54lihaoxin/google_foo_bar
/src/guard_game/solution.py
200
3.75
4
def answer(x): cur = x numSum = 0 while cur > 0: numSum += cur % 10 cur /= 10 if numSum > 9: return answer(numSum) else: return numSum
4258d06e6279cf0aa5a5fcaddef2fa86c0f6ec87
anafplima/ALGORITMOS
/algcesar.py
630
3.96875
4
import string modo = input("Digite E para encriptar ou D para descriptar: ") chave = int(input("Digite o valor da chave: ")) mensagem = input("Digite a mensagem: ") caracteres = "ABCDEFGHIJKLMNOPQRSTUVXWYZ" convertido = "" mensagem = mensagem.upper() modo = modo.upper() for caractere in mensagem: if caractere i...
8f390a7ca2db846236a8f854d5ac4c97873a28db
tjanmaat/Dambot
/dambot/src/pieces/Piece.py
503
3.5
4
from abc import ABC, abstractmethod class Piece(ABC): def __init__(self, game, piece_id, color, enumeration): # check input values self.game = game self.id = piece_id self.color = color self.enumeration = enumeration self.piece_type = None self.tag = "tag_" ...
f317bf039f2af1cd5833ca9d0fd573e19efea599
tjanmaat/Dambot
/dambot/src/bots/Bot.py
349
3.515625
4
from abc import ABC, abstractmethod class Bot(ABC): def __init__(self, color_boolean): if not isinstance(color_boolean, bool): # throw error return self.color_boolean = color_boolean # True if white self.bot_name = None @abstractmethod def choose_move(self...
b54061a730d2ab4e8cf6fe178ba3d4b524fe661f
remingtonCarmi/TrackingSwimmingENPC
/src/d4_modelling_rough/draw_rectangle/draw_rectangle.py
1,236
4.25
4
import numpy as np def draw_rectangle(image, x0, y0, x1, y1, outline=5): """ Turns pixels of an image along a given rectangle into red ones. Does not modify the input. Args: image (numpy array): the input image x0 (integer): the x-coordinate of the top left pixel of the rectangle ...
2a3c24ab759e1a1f6d3a7d41653a4f557222bea6
soberlook/algorythms
/13/13.final.A.datacenters.py
635
3.578125
4
# Посылка 35023983 def max_photo_replica(datacenters_list): if len(datacenters_list) <= 1: return 0 res = 0 while len(datacenters_list) > 1: datacenters_list = sorted(datacenters_list, reverse=True) datacenters_list[0] -= 1 datacenters_list[-1] -= 1 res += 1 ...
6ebf03501666adbd8865678202962d3d79f4297f
bran112299/Blackjack
/blackjack2019.py
4,788
3.59375
4
import random from datetime import datetime random.seed(datetime.now()) #################################### class blackjack: def __init__(self): self.deck = [] # Deck self.suit = ['♠','♥','♦','♣'] self.cards = [2,3,4,5,6,7,8,9,10,'J','Q','K','A'] self.dValue = 0 #summer w...
742c7b4fdf539c152c819ef828ff4724a67c2e79
e8johan/adventofcode2020
/18/day18.py
6,971
3.8125
4
def tokenize(expr): # list of tuples # # ('N', value) => integer value # ('T', char) => token character res = [] # Current number, might be a sequence of digits number = '' while True: # Current token, if found found_token = '' # True if whitespace is fo...
9f566283d767aef36bd58d68d059f3bde0ea6319
swrnkumar/Web_development_jan2021
/python_practice/practice_loops.py
218
4.09375
4
for i in [0,1,2,3,4,5]: print(i) for i in range(6): print(i) names = ["Harry", "Larry", "Ron", "Lara", "Sara"] for name in names: print(name) name1 = "Harry" for character in name1: print(character)
e82bbc630003c1d9ebd823550bb90a5e23fbe936
alucardthefish/DailyCodingProblem
/Problem_9_hard.py
1,094
4.125
4
# 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. # Follow-up: Can yo...
b1f1e449d62884d393b4be2222c0432ed5e7f5bf
BUEC500C1/quality-noracnr
/convertor.py
692
3.90625
4
#Assignment1: Quality #Convert Arabic Numerals to Roman Numerals import sys def convert(a): II = ['','I','II','III','IV','V','VI','VII','VIII','IX'] XX = ['','X','XX','XXX','XL','L','LX','LXX','LXXX','XC'] CC = ['','C','CC','CCC','CD','D','DC','DCC','DCCC','CM'] MM = ['','M','MM','MMM'] if type(a) is int: ...
3448de9698767b7f516e3bac595761e657106fc8
Phuttadon/cs01----------
/Cs01-18.py
312
3.734375
4
from tkinter import * root=Tk() root.title("First GUI") myText= Label(text="My name is ",fg="blue",font=20).grid(row=0,column=0) myText= Label(text="Phuttadon",fg="red",font=20).grid(row=1,column=1) myText= Label(text="Khuntawong",fg="green",font=20).grid(row=3,column=2) root.geometry("300x300") root.mainloop()
642338a0988ad906076f48594d4f61fb3e1fd385
WesleyFakkeldij/Programming
/Les 2/Les 2 Excersise 2_1.py
171
3.71875
4
letters = ('A', 'C', 'B', 'B', 'C', 'A', 'C', 'C', 'B') lijst = sorted(letters) print (sorted(letters)) print(letters.count("A"), letters.count("B"), letters.count("C"))
4588e9e08f3421bb489e92444d989c02831972df
jodham/pythongui
/firstGui.py
843
3.734375
4
from tkinter import * import tkinter.messagebox as mb window = Tk() window.title("login") window.geometry("300x300") label1 = Label(window, text="Welcome", font="times 15 bold") label1.place(x=60, y=20) label2 = Label(window, text="Username", font="times 10 bold") label2.place(x=40, y=60) user_ent = Entry(window) user...
ba7a0aca93f0d8bf3080ca630a638f18af403370
mumana98/CS-303E-Elements-Of-Computers-And-Programming
/Assignments/Assignment11.py
1,581
3.921875
4
#Matthew Umana msu245 import turtle def reverse_string(s): s_new = "" if len(s) <= 1: return s else: s_new = reverse_string(s[1:]) + s[0] return s_new def binary_search(key, lst): low = 0 high = len(lst)-1 while low <= high: mid = (low+high)//2 if lst[...
ac2aeeade4f4981aba0a86fee8a142ccf07e670e
rossco122005/FinalFantasyPython
/src/JSON_test.py
778
4
4
# Simple file for trying out things for JSON and accessing dictionaries import json items = { "Potion": { "hp_healed": 100, "price": 50 }, "Ether": { "mp_healed": 20, "price": 150 } } x = items["Potion"].get("hp_healed") items.update({ "Grenade": { "damage...
2f43bd44fa399da4a4baea0d4feb2dedda13f918
KhizarSultan/Python
/Python Repo/oop/prac.py
3,583
4.09375
4
# oop is the style of code, use to manage the code and understandleable # init method is just like the constructor in c++ # self is used for specific product but class instance is for all the product import dunder as dund class person: pi = 3.14 # Class variable def __init__(self,n,a,g): # insta...
467b7af863cbeb520ddcff0eba8a46012ea103cd
KhizarSultan/Python
/Python Repo/chapter_3/prac.py
1,837
4.25
4
#if statement name = "Khizar" if name == "khizar" or name == "Khizar": print(f"you are khizar") print(f"you are above 23") elif name == "khizra" or name == "khizra": print(f"you are khizra") else: print("Neither khizar nor khizra") #pass statement age= 24 if age == 23: print(f"you ar...
0529004d7727ecc2dbd93195f289cd55901dcf44
KhizarSultan/Python
/Python Repo/chapter_7/prac.py
4,379
4.46875
4
#Dictionaries #Unordered Collection of data in key:value #There is no index in the Dictionary user = {'name' : "khizar" , 'age' : 20} print(user) print(type(user)) #Second method to create dictionary user1 = dict(name = "Khizar",age = 21, Semester = 6) print(user1) #how to access data from dictionary prin...
b215c9ae917fab0f86c5490a7ac04fce13df09e7
kyaing/KDYSample
/kYPython/FluentPython/BasicLearn/OOP/Generator.py
746
3.9375
4
# coding: utf-8 a = [x for x in range(10)] # 列表推导式 b = (x for x in range(10)) # 生成器第一种方式;next(b)来取值,占用内存空间小 # 斐波那切数列 def fib(num): print('---start---') a, b = 0, 1 for i in range(num): print('---1---') # 生成器第二种方式,yield 所在的函数也就称为生成器 # 程序执行到 yield 会停止并返回值;当再次调用next()方法,程序会执行 yield后面语句 yield b print...
35218bbf6eb784ccac7dc229cad0934d9c49b82a
kyaing/KDYSample
/kYPython/Cookbook/Chapter01/filterlist.py
825
3.640625
4
# coding: utf-8 from itertools import compress mylist = [1, 4, -5, 10, -8, 4, 3, 2] l1 = [n for n in mylist if n > 0] # 列表推导式 l2 = [n for n in mylist if n <= 0] print(l1, l2) pos = (n for n in mylist if n > 0) # generator for i in pos: print(i) values = ['1', '2', '-3', '-', '4', 'N/A', '5'] def is_int(val...
3794d079e3c6a7e3a8e6e15d6648e9e508061c4f
kyaing/KDYSample
/kYPython/Cookbook/Chapter02/replacestr.py
497
4.0625
4
# coding: utf-8 import re text = 'yeah, but no, but yeah, but no, but yeah' print(text.replace('yeah', 'yep')) text = 'Today is 11/27/2012. PyCon starts 3/13/2013.' print(re.sub(r'(\d+)/(\d+)/(\d+)', r'\3-\1-\2', text)) # re 模块中的 sub做匹配 text = 'UPPER PYTHON, lower python, Mixed Python' re.findall('python', text, f...
81a1d038bc54592824672c8cf7bca78a77b525ef
kyaing/KDYSample
/kYPython/FluentPython/BasicLearn/OOP/Property.py
595
3.734375
4
class Tool(object): # 类属性 num = 0 # 实例方法 def __init__(self, new_name): # 操作类属性 # Tool.num += 1 # 实例属性 self.name = new_name # 类方法 @classmethod def add_num(cls): cls.num = 10 # 静态方法 @staticmethod def print_menu(): print('=========...
6b51688af0ae10c6a68be9c2e2d79a005388919f
kyaing/KDYSample
/kYPython/FluentPython/BasicLearn/OOP/Module.py
226
3.53125
4
# __all__ 全局变量,向外提供可调用的方法与属性 __all__ = ['test1', 'test2'] def test1(self): print('----test1----') def test2(self): print('----test2----') num = 0 class Test(object): pass
315f6276f5e8dce836cad77bd8d55687bd3ceeb1
Vineeth-97/iiser
/PHY_423/hw2/qn05_vineeth.py
130
3.53125
4
def poly(x, roots): pdt = 1 for r in roots: pdt *= (x-r) return pdt roots = [1, 2] print(poly(1.1, roots))
5124ab783e690c59c349ee45fb41bbcfc81befac
Vineeth-97/iiser
/PHY_423/computationprograms/integrate_pooja.py
386
3.609375
4
import math import numpy as np a=0 b=math.pi def func(x): return np.sin(x)*np.sin(x) def integrate(f,a,b,m): h=(b-a)/(2*m) x=np.linspace(a,b,2*m+1) print("x = ",x) term1=f(a)+f(b) sum=0 for i in range(1,m+1): sum+=f(x[2*i-1]) term2=4*sum sum1=0 for i in range(1,m): sum1+=f(x[2*i]) term3=2*sum1 I=(te...
961bed5a88e22fa873a5a6b1782030ee214aede3
Vineeth-97/iiser
/PHY_423/newton.py
1,387
3.765625
4
#!/usr/bin/env python3.5 """ Modified Newton-Raphson method to find function root """ import sys import math import scipy.optimize def is_equal(a, b): """ Check if floats `a' and `b' are equal within the machine precision """ return abs(a-b) < sys.float_info.epsilon def newton(f, f_prime, a, TOL=1.0...
2d0218575b39916c2807990f609f0c5a353743c6
carinasauter/D06
/D06ex03.py
883
3.890625
4
# write a function that reads from roster.txt prints the following information to the command line: # a. how many first names contain the letter ‘e’ # b. then lists the first_names which contain the letter ‘e’ def find_the_e(): count = 0 list_of_names = [] file = open("roster.txt", "r") new_list = fil...
c84afaaac829843b43317f3bd25bae80bdd95b20
arunchaganty/newsline
/src/article.py
1,418
3.75
4
""" Definition of the Article Class """ import util import lxml.html import urllib class Article: def __init__(self, title, lead, text): title, lead, text = [util.unicode_to_ascii(x) for x in [title, lead, text]] # lead, text = [x.lower() for x in [lead, text]] self.title = title ...
c14b105350e3f78f2c409407d95bc3cada0fd2ec
akshayabaskaran/ishuakshaya
/b7.py
92
3.625
4
#print'Hello' N times import sys b = int(input(' ')) for i in range(b) : print('Hello')
3a7cbd5fd416bbdccadcabc7675290845d95c8f9
merlions777/PyPlayground
/test.py
1,740
4.375
4
msg = "Hellpo World" print(msg) #Data Types #There is no explicit data type declaration is required pi = 22 / 7 var1 = 2999 #The ideal value of pi is 3.141... print(f"The value of pi without typecase is {pi}") #When type casted the value of the pi to intefer print(f'The value of pi type casted to integer is {int(pi)...
5281f28f44b048d2cf4c53795fae613091f9ffa7
aspcodenet/IotMenu
/IotMenu/IotMenu.py
1,031
3.90625
4
def SubMenu1(): b = 555 while True: print("SUB") print("1. Hej") print("2. Hopp") print("3. Avsluta") i = int(input("Välj:")) if i == 1: print("Hej valdes") elif i == 2: print("Hopp valdes") elif i == 3: break ...
5a245f48ad41e6a98175b472ef3c832bfb2146ed
cwsaunders/umaine-coursework
/SIE-507/Week-11/lab-1.py
355
3.875
4
num_of_integers = int(input('')) items = [] smallest = 0 for i in range(num_of_integers): items.append(int(input(''))) for i in range(len(items)): if i == 0: smallest = items[i] if items[i] < smallest: smallest = items[i] for i in range(len(items)): items[i] -= smallest for i in rang...
2bb4ddbdadb46f77e6490f3ba09120938bc6cb1b
cwsaunders/umaine-coursework
/SIE-507/Week-3/cal.py
356
3.71875
4
age = float(input()) weight = float(input()) heart = int(input()) time = float(input()) cal_men = ((age*0.2017)+(weight*0.09036)+(heart*0.6309)-55.0969)*time/4.184 cal_women = ( (age * 0.074) - (weight * 0.05741) + (heart * 0.4472) - 20.4022 ) * time / 4.184 print('Women: {:.2f} calories'.format(cal_women)) print('Me...
43cd368b014d6627f6884f57bcf06adc01a36d7b
Octobers10/AmazonDataCollector
/review_main.py
7,873
3.578125
4
import web_reader import find_review as fr import xlwings as xw import sys import logging from datetime import datetime import time import numpy as np import pandas as pd #Global Variables initialization #write_file is the dataframe that stores the data write_file=pd.DataFrame() def welcome_display(): ''' ...
c3ca0b10179c03651135f596cb30674ab7a0e6b7
bhowbhowbhavya/100DaysofCode
/week2/Day9Project_BlindAuction.py
687
3.515625
4
from IPython import get_ipython get_ipython().magic('clear') data = {} bidding_finished = False while not bidding_finished: name = input("What is your name?") bid = int(input("What's your bid?")) data[name] = bid get_ipython().magic('clear') should_continue = input("Do you wish to continue with an...
85ba250a896a11f7c90afd40f27ab4fac2527de8
BhavanaG7/Data_Structures
/Singly_Linked_List/Linked_List_to_list.py
926
4.09375
4
class Node: def __init__(self,value): self.value=value self.next=None class LinkedList: def __init__(self): self.head=None self.tail=None def append(self,value): if self.head is None: self.head=Node(value) self.tail=self.head ...
bcf982d063f36f2538ee4e73ecad8a5fa01fb64c
jonatanbedoya/ST0245-Eafit
/proyecto/CodigoYaEmpezado/decision_tree.py
1,628
3.6875
4
""" Module containing the necessary classes and functions to build a CART Decision Tree. """ from utilities.utils import class_counts from utilities.math import find_best_split, partition class Leaf: """ A leaf node classifies data. It holds a dictionary of class -> number of times it appears in the rows...
054d1a24460503affccf99e25e57d67d9fc92244
SrivatsavK/Collision-avoidance-in-agents-using-force-based-velocity-obstacles
/agent.py
2,393
3.96875
4
import numpy as np from math import sqrt class Agent(object): def __init__(self, csvParameters, dhor = 5, goalRadiusSq=1): """ Takes an input line from the csv file, and initializes the agent """ self.id = int(csvParameters[0]) # the id of the agent ...
2b5aa6203d2f9d3a5d55406cda56b17871ab2b70
mAhmedSiddiki/Python_Pattern_Program
/18 half diamond star pattern.py
161
3.875
4
# half diamond star pattern a = int(input("Enter a value: ")) for i in range(1,a+1): print("*"*i) for i in range((a-1),0,-1): print("*"*i)
9bdc805daa3eaf34357ed06befbf667ccdc5334f
mAhmedSiddiki/Python_Pattern_Program
/24 E alphabet shape.py
256
4.03125
4
# E alphabet shape - star pattern for row in range(0,7): for col in range(0,5): if((col==0)or((row==0 or row==3 or row==6)and(col>0 and col<5))): print("* ",end="") else: print(" ",end="") print()
cb2790b8bd0aba6cf87c46f276425a17a918fe79
mAhmedSiddiki/Python_Pattern_Program
/44 Y alphabet shape.py
372
3.921875
4
# Y alphabet shape - star pattern i=0#row j=6#column for row in range(0,7): for col in range(0,7): if((row==col and col<3)or(col==3 and (row>2 and row<7))): print("*",end="") elif(row==i and col==j): print("*",end="") i=i+1 j=j-1 e...
7c195a326c615a54da1b50beee02f66f7c6ea17c
mAhmedSiddiki/Python_Pattern_Program
/01 introduction.py
233
3.59375
4
#pattern a = int(input("Enter the first value: ")) #int b = int(input("Enter the second value: ")) #int print("Summation: ",a+b,"\nCode Hunter") print("Code",end="") print("Hunter") for i in range(1,11): print(i)
0b8f54ae7e0aeb150aea91ae4f490523c2e7b57e
mAhmedSiddiki/Python_Pattern_Program
/39 T alphabet shape.py
238
4.03125
4
# T alphabet shape - star pattern for row in range(0,6): for col in range(0,5): if(row==0 or (col==2 and (row>0 and row<6))): print("* ",end="") else: print(" ",end="") print()
367f2f9b99fbd08e6ae6aa3b6efeca48260fda5c
btigercl/data_structure_practice
/sorting.py
6,940
4.25
4
#bubble sort #o(n2) """it has the capability to do something most sorting algorithms cannot. In particular, if during a pass there are no exchanges, then we know that the list must be sorted. A bubble sort can be modified to stop early if it finds that the list has become sorted. This means that for lists that requir...
5c1c9321ff892b9619e6b8485ba6ab392cad3138
CarnunMP/Project-Euler-Solutions
/problems/5-smallest-multiple.py
1,874
4.125
4
### The problem: 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. ### What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? # Hmm. First thought: if a number is evenly divisible by 20, then it's evenly divisible by 10...
3b71543fcf0c748c9300ef62f69dde71d4b09af0
MuYi0420/newstudy
/python/function.py
338
3.515625
4
def SaySome(name, words): print (name +':'+ words) SaySome('Muyi','I love you') SaySome(words='I love you',name='MuYi') #关键字参数 def SaySome2(name='Muyi', words='I love you'): #默认参数 print (name +':'+ words) SaySome2() def SaySome3(*params): print ('length: ' ,len(params)) print ('second:' ,params[1])
cd0ff5d03593076c431679fa8cd66ffa1ea2c6b3
MuYi0420/newstudy
/python/lambda.py
457
3.78125
4
g = lambda x : 2 * x + 1 print (g(5)) h = lambda x , y : x + y print (h(5,6)) list(filter(None, [1, 0, False, True])) #过滤False的数 def odd(x): return x % 2 temp = range(10) show=filter(odd, temp) print (list(show)) show=list(filter(lambda x: x % 2 ,range(10))) #将range里的值带入前边的函数,并筛选出结果为True的range print (show) show=li...
77058dc53983d0f1a6d3be1dda6833dae90f8ce8
degivan/ifmo-intellectual-systems-hw
/SVM/svm/dots.py
399
3.65625
4
from math import sqrt class Dot(object): def __init__(self, arr): self.x = float(arr[0]) self.y = float(arr[1]) self.label = arr[2][0] def __str__(self): return 'x: %f y: %f label: %s' % (self.x, self.y, self.label) def get_x(dot): return dot.x def get_y(dot): retu...
2ccc523d43a3c36754880ac90dadf2207015f5f4
yonwu/thinkpython
/WordPlay/9.6.py
403
3.640625
4
fin = open('/Users/yonwu/thinkpython/WordPlay/words.txt') def is_abecedarian(w): return sorted(list(w)) == list(w) def word_is_abecedarian(f): list_uses_all = [] for line in f: word = line.strip() if is_abecedarian(word): list_uses_all.append(word) return list_uses_all ...
edad0b878566e26d2f4e7493622b6fcfe8446bc3
yonwu/thinkpython
/Fruitfull functions/6.3.py
435
4.03125
4
def first(word): return word[0] def last(word): return word[-1] def middle(word): return word[1:-1] def is_palindrome(s): if len(s) <= 1: return True if len(s) == 2: return first(s) == last(s) elif len(s) > 2: if first(s) == last(s): return is_palindrome...
83f59956bf86788fbaf6512c38cbc9049a8d5aed
niharika95/Python-Programs
/CnB.py
1,053
3.875
4
import random name=0; name=raw_input("What's your name?\n") print "\nOk",name,", let's play Cows n Bulls! \n" #Instructions print "Instructions:" print "1. The computer will generate a random 4 digit number." print "2. You have to guess what number it is. Choose numbers between 1000 and 9999 only!" print "3. For every...
5505e5103b23bddd7c0535c981f3a0e35165c64d
npj6/PC-2020
/p2/pythonp2/threads.py
398
3.6875
4
#! /usr/bin/env python import threading CONTADOR = 0 THREADNUM = 5 ADDNUM = 50000 def thread(): global CONTADOR for i in range(0,ADDNUM): CONTADOR = CONTADOR + 1 def main(): threads = [] for i in range(0,THREADNUM): threads.append(threading.Thread(target=thread)) threads[-1].start() for t in ...
d7040a19e46193982a50d04de974f348275d4d7e
ravikiran300/LetsUpgrade-Python-Essentials
/DAY8_Q1-decorator-Assingment.py
499
3.859375
4
def getInput(calculate_arg_fun): def wrap_function(): a = int(input("\nEnter First Number - ")) b = int(input("\nEnter Second Number - ")) calculate_arg_fun(a,b) return wrap_function @getInput def EvenFinder(start, last): print("\nThe Even ...
dcec3ddcf89bba5bfae28e295b99b51026e6a9fe
LimRaymond/pong_game
/ball.py
212
3.75
4
def ball(turtle): ball = turtle.Turtle() ball.speed(0) # Animation speed ball.shape("square") ball.color("white") ball.penup() ball.goto(0, 0) ball.dx = 0.15 ball.dy = -0.15 return ball
32e9d5db135f9ad661b045662b6b2159b6014b81
mariamafra/infinity_questions
/Jogo/play.py
4,505
3.640625
4
# Criando arquivo play.py #arquivo que vai ficar a logica do jogo propriamente dito #Aqui dentro vai ser chamado as telas de recorde pessoal, global ou não recorde import curses import actions import getData import screen import scoreboard import textPrint def final_game(stdscr, current_user_name, current_user_id, c...
fe447525025b3409479546e3c8cb25388c9beade
mspspeak/problems
/python/euler_nine.py
814
3.703125
4
# A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, # a2 + b2 = c2 # For example, 32 + 42 = 9 + 16 = 25 = 52. # There exists exactly one Pythagorean triplet for which a + b + c = 1000. # Find the product abc. #a + b + c = 1000 #a * a + b * b - c * c = 0 # c = 1000 - a - b # a * a...
ec6f2109ae06b767cbf3f81f68182be5a406929e
Hritvik-55/DataStructures-and-Algorithms
/DataStructures and Algo/Longest_Word_Arrays.py
248
3.609375
4
def func(str): lst=str.split(" ") maxlen=-1 for i in lst: if len(i)>maxlen: maxlen=len(i) result=i return result a="hey how are you bfhvhfvhfdy bhbfhbvhbhgbvhjgfbvhgfbhg" print(func(a))
b29e9ac6898a8004ff8aa5b8ba219db9dfb8bd2e
Hritvik-55/DataStructures-and-Algorithms
/DataStructures and Algorithm/Arrays/Repeated_Characters.py
205
3.609375
4
def func(str): str=str.lower() mydict=dict() for i in str: if (i in mydict): return i else: mydict[i]=1 str="GeeksForGeeks" print(func(str))
20d481801115bdc18e3d293f00048cc4e05100ff
Hritvik-55/DataStructures-and-Algorithms
/DataStructures and Algorithm/Linked Lisst/Insertion_in_LinkedList.py
1,576
4.3125
4
class Node: def __init__(self,data): self.data=data self.next=None class LinkedList: def __init__(self): self.head=None ''' Inserting in Linked List ''' ''' Inserting at the starting of the linked list ''' def inserting_at_front(self,new_dat...
8e942ac0ff9186ffbf352022906ae3a3d159a60b
7ard1grad3/Snake-turtle-py
/food.py
316
3.796875
4
from turtle import Turtle from random import randint class Food: def __init__(self): self.food = Turtle("turtle") self.food.reset() self.food.goto((randint(-280, 280), randint(-280, 280))) self.food.color("green") def pos(self): return self.food.pos()
1706aaf62fee365a963a6c932ba1a6e34ed4b347
c-sosalty/Python-scripts
/str_exo.py
233
4.28125
4
#5.9 -put the string to the inverse #5.10 -see if it's a palindrome ph = "bob" ph_x = "" ph_l = len(ph) n = 0 while n < ph_l: n+=1 ph_x += ph[ph_l - n] if ph == ph_x: print("It's a palindrome") print(ph_x)
b533ffc608aad62b97e5b6a8e7be69df46908d51
michaelchoie/Udacity-Deep-Learning-Nanodegree
/12. intro_to_gans/gan_mnist.py
8,606
3.671875
4
"""Create a GAN that produces MNIST-like images.""" import matplotlib.pyplot as plt import numpy as np import os import pickle import tensorflow as tf import time from tensorflow.examples.tutorials.mnist import input_data class GanMNIST(object): """ GAN that generates MNIST images. Args sess (Se...
62ad4b22f9be1848664729b3c12f5f5295c9f402
R1PLI/python_self_education
/basic/loops/while_loop.py
369
3.828125
4
# name = '' # while True: # print('enter your name') # name = input() # if name == 'your name': # break # print('Thank you') # spam = 0 # while spam < 5: # spam += 1 # if spam == 3: # continue # print('spam is ' + str(spam)) # print('My name is ') # i = 0 # while i < 5: # ...
471f4bbc2667eb8b57fb90cb25945963d3a4575c
mikeshihyaolin/linkcode
/590. N-ary Tree Postorder Traversal.py
607
3.984375
4
# 590. N-ary Tree Postorder Traversal.py # Given an n-ary tree, return the postorder traversal of its nodes' values. # For example, given a 3-ary tree: # Return its postorder traversal as: [5,6,3,2,4,1]. """ # Definition for a Node. class Node(object): def __init__(self, val, children): self.val = val ...
fce80e5a654ca5c38da5e7b6adc828fdb737092e
mikeshihyaolin/linkcode
/179. Largest Number.py
1,173
3.96875
4
# 179. Largest Number.py # Given a list of non negative integers, arrange them such that they form the largest number. # Example 1: # Input: [10,2] # Output: "210" # Example 2: # Input: [3,30,34,5,9] # Output: "9534330" # Note: The result may be very large, so you need to return a string instead of an integer. fro...
40291606c22a8741d9ebe0becce9110cadbd381c
mikeshihyaolin/linkcode
/355. Design Twitter.py
4,953
4.21875
4
# 355. Design Twitter.py # Design a simplified version of Twitter where users can post tweets, # follow/unfollow another user and is able to see the 10 most recent tweets in the user's news feed. # Your design should support the following methods: # postTweet(userId, tweetId): Compose a new tweet. # getNewsFeed(use...
e925d84ba0f2c1882af4af2b28942091a96c9b6b
mikeshihyaolin/linkcode
/1213. Intersection of Three Sorted Arrays.py
1,018
4.21875
4
# 1213. Intersection of Three Sorted Arrays.py # Given three integer arrays arr1, arr2 and arr3 sorted in strictly increasing order, # return a sorted array of only the integers that appeared in all three arrays. # Example 1: # Input: arr1 = [1,2,3,4,5], arr2 = [1,2,5,7,9], arr3 = [1,3,4,5,8] # Output: [1,5] # Ex...
567e0bcaa96ba5e384d57a36ea33f7c5f75d931f
mikeshihyaolin/linkcode
/49. Group Anagrams.py
901
3.875
4
# 49. Group Anagrams.py # Given an array of strings, group anagrams together. # Example: # Input: ["eat", "tea", "tan", "ate", "nat", "bat"], # Output: # [ # ["ate","eat","tea"], # ["nat","tan"], # ["bat"] # ] # Note: # All inputs will be in lowercase. # The order of your output does not matter. class Solut...
2fe12ac2dbba33b0a3825b22323403ff6cebdec8
mikeshihyaolin/linkcode
/953. Verifying an Alien Dictionary.py
2,842
3.96875
4
# 953. Verifying an Alien Dictionary.py # In an alien language, surprisingly they also use english lowercase letters, but possibly in a different order. The order of the alphabet is some permutation of lowercase letters. # Given a sequence of words written in the alien language, and the order of the alphabet, return ...
d9b01824e4a72aef985995a549991f1a51b68836
mikeshihyaolin/linkcode
/535. Encode and Decode TinyURL.py
1,844
4.125
4
# 535. Encode and Decode TinyURL.py # TinyURL is a URL shortening service where you enter a URL such as # https://leetcode.com/problems/design-tinyurl and it returns a short URL such as http://tinyurl.com/4e9iAk. # Design the encode and decode methods for the TinyURL service. # There is no restriction on how your e...
646b73e771bef51186fc26267f44c5e8890e65e4
geinarm/forklift_sim
/forklift_planner/scripts/taskPlanner/actions.py
2,430
3.546875
4
from predicates import * from objects import * class Action(object): def __init__(self): pass class Take(Action): def __init__(self, robot, pallet, stack): self.robot = robot self.pallet = pallet self.stack = stack super(Take, self).__init__() def apply(self, state): if not self.applicable(state): ...
c524e6e061af96eb18adb7599c17602f74a4941d
mitsuki97/code
/python/shiyan11.py
1,380
3.578125
4
# #coding=utf-8 # x=input("请输入优先级:") # rawxlist=x.split("空格")#分割 # print(rawxlist) # xlist=rawxlist.sort()#排序 # print(xlist) # def pcb(): # print('This is a function') # a = 1+21 # print(a) import os import time raw=[] temp=[] #初始化列表 time =[] finish=[] for i in range(5): x = int(input("input a super pl...