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 |
|---|---|---|---|---|---|---|
d8a9530663b133d3350bbeccf3988c2a8f738d16 | jvkus/PyGame-SkEtch | /main.py | 1,987 | 3.59375 | 4 | # Author: Joanna Kus
import pygame as pg
from time import sleep
r = int(input("Pick a red value."))
g = int(input("Pick a green value."))
b = int(input("Pick a blue value."))
bgColor = (r, g, b)
White = (255, 255, 255)
(width, height) = (700, 700)
coords = [350, 350]
oldCoords = [350, 350]
drawBool = True
cursorBool... |
d6d119a01d844faaa2330167e9e29246835bafe6 | Annisotropy/Python | /HW6/Task2.py | 327 | 3.59375 | 4 | class Road:
def __init__(self, length, width):
self._length = length
self._width = width
self.mass1sm = 10
self.height = 5
def mass(self):
bitumen_mass = self._length * self._width * self.mass1sm * self.height
return bitumen_mass
road = Road(1, 2)
print(road.ma... |
6699bddd388f902c2380297f669f178190998fe2 | Annisotropy/Python | /HW4/Task2.py | 174 | 3.65625 | 4 | my_numbers = [300, 2, 12, 44, 1, 1, 4, 10, 7, 1, 78, 123, 55]
new_list = [my_numbers[i] for i in range(1, len(my_numbers)) if my_numbers[i] > my_numbers[i-1]]
print(new_list) |
2e3c62a0757ae2f8f9cf4bbed7733bd74d9bb482 | Annisotropy/Python | /HW2/Task3.py | 594 | 3.90625 | 4 | #1
month1 = input('Введите любой месяц цифрой от 1 до 12: ')
my_dict = {'1': 'winter', '2': 'winter', '3': 'spring', '4': 'spring', '5': 'spring', '6': 'summer', '7': 'summer',
'8': 'summer', '9': 'autumn', '10': 'autumn', '11': 'autumn', '12': 'winter'}
print(my_dict[month1])
#2
month2 = input('Введите любо... |
abbab3f0997e611484012c1616af259d44fe6176 | alex-code4okc/advent-of-code2020 | /Day2/day2_part2.py | 855 | 3.734375 | 4 | def result() -> int:
result = None
with open("input_day2.txt", "rt") as file:
lines = file.readlines()
# remove new lines
lines = [l.strip() for l in lines]
acceptable = []
for line in lines:
condition, password = line.split(":")
min_max, charact... |
7c9879abac0149b1c072961e66d7364716410962 | kim-hwi/Python | /softeer/8단미션.py | 210 | 4.03125 | 4 | import sys
arr = [int(i) for i in input().split()]
# print(arr)
if arr == [1, 2, 3, 4, 5, 6, 7, 8]:
print("ascending")
elif arr == [8, 7, 6, 5, 4, 3, 2, 1]:
print("descending")
else:
print("mixed")
|
e304f219f92cde59c80352cdcd554fe77579db1f | kim-hwi/Python | /Heap/이중우선순위큐.py | 868 | 3.59375 | 4 | import heapq
def solution(operations):
print(operations)
heap1 = []
for i in operations:
if i[0] == 'I':
heapq.heappush(heap1, int(i[2:]))
if i[0] == 'D':
if len(heap1) == 0:
continue
if i[2:] == '-1':
heapq.heappop(heap1... |
844d2367e9bd785b7a4757b42cac052ef66f8fac | kim-hwi/Python | /basictest/나이순 정렬.py | 244 | 3.578125 | 4 | num = int(input())
arr = [[0,0,'']for i in range(num)]
for i in range(num):
arr[i][0] = i
arr[i][1],arr[i][2] = map(str,input().split())
arr.sort(key = lambda x:(int(x[1]),int(x[0])))
for i in range(num):
print(arr[i][1],arr[i][2])
|
f3aa094a2bca69fd9aa554f3959a924477d3fe7d | kim-hwi/Python | /basictest/영화감독 숌.py | 155 | 3.5 | 4 | testcase = int(input())
count = 0
num = 665
while testcase > count:
num += 1
temp = str(num)
if "666" in temp:
count+=1
print(num)
|
ff0ae3aeab1e651665b7f47bc292c8d8718879aa | todixon/practice | /recursive.py | 175 | 4.03125 | 4 |
def recursive(input):
if input <= 0:
return input
else:
output = recursive(input - 1)
print(output)
return output
print(recursive(2)) |
70a5488de69e2f96eba33b2c152ef6d9d2886722 | todixon/practice | /hello.py | 504 | 4.09375 | 4 | # This program says hello and asks for my name
print('Hello world!')
print('What is your name?') # ask for their name
myName = input()
print('It is good to meet you, ' + myName)
print('the length of your name is:')
print(len(myName))
print('What is your age?')
myAge = int(input())
print('You will be ' + str(int(my... |
d133c88ca79b8e137ba209e36ddfb28ceb4cf042 | prtha112/math-lab | /set_intersection.py | 235 | 4 | 4 | def intersection(set1, set2):
inter = list(set(set1) & set(set2))
return inter
set_1 = [1,1,2]
set_2 = [3,1,2,4,5]
print(intersection(set_1, set_2))
set_1 = ['A','B','C']
set_2 = ['C','E', 1]
print(intersection(set_1, set_2)) |
b463b7ae82416f4e22ccbf1b08656edba195f529 | mariellefoster/learning | /number_theory/abundant.py | 242 | 3.84375 | 4 | def abundant():
for i in range(2, 1000):
if i < sum_divisors(i):
print "abundant: " + str(i)
if i%2 == 1:
print "ODD"
def sum_divisors(n):
summ = 0
for i in range(1, n/2+1):
if n%i == 0:
summ += i
return summ
abundant() |
065126994ccd96ae78bd147762f3ce193c089138 | Davidzuluagag/PROGRAMATION | /Talleres y tareas/Taller-prequiz1.py | 766 | 3.984375 | 4 | #-----------MENSAJES---------------#
MENSAJE_BIENVENIDO = "Bienvenido"
PREGUNTA_PACIENTES = "Ingrese numero de pacientes"
MENSAJE_BAJO = "Riesgo bajo"
MENSAJE_MEDIO = "Riesgo medio"
MENSAJE_ALTO = "Riesgo alto"
PREGUNTA_UCI = "Ingrese numero de pacientes en UCI"
#-----------ENTRADAS------------#
_numeroPacientes = " "... |
3e5efb7bdfe7d2d4f3438ab28c8b070dd0b836ef | Davidzuluagag/PROGRAMATION | /Examenes/Quiz 1.py | 1,122 | 4 | 4 | #-----------MENSAJES---------------#
PREGUNTA_TEMPERATURA = "Igrese temperatura corporal (en °C) del usuario"
PREGUTA_PROCEDENCIA = "Ingrese procedencia del usuario"
MENSAJE_HIPOTERMIA = "Hipotermia"
MENSAJE_SALUDABLE = "Saludable"
MENSAJE_ALERTA = "Alerta"
MENSAJE_PELIGRO = "Peligro"
MENSAJE_OBSERVACIÓN = "En observac... |
9682bdce76206453617d5b26c2c219becb5d4001 | yougov/tortilla | /tortilla/formatters.py | 444 | 4.125 | 4 | # -*- coding: utf-8 -*-
def hyphenate(path):
"""Replaces underscores with hyphens"""
return path.replace('_', '-')
def mixedcase(path):
"""Removes underscores and capitalizes the neighbouring character"""
words = path.split('_')
return words[0] + ''.join(word.title() for word in words[1:])
def... |
ec23e639c78ecc7b4134ae5361e0d3acb00fb787 | davidcmm/campinaPulse | /scripts/analise/dadosSet17/usuario/fixnames.py | 727 | 3.5 | 4 | # coding=utf-8
# This script receives a file with street names, qscores and lat/long and replaces street names whitespaces with _
import sys
if __name__ == "__main__":
if len(sys.argv) < 2:
print "Uso: <arquivo com ruas, qscore e lat/long>"
sys.exit(1)
data_file = open(sys.argv[1], "r")
lines = data_file.read... |
bcfc6b454ca877ba7650b1ea12be892b1e978b04 | abhishekshahane/username | /func.py | 1,007 | 3.890625 | 4 | """
DO NOT MODIFY THE CODE
BELOW THIS LINE.
"""
import sqlite3
#Getting the sqlite connection
conn = sqlite3.connect('example.db')
#Creating a object out of that connection.
cursor = conn.cursor()
#Creating the table here
sql ='''CREATE TABLE USERNAME(
USERNAME CHAR(100) NOT NULL,
WEBSITE CHAR(1000)
)'''
#If ... |
62a8b8245b4877f2e8f1599dfea13fc520e06032 | vinay59530/spy-chat | /spydetails.py | 1,045 | 3.75 | 4 | spy_is_online=False
spy_name = raw_input("Enter your Name")
spy_salutation= raw_input("Are You Mr. or Ms. ?")
spy_password=raw_input("Create your password")
print("you have created a password")
spy_age = raw_input("Enter your age")
spy_rate=raw_input("Enter your rating (out of 5)")
if len(spy_name)>0 and spy_age>="18" ... |
63252875d59ce1d4ed17864e6d85a96ce555198e | kaiocp/uri-challenges | /python/1042.py | 177 | 3.71875 | 4 | a, b, c = map(int, input().split())
_list = [a, b, c]
sorted_list = sorted(_list)
for number in sorted_list:
print(number)
print()
for number in _list:
print(number)
|
bba37baa003b4b07bb31c1b5bfac36bb9f9c1afa | kaiocp/uri-challenges | /python/1066.py | 516 | 3.75 | 4 | # storing values
_list = []
for num in range(5):
num = int(input())
_list.append(num)
# counting evens and odds
evens, odds = 0, 0
for num in _list:
if num % 2 == 0:
evens += 1
else:
odds += 1
# counting positives and negatives
pos, neg = 0, 0
for num in _list:
if num > 0:
... |
4664d11d11dcfdd9a52868c6f9afaaee7721f3bd | kaiocp/uri-challenges | /python/1037.py | 322 | 3.765625 | 4 | ent = float(input())
if ((ent >= 0) and (ent <= 25)):
print("Intervalo [0,25]")
elif ((ent > 25) and (ent <= 50)):
print("Intervalo (25,50]")
elif ((ent > 50) and (ent <= 75)):
print("Intervalo (50,75]")
elif ((ent > 75) and (ent <= 100)):
print("Intervalo (75,100]")
else:
print("Fora de intervalo"... |
e7e059b9395b1e22d4932f005031b549a59b3825 | kaiocp/uri-challenges | /python/1060.py | 231 | 3.90625 | 4 | number_list = []
for number in range(0, 6):
number = float(input())
number_list.append(number)
pos_values = 0
for number in number_list:
if number > 0:
pos_values += 1
print(f"{pos_values} valores positivos")
|
e1f7afb9801174f5380cb56e563b09f2f6ee95f0 | mdribera/project-euler | /p001.py | 432 | 4.09375 | 4 | # PROBLEM ONE
# https://projecteuler.net/problem=1
# If we list all the natural numbers below 10 that are multiples of 3 or 5,
# we get 3, 5, 6 and 9. The sum of these multiples is 23.
# Find the sum of all the multiples of 3 or 5 below 1000.
def find_sum_of_multiples(max):
total = 0
for x in range(1, max):
... |
5531520bb4582e1fdb0c439a4aabe1de078de97e | Satomin2864/math_adventure | /chap_3/number_game.py | 591 | 3.734375 | 4 | from random import randint
def numberGame():
number = randint(1, 100)
print("number当てゲームです。")
print("1~100までの数字を当ててください。")
guess = int(input("いくつかと思いますか?"))
while True:
if number == guess:
print("正解です")
break
elif number > guess:
print("不正解です。もっと... |
c835f716667d2854b6658f16c45112e845376c28 | baydingv/pyBase | /ex_2_6.py | 991 | 3.984375 | 4 | # -*- coding: utf-8 -*-
#В программе генерируется случайное целое число от 0 до 100.
# Пользователь должен его отгадать не более чем за 10 попыток.
# После каждой неудачной попытки должно сообщаться
# больше или меньше введенное пользователем число, чем то, что загадано.
# Если за 10 попыток число не отгадано, то в... |
64accf0a27b0e44dd3cea95f2fd3b89b7f0cad56 | NazeliGalsytyan/homework_python | /3_home.py | 1,759 | 3.8125 | 4 | #Task_1
class Circle:
def __init__ (self, radius):
self.radius = input("Enter circle radius value!\n")
def area(self):
print("The area of the circle equals:")
print(int(self.radius) **2 * 3.14)
def perimeter(self):
print("The perimeter of the circle equals:")
print(int(self.radius) *2 * 3.14)
circle_... |
1242dfb0fe79c5b10a512eea2ef543bb4068c4f4 | NazeliGalsytyan/homework_python | /4_home.py | 1,979 | 4 | 4 | class Country:
def __init__(self, continent,name_country):
self.continent = continent
self.name_country = name_country
def country_presemtation(self):
country_return = F"This prodact is made in {self.continent} in {self.name_country}."
return country_return
class Brand:
def __init__(self,name_brand,st... |
87c72440ec6362b1a9f1da1506c2b2c7c1d73098 | NazeliGalsytyan/homework_python | /python_classes/2_homework.py | 948 | 3.734375 | 4 | #homwork_2
# Task_1
celsius = float(input("Temperature in celsius"))
f = (celsius * 9/5) + 32
print("Temperature in fahrenheit", f)
#OR
# c = 25
# number = 32
# f = (c * 1.8) + 32
# print(f)
# # #Task_2
# # #1
# a = 5
# b = 6
# c = 7
# z = (a+ b+ c)/3
# print(z)
# #2
# z = a**c + b**c
# print(z)
# #3
# z = (a + b)... |
fe57a8e2f21221e250e56e7f319d448ce80533ed | NazeliGalsytyan/homework_python | /python_classes/5_homework.py | 1,581 | 4.03125 | 4 | #Task_1
year = int(input("Enter a year and I\'l tell you if it\'s a leap year or not. \n"))
if year % 4 == 0:
if year % 100 == 0:
if year % 400 == 0:
print("{0} is a leap year!".format(year))
else:
print("{0} is not a leap year!".format(year))
else:
print... |
d74fa5642ef8bb8660fcf38a6466d91cef78b7e5 | christopherhui/geeksforgeeks | /graphs/adjlistcol.py | 481 | 3.765625 | 4 | from collections import defaultdict
class Graph:
def __init__(self, vertices):
self.graph = defaultdict(list)
self.vertices = vertices
def addEdge(self, u, v):
if u > self.vertices or v > self.vertices:
raise ValueError("Value of u or v is greater than number of vertices."... |
d817d8f491e23137fd24c3184d6e594f1d8381b0 | GaneshManal/TestCodes | /python/practice/syncronous_1.py | 945 | 4.15625 | 4 | """
example_1.py
Just a short example showing synchronous running of 'tasks'
"""
from multiprocessing import Queue
def task(name, work_queue):
if work_queue.empty():
print('Task %s nothing to do', name)
else:
while not work_queue.empty():
count = work_queue.get()
tota... |
68a9fa74fcc26279e1e184eb9281e458c86b3937 | GaneshManal/TestCodes | /python/practice/sqaure_generator.py | 510 | 4.15625 | 4 | # Generator Function for generating square of numbers
def square_numbers(nums):
for num in nums:
yield num*num
numbers = range(1, 6)
gen_x = square_numbers(numbers)
print "Generator Object : ", gen_x
print "Generator Mem : ", dir(gen_x)
""""
'print '--->', gen_x.next()
print '--->', gen_x.next()
print ... |
efc7eb5facd34819df189af40bff4725e9016aca | FuzzyLogick/ChooseYourOwnAdventure-1 | /pg73.py | 590 | 3.765625 | 4 | def text():
print("")
print("")
#print("[From part 81]")
print("")
print("Standing in line will take too long. Perhaps this man is the only way to get a message to the pharoah. But you can't say anything about the potion. You tell the man that you want to meet the pharaoh in a grove of trees by t... |
220f392ef8c5174db1f915aa8b5209a69061d715 | FuzzyLogick/ChooseYourOwnAdventure-1 | /pg22.py | 1,456 | 3.90625 | 4 | def text():
print("")
print("")
#print("[From part 7]")
print("")
print("You take the slow geology cruiser and hope for the best. You fly low over the forests and lakes of Andromeda. It works. You pass across the other side of the planet undetected by the Voxons. After you land, you are led insi... |
aa93a7a6ec7b84e8166bd117306902a246328a4c | FuzzyLogick/ChooseYourOwnAdventure-1 | /pg28.py | 1,639 | 4.09375 | 4 | def text():
print("")
print("")
#print("[From part 27]")
print("")
print('"Today is the birthday of Lord Snag," says Milo, "and I am baking him a cake."')
print("")
print('"A poison cake, I hope," says Vleet.')
print("")
print('"No," says Milo. "Snag has his slaves taste the food fi... |
c3b18a7e7f9f59926167e38351ad28e96fafbf99 | FuzzyLogick/ChooseYourOwnAdventure-1 | /pg92.py | 999 | 3.65625 | 4 | def text():
print("")
print("")
#print("From part 66")
print("")
print("Your first task is to find Dr. Walker. Whatever is shiny on top of the hill may be a clue, so you walk up there as carefully as you can. At the crest of the hill, you see something amazing: a large spaceship with its hatch op... |
e0e75e87f998f503ddcad6ee8a8fedf140a7eaa0 | FuzzyLogick/ChooseYourOwnAdventure-1 | /pg74.py | 552 | 3.75 | 4 | def text():
print("")
print("")
#print("[From part 21]")
print("")
print("The Hall of Dinosaurs is a big room, but for some reason, all the exits are blocked. The seven people now have you trapped. Giant dinosaur skeletons loom above you.")
print("")
print('"Give us the bottle," says the le... |
32642819cef74b507c4f7751c00f5840997ec062 | FuzzyLogick/ChooseYourOwnAdventure-1 | /pg6.py | 1,312 | 4.0625 | 4 | def text():
print("")
print("")
#print("[From part 41]")
print("")
print("")
print("The liquid smells so good that you take just a tiny sip. It tastes wonderful, too, like honey and cinnamon. You take another sip. The planetarium speaker is saying something about the night sky in August, but ... |
ab976a8b4180302c15e164781a2b467ade29abd4 | FuzzyLogick/ChooseYourOwnAdventure-1 | /pg85.py | 640 | 3.75 | 4 | def text():
print("")
print("")
#print("[From part 51 / part 65]")
print("")
print("You sneak away to the hidden spot where you can be alone. Opening the bottle, you recognize the familiar scent of honey and cinnamon.")
print("")
print("After you take a little sip, you feel warmth in your s... |
49bb7190d717037a7cd9f1518b74dcdedd99f6ed | FuzzyLogick/ChooseYourOwnAdventure-1 | /pg34.py | 539 | 3.5625 | 4 | def text():
print("")
print("")
#print("[From part 23]")
print("")
print("")
print('You call to the guard, "There is something crawling around in here. Please put is un another room."')
print("")
print('"The only thing crawling around will be you three spies," says the guard, "in the Mi... |
2bea88c289e7f417b5433f18af27137aed4a467d | FuzzyLogick/ChooseYourOwnAdventure-1 | /pg94.py | 1,152 | 4.03125 | 4 | def text():
print("")
print("")
#print("From part 89")
print("")
print("You throw stones and sticks to destract the dinosaurs from the aliens. Your plan works. The dinsaurs go away. After the animals have left, you approach the aliens.")
print("")
print('"Thank you, Earthling," they say. ... |
5a9161c4f8f15e0056fd425a5eee58de16ec45bf | beb777/Python-3 | /003.py | 417 | 4.28125 | 4 | #factorial n! = n*(n-1)(n-2)..........*1
number = int(input("Enter a number to find factorial: "))
factorial = 1;
if number < 0:
print("Factorial does not defined for negative integer");
elif (number == 0):
print("The factorial of 0 is 1");
else:
while (number > 0):
factorial = factorial * number
... |
c7237a147182067b9f46e1f106fd946adf4849e2 | haleyxu/PyPractice | /filedeal.py | 794 | 3.921875 | 4 | #打开文件
with open("pi_data.txt") as file_object:
contents = file_object.read()
print(contents)
print('-' * 20)
#打开文件,按行输出
file_name = "pi_data.txt"
with open(file_name) as file_object:
for line in file_object:
print(line.rstrip())
print('-' * 20)
#with代码段外使用文件内容
with open(file_name) as file_objec... |
d692009f8dcc413c01f6621ca2dd4ce862ec117f | ankush4144/File-Handling-Questions | /question-5.py | 538 | 3.90625 | 4 | #Q.5- Write a Python program to write 10 random numbers into a file.
#Read the file and then sort the numbers and then store it to another file.
import random
file1=open('d.txt','w')
for i in range(1,11):
file1.writelines(str(random.randrange(1,100))+'\n')
file1.close()
file1=open('d.txt','r')
file_content=file1.r... |
e4b485f80b9649d0f7bb3b9b5dbf4358a1172d84 | kbm1422/New_Framework | /Sam_Test_Code/Python_Challenge_4.py | 546 | 3.828125 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import urllib
import re
url = "http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing="
number = "12345"
R = re.compile("(\d+)$")
D = re.compile("Divide")
while True:
source = urllib.urlopen(url + number).read()
match = re.search(R, source)
divide = re.sear... |
1c922b07b6b1f011b91bc75d68ece9b8e2958576 | Leah36/Homework | /python-challenge/PyPoll/Resources/PyPoll.py | 2,168 | 4.15625 | 4 | import os
import csv
#Create CSV file
election_data = os.path.join("election_data.csv")
#The list to capture the names of candidates
candidates = []
#A list to capture the number of votes each candidates receives
num_votes = []
#The list to capture the number of votes each candidates gather
percent_votes = []
#... |
eae5cf109c9e7f40267156b4f96b8f6e6266f538 | Ivoah/InteractiveFiction | /demo.py | 1,755 | 3.859375 | 4 | from InteractiveFiction import *
world = World()
@world.room('Bedroom', True)
class Bedroom(Room):
'''Your bedroom. There is a bathroom to the north and a living room to the south.'''
south = 'Living room'
north = 'Bathroom'
@world.room('Living room')
class LivingRoom(Room):
'''A modern looking livi... |
5797e49efd3cfc42d3e8f85b7567a4590da72f12 | AndreDegel/blackjack | /PlayMain.py | 554 | 3.9375 | 4 | __author__ = 'Andre'
"""
Main method to start a blackjack game.
Main in version 1.0, could use shaping up
by using a loop to restart the game and
create every time a new Blackjack object.
from blackjack import Blackjack
"""
game = Blackjack()
"""game2 = Blackjack()
"""
def main():
start = input("Would you like to p... |
ac35daa52a1319932e505b76e0a8e9bbae90889b | principia12/Algorithm-Lickers | /mcjung/remove-invalid-parentheses.py | 1,857 | 3.546875 | 4 | # problem link: https://leetcode.com/problems/remove-invalid-parentheses
import itertools
pas = ['(', ')']
class Solution:
def removeInvalidParentheses(self, s: str) -> List[str]:
result = set()
remove_list = []
basic = self.parsing_parentheses(s)
result.add(basic)
pa_list... |
a55dc8ef112a7043d5ab3843f618265a4103e14c | whisperity/dotfiles-framework | /dotfiles/lazy_dict.py | 1,089 | 3.75 | 4 | class LazyDict(dict):
"""
A version of dict where a user-supplied factory method can be used to
provide None-marked elements.
:note: Why doesn't collections.defaultdict support this... :(
"""
def __init__(self, factory, initial_keys=None):
"""
Create a new dict and register the... |
71000dd86b84710b89b78315df1859d1d12d9259 | pavlee/rsa | /rsa_enc.py | 1,256 | 3.515625 | 4 | import sys
BLOK_CIFRE = 300
BLOK_KARAKTERI = BLOK_CIFRE // 3
plaintext = ""
sifrovani_text = ""
def encrypt(plaintext, key):
ascii_plaintext = bytes(plaintext, "ASCII")
# Tekst se lomi na blokove duzine najvise BLOK_KARAKTERI chara
# Svaki char je predstavljen pomocu trocifrenog broja
bloko... |
faaf4b222a3b9e120d0197c218bcd6e25c3422a4 | bwblock/Udacity | /CS101/quiz-median.py | 621 | 4.21875 | 4 | #! /usr/bin/env python
# Define a procedure, median, that takes three
# numbers as its inputs, and returns the median
# of the three numbers.
# Make sure your procedure has a return statement.
def bigger(a,b):
if a > b:
return a
else:
return b
def biggest(a,b,c):
return bigger(a,bigger(b... |
01bdad6c1614a2db3d954735b3546c3b1445d452 | seanluciotolentino/SimpactPurple | /simpactpurple/Operators.py | 10,291 | 3.59375 | 4 | """
Module for all of the default operators.
"""
import Queue
import numpy as np
import numpy.random as random
class RelationshipOperator():
"""
Controls the formation and dissolution of relationships between agents. At
initialization, the relationship operator creates the grid queues it will
nee... |
852b7503b5a6cba6f532058d664c3c2cd36de376 | hanigue/CTU-codes | /RPH/testiky/strings.py | 632 | 3.828125 | 4 | from collections import Counter
from os.path import splitext
def count_chars_in_string(arg):
cnt = Counter()
for s in range(len(arg)):
cnt[arg[s]] += 1
cnt.pop("\n")
return cnt.most_common(len(cnt))
def count_chars_in_file(arg):
with open(arg, 'r', encoding="utf-8") as f:
... |
c95fe818b4b1336e49416a45e9eb8304780bbfbc | vijayboopathy-zz/learn-python | /ex5.py | 485 | 3.90625 | 4 | my_name = 'Vijayboopatny Elangovan'
my_age = 26
my_height = 74
my_weight = 75
my_eyes = 'Black'
my_teeth = 'White'
my_hair = 'Black'
print(f"Let's talk about {my_name}.")
print(f"He's {my_height} inches tall.")
print(f"He's {my_weight} pounds heavy.")
print(f"Actually that's not too heavy.")
print(f"He's got {my_eyes}... |
4177affcacfc12c25bddd614f54eaa4ef31cab82 | LuffySir/Python-learning | /tkinter_gui/tkinter_gui_event.py | 3,669 | 3.640625 | 4 | # -*- coding:utf-8 -*-
import tkinter
# 事件响应
# bind(seq,func,add)
# bind_class(class,seq,func,add) 类绑定
# bind_all(seq,func,add) 所有组件事件绑定到事件响应函数
# seq为绑定的事件,以<>包围的字符串,如<Button-1>左键按下,<KeyPress-A>按下A键等
class MyButton:
def __init__(self, root, canvas, label, type):
self.root = root
self.canvas = c... |
d45809da871238ef94c6ebf82a09104ca9915c86 | ignovak/my_sandbox | /chess.py | 5,439 | 3.71875 | 4 | #!/usr/bin/env python
#-*- coding: utf-8 -*-
from pprint import pprint
from time import sleep
class Board():
def __init__(self, chars=[]):
self.SIZE = 8
self.board = [[0 for i in range(self.SIZE)] for i in range(self.SIZE)]
# self.OLD_CHARS = {
# 'queen': ['Q', self.__queen],
#... |
a759beda8dd1ef2309a0c200c3442bed4228f455 | naotube/Project-Euler | /euler7.py | 616 | 4.21875 | 4 | #! /usr/bin/env python
# By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13,
# we can see that the 6th prime is 13.
# What is the 10001st prime number?
primes = [2,3]
def is_prime(num):
"""if num is a prime number, returns True, else returms False"""
for i in primes:
if num % i == 0:
... |
cfab23035d6d8755c6b7a631380ea3add940263c | naotube/Project-Euler | /euler44.py | 832 | 3.53125 | 4 | class Pentagonal:
def __init__(self, start=1, maximum=2100000000):
self.start = start
self.maximum = maximum
def __iter__(self):
self.number = self.start
return self
def __next__(self):
pentagonal = int(self.number * (3 * self.number - 1) / 2)
if pentagonal ... |
b050c56f19cb7f9ab011f0c519db652a13369955 | naotube/Project-Euler | /euler145.py | 262 | 3.84375 | 4 | LIMIT = 10 ** 9
reversible = 0
for i in range(1, LIMIT):
if not i % 10 == 0 and all(not int(d) % 2 == 0 for d in str(i + int(str(i)[::-1]))):
reversible += 1
print(i)
print("{0} reversible numbers exist below {1}".format(reversible, LIMIT))
|
09c439bf39db140df5d094265ff57823679bd7b2 | naotube/Project-Euler | /euler43.py | 441 | 3.671875 | 4 | import itertools
if __name__ == "__main__":
primes = [2,3,5,7,11,13,17]
digits = ['0','1','2','3','4','5','6','7','8','9']
pandigital_numbers = itertools.permutations(digits)
pandigital_numbers = ["".join(n) for n in pandigital_numbers if not n[0] == '0']
interesting_numbers = [int(n) for n in pan... |
80663cac907a117527ed74eed69f3138c87ef98a | naotube/Project-Euler | /euler142.py | 426 | 3.546875 | 4 | from itertools import count
def main():
squares = set()
for x in count(3,1):
squares.add(x ** 2)
for y in range(x-1, 0, -1):
if x+y in squares and x-y in squares:
for z in range(y-1, 0, -1):
p = (x+z, x-z, y+z, y-z)
if all(n in... |
66d4fcfa07aed59ff5befc78a6139b11b5fb4b8c | SorenKremer/Boiler_board_hack | /Color_Game.py | 2,497 | 3.984375 | 4 | """start up code needed here"""
print("Hello World")
"""Main starts here"""
wrong_press = 0
number_of_trials = 1
while number_of_trials < 16:
random_number = 0
user_input = 0
import random
for x in range(1):
random_number = (random.randint(0, 9))
if random_number == 0:
print("UP")... |
3afe6d679ce437fc4466278143cff4c97b75a21b | cdrinconm/Cursos-Virtuales | /Coursera/Algorithmic Toolbox/week3_greedy_algorithms/7_maximum_salary/largest_number.py | 425 | 3.640625 | 4 |
def largestNumber():
total = 0
i = 1
while total < n:
if (total + i) == n:
arreglo.append(i)
return len(arreglo)
if (total + i) < n:
total = total + i
arreglo.append(i)
else:
arreglo.append(i)
total = total + i
exc = total - n
arreglo.remo... |
eab7d94b1926d280f96e261156e32f16b796e1e3 | cdrinconm/Cursos-Virtuales | /Coursera/Algorithmic Toolbox/week1_programming_challenges/1_sum_of_two_digits/APlusB.py | 239 | 3.984375 | 4 | # python3
def sum_of_two_digits(first_digit, second_digit):
return first_digit + second_digit
entrada = input()
entrada = entrada.split()
number1 = int(entrada[0])
number2 = int(entrada[1])
print (sum_of_two_digits(number1,number2))
|
4e59686cfdb9ff9c6835c17ee66b0b9ce1956f69 | bgitego/DSP_WITH_PYTHON | /DSP_BOOK/func_fft.py | 5,066 | 3.796875 | 4 | import matplotlib.pyplot as plt
import numpy as np
import cmath as cm
print('DSP Tutorial Implementation of The Discrete fourier transform')
N = 128 # Number of Sample
N_MINUS_1 = N-1 # Used to Define Array access 0 Index Max Value
N_OVER_2 = int((N/2)) # Used to Def... |
f9a5045cb8eb1da9e717ce37487162fcf8335602 | sweakpl/connect-four | /test/connectfour_test.py | 4,634 | 3.515625 | 4 | # This Python file uses the following encoding: utf-8
#python -m unittest test.connectfour_test
import unittest
from gamemodel.connectfour import ConnectFourClassic
from gamemodel.wrongmoveexception import WrongMoveException
class ConnectFourTest(unittest.TestCase):
'''TestCase class for testing the ConnectFourC... |
f9980a6aed23237637945f961672875d962240f1 | muke101/AdventOfCode | /2-1.py | 341 | 3.796875 | 4 | import sys
strings = sys.stdin.read()
double = 0
tripple = 0
for string in strings.splitlines():
characters={}
for character in string:
if character in characters:
characters[character]+=1
else:
characters[character] = 1
if 3 in characters.values():
tripple+=1
if 2 in characters.values():
double+=1
... |
c1640acb6098ab4e8d87c5684dfb88e73a71fb89 | cjcruzrivera/swapps_test_2 | /method.py | 989 | 3.65625 | 4 | """
This file can be imported as a module and contains the following
function:
* getFourLenSubStringRepeated - returns how many substrings of 4 characters appear more than once along a main string
"""
def getFourLenSubStringRepeated(mainString):
"""
Method that identifies how many substrings of 4 characte... |
5887e5004eb41259e28e4f9c908ac8064fa3e703 | Vijay-FSD/Currency-converter | /desktopapp.py | 773 | 3.96875 | 4 | from tkinter import *
window = Tk()
def conversion():
indianrupees = (float(dollars.get())*75)
t1.delete("1.0", END)
t1.insert(END, indianrupees)
canadian = (float(dollars.get())*1.3)
t2.delete("1.0", END)
t2.insert(END, canadian)
euros = (float(dollars.get())*0.84)
t3.... |
9a8afb90a8f875ebb495f1cf54c50612a28613fd | ubaidahmadceh/python_beginner_to_expert | /tables_by_while_loop.py | 209 | 3.96875 | 4 | number = int(input("enter number : "))
start = int(input("enter start point : "))
limit = int(input("enter limit : "))
while start <= limit:
print(f"{number} x {start} = {number*start}")
start += 1
|
250b0995a4454e028efc181c0fd8e2a3970a02e6 | ubaidahmadceh/python_beginner_to_expert | /ordered_dictionaries_in_collections.py | 171 | 3.703125 | 4 | from collections import OrderedDict
my_dictionary = OrderedDict()
my_dictionary[1] = "Apple"
my_dictionary[2] = "Mango"
my_dictionary[3] = "Orange"
print(my_dictionary) |
32867cc63387d79bf31da4ef7395c4713d5b1599 | ubaidahmadceh/python_beginner_to_expert | /deque_in_collection.py | 158 | 3.65625 | 4 | from collections import deque
my_list = ['pakistan', 'india', 'nepal']
deque_of_my_list = deque(my_list)
deque_of_my_list.popleft()
print(deque_of_my_list) |
cd9902d851dd5f7d4527d6bb80fa8abf13ef59c7 | ubaidahmadceh/python_beginner_to_expert | /isdigit_function.py | 218 | 4.25 | 4 | number = input("Enter your number : ")
if number.isdigit():
print("this is numeric (0-9)")
elif number.isalpha():
print("this is string !!")
else:
print("This is not numeric , this is symbol or alphabet")
|
244ef98e42b8538bd4d780203a2cc27956a3f871 | dolandJake/Cs114 | /Cs114/magic8ball.py | 791 | 3.859375 | 4 |
print("Ask any question. about the future.")
life = input()
import random
def getanswer(answernumber):
if answernumber == 1:
return "What do you think?"
elif answernumber == 2:
return "It might be."
elif answernumber == 3:
return "totes mcgoats"
elif answernumber == 4:
... |
06a27040c7d5d372c5a4b69aa53ed6ead2b6949f | Deepika200012/Guvi | /task/firstlast.py | 203 | 3.71875 | 4 | def firstDigit(n) :
while n >= 10:
n = n / 10;
return int(n)
def lastDigit(n) :
return (n % 10)
n = 98562;
print(firstDigit(n), end = " ")
print(lastDigit(n))
|
217e90f00ca3e57f29be4bce036367b3201f2380 | Deepika200012/Guvi | /task/numguess.py | 159 | 3.609375 | 4 | import random
a=int(input("enter the number"))
print(a)
r=random.randint(1,99)
print(r)
if(a==r):
print("success")
else:
print("not success")
|
629c32b051677e577aaa63a269a6cef608432126 | ethanweber/SGD-Loss-Landscape | /generate_dataset.py | 3,078 | 3.59375 | 4 | """Generate synthetic datasets.
"""
import argparse
import pprint
from sklearn.datasets import make_regression, make_classification
from sklearn.preprocessing import MinMaxScaler
import os
import numpy as np
parser = argparse.ArgumentParser(description="")
parser.add_argument('--n', type=int, default=1000, help="numb... |
fe0051ff89d919948011a5cf94a99a282c6e9228 | mglcampos/trader | /htr/helpers/welford.py | 1,389 | 3.625 | 4 | import numpy as np
class Welford(object):
"""Calculate the moving standard deviation using Welford's Algorithm."""
def __init__(self, window_size):
"""Create object with a given window size.
Size can be -1, infinite size or > 1 meaning static size."""
self.window_size = window_size
... |
5244b2220f9a582cc780a374a52ecf7b7cc79c47 | SimmyZhong/leetCode | /179_MaxNum.py | 1,660 | 3.84375 | 4 | """
https://leetcode-cn.com/problems/largest-number/
给定一组非负整数,重新排列它们的顺序使之组成一个最大的整数。
示例 1:
输入: [10,2]
输出: 210
示例 2:
输入: [3,30,34,5,9]
输出: 9534330
说明: 输出结果可能非常大,所以你需要返回一个字符串而不是整数。
"""
class Solution:
def largestNumber(self, numList):
sortList = self.__mergeSort(numList)
result = ''.join([str(each) for each in... |
e78a1c15c7e86aaeec34c7da1b8a00479ca594b3 | sparksmp/Programming_Tools_and_File_Management | /ArticleLetterCount.py | 1,575 | 3.921875 | 4 | """
We want to use Python and an HTML parser called BeautifulSoup
to visit websites (UIC News) and extract their article dates, titles,
article url and the article text.
"""
from bs4 import BeautifulSoup
import urllib3
my_word = "the"
def TheCount(article):
for word in alpha:
D[c] = 0
for c in arti... |
62064319c0e14653d0903ba033bab6d0a58df3bf | sparksmp/Programming_Tools_and_File_Management | /Lecture30.py | 1,474 | 3.90625 | 4 |
"""
We want to use Python and an HTML parser called BeautifulSoup
to visit websites (UIC News) and extract their article dates, titles,
article url and the article text.
"""
from bs4 import BeautifulSoup
import urllib3
#2
def GetArticleText(art_url):
http = urllib3.PoolManager()
requested = http.reque... |
aa51c3ac081bdc54fdae83035e9d9bca83c36f31 | pykili/py-204-hw1-tpeyrolnik | /task_3/solution_3_2.py | 201 | 3.9375 | 4 | string = input()
alphabet = ""
for i in string:
if i not in alphabet:
alphabet+=i
for s in range (1, 9):
string = input()
for k in string:
if k not in alphabet:
alphabet+=k
print (alphabet)
|
8ec44fa264f7d8c6006002d7f96478b2dec81788 | GUOliver/COMP2041-Tutor | /wk12/flask/quick.py | 102 | 3.75 | 4 | #!/usr/local/bin/python3
def s(a, b):
return a + b
number = dict(a=5, b=10)
print(s(**number))
|
a04df7c374427b78bc7711661ada1adbd7b4086d | GUOliver/COMP2041-Tutor | /wk12/flask/sort.py | 131 | 3.765625 | 4 | #!/usr/local/bin/python3
s = dict()
s['a'] = 10
s['b'] = 3
s['c'] = 17
s['d'] = 0
letters = sorted(s, key=s.get)
print(letters)
|
5920e52626ee1c337ddb30f7c3657d62c8012882 | jf115/python-lesson | /Clase 4/condicionales.py | 1,024 | 3.96875 | 4 | # edad = int(input('Ingrese la edad: '))
# if edad >= 18:
# print('Es mayor de edad')
# else:
# print('Es menor de edad')
#edad = int(input('Ingrese la edad: '))
# if edad < 10:
# print('Muy joven')
# elif edad >=10 and edad < 14:
# print ('Es categoria infantil')
# elif edad >=14 and edad < 17:
# ... |
55d554785a728b28f90d235233fcd0d13db0601a | Mahmoud-Arafaa/GenaticsAlgorithms | /assignment_1GenaticAlgorithmsKnapsack/genaticAlgorithmsKnapsack.py | 4,153 | 3.5625 | 4 | import random
input = open(r"DataFile.txt")
test_case_num = int(input.readline())
candidates = 0
maxWeight = 0
weight = []
value = []
pop = []
fitness = []
fitnessSum = 0
GEERATION_NUM = 20000
POP_SIZE = 100
print("Test cases: ", test_case_num)
def generatePOP():
population = []
for i in range(POP_SIZE):
... |
971cad6e99ec5cd69824289f011ee12c5142947a | Miyayx/LeetCode | /python/103_binary_tree_zigzag_level_order_traversal.py | 854 | 3.8125 | 4 | # Definition for a binary tree node
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
# @param root, a tree node
# @return a list of lists of integers
def zigzagLevelOrder(self, root):
def add_to_li... |
a5dbba04a03a87aea4eed1853168eaa1784f73aa | fac33/CS0008-f2016 | /f2016_cs8_fac33_fp/f2016_cs8_fac33_fp.py | 7,649 | 3.765625 | 4 | # Template for code submission
# name: Fanyang Cheng
# email: fac33@pitt.edu
# date: 12/10/2016
# class: CS0008-f2016
# instructor: Max Novelli (man8@pitt.edu)
#
# Description
# description of this file goes here
# Starting with Python, final projet
# notes
# The program should provide output on the screen similar to t... |
fe806d525ec60e6eb789350136b62132c979a08d | luizsousasuper/circuitoseletricos | /rlc_paralelo.py | 2,332 | 3.65625 | 4 | """"
09/2021 - Código da resposta de um circuito RLC paralelo, todos os casos são contemplados.
"""
import matplotlib.pyplot as plt
import numpy as np
import math
R = float(input('Valor de R [ohm]: ')) #80
L = float(input('Valor de L [H]: ')) #200 * 10 ** -3
C = float(input('Valor de C [F]: ')) #5 * 10 *... |
95a17e11a79f68563c393524c22b6f45b0365599 | rob256/adventofcode2017 | /python3/day_2/day_2_part_1.py | 977 | 4.15625 | 4 | from typing import List
def checksum_line(numbers_list: iter) -> int:
"""
Given a list of numbers, return the value of the maximum - minimum values
"""
min_number = max_number = numbers_list[0]
for number in numbers_list[1:]:
min_number = min(min_number, number)
max_number = max(ma... |
90bd3d19039903b6001e349e42999f6c41339567 | ramjoshi/phonepad-trie | /suggester.py | 1,598 | 3.5625 | 4 | from trie import patricia
KEYMAP = {
'2': 'abc',
'3': 'def',
'4': 'ghi',
'5': 'jkl',
'6': 'mno',
'7': 'pqrs',
'8': 'tuv',
'9': 'wxyz'
}
ptrie = patricia()
def keysearch(seq):
suggestions = {}
if len(seq) == 3:
for ci in KEYMAP[se... |
88fba8cb95b7e3512ad5a1105182f2238462f69e | waltaskew/book-to-music-converter | /bemusic/words.py | 1,109 | 3.875 | 4 | """Extract words and useful word features from a text."""
import nltk
import nltk.tokenize as tokenize
from nltk.corpus import stopwords
from nltk.corpus import wordnet
NOUN_TAG = 'N'
STOP_WORDS = set(stopwords.words('english'))
def iter_nouns(text):
"""Given a text, return an iterator yielding all of the no... |
8a133240dad352f45daeb2e44b08f2a13cdccb42 | jvitorn/python_init | /ex05.py | 445 | 4.0625 | 4 | prova1 = int(input('Digite uma nota: '))
prova2 = int(input('Digite uma nota: '))
prova3 = int(input('Digite uma nota: '))
media = (prova1+prova2+prova3)/3
if(media >=7):
print('Você foi aprovado')
else:
print('Você Não foi aprovado e terá que fazer o exame final')
exame = int(input('Digite sua nota no exam... |
f114f3109b41762c0a9fde9b61f77d6aaaed3e85 | sindhu819/DP-3 | /Problem-23.py | 1,313 | 3.578125 | 4 | #minimum falling path -931
#Time complexity =O(N^2)
#space complexity =O(N^2)
#passed all test cases
#Approach- DP first row remains the same. Subsequent rows takes the minimum value from above rows and add the value in current row column value. for 1 and last columns it's different and middle columns it's different.
... |
3405556565db382761660e3ce2db8fc1d2188c92 | chrishowes55/rock_paper_scissors | /RockPaperScissorsTwentyFive.py | 3,117 | 4.03125 | 4 | from random import randint
import time
playing = True
main_array = ['gun', 'dynamite', 'nuke', 'lightning', 'devil', 'dragon', 'alien', 'water', 'bowl', 'air', 'moon', 'paper', 'sponge', 'wolf',
'cockroach', 'tree', 'man', 'woman', 'monkey', 'snake', 'axe', 'scissors', 'fire', 'sun', 'rock']
... |
15c1912330e73e8f067beb37d0b1fe8561c80072 | sunnyfriend/blog | /blog6/test_zhuangshi.py | 300 | 3.609375 | 4 | import time
def timer(n):
def wrap1(func):
def wrap2(*args,**kwargs):
time1 = time.time()
for i in range(n):
result = func(*args,**kwargs)
time2 = time.time()
print(time2-time1)
return result
return wrap2
return wrap1
@timer(10000000)
def foo(x,y):
return x ** y
foo(9,3) |
e6886af2f0373dea4fac1f974cfca7574bca353b | daniel-cretney/PythonProjects | /primality_functions.py | 481 | 4.4375 | 4 | # this file will take a number and report whether it is prime or not
def is_primary():
number = int(input("Insert a number.\n"))
if number <= 3:
return True
else:
divisor = 2
counter = 0
for i in range(number):
if number % divisor == 0:
... |
ec0481ed09ec5b592cbffaddbf9b58844f40ec92 | jamesjakeies/python-api-tesing | /python_crash_tutorial/examples/examples/InText/list.py | 227 | 3.875 | 4 | # list.py
# in-text examples
items = [10, 3, -1, 8, 24]
print(items[1])
print(items[-1])
print(items[2:4])
print()
items = [-2, 5, 3, -8, 7]
items[0] = 10
print(items)
items = [-2, 5, 3, -8, 7]
items[1:3] = [0]
print(items)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.