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
2d6f0cda929ff0fb4373b3c91570df086c5d3a77
mjdarby/Brain2Speare
/brain2speare.py
15,746
3.859375
4
#!/usr/bin/env python import re, sys, roman, math, random # Functions to convert the BF to Shakespeare def get_parentheses(text): stack = [] parentheses = {} scene_number = 2 for idx, instr in enumerate(text): if instr == '[': stack.append(idx) elif instr == ']': old_idx = stack.pop() ...
f10878df0f5f5244e74d3737001c869d55a044a8
Ayikanying-ux/calculator.py
/main.py
513
3.984375
4
from functions import * print("What do you want to do?") print("1. Addition") print("2. Subtraction") print("3. Multiplication") print("4. Division") choice = int(input("Enter your choice: ")) num1 = int((input("enter number1: "))) num2 = int((input("enter number2: "))) if choice == 1: addit...
348fd65fc03833ef71507ff64de0910772a24c1b
ToniDS/digital-divide
/Old/cleaning.py
554
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Oct 7 16:30:46 2017 @author: antonia """ digital = pd.read_csv('WB_Data_Digital.csv') countries = pd.read_csv('List of countries.csv', ) digital = digital[digital['country'].isin(countries['Economy'])] digital = digital[digital['date'] > 1991] for x ...
ea6c9260428a2c0ac42c4601e2fca04069efa9c8
davemolk/cWars
/8kyu_MakeUpperCase.py
188
3.578125
4
''' https://www.codewars.com/kata/57a0556c7cb1f31ab3000ad7/train/python Write a function which converts the input string to uppercase. ''' def make_upper_case(s): return s.upper()
486a7fd8afbfa226b1059f5d50b4ca25ee7fcb18
davemolk/cWars
/7kyu_FilterLongWords.py
314
3.953125
4
''' https://www.codewars.com/kata/5697fb83f41965761f000052 Write a function filter_long_words that takes a string sentence and an integer n. Return a list of all words that are longer than n. ''' def filter_long_words(sentence, n): return list(filter(lambda word: len(word) > n, sentence.split(' ')))
56a5bcb8594f8f59757c0cff07b72624c08e631b
mukesh366/numberGuessingGame
/PythonPractie/NumberGuessingGame.py
618
4.09375
4
import random winning_number=random.randint(1,100) guess=1 game_over=False number= int(input("Please enter an number between 1-100: ")) while not game_over: if number==winning_number: print(f"Congratulation you Win!!!, and you guess this game in {guess} times") game_over=True els...
d20ad7cd840bd84b75dc0988dadddd68f335f5e6
spfantasy/LeetCode
/x.py
2,131
3.78125
4
class Solution: def mergeTrees(self, t1, t2): """ :type t1: TreeNode :type t2: TreeNode :rtype: TreeNode """ def traverse(node, t1, t2): if (t1 and t1.left) or (t2 and t2.left): left_val = 0 if t1 and t1.left: ...
370af2ca42533702b67c4ee47c97b60768d1e863
a013152/Python3
/part2/my_dist.py
289
3.921875
4
''' 字典, 可变有序键值容器 ,key:value 组成 不允许同一个键出现两次 ''' d = {"A":1, "B":2, "C":3} print(d) keys = d.keys(); values = d.values(); print(str(keys) + str(values)) #add d["D"] = 4 print(d) #del del d["D"] print(d) #claer d.clear(); print(len(d))
878dbef5f839e70a42c58ceab1a3df3365bcfcab
siinatra35/route-cipher
/main.py
14,411
3.53125
4
import math import sys import re # Current path position: g_posR = 0 # row position g_posC = 0 # column position # Current path direction: g_dirR = 0 # row direction g_dirC = 0 # column direction # Current path borders: g_borderL = 0 # left column g_borderT = 0 # top row g_borderR = 0 # right c...
5608f89f6c8f482e12821a8c2f4fbe17fa3a7322
JamesHarden24/C_Exec
/python/10_函数/递归/factorical.py
223
3.890625
4
def factorical(n): if n == 1: return 1 else: return n * factorical(n-1) number = int(input('请输入一个正整数:')) result = factorical(number) print('%d 的阶乘是 %d' % (number, result))
d74bd0aa45531cf797b99188b2143371c6c41914
AndySECP/Neural-Network-Music-Generation
/Gpt/capita.py
1,558
3.890625
4
# Capita is a small library that preprocesses capitalization from text # and can undo this pre-processing (through the unprocess_capitalization). # It is used in the Summarization notebook, to process raw text into words which can then be tokenized and numerized. # You do not need to modify this file. from segtok imp...
1e38cb2f374eede29eaf6520bfb1f97d84a10f6c
TolpaBomjey/GB.Python.HW
/HW2/task2-1.py
558
4.3125
4
# Создать список и заполнить его элементами различных типов данных. # Реализовать скрипт проверки типа данных каждого элемента. # Использовать функцию type() для проверки типа. Элементы списка # можно не запрашивать у пользователя, а указать явно, в программе. someList = ["раз", 2, None, 3.14] for smth in someLi...
36f42da49b3aa743cee7722bf0def14fda5c167b
TolpaBomjey/GB.Python.HW
/HW2/task2-4.py
558
4.125
4
# Пользователь вводит строку из нескольких слов, разделённых пробелами. # Вывести каждое слово с новой строки. Строки необходимо пронумеровать. # Если в слово длинное, выводить только первые 10 букв в слове. userFrase = input("Давай вещай. Слова через пробел >>>") words = list(userFrase.split(" ")) for w, el in ...
9566699fb7572a0214f100353c946062ed5c2abe
serjiogoro/lesson1
/list_dict.py
365
3.8125
4
a = [3,5,7,9,10.5] print(a) a.append('Python') print(len(a)) # print(a[0]) print(a[-1]) print(a[2:4]) a.remove('Python') #---------------------- d = {"city": "Москва", "temperature": "20"} print(d['city']) d['temperature'] = int(d['temperature']) - 5 print(d) # print(d.get('country')) print(d.get('country', 'Россия')) ...
0538ff67dce53d3928415a2a61717861b56db5aa
ejramirez5/Lab3A
/lab3.py
6,515
3.953125
4
""" CS 2302 Emilio Ramirez Lab 3 A Diego Aguirre, Manoj Saha Last Date Modified: Novemeber 4th, 2018 Purpose: Use AVL and RedBlack trees to find the cosine distance between words( similarity) """ import math from AVL import Node from AVL import AVLTree from RBT import RBTNode from RBT import RedBlackT...
7d733fd3228267fd8b8a8d15bd6ff6bbe20611c5
PracticalMetal/Number_Guessing_Game
/main.py
1,142
4.09375
4
import random from art import logo def game(lives): chosen_num=random.randint(1,100) print(f"You have {lives} attempts remaining to guess the number") while lives!=0: user_input=int(input("Make a guess: ")) if user_input==chosen_num: print("Amazing! You won!") b...
a893cd5e53c840925e54c60af40514bb8fa51d07
mansoniakki/PY
/Reverse_Input_String.py
412
4.40625
4
print("##################This script with reverse the string input by user###########") name=input("Please enter first and last name to reverse: ") print("name: ", name) words=name.split() print("words: ", words) for word in words: lastindex = len(word) -1 print("lastindex ", lastindex) for index in range...
63582443b16149b97f551b6a9f80845fa8b60a30
rbenf27/dmaimcoolshek6969
/PYTHON/COLOR GUESSER.py
530
4.125
4
import random color = random.randint(1,7) if color == 1: color = "yellow" if color == 2: color = "green" if color == 3: color = "orange" if color == 4: color = "blue" if color == 5: color = "red" if color == 6: color = "purple" user_choice = input("Choose a c...
4d6890ee8056a6a8f55f4c99cb9450a8b08d4d33
GMDEEP/Learn_Python_beginner
/exercises/17-Russian-Roulette/app.py
323
3.640625
4
import random bullet_position = 3 def spin_chamber(): chamber_position = random.randint(1,6) return chamber_position # DON'T CHANGE THE CODE ABOVE def fire_gun(): # YOUR CODE HERE if (spin_chamber()==bullet_position): return ("FIRE!!!....... are you dead?") else: return ("Keep playing!") print(fire_gun...
43989f3599749eaca1e50d0982ae655f90a2d709
cepalle/prologin-trainning
/2019/regional/lv4_1.py
430
3.546875
4
n = int(input()) m = int(input()) k = int(input()) memo = {} def count_tour(n, m): if n == 0: return 1 if m <= 0: return 0 if n == 1: return m key = str(n) + " " + str(m) if key in memo: return memo[key] res = 0 for nb in range(0, k + 1): if nb <=...
d07d209b7d9d661203b7d8d1f4fc9943badff741
cepalle/prologin-trainning
/2019/qualification/lv1.py
219
3.796875
4
p = int(input()) input() lp = [int(e) for e in input().split()] if len(list(filter(lambda e: e < p, lp))) >= 3: print('ARNAQUE !') else: print('Ok bon voyage, bisous, n\'oublie pas de m\'envoyer des photos !')
056d989e5f9c84e32837fb7d60ab033a76ac3e7b
yuangaonyc/project_euler
/problem_26.py
748
3.53125
4
from decimal import * getcontext().prec = 2000 def super_check(pattern, string): i = 0 check = True while check and i <= len(string)-len(pattern): if string[i:i+len(pattern)] != pattern: check = False i += len(pattern) return check def recurring(digits): k = int(len(digits)) if k < 2000: return '' for...
62da0258b2f9da4649ef9a9200f320116b7d5bfb
yuangaonyc/project_euler
/problem_17.py
1,563
3.6875
4
read_first_d = {'0': '', '1': 'one', '2': 'two', '3': 'three', '4': 'four', '5': 'five', '6': 'six', '7': 'seven', '8': 'eight', '9': 'nine'} read_teens = {'0': 'ten', '1': 'eleven', '2': 'twelve', '3': 'thirteen', '4': 'fourteen', '5': 'fifteen', '6': ...
b8bb75377b01fe4fcaa2e28756e5129da8755507
bryanramos/electroreel-theme
/me.py
774
3.828125
4
class Node(object): # Constructor def __init__(self, data, next=None): self.data = data self.next = next #List Functions class List(object): # Constructor def __init__(self): self.head = None self.tail = None def Print(self): # Prints list L's...
21583769ffd0a650fb4f249149bef2229ec0f53b
ricbit/Oldies
/2020-03-birthpalin/birthpalin.py
463
3.625
4
# Check if a given age is palindrome in base b while the year is palindrome in base b**2 def to_base(n, base): ans = [] while n > 0: ans.append(n % base) n //= base return ans def is_palin(n): return n == n[::-1] for age in range(1, 120): for base in range(2, age): ageb = to_base(age, base) ...
4fe4dd8958bca54151eda0116626a4a2835b1628
ricbit/Oldies
/2011-11-aiclass/final_logic.py
554
3.5
4
# Logic, final 5 import sys def imp(a,b): return not(a and not b) def eqv(a,b): return a == b def tautology(exp): trues = 0 falses = 0 for i in range(4): pink = (i & 1) > 0 green = (i & 2) > 0 if eval(exp): trues += 1 else: falses += 1 return trues and not falses expressions...
279a7ada18aa54d20bfbc01b7c8e432517915431
ricbit/Oldies
/2013-04-analytic/part1/ex643.py
1,001
3.78125
4
# Count the amount of interal nodes in all binary trees of size N, # grouping by number of external children. import itertools def insert(p, elem): if elem < p[0]: if p[1] is None: p[1] = [elem, None, None] else: insert(p[1], elem) else: if p[2] is None: p[2] = [elem, None, None] ...
f814fa5490af69640ff009e05ec7c7e3eb3ae959
ricbit/Oldies
/2013-04-analytic/part1/ex745.py
497
3.5
4
# Count how many inversions there are in an all involutions of size N. import itertools def is_involution(p): for x in p: if not (p[x] == x or p[p[x]] == x): return False return True def inversions(p): ans = 0 for i, x in enumerate(p): ans += sum(1 for y in p[:i] if y > x) return ans def gen...
1fa106b21e7f3f36f0cd70055ba2bbd6ba1b1ffc
ricbit/Oldies
/2008-06-nthprime/nth_prime.py
680
4
4
# Evaluate the nth prime using a formula based on Wilson's theorem. # Due to the limited precision of python's float implementation, # it's only reliable up to n=6. # Ricardo Bittencourt 2008 import math def factorial(j, memo={}): if j not in memo: memo[j] = 1.0 if j < 2 else j * factorial(j-1) return memo[j...
b19b671d032613f87c0c9594b12c087a838c0257
marcelomrocha/frecog
/server.py
603
3.546875
4
#!/usr/bin/env python3 import socket HOST = '' # Standard loopback interface address (localhost) PORT = 3030 # Port to listen on (non-privileged ports are > 1023) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((HOST, PORT)) s.listen() conn, addr = s.accept() print('Connected by', addr) while Tr...
3666ee124c0ec9120a52bb6b04a74d94b841358c
AashishCB/Simple-REST-api
/app.py
2,100
3.71875
4
from flask import Flask, jsonify, request, render_template app = Flask(__name__) stores = [ { 'name': 'My woderful store', 'item': [ { 'name': 'My item', 'price': '15.99', } ] } ] ''' Since, we are acting like a server, when we receive post request then we get data and deal with it when we rec...
6f3672ed227fda5ec9345062a21e8b9304a4b777
pombredanne/simfish
/src/simfish.py
16,604
4.09375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Fish tank simulator """ import curses import random import time TANK_WIDTH = 15 TANK_HEIGHT = 10 UNIT_WIDTH = 5 UNIT_HEIGHT = 2 EAST = +1 WEST = -1 class EdgeOfTank(Exception): def __init__(self, *args, **kwargs): Exception.__init__(self, *args, **k...
d15b60e4518cdac334b0163869faf17493524265
Bestradas/PolyAlphabeticCipher
/FileUtils.py
595
3.640625
4
FILE_WITH_TEXT_TO_ENCRYPTING = "Files/file_with_text_to_encrypt.txt" ENCRYPTED_RESULT_FILE = "Files/encrypt_result_file.txt" DECRYPTED_RESULT_FILE = "Files/decrypt_result_file.txt" class FileUtils: def readEncryptedFile(self): with open(FILE_WITH_TEXT_TO_ENCRYPTING, 'r') as file: return file....
266ef02d4d049d9b46ae983e73fcbcc755262482
prabal03/python
/main.py
620
3.796875
4
def main(): user = int(input("enter the no u want : ")) boolean = int(input("choose 1 or 0 : ")) convert = bool(boolean) if convert == True : for i in range(user): for j in range(i+1): print("*", end="") print("") else: for i in range...
78254a048d07f0b6c1395ae4131c989ebb28ce48
janealdash/T2.9
/task2.9.py
152
3.921875
4
n=int (input()) factorial=1 if n<0: print() if n==0: print("1") else: for i in range(1,n+1): factorial=factorial*i print(factorial)
2216673c570e88b2cac03231c62d6c587ca3b933
rmulton/ivf
/project/program/node.py
395
3.765625
4
class Always: """ Represents a node that has a Always boolean expression as a condition """ def __init__(self): return class If: """ Represents a node that has a If boolean expression as a condition """ def __init__(self): return class End: """ Represents a fina...
d35020397597e70f82a3472d45feca10de7d9821
arthurodriguesbatista/stock-investment
/bank.py
729
3.765625
4
import math class Bank(object): def __init__(self, safe_box): self.number_of_shares = 0 self.safe_box = safe_box self.initial_value = safe_box def purchase(self, porcentage, value_per_share): if(self.safe_box > 0 and self.safe_box >= value_per_share): value_to_buy = self.safe_box * porcentage while(val...
bf16d3593ae5187b65d0969a8aa184d375e65225
joshuapena/factorPython
/factor00.py
993
3.9375
4
#!/usr/bin/python -t # Joshua Pena import sys # - - # This program factors two negative numbers def factor00(additionGoal, multiplyGoal): num1 = 0 num2 = 0 check = 0 multiplyCheck = 0 additionCheck = 0 impossible = 0 if (multiplyGoal > additionGoal): possibleCheck = additionGoal else: possi...
ecf0668772c133ae7726ad676a0da78954f1df22
zhixuanyang/Datasci_Fall_18
/ds220/db_test.py
1,031
3.515625
4
import sqlite3 import pandas as pd conn = sqlite3.connect('airline.db') c = conn.cursor() try: c.execute(''' CREATE TABLE `airline data` ( City1 CHAR(3) NOT NULL, City2 CHAR(3) NOT NULL, `Average Fare (AvgFare)` ...
50c02b0795e04216bae773a0d2fff8d837eb5d63
zhixuanyang/Datasci_Fall_18
/ndl/training1.py
1,865
3.546875
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split class LinearRegression(object): def __init__(self, filepath): self.data = pd.read_csv(filepath) self.X = self.data.X.values self.n_samples = self.X.size self...
037444cb10bf2779b5dda7768367ba523d0338ff
Bogomil94/pythonProject
/Week 3 Homework/Exercise 3.1.1.py
297
4
4
number=int(input("Write a number")) if number==0: print("Monday") elif number==1: print("Tuesday") elif number==2: print("Wednesday") elif number==3: print("Thursday") elif number==4: print("Friday") elif number==5: print("Saturday") elif number==6: print("Sunday")
a09def837558fca43a562701f9781cd9d0fab641
dancingowl/pre-education
/quiz/pre_python_01.py
735
3.984375
4
"""1. 아래와 같이 숫자를 두번 물어보게 하고 ★을 출력해서 사각형을 만드시오 가로의 숫자를 입력하시오 : 세로의 숫자를 입력하시오 : 예시 <입력> 가로의 숫자를 입력하시오 : 5 세로의 숫자를 입력하시오 : 4 <출력> ★★★★★ ★★★★★ ★★★★★ ★★★★★ """ row=int(input('가로의 숫자를 입력하시오 : ')) #int를 왜 써줘야 하는지? input된 숫자를 정수로 인식을 못함. col=int(input('세로의 숫자를 입력하시오 : ')) print('가로:',row,'세로:',col,'의 사각형...
fc7e5ec06d19b9a4a1398798f589c0982331c192
meloning/pythonSyntaxEx
/chapter9/ObjectEx.py
652
4.15625
4
class BookReader: __country = 'South Korea' def __init__(self, name): self.name = name def read_book(self): print(self.name +' is reading Book!!') def set_country(self, country): self.__country = country def get_country(self): return self.__country reader = BookReade...
77d33fa16877be5e164099b80f1fb3741717af69
meloning/pythonSyntaxEx
/chapter5/SetTypeEx.py
253
3.546875
4
# Set 순서없이 중복 미허용 lang = {'java', 'java', 'python', 'C++', 'python'} print(lang) print('java' in lang) print('javascript' in lang) a = set('abracadabra') b = set('alacazam') print(a) print(a-b) print(a|b) print(a&b) print(a^b)
2dab607e735fa36497d2ed615257b9afbcef6a1e
meloning/pythonSyntaxEx
/chapter7/StringEx.py
2,004
3.890625
4
""" c = input('영어 대소문자로 이루어진 문장을 입력하세요.') print('모두 대문자로 출력\n', c.upper()) print('모두 소문자로 출력\n', c.lower()) new_s = str() for s in c: if s.lower(): new_s += s.upper() else: new_s += s.lower() print('대소문자 바꿔서 출력\n' + new_s) print('대소문자 바꿔서 출력\n' + c.swapcase()) """ """ # String reverse i =...
3846c24ad995e8fcd6c54ce4eb801b00ff23d2fc
greenpony/tests
/uv_test.py
1,571
3.953125
4
#!/usr/bin/python2 # -*- coding: utf-8 -*- import random, sqlite3, datetime db_file = "uv_test.sqlite" def create_db(): conn = sqlite3.connect(db_file) c = conn.cursor() c.execute("CREATE TABLE tries (date text, tries integer)") conn.commit() conn.close() def store_tries(t): conn = sqlite3.connect(db_file) c...
ef11c46dbe8514c6030107d0d1bdc9a86e4ab6d7
Krishnakumar01-zz/part6
/2.py
364
3.765625
4
def flatten_dict(a,result=None): '''returns a flattened dict by joining the keys with "."''' if result is None: result={} for i in a: if isinstance(a[i],dict): b={} for k in a[i]: p=a[i][k] b[i+'.'+k]=p flatten_dict(b,result) else: result[i]=a[i] return result print(flatten_dict({'a':1...
452f5062aeca253fdcd9a24660972ba9286d55ec
yu-hanyang/my-spider-learning-by-python
/spider/第四章/4_2_多线程.py
917
3.859375
4
#多线程 from threading import Thread #线程类 # def func(): # for i in range(100): # print('func',i) # # if __name__ == '__main__': # t=Thread(target=func)#创建线程并给线程安排任务 # t.start()#多线程状态为可以开始工作状态,具体执行时间由CPU决定 # # for i in range(100): # print('main',i) # class MyThread(Thread): ...
abed062ee56f94c0b7f142ec0d04a20ece2e77d9
atataria/ICB_EX8
/Exercise-8-q2
402
3.953125
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Thu Nov 1 16:21:48 2018 @author: atatarian """ print("I'm thinking of a number 1-100...") import numpy num = numpy.random.choice(101) guess = -1 while num != guess: guess = int(raw_input()) if guess > num: print('Lower') ...
92b670aa472352a8e13d8b3ddc5354d806230d2d
HappyAWolf/Data-Wrangling-with-MongoDB
/Lesson4_Working_with_MongoDB.py
7,013
4.625
5
# Kicking the tires on MongoDB """ Your task is to sucessfully run the exercise to see how pymongo works and how easy it is to start using it. You don't actually have to change anything in this exercise, but you can change the city name in the add_city function if you like. Your code will be run against a MongoDB ins...
6dfb3cca33d5f0c6045d38b3cebdae2e86d114a7
sabapathy1234/P.saba
/saba17.py
138
3.78125
4
num1=int(input()) x=num1 y=0 while(num1>0): var=num1%10 num1=num1//10 var1=var**3 y=y+var1 if(x==y): print("yes") else: print("no")
b3b4ba0a2f0fc124efd66ca1ce27c9ea709dd18b
sabapathy1234/P.saba
/saba90.py
123
3.796875
4
s123,ss123,sss123=input().split() if(ss123=='/'): print(int(s123)//int(sss123)) else: print(int(s123)%int(sss123))
6871a062cf4b83a368c81dc9c5320c828b623556
sabapathy1234/P.saba
/saba40.py
153
3.640625
4
ch22=input() fi=0 for i in range(len(ch22)): if(ch22[i].isdigit() or ch22[i].isalpha() or ch22[i]==(" ")): continue else: fi+=1 print(fi)
ed9ee4ffcacf98ec208c97e24c4142a5865c0145
sabapathy1234/P.saba
/sab11.py
52
3.640625
4
s1=int(input()) while(s1%2==0): s1=s1//2 print(s1)
7c958f7b1fe5f2e0ab2d9971220ec955e10cefc2
sabapathy1234/P.saba
/saba16.py
222
3.53125
4
lower,upper=map(int,input().split()) for num1 in range(lower,upper + 1): if num1 > 1: for i in range(2,num1): if (num1 % i) == 0: break else: print(num1,end=" ")
50acee58f9cd1cad3d856d2d4d229254bbff04d3
sabapathy1234/P.saba
/sab19.py
109
3.5625
4
num11=int(input()) f11=11 for i in range(1,num11+1): if(i>=0): f11=f11*i i+=1 print(f11)
515dfafec14fc1afedda44b4f8a31725077a759d
8BallDuVal/PythonFunctions
/CallFunctionFromFile.py
527
3.71875
4
from Functions import add_two_nums from Functions import multipy_two_nums from Functions import Circle from Functions import Triangle print('The result of adding 10 + 25 using the imported function: ', add_two_nums(10, 25)) print('The result of multiplying 12 * 12 using the imported function: ', multipy_two_nums...
c21221db62ab8b5c3b5e9520f2411b789d408c9d
rykostas/Wikidumps-preprocessing
/combination.py
614
3.5
4
import os #Finding all files to combine def find_the_way(): path = './text/' xml_files = [] # r=root, d=directories, f = files for r, d, f in os.walk(path): for file in f: if '.txt' in file: xml_files.append(os.path.join(r, file)) return xml_files filen...
282a70e4b4a762c8e1dee8403eebd89492a7baae
Fabhi/Project-Euler
/1 - Multiples of 3 and 5.py
390
3.703125
4
# Problem 1 - Multiples of 3 and 5 # https://projecteuler.net/problem=1 def main(num): mul3 = [i for i in range(num) if i%3 == 0] mul5 = [i for i in range(num) if i%5 == 0] mul3n5 = [i for i in range(num) if i%15 == 0] # By Principle of Inclusion and Exclusion final = sum(mul3) + sum(mul5) - su...
9942508ffcaf74f91ba839eb67e507861c98ddf1
klim1286/PythonBasics
/unit6-3.py
712
3.734375
4
class Worker: def __init__(self, name, surname, position, wage, bonus): self.name = name self.surname = surname self.position = position self._income = {"wage": wage, "bonus": bonus} pass class Position(Worker): def get_full_name(self): print(f'Полное имя: {self...
c629cbdd90dab58a61b3447a0fd008ed272ee17d
klim1286/PythonBasics
/unit6-4.py
1,443
3.8125
4
from random import choice class Car: def __init__(self, speed, color, name, is_police): self.speed = speed self.color = color self.name = name self.is_police = is_police def go(self): print(f'{self.name} поехала') def stop(self): print(f'{self.name} остано...
fe5bef45aa32694d3d61d0b0c6c8f160a98af6fb
klim1286/PythonBasics
/unit3-4.py
937
3.921875
4
def my(a, b): degree = a for i in range(1, abs(b)): degree = degree * a value = 1 / degree print(f'Результат возведения в степень с помощью цикла: {value}') def err(): print('Ошибка! Введено значение не удовлетворяющее условию') while True: try: x = input('Введите действитель...
6970e6980442427077d3034526fcaebd04086b7a
billyfournier/WebCrawler
/crawler.py
1,239
3.71875
4
# import the urlopen function from the urllib2 module from urllib2 import urlopen # import the BeautifulSoup function from the bs4 module from bs4 import BeautifulSoup # import pprint to print things out in a pretty way import pprint # choose the url to crawl url = 'http://www.codingdojo.com' # get the result b...
900abf8bc038b67b8cddbdb8a746a44794f07ef4
Brown-University-Library/vivo-data-management
/vdm/author_names.py
2,079
3.75
4
from collections import namedtuple from nameparser import HumanName #A named tuple to represent author names. #This has to be declared outside of the function for pickling. #http://stackoverflow.com/questions/16377215/how-to-pickle-a-namedtuple-instance-correctly Author = namedtuple('Author', ['full', 'last', 'fi...
aa56ec26aded3e362b7e89c731a3322d5e4c8f62
JayeshThatte/Basic-Regression
/myai.py
1,746
4.03125
4
# Import all the required libraries import random import matplotlib.pyplot as plt import pandas as pd # Read the dataset f = pd.read_csv("Salary.csv") exp = f["YearsExperience"].values salary = f["Salary"].values # Get random weight INIT = random.uniform(-30,30) # Since we dont know the learning rate,...
e70851cf4595a6a2f621cfe5bb587337236805d6
jakerockland/data-structure-essentials
/searching.py
655
3.875
4
# Implementations of various searching algorithms # By: Jacob Rockland # linear search is an O(N) search algorithm def linear_search(items, key): for item in items: if item == key: return item return None # element not found # binary search is an O(log(N)) search algorithm *requires item...
f31a9a0fe3a3642263c05c365dffa4db220de581
rbrown540/Python_Programs
/Calculate.py
2,967
4.40625
4
# Richard Brown - SDEV 300 # March 16, 2020 # Lab_One - This program prompts the user to select a math function, # then performs that function on two integers values entered by the user. print ('\nWelcome to this awesome Python coded calculator\n') # provide user with the math function options print ('Select 1 for ADD...
f366a69f898f1bc46e0495605878eefb3dcb438e
richa18b/Python
/oops.py
2,829
4.15625
4
import random import sys import os class Animal : _name = None #this is equivalent to __name = "" _height = 0 #_ means that it is a private variable _weight = 0 _sound = "" #constructor def __init__(self,name,height,weight,sound): self._name = name self._height = height ...
7d6e9b19d7f2ba2da75911fc61a300d39cf1857f
kunlee1111/oop-fundamentals-kunlee1111
/Coin.py
1,790
4.21875
4
""" ------------------------------------------------------------------------------------------------------------------------ Name: Coin.py Purpose: Simulates 1000 flips of a coin, and tracks total count of heads and tails. Author: Lee.K Created: 2018/11/30 ---------------------------------------------------------...
9f3d4b125d9fbf8c6e413919f5df2974a13117db
pspankov/tetris
/tetris/game.py
3,582
3.59375
4
import time class Tetris: """ Tetris mechanics https://meatfighter.com/nintendotetrisai/#The_Mechanics_of_Nintendo_Tetris """ ''' Lines cleared Points 0 0 1 40 2 100 3 300 4 1200 ''' POINTS = [0, 4...
32d3c5521aa7d2cb76ecd90db094d99a8147b050
Hemvati/5-June
/strfn.py
155
4.125
4
def string(): s1=str(input("Enter a string:")) s2=str(input("Enter another string:")) s3=s1+s2 return s3 print("The concatenated string is ",string())
1006925e59395db2e0a9fb9d3a0ecd062279227f
djsensei/DFS
/ffscraper.py
7,396
3.515625
4
''' Fantasy Football Data Scraper Pulls JSON data from http://football14.myfantasyleague.com/<year>/export Processes it and returns useful CSV files for further analysis. Dan Morris Last Updated 5/2/2014 ''' import simplejson as json from urllib2 import urlopen url_base = 'http://football.myfantasyleague.com/' url_e...
686d54e4a853f9960c53ad4636dbefbff676f32a
RTwTools/AdventOfCode
/AdventOfCode2017/AdventOfCode2017/AOC_03/day03.py
1,325
3.8125
4
# (ringNr * 2) + 1 = ringIdx # ringIdx * ringIdx = Max ring value def getMaxRingValue(ringNr): return pow((ringNr * 2) + 1, 2) def getRingNr(number): ring = 0 while True: # Check if number is in current ring maxRingValue = getMaxRingValue(ring) if (maxRingValue >= number): ...
d475473f48da73c2f6989da0bad55ebf7522397b
JGilba/Python_Exercices
/Seção 04 - Variáveis e Tipos de Dados/06.py
141
4.03125
4
temp_celcius = float(input('Informe uma temperatura em Celcius: ')) print('{} °C = {:.2f} °F'.format(temp_celcius, temp_celcius*(9/5)+32))
8d46158bd8cdfbc2a4a0e57878339af015feca1b
JGilba/Python_Exercices
/Seção 05 - Estruturas Lógicas e Condicionais/03.py
175
4.09375
4
numero = float(input('Digite um número: ')) if numero > 0: print(f'Raíz de {numero} = {numero**0.5:.2f}') else: print(f'{numero} elevado ao quadrado = {numero**2}')
6a1da31b9f455052454b2fc4ed6f9290ddb5f528
JGilba/Python_Exercices
/Seção 04 - Variáveis e Tipos de Dados/15.py
173
4.3125
4
from math import degrees angulo_radianos = float(input('Informe um ângulo em radianos: ')) print('{} radianos = {:.3f}°'.format(angulo_radianos, degrees(angulo_radianos)))
5f5ae510f474bcefdb3f77def2c699db8a641da4
JGilba/Python_Exercices
/Seção 05 - Estruturas Lógicas e Condicionais/28.py
737
3.890625
4
print('[0] Geométrica\n[1] Ponderada\n[2] Harmônica\n[3] Aritmética') opcao = int(input('Escolha uma média: ')) if not(0 <= opcao <= 3): print('Opção inválida! Tente novamente.') else: x, y, z = map(int, input('Informe três números: ').split()) if opcao == 0: #Geométrica media = (x*y*z)**(1/3) e...
6db182255462c8d6d5c6149b6365e8a83eae84d6
JGilba/Python_Exercices
/Seção 04 - Variáveis e Tipos de Dados/36.py
165
3.765625
4
from math import pi altura, raio = map(float, input('Informe a altura e em seguida o raio do cilindro: ').split()) print('Volume: {:.2f}'.format(pi*raio**2*altura))
db354e2c39fee06a912c0e9ff0bf2acdce891753
JGilba/Python_Exercices
/Seção 04 - Variáveis e Tipos de Dados/34.py
106
3.84375
4
from math import pi raio = float(input('Raio: ')) print('Área do círculo: {:.2f}'.format(raio*raio*pi))
1424f8aa70525713582cfe5b0e78864c410a596b
JGilba/Python_Exercices
/Seção 04 - Variáveis e Tipos de Dados/01.py
93
3.9375
4
numero = int(input('Digite um número inteiro: ')) print(f'O número digitado foi {numero}')
76562b4774f212a6cf4c0b2f356e46338b990933
JGilba/Python_Exercices
/Seção 04 - Variáveis e Tipos de Dados/38.py
184
3.75
4
salario_funcionario = float(input('Informe o salário do funcionário em reais: ')) print('O salário do funcionário após o aumento é: R$ {:.2f}'.format(salario_funcionario*1.25))
3b7f94ae1ce782f94a9e26bcef0fe53f60fa6cb7
JGilba/Python_Exercices
/Seção 05 - Estruturas Lógicas e Condicionais/10.py
233
3.71875
4
sexo = input('Informe o seu sexo [M/F]: ') altura = float(input('Informe sua altura em metros: ')) print('Peso ideal: ', end='') if sexo.upper() == 'M': print(f'{72*altura - 58:.2f}') else: print(f'{62.1*altura - 44.7:.2f}')
43b725d982c5dc6ec916742659b6edbbe6bf7bee
JGilba/Python_Exercices
/Seção 05 - Estruturas Lógicas e Condicionais/12.py
174
4.0625
4
from math import log numero = int(input('Digite um número inteiro: ')) if numero < 0: print('Número inválido') else: print(f'Log de {numero} = {log(numero):.3f}')
22fce435d86987596d7086a919be36e559c9e4b9
JGilba/Python_Exercices
/Seção 04 - Variáveis e Tipos de Dados/19.py
123
3.703125
4
litros = float(input('Informe um volume em litros: ')) print('{} litros = {} metros cúbicos'.format(litros, litros/1000))
b04857547f7deb40381f9dfaa5442fd245194716
ray11furtado/vue-youtube
/jesy.py
81
3.8125
4
x = 8 y = x + 1 x = (y + 2*x) // 6 y = -(y+1) y = x/y print(x, 'x') print(y, 'y')
48d8a4029ac14eac41719275a88517f189618b8d
willianyamauti/Early-python-projects
/forca.py
4,198
3.671875
4
""" Jogo da forca v.0.01 Nessa versao o programa usa as funções getpass e any e map para conferir se a string possui digitos # paalavra = getpass.getpass(prompt ='') # string = 'abc2' resultado = any(chr.isdigit() for chr in strin) #retorna o valor em bool Nesta versao o jogo funciona apenas no terminal ...
df25914cc08c600e8d1e8b80f4e027dbb7640c09
kaurmandeep007/daily-diary
/dictionary.py
868
4.25
4
dict={ "brand":"ford", "model":"mustang", "year":1964 } print(dict) #acess items: x=dict["model"] x=dict.get("model") print(x) #change values: dict["year"]=2014 print(dict) #loop through a dictionary: for x in dict: print(x) #if key exists: if "brand" in dict: print("yes,'b...
5bed45624e8e6c8f4d7bd8481267aaf37900cb55
marieleponti/bio
/bio.py
6,990
3.8125
4
# Mariele Ponticiello # CSCI 687 # Project 1 # 11 October 2020 # read in file from command line import sys numArg = len(sys.argv) if numArg < 2: print('Insufficient arguments.') elif numArg == 2: commands = sys.argv[1] array_size = 100 elif numArg == 3: commands = sys.argv[2] array_size = int(sys....
d64728f99b0089fbca68bdef03db6982d570d8d4
gingij4/Forritun
/bmistudull.py
560
4.53125
5
weight_str = input("Weight (kg): ") # do not change this line height_str = input("Height (cm): ") # do not change this line height_float = (float(height_str) / 100) weight_float = float(weight_str) bmi = (weight_float / (height_float)**2) print("BMI is: ", bmi) # do not change this line #BMI is a number calcu...
3429e51574381399b30358ca4c94015f8ca16731
gingij4/Forritun
/star.py
169
3.84375
4
stars = int(input("Max number of stars: ")) # Do not change this line star = "*" for i in range(1,stars): print(star*i) for i in range(stars,0,-1): print(star*i)
f1598ee77447993c5bd7626fb4608b85a324ceb3
gingij4/Forritun
/evenoddwhile.py
156
4.09375
4
num = int(input("Input an int: ")) # Do not change this line odd = 1 count = 1 while (count <= num): print(odd) count = count + 1 odd = odd + 2
5320b20100264f727b307f4e08cd77be66b34cf2
VanessaDiaz99/Grupo4
/CalculadoraPrueba1.py
1,874
4.09375
4
#Autor:Vanessa Diaz Layton def Numerico(cadena): try: float(cadena) return True except ValueError: return False print ("Calculadora") print ("Ingrese el digito correspondiente a la operacion que quiere realizar") Operacion=int(input(" 1.Suma\n 2.Resta\n 3.Multiplicacion\n 4.Divi...
b449c6dad1e7eb1e3f29a7d3035a3283c9f0a3e9
moward98/TicTacToe
/TicTacToe/TicTacToe.py
13,164
3.5
4
#imports import pygame as game import sys import time from pygame.locals import * # Global Var #gamepiece being placed piece = 'X' # Winner winner = '' #X and O score xCount = 0 oCount = 0 #Draw isDraw = False #game window width WIDTH = 400 #game window height HEIGHT = 400 #set colours ...
84175f87c22248ec9bbc7a12a9444c5f7aab4fcd
increasesong/OOP
/hw02/main.py
343
3.796875
4
def bsearch(data, target): first = 0 last = len(data) - 1 while first <= last: mid = (first + last) // 2 if data[mid] == target: return mid elif mid < target: first = mid + 1 else: last = mid - 1 return None #example print(bs...
86f65c7b396d872e88a074f283f5f762378eb04f
Jasmin-dai/testDD
/demo.py
110
3.796875
4
print("hello world!") print("你好啊") value=input("请输入一串数字:") num=len(value) print(num)
bcdf63a9111d9491ed27d32b71e1e4940c9dcccc
hermesespinola/interview_practice
/strings/balanced.py
1,297
3.6875
4
def is_balanced(text): val = sum([1 if c == '(' else -1 if c == ')' else 0 for c in text]) return val == 0 def is_balanced2(text): stack = [] for c in text: if c == '(': stack.append(c) elif c == ')': if len(stack) == 0: return False e...
ffcb3939b0da1058ca406c5ae675db59f011504a
hermesespinola/interview_practice
/arrays/sudoku2/sudoku2.py
538
3.53125
4
# IDEA: use generators def sudoku2(grid): # map of elements seen in each row, col and subgrid seen = [[set(), set(), set()] for _ in xrange(9)] for i in xrange(9): for j in xrange(9): n = grid[i][j] if n != '.': subgrid = i / 3 + j / 3 * 3 if ...
efd1a32ffc39ca682cc97e5a0008b86386b71157
FisicaComputacionalOtono2018/20180904-examen-primerparcialpythonbeginersdiagramsandplots-edgarefrent
/ejercicio3.py
572
3.609375
4
import numpy as np import matplotlib.pyplot as plt # los datos x = np.array(float(input('Dame los coeficientes: '))) y = np.array(float(input('Dame los coeficientes: '))) # Calcular ajustes para diferentes grados sols = {} for grado in range(1,6): z = np.polyfit(x, y, grado, full=True) sols[grado] = z # trazar d...
a4b589257d1894c13d6847e4a33929cbef3d0c75
marcuskeenan/fresh_tomatoes
/media.py
1,195
3.671875
4
import webbrowser class Movie(): def __init__( self, movie_title, movie_year, movie_rating, movie_genre, movie_storyline, poster_image, trailer_youtube ): """Creates an instance of the movie class....
98d5775c771ff3d5c532e660c53ddc5fa4de72c9
danielle8farias-zz/hello-world-python3
/exercicio_py/ex0018_matrizes/funcoes_matriz.py
5,245
4.09375
4
######## # autora: danielle8farias@gmail.com # repositório: https://github.com/danielle8farias # Descrição: Diversas funções para matrizes. ######## def construir_matriz (num_linhas, num_colunas): ''' Recebe um número de linhas e colunas e contrói uma matriz com os valores escolhidos pelo usuário ''' ...