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
457da1c4d16bb155ba8dce554cc02dfbffa63b57
JackelyneTriana/AprendaPython
/3.MAYOROMENOR.py
280
4.03125
4
numero1 = input("Ingresa un numero: ") numero2 = input("Ingresa otro numero: ") if numero1 < numero2: print("El numero " + numero2 + " es mayor") elif numero2 < numero1: print("El numero " + numero1 + " es mayor") else: print ("Los numeros son iguales")
76e7442dbd667b917a62e10cd32f41d2c930ccde
CodingHorrors/Cardgame
/panda.py
627
3.515625
4
import pandas p = r"C:\Users\Alex\Documents\Programming\ProjectCardgame\test.csv" new_names = input("Add one or multiple new names, seperated by ,\n>") new_names = new_names.replace(" ","").split(",") print(new_names) with open(p, mode='a+', newline='') as score_file: data = {"Name" : new_names, "Score"...
466de4535f54e8a8b301ab056820a86ca110fee5
robinroyer/trilateration
/trilateration/model/circle.py
4,029
3.5625
4
import math import pyproj from sympy import Symbol from sympy.solvers import solve from point import point from ..utils.utils import is_number from projection import projection class circle: """Reprensation of a geographic circle""" def __init__(self, a_point, radius): """circle constructor A...
e34c6642b1f057049a559a3783d8434d904dcace
blueboy1593/KAKAO_problem_solving
/2020_KAKAO_BLIND_RECRUITMENT/괄호변환.py
1,915
3.5
4
# 문제 이해하는게 넘 짜증나! # 재귀 함수가 꼭 들어가야 하는구나. # 재귀 함수는 return이 안먹히는데??? # 1. 입력이 빈 문자열인 경우, 빈 문자열을 반환합니다. 이거 괜히 준게 아니고, 재귀에서도 return 먹히기는 하네.... def arrange(u): if len(u) == 2: return '' else: uu = '' for i in range(1, len(u) - 1): if u[i] == '(': uu += ')' ...
cbcb4462cfeef766da4171122f8685d2590bd27b
blueboy1593/KAKAO_problem_solving
/2018_KAKAO_BLIND_RECRUITMENT/다트게임.py
1,476
3.515625
4
def solution(dartResult): answer = 0 score_list = [0] * 4 stack_list = [] # stack = ['', '', ''] num = '' for i in range(len(dartResult)): if dartResult[i] == "S" or dartResult[i] == "D" or dartResult[i] == "T": if i != len(dartResult) - 1: if dartResult[i + 1...
53261c105ebb6551e5e3a0072d952a67da1d63d6
poofplonker/EffectivePython
/Chapter1/lesson_six.py
1,668
4.15625
4
""" Lesson Six: Don't use start, end and slice in a single Slice """ from itertools import islice A = list(range(10)) #We can use the slice stride syntax like this: print("Even: ", A[::2]) print("Odds: ", A[1::2]) # Seems good right? The problem is that :: can introduce bugs. # Here's a cool idiom for reversing a s...
8ba0e38741e1eed3936a87a07060012c14014b97
Takahiro800/Atcoder1
/ABC/A/160A.py
99
3.546875
4
S = input() m = list(S) ans = 'No' if (m[2] == m[3]) and (m[4] == m[5]): ans = 'Yes' print(ans)
a1669ef01aac3ba786b305940c8d7ca87fae532e
mypluribus/pyrecon
/kml.py
2,583
3.5
4
#!/usr/bin/env python class Args(object): ## ## Argument parser ## import argparse parser = argparse.ArgumentParser(description='Use Python to write a KML file for Google Earth') parser.add_argument( '--geodata', '-g', '-geodata', metavar='[GEODATA]', dest='geodata', ...
16120385f8acc2190763232c1fee4532b5b58826
rafiwibawa/Online-Test
/Q12.py
189
3.71875
4
a = 5 s = a - 1 # for spaces for i in range(0, a): for j in range(0, s): print(' ', end='') s -= 1 for j in range(0, i + 1): print('* ', end='') print('')
389800dcc03c05a7a89522153ca2599f9fc75427
riniguez91/year-13
/recursion.py
562
3.828125
4
'''def fibonacci(x): if x == 1 or x ==2: return 1 return fibonacci(x-1) + fibonacci(x-2) for i in range(1,20): print(fibonacci(i))''' def explode(word): if len(word) <= 1: return word else: return (word[0] + " " + explode(word[1:])) def removeDups(word): ...
9558e35fbdf794b385bf130fd77badc1fa414f1c
Maxzolythus/Old-Work
/S_C.py
2,162
3.953125
4
import random # instead of using an if/then tree, first we store the damage range # of all the weapons in the game WEAPONS = {'stick': (3, 10), None:(1,8), 'knife':(4,16)} #and instead of tracking inventory with one variable, have a 'player' who # has stuff in a dictionary: player = {'weapon':None, 'health': None} ...
a3738846c3e15be385892bc707f29490970b9c76
mafiaboy007/Python
/password_generator.py
317
3.9375
4
import random import string n = int(input("Enter the length of the password : ")) def generate(n): password = '' for i in range(n): password += random.choice(string.ascii_letters) password += str(random.randint(0, 10)) if len(password) == n: break else: continue return password print(generate(n))
c7ab2e6cf0a3372fc818dc860011cd24f3b90574
Faraday1221/project_euler
/problem_2.py
851
3.828125
4
#Each new term in the Fibonacci sequence is generated by adding the previous two #terms. By starting with 1 and 2, the first 10 terms will be: # #1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... # #By considering the terms in the Fibonacci sequence whose values do not exceed #four million, find the sum of the even-valued terms...
6d4a38c8d0b9ed597267edfe52dd5590f1b00cc9
dina2050/exo_python
/test.py
4,738
3.6875
4
# n=5 # x=4 # y=0 # spaces="" # stars="*" # for i in range(n): # for j in range (x, x-1): # for k in range (y,2*y+1): # print("/n"+"stars"+"spaces") # n=5 # stars=" " # for i in range(n): # for nb_spaces in range(n-i-1): # stars+=" " # for nb_stars in ran...
8ccc3fa469cb3870eacf04f86d92476e1f233db5
BoobeshP/turtle-projects
/turtle p05 (stars).py
390
3.5
4
import turtle as t a = t.Turtle() a.getscreen().bgcolor("black") a.penup() a.goto(-200,50) a.pendown() a.hideturtle() a.color("orange") a.speed(0) def star(t,size): if size <=10: return else: for i in range(5): t.begin_fill() t.forward(size) star(t,size/3) ...
d92a59a2e3c2804a4dc6f805decd935a886b83d3
GeorgeYan/op_py
/unicode.py
175
3.578125
4
#-*-coding:utf-8-*- import sys def Main(): print u"我是啦啦啦" unicode = u"我" str="我" print len(unicode),len(str) if __name__=="__main__": Main()
d7c7217a1ce1d50f493ac86eea040675f43d0ad1
agrisjakob/QA-Academy-Work
/Python/Python Exercises and Tasks/Grade calculator.py
1,242
4.40625
4
# Challenge # • Create an application which asks the user for an input for a maths mark, a chemistry mark and a physics mark. # • Add the marks together, then work out the overall percentage. And print it out to the screen. # • If the percentage is below 40%, print “You failed” # • If the percentage is 40% or higher, ...
44eb170b6d830bf90a31235b9c87d074de5950ee
agrisjakob/QA-Academy-Work
/Python/Python Exercises and Tasks/Challenge of the day/Flask challenge one.py
463
3.84375
4
#CHALLENGE OF THE DAY #Write a FUNCTION which takes an integer input, a, and returns the sum a+aa+aaa+aaaa. #So if 2 was the input, the function should return 2+22+222+2222 which is 2468. #three(9) → 11106 #three(5) → 6170 def three(i): String = str(i) first = int(String) second = int(String * 2) ...
d5e0bc68bec0dbf66648682e73df4bef5125e1de
bjmcminn/udacity
/mapreduce_data_count_mapperreducer_mtadata.py
5,157
3.625
4
import logging import sys import string import re # Commented for debugging #from util import logfile #logging.basicConfig(filename=logfile, format='%(message)s', #level=logging.INFO, filemode='w') def mapper(): """ The input to this mapper will be the final Subway-MTA dataset, the same as ...
15cf1a78714ef26a68d9218e6e5fcfd2ab9117d5
1Mi2Nombre3/LAB-111-Tarea2
/Ejercicio1.py
993
4.03125
4
print("***********") print("Ejercicio 1") print("***********") print("") print ("¿Cuanto tiempo debo estudiar para un examen?") print ("") X = int (input("Ingrese un tiempo en SEGUNDOS: ")) print("") print("¿Cuanto tiempo durara el examen?, en horas, minutos y segundos.") print("Ingrese un tiempo en segund...
c0cff429b41131a60c3a1fbcbc21c6fa78c38a89
iamsunrise/algorithm
/singLinkList.py
1,689
3.90625
4
class Node(object): def __init__(self,item): self.next = None self.item = item class SingLinkList(object): def __init__(self,item=None): if item != None: node = Node(item) self.__head = node else: self.__head = item def isEmpty(self): ...
6fd9ed723fc4d4aba0b52325a8506cf6c138e8b0
vitormrts/uri-online-judge
/strings/1024.py
518
3.90625
4
def criptografia(string): msg1 = "" for char in string: if char.isalpha(): msg1 += chr(ord(char) + 3) else: msg1 += char msg1 = msg1[::-1] meio = int(len(msg1)/2) primeira_metade = msg1[:meio] segunda_metade = msg1[meio:] msg2 = "" for char in segu...
0b62c1d2f1a1625d9166349db4c44e3444541ec9
BUNYODBEK-RASULOV/while_yechimlari
/while_7.py
106
3.78125
4
# 7-topshiriq n = int(input("N sonini kiriting:")) i=1 while(i**2<n): i=i+1 else: print(i)
ced0cecc6d5b07a080158f90415fcc4a0d5524b5
BUNYODBEK-RASULOV/while_yechimlari
/while_2.py
165
3.84375
4
# 2-topshiriq a = float(input("A sonini kiriting:")) b = float(input("B sonini kiriting:")) i=0 while (a - b > 0): i=i+1 a = a - b else: print(i)
ca9b75d544748d4af11132b84c70d2940e7341f8
ArslanAhmad117/CALCULATOR
/main.py
366
4.25
4
int_1 = int(input("ENTER THE FRIST NUMBER")) int_2 = int(input("ENTER THE SECOND NUMBER")) operator = str(input("ENTER THE OPERATOR")) if operator == '+': print (int_1 + int_2) elif operator == '-': print (int_1 - int_2) elif operator == '*': print (int_1 * int_2) elif operator == '/': print (...
70d95f95fbc0cd01e8b4602d9c9ee7a4950fe847
lbarner/NationalParksMap
/src/park.py
452
3.578125
4
class Park: park_count = 0 park_list = [] def __init__(self, park_name, park_region, park_state, park_founded, park_id, park_visited): self.name = park_name self.region = park_region self.state = park_state self.founded = park_founded self.id = park_id self.park_visited = park_visited self.park_list....
a0909ccd877dbd4db33f1c32e965b68b3296aeb7
cubitussonis/WTAMU
/assignment2/program4_table_of_powers.py
1,029
4.15625
4
#! /usr/bin/env python3 #welcome message print("Table of Powers") choice = "y" while choice.lower() == "y": #user input - start number must be lower than stop number startNumber = int(input("\nStart number:\t")) stopNumber = int(input("Stop number:\t")) while startNumber >= stopNumber: ...
305faad0957f6d8092c4c4d3a099f2e6ef3ad338
cubitussonis/WTAMU
/assignment4/p5-2_guesses.py
1,574
4.21875
4
#!/usr/bin/env python3 import random def display_title(): print("Guess the number!") print() def get_limit(): limit = int(input("Enter the upper limit for the range of numbers: ")) # limit must be at least 2, otherwise the game makes no sens while limit < 2: print("Smallest po...
9c09a7aab92cfdd78fe11c24343d7307f5dbbea2
Samcfuchs/TicTacToe
/human.py
2,935
3.75
4
# Human Player program end from interface import * class Human: """interface for a human player""" def __init__(self, player, gameinstance): #super(Human, self).__init__() from interface import Game self.gameinstance = gameinstance self.keymap = [7,8,9,4,5,6,1,2,3] # matches num...
4ffb1dddd70573ec953a7d1f10fd556d68ad696f
jchurtado112/Lab_7
/lab7.py
3,002
4.1875
4
#Jesus Hurtado, Lab 7 Option A, CS 2302 Data Structures, Fall 2018 #Implement the dynamic-programming algorithm edit distance and test your results # Method to edit matrix and get number of changes needed to convert one word to another one def edit_list(s1,s2): l1 = len(s1) l2 = len(s2) matrix...
1baa0ee553afac35416b6a673b3f88645b10ef22
tanetch/CP3-Tanet-Chanthsithiporn
/Exercise8_Tanet_C.py
991
3.765625
4
username = "admin" password = "0000" UserInputUsername = input("Username: ") UserInputPassword = input("Password: ") if UserInputUsername == username and UserInputPassword == password: print("Log in completed") print("Service List") print("1. One-side document printing 0.5 THB per page") print("...
f4216b05170c13a8363ebe7ad5f37dc2cf23563b
karans5004/Python_Basics
/ClassesAndObjects.py
2,400
4.875
5
""" # Python3 program to # demonstrate instantiating # a class class Dog: # A simple class # attribute attr1 = "mammal" attr2 = "dog" # A sample method def fun(self): print("I'm a", self.attr1) print("I'm a", self.attr2) # Driver code # Object instantiation Rodger ...
f0511f12ac8b02f306d5b5f2a5eac9d26d53528e
karans5004/Python_Basics
/day1_solution3.py
600
4.25
4
# Python3 Program to check whether a # given key already exists in a dictionary. # Function to print sum def checkKey(dict, key): if key in dict.keys(): return 1 else: return 0 # Driver Code dict = {'a': 100, 'b':200, 'c':300} key = input('Please Enter the Key : ') flag = checkK...
3df6ef4c4be687872ea8f2bb323fd81700ca5f2c
karans5004/Python_Basics
/AnonymousFunctions.py
2,108
4.75
5
""" In Python, anonymous function means that a function is without a name. As we already know that def keyword is used to define the normal functions and the lambda keyword is used to create anonymous functions. It has the following syntax: Syntax lambda arguments : expression This function can have any number o...
2cab37c7bc314d5554dccc18108d8aa9a0a39e96
yuannanchuan/yuannanchuan
/day-3/列表.py
1,840
3.78125
4
# -*- coding:utf-8 -*- """ @author:luomi @file: 列表.py @date: 2021/01/09 17:18 """ """ 字符串:str 列表:list [] """ #空列表 list_empty = [] #非空列表. 成员.每个成员之间用逗号隔开 #成员可以是任意类型 #可以重复 #列表是有序的,可以通过索引取值 list_py37 = ["小李子","小豆子","小楠楠","明明","天天","小李子"] py37_teacher = ["简神"] py37_listsss = [111,222,[6666,7777]] #取值. - 下标取值.列表名[下标] 下标...
0f9b6ae3a638e3998491c65652d67d620b477a18
yuannanchuan/yuannanchuan
/作业作业/类和对象的作业.py
3,768
4.21875
4
""" 2021 - 0127 - 类和对象1 1、实例属性怎么定义? self.属性名 = 属性值 2、实例方法中的self代表什么?(简答) 代表对象 3、类中__init__方法在什么时候会调用的?(简答) 实例化对象的时候调用 """ """ 5、封装一个学生类Student,(自行分辨定义为类属性还是实例属性,方法定义为实例方法) - - 属性:身份(学生),姓名,年龄,性别,英语成绩,数学成绩,语文成绩, - 方法一:计算总分, - 方法二:计算三科平均分 - 方法三:打印学生的个人信息:我的名字叫XXX,年龄:xxx,性别:xxx。 请定义此类,并实例...
1a3315479a6035c1f48d078c1aed44073d931059
yuannanchuan/yuannanchuan
/day10/多种异常处理.py
500
3.640625
4
num = input("请输入一个数字") try: res = 100 / int(num) except: # tey里面的语句报错了 # 你抓到了异常,你自己额外添加的处理 print("输入内容有误,请输入非0的数字!不能输入0或者其他非数字") # 你处理完了后,把错误又抛出给python解释器 raise """ except ValueError as e: print("输入有误,请输入数字类类型!") print(e) except Exception as e: print("其它未知错误") print(e) """ ...
5d12ffe898528702ff61774d877e43ab68850777
yuannanchuan/yuannanchuan
/day15/执行日志.py
2,529
3.875
4
""" 第4题 :定义类并实例化对象 定义一个登录的测试用例类LoginCase。每一个实例对象都是一个登陆测试用例。 属性:用例名称 预期结果 实际结果(初始化时不确定值哦) 方法: 1) 运行用例 说明:有2个参数:用户名和密码。 能够登录成功的用户名:py37, 密码:666666。 通过用户名和密码正确与否来判断,是否登录成功。并返回实际结果。 ps: 可以在用例内部考虑处理不符合的情况哦:密码长度不是6位/密码不正确/用户名不正确等。。 2) 获取用例比对结果(比对预期结果和实际结果是否相等,并输出成功or失败) 实例化2个测试用例 ,...
cd845ab8d2924deeb2020861807aefc51dc30022
santiagozdw/git-learning-task
/Zadanie2.py
243
3.890625
4
print("Zadanie2") a = [] cubed = [] squared = [] for i in range(100): if i % 5 == 0: a.append(i) cubed = [number * number * number for number in a] squared = [number * number for number in a] print(a) print(squared) print(cubed)
80ff50b57c049b7761f1673f0610f5d3a69e1d0e
NAisaac/movieTrailers
/1break_time.py
485
3.6875
4
import time import webbrowser ### This program opens up a URL every 2 hours from the start of the program; 3 times in total total_breaks = 3 break_count = 0 # ctime gives us the current time print ("This program started on " + time.ctime() + "and will run every 2 hrs") while (break_count < total_break): # sleep p...
3caf7582c08abd8f8a8b7141b8bb14181226b564
jtdykstra/interviews
/python-trees.py
1,749
3.953125
4
class TreeNode: def __init__(self, data, left=None, right=None): self.left = left self.right = right self.data = data self.col = 0 self.row = 0 # constructing the tree (bottom up) """ 0 / \ 1 2 / \ / \ 3 4 5 6 """ six = TreeNode(data=6) five = Tr...
0add3d75735397e008ddce6dc18c04990428fab1
Cobraderas/LearnPython
/PythonGround/PythonIterators.py
1,880
4.71875
5
# an iterator is an object which implements the iterator protocol, which consists of the methods __iter__() # and __next__() # return an iterator from tuple, and print each value mytuple = ("apple", "banana", "cherry") myit = iter(mytuple) print(next(myit)) print(next(myit)) print(next(myit)) print(" ") mystr = "b...
87639ce4dc7891b3b325ec2c5a331c5addf1defb
Cobraderas/LearnPython
/PythonGround/DateTime.py
516
4.25
4
import datetime x = datetime.datetime.now() print(x) print(x.year) print(x.strftime("%A")) # create date object x = datetime.datetime(2020, 5, 17) print(x) # The datetime object has a method for formatting date objects into readable strings. # The method is called strftime(), and takes one parameter, format, to spec...
51fb77dbf567d4b9298d031fa3acbe0277948c85
Cobraderas/LearnPython
/PythonGround/SelectorLearn.py
676
3.625
4
from selenium import webdriver from selenium.webdriver.common.by import By # from time import sleep driver = webdriver.Chrome() driver.get("https://google.com") # get the element by selector and pass some text driver.find_element(By.NAME, "q").send_keys("books") # get the element and print the selected value print(d...
69f7f0a255d2471ea0c8c5ea676cc0b88f372489
Cobraderas/LearnPython
/PythonGround/FileInputOutput.py
1,880
3.921875
4
# my_list = [i ** 2 for i in range(1, 11)] # # Generates a list of squares of the numbers 1 - 10 # # f = open("demofile.txt", "w") # # for item in my_list: # f.write(str(item) + "\n") # # f.close() # pass "r+" as a second argument to the function so the file will allow you to read and write to it # my_file = open...
8939d31d2482b8c79659770d9151fcb2abb02505
txd283/FeCu-Irradiation-KMCLib
/UsefulCode/convertToCFG.py
2,332
3.5
4
# Author = Thomas Davis, email = txd283@bham.ac.uk / University of Birmingham # This is used to convert the lattice output files to CFG files for atomeye # visualistion. to run the code, you need to paste it at the end of the lattice # output. A method could be 'cat convertToCFG.py >> results1.py' then 'python results...
9a70c889996df5d8a933151c519468b864b28f47
waSclthu11/Platformer
/platformer.py
6,663
3.609375
4
""" platformer.py Author:waSclthu11 Credit:The example platformer program helped a lot, especially with subclasses, which I used for the terrain. Also Mr.Dennison helped with the collision detection setup. Assignment: Write and submit a program that implements the sandbox platformer game: https://github.com/HHS-IntroPr...
85f9e98409349733eee5cd9b09280db4f2bf08fe
nkostopoulos/bloom_filters
/locality_sensitive_bf/string_to_vector_converters/unigram_version.py
2,041
3.921875
4
import string import sys def get_dictionary_of_character_order(): ''' Returns the dictionary with the order of letters and digits, e.g. a is 0, b is 1, .... , z is 25, 0 is 26, 1 is 27, 9 is 35 ''' character_order_dict = dict() letter_list = string.ascii_lowercase digit_list = '0123456789-\\' concatenated_list...
4db9d27bcc2df09e40488a7a2d7eb61e6b26d0b7
afakharany93/haker_rank_statistics
/day6/TheCentralLimitTheoremIII.py
1,339
3.515625
4
import math def standard_normal_distribution(x): return math.exp(-x**2 / 2) / math.sqrt(2*math.pi) def normal_distribution(x, mean, std): return standard_normal_distribution((x-mean)/std)/std def cumulative_distribution(x, mean, std): erf_value = math.erf((x-mean)/(std*math.sqrt(2))) return 0.5*(1+er...
1f047dd01d65f3cfb94f4575ce788bf433399a5b
afakharany93/haker_rank_statistics
/day4_geometric_distribution/geometric_distribution_II.py
249
3.640625
4
def geo_prop(n , p): q = 1-p return q**(n-1) * p if __name__ == "__main__": p1,p2 = map(float, (input()).split()) p = p1/p2 n = int(input()) prop = map( lambda y : geo_prop(y,p), range(1,n+1)) print(round(sum(prop),3))
4982f25d82bbeb53ed86183e2ec0644205a635e7
neerajjadhav3012/Programming
/Core_Algorithms/PythonArrayPairSum.py
1,096
4.03125
4
# coding: utf-8 # # Array Pair Sum # # ## Problem # # Given an integer array, output all the ** *unique* ** pairs that sum up to a specific value **k**. # # So the input: # # pair_sum([1,3,2,2],4) # # would return **2** pairs: # # (1,3) # (2,2) # # **NOTE: FOR TESTING PURPOSES CHANGE YOUR FUN...
b342ae16da9828bbaadfe22d0f919434439d2748
K4153RR/CrackingTheCodingInterview-Python
/ch2_linked_lists.py
6,817
3.828125
4
from data_strucutre.LinkedList import Node def remove_dups(linked_list): """ Remove duplicates of a linked list """ cur = linked_list if not cur: return None visited = set() visited.add(cur.data) while cur and cur.nextNode: if cur.nextNode.data in visited: c...
92cdf86cd0ebb461b80b57585955618cd57fe996
hkalipaksi/pyton
/week 2/if.py
145
3.984375
4
age=input("how old are you?:") if age>10: print("you are too old") elif age==10: print("print you are good") else: print("you are good")
2cd527c7d49f709d2f77161eb14abf973438ef52
hkalipaksi/pyton
/week 10/functionhello.py
477
3.796875
4
def say_name (name) : print name say_name("alvian") def say_name (name) : print "hello {}".format (name) say_name ("haekal") def say_name_age (name,age) : print "hello my name is {}, I am {} years old".format (name,age) say_name_age ("acid",11) def say_name_age_haha (name,age) : print "hello my name is {}, I...
eeb2b2dcee223e8b7808fd88f3c59c01093c3cd9
hkalipaksi/pyton
/week 1/hello_word.py
525
4.125
4
#mencetak string print("hello word") #mencetak angka print(90) #mencetak contanse string "1"+"2" hasilnya 12 print("1"+"2") #mencetak contanse string "hello"+"word" hasilnya 12 print("hello"+"word") #mencetak angka hasil perjumlahan hasil yang dicetak 3 print(1+3) #deklarasi variabel dengan nama var var=12 #Perka...
14346136e7119326a97dda86e47bdcbd35aa4cf5
bardia-p/Raspberry-Pi-Projects
/button.py
923
4.1875
4
''' A program demonstrating how to use a button ''' import RPi.GPIO as GPIO import time import lcd_i2c PIN = 25 #Setup and initialization functions of the LCD def printLCD(string1, string2): lcd_i2c.printer(string1, string2) def setup(): lcd_i2c.lcd_init() #General GPIO Setup GPIO.setmode(GPIO.BCM) #sets h...
c50b74478bd6825be211645150644742e7c087d8
devil19960106/leetCode
/恢复空格(动态规划+字典树)/respace.py
2,418
3.78125
4
# 题目描述 # 哦,不!你不小心把一个长篇文章中的空格、标点都删掉了,并且大写也弄成了小写。像句子 # "I reset the computer. It still didn’t boot!"已经变成了"iresetthecomputeritstilldidntboot"。在处理标点符号和大小写之前, # 你得先把它断成词语。当然了,你有一本厚厚的词典dictionary,不过,有些词没在词典里。假设文章用sentence表示,设计一个算法, # 把文章断开,要求未识别的字符最少,返回未识别的字符数。 # 注意:本题相对原题稍作改动,只需返回未识别的字符数 # # 示例: # 输入: # dictionary = ["looke...
8a967d9f204fc75292e8c8d8f96e19d5b0f89407
GaloisInc/SocialCyberLAGOON
/lagoon/ingest/python_peps/peps.py
6,174
3.515625
4
import os import csv from tqdm import tqdm import requests from bs4 import BeautifulSoup from typing import Dict, Any def get_soup(url: str) -> BeautifulSoup: """ Get the BeautifulSoup scrape of a URL """ return BeautifulSoup(requests.get(url).content, "html.parser") def get_authors() -> Dict[str,Dict[str,A...
4709f448799e74a87e36271ea994a8163e01e10d
jonah-chen/csc180
/lab6/ttt.py
4,535
4.15625
4
''' X | O | X ---+---+--- O | O | X ---+---+--- | X | ''' import random def print_board_and_legend(board): for i in range(3): line1 = " " + board[i][0] + " | " + board[i][1] + " | " + board[i][2] line2 = " " + str(3*i+1) + " | " + str(3*i+2) + " | " + str(3*i+3) print(line1 + "...
a7c2d7dd96f89664e1953be9fbfbb8ee0040df59
jonah-chen/csc180
/project2/debug.py
712
3.5625
4
'''Debugger and Helper functions for the Project''' import numpy as np # from gomoku import print_board def random_board(shape, bad=False): board = np.random.randint(-1,2,size=shape) if bad: return convert_good_to_bad_board(board) return board def convert_good_to_bad_board(good_board): bad_...
1e5fe7df6ceb195394019434bbdb9f620ddfa311
VisargD/Problem-Solving
/Day-13/(Using Set) Find-All-Numbers-Disappeared-in-an-Array.py
1,797
3.640625
4
""" Problem Name: Find All Numbers Disappeared in an Array Platform: Leetcode Difficulty: Easy Problem Link: https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/ """ """ APPROACH: The problem states that a list containes value ranging from 1 to length but few are repeating twice, once or are not p...
af60ea8239d8ec4755cd6ffafcfd76753c2f4590
VisargD/Problem-Solving
/Day-10/(3-Way Partitioning) Sort-Colors.py
2,748
4.25
4
""" Problem Name: Sort Colors Platform: Leetcode Difficulty: Medium Platform Link: https://leetcode.com/problems/sort-colors/ """ """ APPROACH: In this approach, 3 pointers will be used. Initially zero_index will point to the first index (beginning) of list and two_index will point to the last index (end). In order to...
bf9f8b7f32eaa867f56de4c9058afd8b76438b6c
VisargD/Problem-Solving
/Day-3/Path-Crossing.py
1,499
4.09375
4
""" Problem Name: Path Crossing Platform: Leetcode Difficulty: Easy Problem Link: https://leetcode.com/problems/path-crossing/ """ class Solution: def isPathCrossing(self, path: str) -> bool: # Create a dictionary with origin (0, 0) as a key and its occurence (initially 1) as its value. # x and y...
2395629f32eaef96379ab69e48377af1a0402b3a
VisargD/Problem-Solving
/Day-4/Find-First-and-Last-Position-of-Element-in-Sorted-Array.py
1,933
3.546875
4
""" Problem Name: Find First and Last Position of Element in Sorted Array Platform: Leetcode Difficulty: Medium Problem Link: https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/ """ class Solution: def searchRange(self, nums: List[int], target: int) -> List[int]: # Init...
27a11144792d78850583c4bebbd8bd4c2c6b38c8
VisargD/Problem-Solving
/Day-11/Longest-Common-Prefix.py
2,183
3.953125
4
""" Problem Name: Longest Common Prefix Platform: Leetcode Difficulty: Easy Problem Link: https://leetcode.com/problems/longest-common-prefix/ """ """ APPROACH: Initially, longest common prefix is the first word of the list. Then second word is compared with 'common' character-by-character. 'common' is updated with o...
9f68c5b9401f37c3f7940128453f58553dd3cb68
Jonathan-Walsh/PokemonDataToCSV
/cleanUpEvoList.py
1,811
3.671875
4
"""Purpose: Converts a table I grabbed from a Pokemon wiki and put in an excel file to a csv with a cleaner format""" """Output: csv file with two columns: Pokemon A, Pokemon A's evolution(s)""" """ The output csv contains a row for every single pokemon that has one or more evolution""" """ The second co...
fb163e0d9d66defdc5be489c432da4c9c7459bc8
tolgagolbasi/HomeworkCENG
/algorithm analysis/timeit Presentation-Buket/fibRepeater.py
824
4.1875
4
from timeit import Timer #Iterative method def fibIter(n): if n<=2: return 1 else: a,b,i=1,1,3 while i<=n: a,b=b,a+b i+=1 return b # Recursive method def fibRec(n): if n<=2: return 1 else: return fibRec(n-2)+fibRe...
534797aa4dce5932cf15329917d1335ea6083f51
AndSonder/game2048
/bll.py
5,877
3.546875
4
""" 游戏逻辑控制器,负责处理游戏核心算法. """ from model import DirectionModel from model import Location import random class GameCoreController: def __init__(self): self.__list_merge = None self.__map = [ [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], ...
a25ccc84bb4496d53164e437523d7b0a4243e3f2
CodeMechanix/Grooming-Python
/library_function.py
278
3.546875
4
from math import sqrt, floor, ceil num1 = 10 num2 = 5 print(max(num1, num2)) # 10 print(min(num1, num2)) # 5 print(abs(-num1)) # 10 print(pow(num1, num2)) # 100000 print(sqrt(num1)) # 3.1622776601683795 print(round(3.8)) # 4 print(floor(3.7)) # 3 print(ceil(3.7)) # 4
94365085d60acf005a3da6580493232baf1decd9
CodeMechanix/Grooming-Python
/if_else_statement.py
234
3.9375
4
mark = 50 if mark >= 80: print("You Got A+") if 70 <= mark < 80: print("You Got A-") elif 60 <= mark < 70: print("You Got B") else: if 50 <= mark < 60: print("You Got C") else: print("You Failed")
ad4dbdf0181d62c6319bf0fb5431fafd6a269137
natnic17/basic_python
/lesson 1/task2.py
306
3.890625
4
time_sec = int(input('Введите время в секундах: ')) minutes = time_sec // 60 sec = time_sec % 60 if minutes < 60: hours = 0 print("%02d:%02d:%02d" % (hours, minutes, sec)) else: hours = minutes // 60 mins = minutes % 60 print("%02d:%02d:%02d" % (hours, mins, sec))
ef047d9fab947eae8cddb4c3a96bc5a9c17edbfd
tj3407/Python-Projects-2
/math_dojo.py
2,282
4.15625
4
import math class MathDojo(object): def __init__(self): self.result = 0 def add(self, arg, *args): # Check the type() of 1st argument # if tuple (which can be a list or another tuple), iterate through values if type(arg) == tuple or type(arg) == list: for i in arg: ...
4f99a99fdbbd57f388b9b7b5400e4202157b423d
tj3407/Python-Projects-2
/tutorial.py
453
3.75
4
class User(object): def __init__(self, name, email): self.name = name self.email = email self.logged = False user1 = User("Anna Propas", "anna@anna.com") print user1.name print user1.logged print user1.email def varargs(arg1, *args): print "Got "+arg1+" and "+ ", ".join(args) varargs("one...
fd4655ab34fb231a1b4773db6904f75f2ad15115
tj3407/Python-Projects-2
/hospital.py
2,110
3.78125
4
class Patient(object): def __init__(self, id, name, allergies): self.id = id self.name = name self.allergies = allergies self.bed_num = None class Hospital(object): def __init__(self, hospital_name, capacity): self.patients = [] self.hospital_name = hospital_name...
f1a385b720bb04b886e016cbfb947587f4f28464
adamhaney/pykell
/types.py
2,567
3.8125
4
class T(object): """ A pykell 'type' class. This is different from a python type in that it allows a type to be the union of multiple types and allows for data validation to be baked into the type. This allows us to create types for things like, 'even_positive_number' >>> even_positive_number ...
7ae69b6dc6b2940297fcb709f494250426944df0
jethridge13/Project-Euler-Python-Scripts
/89.py
516
3.515625
4
# Problem: Take the 89.txt file and see if it can be improved, counting the total number of characters saved. import functions import time start = time.time() chars = 0 f = open("89.txt", "r") for line in f: l = line[:len(line)-1] number = functions.numberFromRomanNumeral((l)) improved = functions.numberT...
1f15f8d8505b1d059c0c3b3560489a1f075f6369
jethridge13/Project-Euler-Python-Scripts
/17.py
619
3.875
4
# Count the number of letters from num2words import num2words import re import time def returnNumbersOnly(string): return re.sub('[^09a-zA-Z]+', '', string) def rangeForNumbers(start, end): sum = 0 for i in range(start, end + 1): sum += len(returnNumbersOnly(num2words(i))) return sum start =...
a1810e8b8423e6a3c078870f7d10655fd2b1c440
jethridge13/Project-Euler-Python-Scripts
/21.py
1,027
3.75
4
# The sum of all amicable numbers under 10000 import time import functions def isAmicable(n): divisors = functions.getDivisors(n) if len(divisors) > 0: divisors.remove(max(divisors)) dSum = sum(divisors) sumDivisors = functions.getDivisors(dSum) if len(sumDivisors) > 0: sumDivisors...
7984cd6cdfa0538ea698d5a88431760f7fea9ab7
liuyuan0627/LeetCode
/python/500_keyboard_row.py
501
3.703125
4
class Solution(object): def findWords(self, words): """ :type words: List[str] :rtype: List[str] """ letters = ['qwertyuiop', 'asdfghjkl', 'zxcvbnm'] result = [] for word in words: w = set(word.lower()) if w.issubset(letters[0]) or w.is...
3e3cd7196e617b13fc28175678ec43baee4d941f
janaki-rk/silver_train
/Coding Challenge-5.py
766
4.4375
4
# DAILY CODING CHALLENGE 5 # Question asked by:JANE STREET # cons(a, b) constructs a pair, and car(pair) and cdr(pair) returns the first and last element of that pair. For # example, car(cons(3, 4)) returns 3, and cdr(cons(3, 4)) returns 4.Implement car and cdr. # Step 1: Defining the already implemented cons functio...
b84172daef6244d23a57e2b64bcc9b5094fdc069
janaki-rk/silver_train
/Coding Challenge_15.py
637
3.90625
4
# DAILY CODING CHALLENGE 15 # Question asked by: FACEBOOK # Given a stream of elements too large to store in memory, pick a random element from the stream with uniform # probability. # Importing the necessary libraries import random # Step 1: Solving using Loop variants def stream_elements(big_stream): random_el...
886dff703a512ddee03210bb0d14d922b315e314
janaki-rk/silver_train
/Coding Challenge_14.py
1,319
4.28125
4
# DAILY CODING CHALLENGE 14 # Question asked by: GOOGLE # The area of a circle is defined as πr^2. Estimate π to 3 decimal places using a Monte Carlo method. from random import uniform from math import pow # Step1: Solving the area of the circle with detailed descriptions # 1--Set r to be 1 (the unit circle) # 2--Ra...
4e57c084d3a6812abab1039af460194f16e92a3e
fatfox2016/LearnTensorFlow
/ex/ex21.py
648
4.0625
4
def add(a,b): print "ADDING %d + %d" % (a,b) return a + b def subtract(a,b): print "SUBTRACTING %d - %d" % (a,b) return a - b def multiply(a,b): print "MULTIPLYING %d * %d" % (a,b) return a * b def divide(a,b): print "DIVIDING %d / %d" % (a,b) return a / b print "Let's do some math with just functions!" age = a...
fc722f9bda1d16a50d13df0e5675b76cf33c1230
Roger-Coelho/Algoritmos-de-Ordenacao
/insertionsort.py
296
3.640625
4
a = [25,32,2,15,98,31,77,56,32,1,6] #Array não ordenado print(a) #Insertionsort for j in range(1,len(a)): chave = a[j] i = j - 1 while i >= 0 and a[i] > chave: a[i + 1] = a[i] i = i -1 a[i + 1] = chave #Array ordenado pelo Insertionsort print(a)
7447b4062cb25f60ecbf73d8c0f2208277b247d4
hoyasmh/PS
/boj/04001-05000/4072.py
88
3.734375
4
s=input() while s!='#': print(' '.join([i[::-1] for i in s.split()])) s=input()
9da4aed5e5b593a525ee11e806e5de8150291d7b
hoyasmh/PS
/boj/09001-10000/9095.py
182
3.796875
4
for i in range(int(input())): n=int(input()) if n<3: print(n) else: a,b,c=1,2,4 for i in range(n-3): a,b,c=b,c,a+b+c print(c)
fe20ef8753f474edabbc0428cab4a55cdfaf2235
DaniloCoelho/estudos-python
/guarde 5 num numa lista e mostre o maior menor e sua posiçao.py
766
3.90625
4
#Faça um programa que leia 5 valores numéricos e guarde-os em uma lista. No final, mostre qual foi o maior e o menor valor digitado e as suas respectivas posições na lista. numeros = [] menor = 0 maior = 0 count = 0 for i in range(0,5): numeros.append(int(input(f'digite um numero na posição {i} '))) if i == 0...
3a1bdcfaf10a41fa4b172c7de7195a061f2aa26c
DaniloCoelho/estudos-python
/lotofacil 5.py
1,059
3.59375
4
jogo1 = [1,2,4,5,6,7,9,10,11,13,15,16,17,21,25] jogo2 = [3,4,8,10,11,12,14,17,18,19,20,22,23,24,25] s1 = 0 s2 = 2 valor1 = 0 valor2 = 0 print('Lotofácil') print() entrada = input() sorteado = [] if len(entrada)>15: #tratar string, tirar espaços list = entrada.split() entrada = ''.join(list)# juntar lista em u...
a3f0f2c5765d945bcca93af2ab7a73a388bb03f2
DaniloCoelho/estudos-python
/numero primo.py
289
3.9375
4
num = int(input('digite um numero ')) nprimo = 0 for i in range(1,num+1): if num % i == 0 and num != i and i != 1: nprimo = nprimo +1 if not nprimo >0: print('numero primo') else: print('nao é primo')
0aab1637a3359841b5e4751a33770ed5b4a860a2
DaniloCoelho/estudos-python
/bin octa hexa tradicional.py
441
3.96875
4
num = int(input('digite um número ')) print('1》binário , 2》octal , 3》hexadecimal') bin = [] escolha = input('') if escolha == 'a': while num > 0: bin.insert(0 , int((num % 2))) num = num // 2 else: bin2 = ''.join(bin) print('em binário é ', bin2) elif escolha == 2: ...
ef4476074d9c3dcfe6e78e004f1a4d87fc4edf48
DaniloCoelho/estudos-python
/ler num , separar em num , par e impar.py
875
3.890625
4
#082: Crie um programa que vai ler vários números e colocar em uma lista. Depois disso, crie duas listas extras que vão conter apenas os valores pares e os valores ímpares digitados, respectivamente. Ao final, mostre o conteúdo das três listas geradas. num = [] par = [] impar = [] esc = 'S' while True: n = int(inp...
abf5e5b82f715bf408200e0b41d3f07be8eeeafd
mishaaggarwal15/Business_Analytics
/multiple_linear_regression.py
1,649
3.9375
4
#Multiple Regression # Importing the libraries import pandas as pd import seaborn as sns # Importing the dataset dataset = pd.read_csv('/Users/mishaaggarwal/Downloads/stud_reg_2.csv') print(type(dataset)) #Data Visualization: sns.heatmap(dataset) X = dataset.iloc[:, :-1].values y = dataset.iloc[:,2].values # Split...
4e7ed816694e5d0efdfdf47bbc01dca67be9d15a
krishnanand2000/app-exc.-6
/app exp 6/6.3.py
701
3.71875
4
import sqlite3 as sql con = sql.connect('mydb_ms.db') def database(con): csr = con.cursor() csr.execute("CREATE TABLE tble(id num , name varchar , year int)") csr.execute("INSERT INTO tble VALUES(1,'Krishnanand', '2a')") csr.execute("INSERT INTO tble VALUES(2,'mohit', '1a')") csr.execute("...
397215517ee3911ee6cf5d633c35c238ed931715
alexprengere/euler
/001/main.py
323
4.03125
4
#!/usr/bin/env python """ $ python main.py 1000 233168 """ import sys def is_divisible(i, args): """Returns True if i is divisible by any element of args""" return any(i % a == 0 for a in args) if __name__ == '__main__': n = int(sys.argv[1]) print(sum(i for i in range(n) if is_divisible(i, (3, 5))...
b96b73bcc657264a9d56c659c6cd0352ac6b6adf
alexprengere/euler
/010/main.py
396
3.90625
4
#!/usr/bin/env python """ $ python main.py 2000000 142913828922 """ import sys from math import sqrt def is_prime(p): return all(p % i != 0 for i in range(2, 1 + int(sqrt(p)))) def sum_primes(n): total = 2 for p in range(3, n + 1, 2): if is_prime(p): total += p return total i...
d55ba64d958c97fc5ec6948136d04bac5a109030
crodrigr/Fundamentos-Programaci-n
/ListaPalindroma.py
458
3.765625
4
def palindroma(l): sw=True tl=len(l) if tl%2==0: hasta=int(tl/2) else: hasta=int((tl-1)/2) for i in range(hasta): if l[i]!=l[(tl-1)-i] : sw=False break return sw cadena=input("Ingrese una cadena: ") cadena=list(cadena) temp=list(cadena) #print("L...
256cb06a3407866bd9bfff8469f9b16f276e6482
crodrigr/Fundamentos-Programaci-n
/Reto1.py
346
3.96875
4
print(" CALCULAR NOTA QUE NECESITA\n ") c1 =float(input(" - ingrese la nota del primer parcial: ")) c2 =float(input("\n - ingrese la nota del segundo parcial: ")) nl =float(input("\n - ingerse la nota de laboratorio: ")) nc=60-(nl*0.3) ca=(c1+c2) c3=((30*nc)-(7*ca))/7 print(("\n - Necesita Sacar"),c3,(" en el te...
34aae364bf7b3db0c38b6f048da2f06f0057335f
pedro-augustof/Python
/DIO/Resolvendo algoritmos com Python/fibonatti.py
726
3.890625
4
# A seguinte sequência de números 0 1 1 2 3 5 8 13 21... é conhecida como série de Fibonacci. Nessa sequência, cada número, depois dos 2 primeiros, é igual à soma dos 2 anteriores. Escreva um algoritmo que leia um inteiro N (N < 46) e mostre os N primeiros números dessa série. # Entrada # O arquivo de entrada contém u...
4fc072551f052b65b39afdbcb20599a57bdabf31
huang-jingwei/Coding-Interview-Guide
/chap2/09.复制含有随机指针节点的链表/09_copyRandomList.py
987
3.59375
4
# Definition for a Node. class Node: def __init__(self, x: int, next: 'Node' = None, random: 'Node' = None): self.val = int(x) self.next = next self.random = random class Solution: def copyRandomList(self, head: 'Node') -> 'Node': if head == None: # 输入节点是空节点,z直接返回空节点 ...
452ce066312900a82da61cde6fb70c135e9ecf75
huang-jingwei/Coding-Interview-Guide
/chap1/01.设计一个有getMin功能的栈/01_MinStack.py
992
3.859375
4
class MinStack: def __init__(self): self.stack=[] #初始化数据栈 self.minStack=[] #初始化最小数据栈,栈顶元素为数据栈的最小值 self.size=0 #记录栈中元素个数 def push(self, x: int) -> None: if self.size==0: self.minStack.append(x) else: curMin=self.minStack[-1] ...