blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
7712e0b53a669950304618dd62d634f00ce784dc
rht/housing-model
/src/main/resources/calibration/code/InitialSalePrice.py
6,563
4
4
# -*- coding: utf-8 -*- """ Class to study the initial ask price by households when they bring their properties to the market. It uses data from Katie Low's HPI and Zoopla data @author: daniel, Adrian Carro """ import Datasets as ds import matplotlib.pyplot as plt from datetime import datetime import numpy as np impo...
99e0f69cbf17c5a766c3e8d56d9f44e7e4fbbbf6
htsnet/Tic-Tac-Toe
/ticTacToe.py
3,855
3.90625
4
# -*- coding: utf-8 -*- """ Created on Thu May 28 14:25:04 2020 @author: hamil """ import random player = 0 board = [] sign = '' computer = 0 start = True def reset(): global board board = ['1', '2', '3', '4', '5', '6', '7', '8', '9', ] def printBoard()...
52e37e46a3c6e4a3e10fb3d16775c7713c21981a
e-safe/devlab-hw
/homework1/ex8.py
123
3.578125
4
# coding=utf-8 x = int(input("Часы ночью:")) y = int(input("Минуты днем:")) min = x * 60 print(y + min)
803ef8dbc472b058d4763abbd01eb266cb806448
daniel-reich/ubiquitous-fiesta
/KLke67efuam6ajLrt_16.py
419
3.515625
4
def shuffle_count(num): lst = list(range(1,num+1)) count = 0 new_list = [] pos = [i for i in range(len(lst)) if i%2!=0] while True: newlist = lst[:len(lst)//2] for i in range(len(pos)): newlist.insert(pos[i],lst[len(lst)//2:][i]) count+=1 if ...
4fa29ff8afd553c77003681c263f51b112f54751
riley-csp-2019-20/1-2-3-apple-avalanche-pickles12
/123.py
5,564
3.625
4
# a123_apple_1.py import turtle as trtl import time import random as rand apple_image = "apple.gif" # Store the file name of your shape ground_height = -200 apple_letter_x_offset = -25 apple_letter_y_offset = -50 screen_width = 400 screen_height = 400 letters = ["a","b","c","d","e","f","g","h","i","j","...
ece3a667858c47564a58c816984e116915447897
Qustomxyz/GeekBrainsPython
/Lesson1/task2.py
1,928
4.34375
4
# Задача: используя цикл запрашивайте у пользователя число пока оно не станет больше 0, но меньше 10. # После того, как пользователь введет корректное число, возведите его в степерь 2 и выведите на экран. # Например, пользователь вводит число 123, вы сообщаете ему, что число не верное, # и сообщаете об диапазоне допуст...
08e0baacc316f034b9fe4f24d1f4bb5a9674b454
CodeHemP/CAREER-TRACK-Data-Scientist-with-Python
/08_Introduction to Data Visualization with Matplotlib/03_Quantitative comparisons and statistical visualizations/05_Adding error-bars to a bar chart.py
1,408
4.375
4
''' 05 - Adding error-bars to a bar chart Statistical plotting techniques add quantitative information for comparisons into the visualization. For example, in this exercise, we will add error bars that quantify not only the difference in the means of the height of medalists in the 2016 Olympic Games, but also the s...
ae99a00f95caead528d797dfb3d7e71deed1b673
marcos1561/Q-Learning
/env.py
5,194
3.90625
4
import numpy as np class Maze(object): ''' Ambiente no qual o agente será treinado ''' def __init__(self): ''' self.agent_pos: np.Array Posição inicial do agente. O primeiro elemento informa a linha e o segundo a coluna do labirinto, em que o age...
dba5da4c78fb9e503821c2f15a63ae1692639e4a
ywcmaike/OJ_Implement_Python
/sort/shell_sort.py
703
4.0625
4
# -*- coding: utf-8 -*- # 不稳定 def shell_sort(lists): count = len(lists) step = 2 group = count // step while group > 0: for i in range(0, group): j = i + group while j < count: k = j - group; key = lists[j] while k >= 0: ...
560dbee2246b92dd16dde83d30f872cc18123200
15110500442/2017-python-
/day00/计算偶数的结果.py
169
3.546875
4
result1 = 0 result2 = 0 i = 0 while i <= 100: if i%2 == 1: print(i) result1 += i else: result2 += i print("和%d"%result1,result2)
03c8290e79ceaf4aa023cf961fab825cd4cf03d7
diegozencode/holbertonschool-higher_level_programming
/0x0B-python-input_output/0-read_file.py
288
4.25
4
#!/usr/bin/python3 """ Read file module """ def read_file(filename=""): """reads a text file and prints it to stdout Args: filename (string): file name """ with open(filename, encoding="utf-8") as fn: for line in fn: print(line, end="")
8704d419594478360cb15dc10fec204df30021d1
Anjanaanjujsrr/anju-s-codekata
/set 9e.py
97
3.640625
4
#anju string=input() num=len(string) print(string[::2],end=' ') print(string[1:num:2],end='')
dd2b013c1d7ca9ce86f39b179395274980a95fc9
lxconfig/UbuntuCode_bak
/algorithm/leetcode/dp/06-最小路径和.py
1,603
3.671875
4
""" 给定一个包含非负整数的 m x n 网格,请找出一条从左上角到右下角的路径,使得路径上的数字总和为最小。 """ class Solution: def minPathSum(self, grid: list) -> int: """动态规划-从左上角出发 dp[i][j]表示为了到达(i,j)位置,需要的最小路径和是多少 即:为了到达(i,j),只能是从其上面位置往下走,或者左边位置往右走 如:dp[1][1] = min(dp[0][1], dp[1][0]) + grid[1][1] 也就是...
3f27fbe7695b281a5a1bb47adba2f257977b4c08
NuradinAhmed/PyStudentManage-App
/PlurasightgettingStartedCourse_Exceptions.py
389
3.984375
4
student = { "Name": "Nuradin", "Student_Id": 12345, "feedback": None } student["last_name"] = "Ifrah" try: last_name = student["last_name"] numbered_lastname = last_name + 9# except KeyError: print("Error finding last_name") except TypeError: print("I cant add these two together!") except E...
403982b599cbd1f69d9658ae3c073413938e604c
gabriellaec/desoft-analise-exercicios
/backup/user_393/ch34_2020_10_05_21_53_08_820907.py
620
3.578125
4
def eh_primo(x): i= 3 if(x==2): return True elif(x==1): return False elif(x==0): return False elif(x==3): return True elif(x%2==0): return False while(x > i): if(x%i==0): return False i= i + 2 return True...
9ec38ac6ccc6f99a39c8bfaf3cea17b689dbb218
alrzasdqi/Hello-World
/list.py
539
4.0625
4
a=2 numbers = [1,2,3,4,5,6,7,8,9] numbers.append(10) numbers.remove(a) numbers.pop(-3) numbers.pop(0) b=numbers.index(5) print("b is: ",b) numbers.reverse() numbers.sort() for i in numbers: print(i) count=numbers.count(6) print("no.6 count is: ",count) ################################################## #store lists...
b7593655dcfee8b4b7e3355b6cc51c66ad6521ea
qoqolo/Battle_of_warriors
/change_color.py
412
3.515625
4
from PIL import Image picture = Image.open("qwe.png") picture = picture.convert('RGBA') # Get the size of the image width, height = picture.size for x in range(width): for y in range(height): current_color = picture.getpixel( (x,y) ) R,G,B,A = current_color if A == 0: continue ...
12d8e960a6a8add6aabf2f5dc8896e7bdb25b70d
felixguerrero12/operationPython
/learnPython/ex11_Asking_Questions.py
517
4.0625
4
# -*- coding: utf-8 -*- # Created on July 26th # Felix Guerrero # Exercise 11 - Asking the questions - Learn python the hard way. # Ask Questions and Input Raw Input - #1 print "How old are you?" age = raw_input() # Ask questions and input raw input - #2 print "How tall are you?" height = raw_input() # Ask question...
9a20f3a33ee0191a2b4d453f5736e443769ede11
cddolanc/cct-start
/wk10/ftft_copy.py
5,051
3.984375
4
#------Global variables--------- # Game Board board = ["#", "-", "-", "-", "-", "-","-", "-", "-", "-"] # If game is still going game_continues = True # Won or Tie? winner = None # Whos turn is it? def current_player(): current_player = input('Welcome To Tic-Tac-Toe!\n Please ...
2938a6f9e372027697e46b0371a2fc7c75a26e58
finallyegg/Leetcode_py
/547. Friend Circles.py
861
3.65625
4
# June 2 2020 from typing import List # Union Find class Solution: def find(self,parent_array, i): if parent_array[i] == -1: return i else: return self.find(parent_array,parent_array[i]) def findCircleNum(self, M: List[List[int]]) -> int: parent = [-1] * (len(M...
8a516093087cc0a28fc9a1b2e835901a9b797c7b
dogunter/matplotlib_tutorials
/5-bargraphs.py
3,265
4.34375
4
import numpy as np import matplotlib.pyplot as plt # Bargraphs are a way of presenting data on various topics. # the pyplot.bar() plot is described at this URL: # https://matplotlib.org/api/_as_gen/matplotlib.pyplot.bar.html # # Suppose you took a large poll of students to see how they # spend their time throughout ...
8c33dcf2e68f8ad4789fc2961e63e5085ab2bde1
ah450/fibonacci
/fib.py
416
4.1875
4
#!/usr/bin/env python # Usage : fib.py n # prints the nth fibonacci number import sys import math if len (sys.argv) != 2: print 'Usage fib.py n\nWhere n is the index of the fibonacci number.' sys.exit(-1) n = int(sys.argv[1]) golden_ratio = (1 + math.sqrt(5)) / 2 def fib(n): return (golden_ratio ** n - (-...
9035f8ce496bd1d57a613c234440a698783cbec0
stacykutyepov/python-cp-cheatsheet
/educative/slidingWindow/longestSubstringwithK.py
724
3.515625
4
""" time : 17 min error: used pop instead of del ht[jc] """ def longest_substring_with_k_distinct(str, k): j, lgSub = 0, 0 ht = {} for i, c in enumerate(str): if c in ht: ht[c] += 1 else: ht[c] = 1 if len(ht) <= k: lgSub = max(lgSub, i-j + 1) else: jc = str[j] h...
95082dfa5f57202271eef2652028bcc12bee9c8b
nevaan9/Hands-On-Data-Analysis-with-Pandas-2nd-edition
/visual-aids/visual_aids/finance_viz.py
3,965
3.796875
4
"""Functions for creating visual aids for finance concepts.""" import random import string import matplotlib.pyplot as plt from matplotlib.ticker import FormatStrFormatter import stock_analysis RED = '#B30000' GREEN = '#5BC95B' BLUE = '#00B3B3' def support_and_resistance(): """Show sample support and resista...
66f2060b8f60dca82a9420e65f3d59b133836a87
alex-d-bondarev/learn-python
/hackerrank/collections/namedtuple.py
371
3.578125
4
"""4 lines of code are not very readable""" from collections import namedtuple if __name__ == '__main__': number_of_students = int(input()) Student = namedtuple("Student", input().split()) scores = [] for _ in range(number_of_students): scores.append(int(Student(*input().split()).MARKS)) ...
4e3e8e32291aa3c57a96547185a1c435193d318a
heleneunji/Basic-python
/20190326.py
1,606
3.875
4
number=int(input('수를 입력하세요 : ')) print(number,'을(를) 입력하셨습니다') if number<0: print('판별할 수 없는 수를 입력하셨습니다') elif number % 2 == 0: print(number,'은(는) 짝수입니다') else: print((number,'은(는) 홀수입니다')) treehit=0 while treehit < 10: treehit = treehit+1 print('나무를 %d번 찍었습니다.'%treehit) if treehit==10: ...
f49a1f44481473a6aa829029a25146aa32986ce9
melwyn-rodrigues/Udacity-CS-101-Introduction-to-Computer-Science
/Lesson-2/quiz-print-all-links-option2.py
1,573
3.84375
4
# Print all links that appear in the string titled 'page' page=('<div id="top_bin"><div id="top_content" class="width960">' '<div class="udacity float-left"><a href="http://stanford.com"><a href="http://udacity.com">') def get_next_target(page): start_link = page.find('<a href=') #print (start_link) ...
9d1f7494dc1ad97c413b435909c42568f18cad3e
VishnuKandoth/Python-Programs
/regex_email.py
228
3.5
4
import re emailid=raw_input("Enter the email: ") mailid=re.compile("(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)") idtest=mailid.match(emailid) if idtest is None: print "mailid Mismatching" else: print "mailid Accepted"
57a7f034e4b8dfe1f329290fbe0d72ec4688bed9
yaya319/python_for_everyone_ex
/chapter4.py
2,348
4.1875
4
# -*- coding: utf-8 -*- """ Created on Sun Oct 14 21:52:07 2018 #Exercise 1: Run the program on your system and see what numbers you get. Run the program more than once and see what numbers you get. import random for i in range(10): x = random.random() print(x) random.randint(5, 10) #Exerci...
1755d29a467ed1b149d52f326754d0a674486144
storm0530/A2_Assignment
/Missing_data_completion.py
3,640
3.59375
4
# Multiple regression analysis code import numpy as np import pandas as pd import pprint as pp import statsmodels.api as sm import statsmodels.formula.api as smf DUMMY_FLAG = 0 # 1: Use dummy variables, 0: Don't use # select header for explanatory variable HEADER_FOR_ANALYZE = ["Age","Drink","Total_Cholesterol(mg/dL...
d0261e20a8b75e232b01903a85114e3193b53ccb
Seun1609/Python-Training
/Friday/Project 2- Calculate grades/calculate_grades.py
602
3.5625
4
def get_grade(score): if score < 0 or score > 100: return "-" elif score >= 70: return "A" elif score >= 60: return "B" elif score >= 50: return "C" elif score >= 45: return "D" elif score >= 40: return "E" else: return "F" f1 = open("...
438d387f1f46369910f733bb46723bb5e362781b
VinayakBagaria/Python-Programming
/New folder/Weird and Not weird.py
226
4.09375
4
n=int(input()) if n%2==0: str='Weird' else: str='Not Weird' if n>=2 and n<=5 and n%2==0: str='Not Weird' if n>=6 and n<=20 and n%2==0: str='Weird' if n>20 and n%2==0: str='Not Weird' print(str)
846f961fc942645e5b1714013425400406f37d35
milansanders/AdventOfCode2020
/09/09B_alt.py
1,067
3.59375
4
import itertools numbers: [int] = list(map(lambda line: int(line.rstrip()), open('input.txt', 'r').readlines())) preamble_length: int = 25 def is_valid(preamble: [int], target: int) -> bool: return target in map(sum, itertools.combinations(preamble, 2)) def invalid_number(numbers: [int], preamble_length: int) ...
17d080edaeb450228be0a809ff4bb860af3ac246
jack1806/data-security-using-k-anonymity
/main.py
3,329
3.625
4
# Import all the required libraries first # Use pip install <name> if got some error while importing import pandas as pd import csv # Initialize the array with all the dataset headers (attributes) headers = ['caseNumber', 'treatmentDate', 'statWeight', 'stratum', 'age', 'sex', 'race', 'diagnosis', 'bodyPart', ...
ec631d851518a186b9bd2fb53ceaa1c457aa0a88
impankaj91/Python
/Chepter-9-File input-output/Prac4-donkey.py
201
3.5
4
#Replace A donkey Word With ##### with open("donkey.txt","r") as f: data=f.read() if 'Donkey' in data: with open("donkey.txt","w") as f: f.write(data.replace('Donkey','#####'))
a5ee4a62c34ae06d79b807b1b2bd6c5963fbb2c6
peterhogan/python
/class_test.py
210
3.6875
4
class List(object): def __init__(self, number): self.number = number def write_numbers(self): for i in self.number: print i x = [1,2,3,4,5,6] y = [6,6,6,6,6,6] x.write_numbers() y.write_numbers()
a2c7bb51b6401251d15c64dfa178674ac9af7364
huhujiajia/ArchMM
/archmm/misc/utils.py
1,140
3.828125
4
# -*- coding: utf-8 -*- # utils.py # author: Antoine Passemiers import numpy as np def abstractpythonmethod(func): def func_wrapper(*args): raise NotImplementedError( "%s abstract method must be implemented" % func.__name__ ) func_wrapper.__name__ = func.__name__ return func_w...
ce19e4adbd1a40ddc079c2fbe44b80474be66ce7
Piikasooo/py_queue
/queue.py
515
3.578125
4
''' Module Queue ''' class Queue: ''' class Queue ''' def __init__(self, lngth=0): ''' :param length: ''' self.data = [] self.lngth = lngth def push(self, value: int): ''' :param value: :return: ''' if self.lngth a...
68506fd4d8abd542856573ed63c26db11833af21
DoubleChuang/ncappzoo
/apps/video_face_matcher/Person_profile.py
582
3.65625
4
class Person_profile(): ''' Used to identify the person with an image read from file. Used when identifying input and output that will be sent/received with the face_detection_retail_0004 network. Parameters ---------- name (str) - Name of the person. image_path (str) - File path of the im...
140696f3cf0fb5bce254aeba1e15a042ddce991d
gspillman/tacohunter
/tacos.py
1,577
3.546875
4
#This script finds the unique listing of the top rated taco joints #in Austin, TX (according to Yelp.com) import requests from bs4 import BeautifulSoup baseurl = "https://www.yelp.com/search?find_desc=tacos&find_loc=" location = 'Austin, TX' start_results = 0 url = baseurl + location + "&start=" + str(start_results)...
f54d0883aeb3a6c9c7bc985aed35b79654ed8502
geluso/kexp_song_search_engine
/internationalization/complex_chars.py
993
3.578125
4
#!/usr/local/bin/python # -*- coding: utf-8 -*- import argparse import sys import codecs sys.stdout=codecs.getwriter('utf-8')(sys.stdout) parser = argparse.ArgumentParser(description="Detect internationalizatins in words in line-separated a file") parser.add_argument("filename", type=str, help="the file to be proces...
fc3a3688abbe48deffc06c8ae701c8b71a066c31
Prathamdoshi/Self-Taught-Programmer-Book-Exercises
/chapter_20_solution.py
543
3.71875
4
# chapter 20 solution import urllib.request # urlib to get/post content from bs4 import BeautifulSoup # parsing library site = "https://news.google.com/topstories?hl=en-US&gl=US&ceid=US:en" # source request_handler = urllib.request.urlopen(site) # make a get call html = request_handler.read() # read the html from ...
657bcdf26716f220138ec8ef81531bba40e6e5d5
vonzhou/Core-Python-Programming
/chapter13/demo11-inherit.py
281
3.546875
4
class P(object): 'parent P class' def __init__(self): print "creat an instance of", self.__class__.__name__ class C(P): pass p = P() print p.__class__ print P.__base__ print P.__doc__ print '-------------------' c = C() print c.__class__ print C.__base__ print C.__doc__
e84cbfa20e8f9c86833193cc0b74e96ceb92e3c9
Introduction-to-Programming-OSOWSKI/3-2-echo-EvanSnyder2023
/main.py
126
3.75
4
def echo(x, y): word = x for i in range(1, y): word = word + x return word print(echo("dog",5))
bcb97eb9cd5d786815912b6d6a93f7cfd6a074a5
EkaterinaArseneva/hometask3
/task3.3.py
487
4.125
4
"""Реализовать функцию my_func(), которая принимает три позиционных аргумента, и возвращает сумму наибольших двух аргументов.""" def my_func(num1, num2, num3): result = sum([num1, num2, num3]) - min(num1, num2, num3) return result try: print(my_func(int(input('num1: ')), int(input('num2: ')), int(input(...
0db7e4fd771cc3b4badc809aa14a5abbdb793e74
andrezzadede/Curso_Python_Guanabara_Mundo_2
/Mundo 2 - Exercicios/41Exercicio.py
744
4.125
4
print('** Bem vindo ao exercicio 41') print('A confederação nacional de natação precisa de um programa que leia o ano de nascimento de um atleta e mostre sua categoria de acordo com sua idade\n' 'Até 9 anos: Mirim' 'Até 14 anos: Infantil' 'Até 19 anos: Junior' 'Até 20 anos: Sênior' 'Acima:...
6059eeb4cc6972dd0f024eac4a62a00c838bd50b
Aneesh540/python-projects
/cbse.py
1,424
4.21875
4
"""class for vector *, +, /,- and many others hypot function gives -/x**2 + y**2 i.e. hypotaneous """ from math import hypot,sqrt class Vector: """docstring for Vector class NOTE: len(v) length of vector gives different result i.e. x+y coz here we use different length method ...
c5060e687f6fe6d69cd173e2c83b74f9d80bc0f7
Dan12/iit-class
/lesson_notes/lecture2/test.py
918
3.734375
4
print("hello world") x = True y = False print(x or y) print(x and y) print(not x) z = 1 print(y or z) # same thing in memory print(x is x) print(x is not x) x = 2 y = 6 print(x//y) print(x/y) print(y**x) print(divmod(y,x)) x = complex(2,4) print(x) print(x.conjugate()) y = -5 print(-y) print(+y) print(y.__add__(z)) p...
bbcb7eeb5ea641f2ff5bfe74f423fc4efdf8d648
pritpal1/Python-basic-part1
/PosNeg.py
94
3.921875
4
a = int(input('enter the value')) if(a>=0): print('Positive') else: print('Negative')
acf520d0daff526ea530825195a3aef3f605f879
kemingy/daily-coding-problem
/src/friend_group.py
1,360
4.15625
4
# A classroom consists of N students, whose friendships can be represented in # an adjacency list. For example, the following descibes a situation where 0 # is friends with 1 and 2, 3 is friends with 6, and so on. # {0: [1, 2], # 1: [0, 5], # 2: [0], # 3: [6], # 4: [], # 5: [1], # 6: [3]} # Each stu...
d1194035877ccf46cd000542fa0cb83f128378d8
AdamZhouSE/pythonHomework
/Code/CodeRecords/2847/60900/255175.py
192
3.609375
4
n = input() str1 = input() nums = str1.split(" ") str2 = input() nums2 = str2.split(" ") count = 0 for i in range(int(nums2[0]),int(nums2[1])): count = count + int(nums[i-1]) print(count)
b01cedc05b8de8a9e6c7bc74c8699473b9207e5b
tianwei1992/Python_oop_leaning
/advanced/class_attributes_management/descriptor_demo/descriptor_basic_demo.py
1,687
4.03125
4
""" class Descriptor: "docstring goes here" def __get__(self, instance, owner): ... # Return attr value def __set__(self, instance, value): ... # Return nothing (None) def __delete__(self, instance): ... # Return nothing (None) 带有任何这些方法的类都可以看作是描述符,描述符的实例可以作为其他的类的属性的值。 这样,当访问或...
9bcd8db0a8dc0c00c8613c771d6558150a09e964
mjson1954/WIC
/programmers/윈터코딩 코딩테스트/1.py
663
3.734375
4
def solution(n, delivery): answer = '' n = ['' for i in range(n+1)] delivery.sort(key=lambda x:x[2], reverse=True) for i in delivery: # print(i) one = i[0] two = i[1] if(i[2] == 1): n[one] = 'O' n[two] = 'O' else: if(n[one...
4d513118c8f8773a3bd433407453f7f2821aa59f
singi2016cn/python-start-programming
/5/5.7/fruits.py
407
3.921875
4
# 水果 favorite_fruits = ['apple', 'pear', 'grape'] if 'apple' in favorite_fruits: print('You really like apple!') if 'pear' in favorite_fruits: print('You really like pear!') if 'grape' in favorite_fruits: print('You really like grape!') if 'watermelon' in favorite_fruits: print('You really like waterme...
c0dfd67b5b61c81587f26ab6269ba2f0101a4819
buscaroli/python-basics
/strings/str002.py
771
3.921875
4
# Learning Python: Strings # Matteo import re s = '''Destiny shall draw the lightning down from Heaven, Roll its thunder far, across the sea To where I wait, upon the Shore of Wonders, On the day the sky is open And the Tree is split asunder. Lady Cygna''' print('Original string:'.center(40, '~')) print(s) print('')...
2885dbe41c1e630dce025cc1cabfdc767c780c82
Joshua-Hwang/Lilypond-research
/attempt2/staticvisualiser.py
3,351
3.5625
4
#!/usr/bin/env python3 import sys import csv import math import argparse import fileinput from matplotlib import pyplot as plt from matplotlib import animation parser = argparse.ArgumentParser(description="Takes an input of *.lp format and generates a visual") parser.add_argument("inputfile", help="if specified read...
dbb5af2b0f8f75280507a283b1c9fc9c28e796e4
ChromeUniverse/CompetitiveProgramming
/OBI/chaves_P2.py
476
3.609375
4
# https://olimpiada.ic.unicamp.br/pratique/p2/2016/f1/chaves/ num_lines = int(input()) num_brackets = 0 fail = False for i in range(num_lines): line_input = list(input()) for char in line_input: if char == '{' : num_brackets += 1 elif char == '}': num_brackets -= 1 ...
68dc23bbf1508ab518cc0bbc1f9919cc78b71fa9
Szyszuniec/100-zada-
/zadanie 21.py
1,164
4.5625
5
# A robot moves in a plane starting from the original point (0,0). # The robot can move toward UP, DOWN, LEFT and RIGHT with a given steps. # The trace of robot movement is shown as the following: # UP 5 # DOWN 3 # LEFT 3 # RIGHT 2 # ¡­ # The numbers after the direction are steps. Please write a program to comp...
4f85d4a558332f5102f43ff2b5852b51936955fb
Kavri/CODEME-PYTHON
/Control instructions/15 - warm - cold game.py
1,328
4.15625
4
# Create a game - warm cold # The computer draws a number - range from 1 to 100. # User gives his luck. # Computer responds warm - cold (up to 6 times) # If the user guesses the number - win! import random print('GAME WARM COLD') help = input('Do you want to see the rules of the game?? Enter YES / NO: ') he...
6c1e6ca59d06ef1fa977fd4421d751563fca111e
chithien0909/Competitive-Programming
/Leetcode/Leetcode-Count Primes.py
401
3.75
4
class Solution: def countPrimes(self, n: int) -> int: if n <= 2: return 0 prime = [] notPrime = set() for i in range(2, n): if i not in notPrime: prime.append(i) cur = i + i while cur < n: notPrime.add(cu...
112d6b36d19ca073b7ca19456f690718c0e17a86
douglasrodriguess/basic-to-advanced-python-course
/08-functions/exercise/Exercise11.py
704
3.921875
4
import statistics def media(num, nome): """ Funcao que calcula a media :param num: lista de numeros que serao realizados para o calculo da media :param nome: parametro de escolha se e media ponderada ('P') ou aritmética ('A') :return: retorna a media """ if nome == 'A': me...
04b443a665e15a8b76af51a614982928a3f9b1f0
yujiintel/bit-baibai_naga
/bit-baibai_naga/bitbaibai/Markets/Authenticator.py
3,909
4.09375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ This file contains the an abstract base class (ABC) that serves as an interface for trading on any market. """ from abc import ABC, abstractmethod class Authenticator(ABC): """ An Authenticator inheriting from this class should be defined for every market...
c190db5464702c8158484f58d80a50d826de8f5b
Aasthaengg/IBMdataset
/Python_codes/p03672/s394754981.py
268
3.6875
4
def isEvenStr(s): if len(s) % 2 == 1: return False elif s[0:int(len(s)/2)] == s[int(len(s)/2):]: return True else: return False s = input() l = len(s) i = 0 while not isEvenStr(s) or i == 0: s = s[:-1] i += 1 if isEvenStr(s): print(l - i)
ae088f31e1b183d6fadad548557359efa9811a90
santiagolopezg/dailySEP
/dailysep.py
12,131
3.53125
4
#dailySEP bot import urllib2 import random import datetime from HTMLParser import HTMLParser import re def html_to_string(url): html_content = urllib2.urlopen(url).read() # now I have the web page in HTML format, I need to extract info of interest #print html_content ''' ...
5aa9adce13fb429f5d32645d283940f7a8a63b29
prasunroy/pytorch-bootcamp
/nn_torch_v5.py
2,334
3.796875
4
# -*- coding: utf-8 -*- """ Implementation of a neural network using PyTorch nn module with optim package. Created on Wed Mar 27 16:00:00 2019 Author: Prasun Roy | CVPRU-ISICAL (http://www.isical.ac.in/~cvpr) GitHub: https://github.com/prasunroy/pytorch-bootcamp References: [1] https://pytorch.org/tutorials/beginner/p...
af962e078b86c92168bba5b3078b387ca5f37b88
vjayd/serve
/fileread.py
858
3.671875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon May 20 17:58:12 2019 @author: vijay """ import sys def write_check(filename, version): f=open("god", "r") f1 = f.readlines() exist = False for x in f1: splitted = x.split(";") name = splitted[0].split(":") versi...
03cb513ecd4c70d898014a6e24ab1857163c7646
devchandansh/python-coding
/distance_by_coordinate_positions_of_robot_movements.py
3,977
4.40625
4
""" @author: Chandan Sharma @GitHub: https://github.com/devchandansh/ """ """ ================================================================ A Robot moves in a Plane starting from the origin point (0,0). The robot can move toward UP, DOWN, LEFT, RIGHT. The trace of Robot movement is as given following: Assumed ...
060ac9af9c44100ffaba335fe1ca79ebba930d26
Eureka2018/eular
/code/pe-4.py
913
3.671875
4
def is_palindrome(olds): s = str(olds) for i in range(0, len(s)/2): if s[i] != s[-i-1]: return False return True def is_palindrome_2(num): r = 0 n = num while n > 0: r = r * 10 + n % 10 n = n / 10 return r == num def find_palindrome_1(r): mp = 0 for i in r...
d044b238d5af78d5045b860f1e4c2dda351f5849
Henry-choi426/python_example
/Example_0702.py
426
3.8125
4
""" - 백준 - 이진수 변환 - URL : https://www.acmicpc.net/problem/10829 - 문제 분석 재귀함수를 활용하여 이진수로 변환하기. """ def solution(number): if number == 1: return "1" else: if int(number) % 2 == 1: # 홀수일 때 return solution(number//2)+'1' else: return solution(number//...
0179a10273762e22707d661bd2116e8f602f7a49
chunyuema/ProPython
/list-dict-comprehension.py
539
3.96875
4
l = [1, 2, 3, 4] # Performing mathematical operations on the entire list l2 = [x**2 for x in l] d2 = {x: x**2 for x in l} print(l2, d2) # Combining multiple lists into one a = [1, 2, 3] b = [7, 8, 9] print([(x+y) for (x, y) in zip(a, b)]) # [8, 10, 12] print([(x, y) for x in a for y in b]) # [(1, 7), (1, 8), (1, 9),...
746701e86acf2b7c85853348a9ceb653dd3be162
js837/project-euler
/1-100/38/pandigital_multiples.py
443
3.53125
4
def is_pandigital(str_n): if len(str_n)!=9: return False for i in xrange(1,10): if str(i) not in str_n: return False return True def is_concat_pandigital(n): result='' i=1 while len(result) < 9: result+=str(i*n) i+=1 if is_pandigital(result): return int(result) else: ...
5d141c5d85b6faf898212935de684af17bff36db
yelongyu/leetcode
/500.keyboard_row.py
1,795
3.875
4
# -*- coding: utf-8 -*- """ Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard. """ __author__ = 'yelongyu1024@gmail.com' KEYBOARD = { 'row1': ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p'], 'row2': ['a', 's', 'd', 'f', 'g', 'h', 'j...
0131edaa8f77c219b7b78faba745a8544ca5979a
greenmac/python-morvan-crawler
/201beautifulsoup-basic.py
612
3.5625
4
# https://morvanzhou.github.io/tutorials/data-manipulation/scraping/2-01-beautifulsoup-basic/ # https://github.com/MorvanZhou/easy-scraping-tutorial/blob/master/notebook/2-1-beautifulsoup-basic.ipynb # https://morvanzhou.github.io/static/scraping/basic-structure.html from bs4 import BeautifulSoup import requests html ...
033ea56b92f205e9e3c1f6e54a29eca66c96c228
Lucass-Adriano/Projetos
/curso 1/semanas 1 e 2/temperatura.py
191
3.921875
4
temperaturaFarenheit = input('Digite a temperatura em Farenheit\n') temperaturaCelcius = (float(temperaturaFarenheit) - 32) * 5 / 9 print('a temperatura em celsius é', temperaturaCelcius)
10f2f2e8aca0a12f70d9c46d11979c1a394a9475
deltahalo099/physics-251
/hw1/hw1_4.py
462
4.25
4
# -*- coding: utf-8 -*- """ Created on Sun Jan 26 16:38:38 2020 @author: Omar Abdelaal """ import math #function definition to caclulate volume and surface area #prints in proper format def sphereinfo(r): surface_area = 4*math.pi*(r**2) volume = (4/3)*math.pi*(r**3) print('for radius r = {}'.format(...
3caafab6822906f8d56168333d3ad3c63d26e43a
diontran/GameSearchROPASCI360
/team_name/player.py
7,263
3.765625
4
from team_name.Board import * import team_name.util as ut import random import itertools import copy from team_name.gametheory import * class Player: TOKEN_TYPE = ['r','p','s'] def __init__(self, player): """ Called once at the beginning of a game to initialise this player. Set up an i...
ce1df7d4f40748c18a956ffae00f548006feb758
bagerakbay/Neural-Net-Training
/bgrNN01.py
1,467
3.8125
4
#!/usr/bin/python3 #Simple neural network code # based on https://medium.com/technology-invention-and-more/how-to-build-a-simple-neural-network-in-9-lines-of-python-code-cc8f23647ca1 # Removed matrix codes to make it more readable # thanks to aib from math import e def normalize (x): return (1 / ( 1 + pow(e, -1*x))...
40a4b3efe7956b2f3291742f77752c0f9d56fe45
Alafresh/holbertonschool-higher_level_programming
/0x03-python-data_structures/8-multiple_returns.py
196
3.734375
4
#!/usr/bin/python3 def multiple_returns(sentence): if not sentence: return len(sentence), None length = 0 for i in sentence: length += 1 return length, sentence[0]
5ddbec29efed36d2ee36653266eeb6378bdeea7f
631068264/algorithm
/binary_tree.py
8,379
3.515625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @author = 'wyx' @time = 16/10/26 20:23 @annotation = '' """ from collections import OrderedDict from collections import deque from heap import ObjectPriorityQueue class HuffmanNode(object): def __init__(self, data, priority): self.priority = priority ...
ffeff826e2d4f12934ec44d1cc557b0d3572e926
KimEklund13/SeleniumWD-with-Python3x
/basicsSyntax/listsdemo.py
380
3.984375
4
x = 10 cars = ["bmw", "honda", "audi"] # lists are a collection of values empty_list = [] print(cars) print(empty_list) x = "test" # Strings are a collection of characters print(cars[0]) num_list = [1, 2, 3] sum_num = num_list[0] + num_list[1] print(sum_num) more_cars = ["bmw", "honda", "audi"] print(more_cars[1...
9f9b3799c5a98aa9fa4b52e0e6a2ecffda3a9604
theindianczar/VirtEnvProj
/tuples.py
768
4.0625
4
#tuple numbers =(1,2,3,4,5,6) letters=('a','b','c','d') m=('a',23,10.5) #nested tuple two_dim = ((2,3),(5,3),(7,2)) print(m[2]) print(two_dim[1][1]) #pack and unpack tuples packing_tuple = 2,5,'Space' print(packing_tuple) a,b,c = packing_tuple print(a) print(b) print(c) print(packing_tuple) numbers =(8,9,2,3,4,5...
89b0b6b133a4f827b820fcef5deea17bc2a07b21
Endemoniada/yahtzee
/scoreboard.py
3,002
3.671875
4
import re from rules import Rules class ScoreBoard(object): # TODO: Everything def __init__(self): self.scoreboard_rows = { 1: "Aces", 2: "Twos", 3: "Threes", 4: "Fours", 5: "Fives", 6: "Sixes", 7: "Three of a Kind", ...
dd601d32ef5857c9422ca60d43b414499951f73f
mathiasn98/Crossword_Solver
/main.py
7,225
3.5625
4
#Name : Mathias Novianto #Date : 23 January 2018 import time class Possible_Place: #class for box location, contains x position (horizontal), y position (vertical) #, its length and its orientation def __init__(self, x_in, y_in, length_in, horizontal): self.x = x_in self.y = y_in ...
7ced3a01dc48f77219ebbda82f510ab9d4948872
dhsTStroud/classicCrawler
/sprite_list.py
9,915
3.609375
4
# refer to pygame as "pg" import pygame as pg # other game files from settings import * from random import randint from sprites import * ################################################################################ # SPRITE CLASSES # player sprite class Actor_Player(Actor): # KEYWORDS AND CLASS VARIABLES ...
c7a510bfbc2c7c5da1ef640fa71c812361f23a0d
rv619/Machine-Learning
/1D_Linear_Regression/linear_reg_1D.py
2,561
3.796875
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt def split (dataset, training_ratio): n = len (dataset) # Size of dataset r = int (training_ratio * n) # No. of training examples np.random.shuffle (dataset) # Shuffling the dataset return dataset[:r,:], dataset[r:,:] def ...
dc3185aba4364dbdb387be73e72076cb4bbc1f7f
Patrickwyl/CSC148-18winter
/A1/game.py
7,464
3.859375
4
""" Create a class Game for general games. """ from typing import Any from current_state import CurrentState from current_state import SubtractState from current_state import ChopstickState class Game: """Represent a class Game for genral games. """ def __init__(self, is_p1_turn: bool) -> None: ...
94b4d81f5802acd52c79793367de7e8b03840fe4
nekapoor7/Python-and-Django
/IMP_CONCEPTS/Decorator/Decorator_Factorial.py
405
4
4
def factorial_number(s): def helper(x): if x > 0 and type(x) == int: return s(x) else: raise Exception("Argument is not an Integer and Negative") return helper @factorial_number def factorial(n): if n == 1: return 1 else: return n...
38980e126a98a0cd17b491e3ca64f4315fd77493
wuqunfei/algopycode
/notes/two_point.py
339
3.53125
4
from typing import List def two_point(array: List): n = len(array) i, j = 0, n - 1 # init two point while i < j: # terminator if True: # Meet Left side move i += 1 if True: # Meet right side move j -= 1 # Return the requiremen...
3bfcd75f79319d0b5eb3c4e1d18b947b9646bb89
RetCTR/Scrabble_Scorer_Python
/scrabble_scorer_roger.py
3,475
3.90625
4
old_point_structure = { 1: ['A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T'], 2: ['D', 'G'], 3: ['B', 'C', 'M', 'P'], 4: ['F', 'H', 'V', 'W', 'Y'], 5: ['K'], 8: ['J', 'X'], 10: ['Q', 'Z'] } def old_scrabble_scorer(word): word = word.upper() letter_points = "" for char in word: for...
aa776abf82b81a6612d1641e30f8f4172ddb20c6
Taylor4484/CS-313E---Elements-of-Software-Design
/Assignment 1/open.py
565
4.28125
4
#Read File openfile = open('myWordList.txt', 'r') #Create wordList from content of read file wordList = openfile.readlines() #Clean the wordlist cleanWordList = [line.strip().rstrip() for line in wordList] #Set a default filename defaultFile = 'myWordList.txt' #Tell user the default filename print('The default fi...
ce3d66e0b0f0546d2b0a5e594044fb51ececbaa8
daniel-reich/ubiquitous-fiesta
/ZdnwC3PsXPQTdTiKf_2.py
143
3.96875
4
def calculator(num1, operator, num2): return "Can't divide by 0!" if num2==0 and operator=='/' else eval(str(num1) + operator + str(num2))
4c4334e61534b7a4fadbf88f16f5f9fc595613b1
PyLov3r/Python-Beginner
/b)Strings.py
855
4.21875
4
""" Temario: 1.- Strings 2.- Backslash 3.- Newlines 4.- Concatenation 5.- String operations 6.- String problems """ #Strings print("Python is fun") print('Python is fun') #Backslash print('Brian\'s mother: He\'s not angel. He\'s a very naughty boy.') #Newlines print("Hello\n there.") print("""Th...
dbb7df6ab0b6007c9fa0359b08e027b2db8fe235
katheroine/languagium
/python/strings/string_interpolations.py
1,533
3.75
4
#!/usr/bin/python3 i = 1; f = 2.3; s = "apple" print("i = %i, f = %f, s = %s"%(i, f, s)) print(f"i = {i}, f = {f}, s = {s}") print("i = {}, f = {}, s = {}".format(i, f, s)) print("i = {0}, f = {1}, s = {2}".format(i, f, s)) print("i = {integer_value}, f = {floating_point_value}, s = {string_value}".format(integer_val...
605785be66b3082442af90a1cee8ff9082bc4f87
HEroKuma/leetcode
/0628-maximum-product-of-three-numbers/maximum-product-of-three-numbers.py
535
3.984375
4
# Given an integer array nums, find three numbers whose product is maximum and return the maximum product. # #   # Example 1: # Input: nums = [1,2,3] # Output: 6 # Example 2: # Input: nums = [1,2,3,4] # Output: 24 # Example 3: # Input: nums = [-1,-2,-3] # Output: -6 # #   # Constraints: # # # 3 <= nums.length <= 104 #...
be9e079a95b39cf1dcd544048dc9bd89170e5a55
hyun-minLee/20200209
/st01.Python기초/py05형변환/py05_02_문자열포맷팅.py
380
4
4
print("I eat %d apples." %3) number=10 day="three" print("I ate %d apples. so I was sick for %s days" %(number, day)) print("%10s" %"hi") #10번까지 공백을 채우면서 띠고 hi출력 print("%-10sjane." %'hi') print("%0.5f" %3.42134234) #0.4< 소숫점이하 5자리까지 나와야한다. print("%10.4f" %3.42134234) #0.4< 소숫점이하 4자리까지 나와야한다.
91cb8a5212ecf1289b63dbc6101740f541165d81
darraes/coding_questions
/v2/_leet_code_/0128_longest_consecutive_sequence.py
1,048
3.703125
4
class Solution: def longestConsecutive(self, nums): """ :type nums: List[int] :rtype: int """ nums_set = set(nums) longest_streak = 0 for num in nums_set: if num - 1 not in nums_set: current_streak = 1 current_num = ...
2f052a78263ad3b9fe078b42ddcf7b296e0de554
weiyuyan/LeetCode
/剑指offer/面试题3.数组中重复的数字.py
2,425
4.09375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # author:ShidongDu time:2020/1/27 ''' 给定一个长度为 n 的整数数组 nums,数组中所有的数字都在 0∼n−1 的范围内。 数组中某些数字是重复的,但不知道有几个数字重复了,也不知道每个数字重复了几次。 请找出数组中任意一个重复的数字。 注意:如果某些数字不在 0∼n−1 的范围内,或数组中不包含重复数字,则返回 -1; 样例 给定 nums = [2, 3, 5, 4, 3, 2, 6, 7]。 返回 2 或 3。 ''' # 方法一:先排序,后查找 # class Solution(obj...
7fcb0aa3f8f986db075eb4f2e5afc9f700bbc53f
marymcharg/QM2-groupwork
/data-sources/adding_continents.py
897
3.765625
4
# creates "continents.csv" from "1971_2011_top_40_new.csv" & "Countries-Continents.csv" # removes rows with no data in "Contry of Origin" column in "1971_2011_top_40_new.csv" CONTINENT = 0 COUNTRY = 1 import pandas as pd import numpy as np df1 = pd.read_csv("1971_2011_top_40_new.csv") df2 = pd.read_csv("Co...
22d8bd009040f0271168e25d4ac559081f8d6584
adhikaridev/8-puzzle
/manhattan.py
456
3.953125
4
def manhattan(current_index, goal_index): position = {0:(0,0),1:(1,0),2:(2,0),3:(0,1),4:(1,1),5:(2,1),6:(0,2),7:(1,2),8:(2,2)} x_position,y_position = position[current_index] x_goal,y_goal = position[goal_index] global distance distance += abs(x_position - x_goal) + abs(y_position - y_goal) #print m...
115fbb2e013132987e65a5451ce2cd93c655b00b
marysiuniq/advent_of_code_2020
/09/puzzle_9_2.py
1,537
4.3125
4
# -*- coding: utf-8 -*- """ Created on Tue Dec 8 06:05:26 2020 @author: Marysia Puzzle 9 part 2 from https://adventofcode.com/2020/day/9 The final step in breaking the XMAS encryption relies on the invalid number you just found: you must find a contiguous set of at least two numbers in your list which sum to the inv...