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
a99a418e8e84cd94c2f22546a795d1da385efb8a
grg909/LCtrip
/Queue_Stack/Topological_Sorting.py
2,367
3.984375
4
# -*- coding: UTF-8 -*- # @Date : 2019/12/6 # @Author : WANG JINGE # @Email : wang.j.au@m.titech.ac.jp # @Language: python 3.7 """ """ from collections import deque """ Definition for a Directed graph node class DirectedGraphNode: def __init__(self, x): self.label = x self.neighbors = [] ""...
f23c62134da7b87bd5d5a1b3c9fc4efbedcf3173
nithish-thomas/adventOfCode2020
/aoc20/day19/day_1_4.py
1,490
3.546875
4
import functools import re from typing import Dict, List, Set def parse_rules(rules_inp): rule_inp = rules_inp.split('\n') rules: Dict[int, List[List[str]]] = {} for rule in rule_inp: rule = rule.split(':') rule_sep_with_pipe = rule[1].split('|') rule_description: List[List[str]]...
cdf7b88a93901be4661b626046d6aa6256fe2029
nithish-thomas/adventOfCode2020
/aoc20/day16/day_1.py
1,282
3.546875
4
import re def parse_rules(rules): rules_arr = rules.split('\n') regex = re.compile(r'(.*): (\d+)-(\d+) (.*) (\d+)-(\d+)') arr_ = [(regex.match(rule)) for rule in rules_arr] return [(item.group(1), int(item.group(2)), int(item.group(3)), int(item.group(5)), int(item.group(6))) for item in arr_] def m...
6454bee870964fd13c06529e45f597b82047a215
Pschiee/SQL-Python
/SQL_To_Python.py
2,743
3.53125
4
def get_queries(file): query = '' statements=[] labels=[] #Goes through file line by line. Removes \n first. If the line is a comment, it adds it to the label list. #It will continue adding the lines until it finds the ; at which point is assumes end of query. for line in file: line...
7c541024c900a6c67dfe918bc6adb9dcce57067b
lesshuman/misc_tasks
/yandex/B.py
1,046
3.59375
4
""" Требуется найти в бинарном векторе самую длинную последовательность единиц и вывести её длину. Желательно получить решение, работающее за линейное время и при этом проходящее по входному массиву только один раз. """ n = int(input()) max_res = 0 prev = -1 res = -1 for i in range(n): c = int(input()) if c ==...
889f3f7964600018ae0d002057c3903fe09e1932
lesshuman/misc_tasks
/yandex/2A.py
650
4.1875
4
''' Дан список. Определите, является ли он монотонно возрастающим(то есть верно ли, что каждый элемент этого списка больше предыдущего). Выведите YES, если массив монотонно возрастает и NO в противном случае. Test cases: [in]: 1 7 9 [out]: YES [in]: 1 9 7 [out]: NO [in]: 2 2 2 [out]: NO ''' def is_increasing(s): i...
3f7d9ddd5b336d10ee26ea605a886daa74f67508
kmaheshwari/ds_and_algo
/recursion/gray_code.py
971
3.921875
4
class Solution: # Gray Code # The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0. For example, given n = 2, return [...
3a7831df8a90d822dd97cfb07a8b10c9e7ab275e
EdvinAlvarado/Code-Wars
/WhichAreIn/WhichAreIn.py
313
3.890625
4
def in_array(array1, array2): found = set() for ar2 in array2: for ar1 in array1: if ar2.find(ar1) != -1: found.add(ar1) foundlist = list(found) foundlist.sort() return foundlist arr1 = ["arp", "live", "strong"] arr2 = ["lively", "alive", "harp", "sharp", "armstrong"] print(in_array(arr1, arr2))
bb9d7c309c187c7106e758685a02ffb1a9279c24
sourav9064/coding-practice
/coding_10.py
746
4.1875
4
##Write a code to check whether no is prime or not. ##Condition use function check() to find whether entered no is ##positive or negative ,if negative then enter the no, ##And if yes pas no as a parameter to prime() ##and check whether no is prime or not? num = int(input()) def check(n): if n >= 0: ...
9be112de553bec1a1af362c51ecd2877e622c214
sourav9064/coding-practice
/coding_22.py
1,385
4.21875
4
##A doctor has a clinic where he serves his patients. The doctor’s consultation fees are different for different groups of patients depending on their age. If the patient’s age is below 17, fees is 200 INR. If the patient’s age is between 17 and 40, fees is 400 INR. If patient’s age is above 40, fees is 300 INR. Write ...
6cc3f98b86051dcd379f44563bd15374d34e62b7
sourav9064/coding-practice
/prime_series.py
310
3.953125
4
num = int(input()) def prime(n): if n>1: for i in range(2,n): if n%i == 0: print("not prime number") break else: print("prime number") print(n) else: print("not prime number 2") prime(num)
f2e698e05e449961409b844e9bc4b667a2042cab
sourav9064/coding-practice
/coding_8.py
1,058
4.15625
4
##The program will recieve 3 English words inputs from STDIN ## ##These three words will be read one at a time, in three separate line ##The first word should be changed like all vowels should be replaced by * ##The second word should be changed like all consonants should be replaced by @ ##The third word should b...
c0ef09f51e16d04e118cef4768cf0e65ab90b650
bitwoman/python-basico-avancado-geek-university
/Variáveis e Tipos de Dados/exercicio_10.py
358
4.0625
4
#10.Leia uma velocidade em km/h (quilômetros por hora) e apresente-a convertida em m/s (metros por segundo). #A fórmula de conversão é M = K/3.6, sendo K a velocidade em KM/h e M m/s. km = float(input('Digite uma velocidade em km/h: ')) ms = km/3.6 print('A velocidade %.2f em quilômetros por hora, equivale à %2.f em ...
97954d07d327b532ba30e0c88c4f7d07d813b5e6
bitwoman/python-basico-avancado-geek-university
/Estruturas Lógicas e Condicionais/#07.py
444
4.03125
4
#7. Faça um programa que receba dois números e mostre o maior. Se por acaso, os dois números forem iguais, imprima a mensagem "números iguais". numero_1 = int(input('Digite um número inteiro qualquer: ')) numero_2 = int(input('Digite um número inteiro qualquer: ')) if numero_1 > numero_2: print(f'O número {numero_1...
cdc7511ebd55b52a7d1438d0eecfcc51228ef5c1
bitwoman/python-basico-avancado-geek-university
/Variáveis e Tipos de Dados/exercicio_14.py
375
3.953125
4
#14. Leia um ângulo em graus e apresente-o convertido em radianos. #A fórmula de conversão é R = G x PI/180, sendo G o ângulo em graus e R em radianos e PI = 3.14. pi = 3.14 angulo_graus = float(input('Digite o valor de um ângulo em graus: ')) radianos = angulo_graus * pi/180 print('O ângulo %.2f em graus, equivale à...
8da6b2e05082428d51b8f2e2fa387b72dfa36b27
bitwoman/python-basico-avancado-geek-university
/Variáveis e Tipos de Dados/exercicio_32.py
359
3.84375
4
#32. Leia um número inteiro e imprima a soma do sucessor de seu triplo com o antecessor de seu dobro. numero = int(input('Digite um número inteiro: ')) triplo = numero**3 dobro = numero**2 sucessor = triplo + 1 antecessor = dobro - 1 soma = sucessor + antecessor print(f'A soma do sucessor de seu triplo com o antecess...
b3c6b4f25e2fe162308638e5fbfb628779658a5a
bitwoman/python-basico-avancado-geek-university
/Estruturas Lógicas e Condicionais/#02.py
415
4.1875
4
#2. Leia um número fornecido pelo usuário. Se esse número for positivo, calcule a raiz quadrada do número. #Se o número for negativo, mostre uma mensagem dizendo que o número é inválido. from math import sqrt numero = int(input('Digite um número inteiro qualquer: ')) if numero > 0: sqrt = sqrt(numero) print...
1a8e06af5386393ac80f5e1e80019644a79eebff
bitwoman/python-basico-avancado-geek-university
/Variáveis e Tipos de Dados/exercicio_23.py
354
3.71875
4
#23. Leia um valor de comprimento em metros e apresente-o convertido em jardas. #A fórmula de conversão é J = M/0.91, sendo M o valor em metros, e J o valor em jardas. const= 0.91 metros = float(input('Digite um valor de comprimento em metros: ')) jardas = metros/const print('O valor %.2f em metros, equivale à %.2f e...
78b91e5dac645f302a4dfecbca3e4edb5a51dfc3
bitwoman/python-basico-avancado-geek-university
/Variáveis e Tipos de Dados/exercicio_15.py
373
4
4
#15. Leia um ângulo em radianos e apresente-o convertido em graus. #A fórmula de conversão é G = Rx180/PI, sendo G o ângulo em graus e R em radianos e PI = 3.14. pi = 3.14 radianos = float(input('Digite o valor de um ângulo em radianos: ')) angulo_graus = radianos * 180/pi print('O ângulo %.2f em radianos, equivale ...
dc4be8b4160705bbfbcb624d1e30cef105d366dc
bitwoman/python-basico-avancado-geek-university
/Variáveis e Tipos de Dados/exercicio_20.py
369
3.53125
4
#20. Leia um valor de massa em quilogramas e apresente-o convertido em libras. #A fórmula de conversão é L = K/0.45, sendo L o valor em libras e K o valor em quilogramas. const = 0.45 quilogramas = float(input('Digite um valor em quilogramas: ')) libras = quilogramas/const print('O valor %.2f em quilogramas, equival...
b48e0a2e3b7adf138e3e969f6e3fa35d7c67fb4c
oktavianidewi/interactivepython
/stack.py
563
3.921875
4
class stack: def __init__(self): self.rak = [] def push(self, item): self.rak.append(item) def pop(self): return self.rak.pop() def isEmpty(self): return self.rak == [] def peek(self): return self.rak[len(self.rak)-1] def size(self): return le...
4b781b9f25234e85fe668d8fe3cecc46fcef8d47
oktavianidewi/interactivepython
/recursion_palindromeRemoveWhite.py
311
3.890625
4
# Write a function that takes a string as a parameter and # returns True if the string is a palindrome, False otherwise. # Remember that a string is a palindrome if it is spelled # the same both forward and backward. def removeWhite(): pass def isPal(): pass # testEqual(isPal(removeWhite("x")),True)
b1d106ecf97e0dd1712cf1d936610f9348b15e53
jakem68/rpi_experiments
/vicky_birthday.py
3,876
3.609375
4
#!/usr/bin/env python import time import grovepi from grovepi import * from grove_rgb_lcd import * from time import sleep from math import isnan # set green as backlight color # we need to do it just once # setting the backlight color once reduces the amount of data transfer over the I2C line setRGB(0,2...
e9ae990a391c36c093c5f6661ec911cfb324b7da
GitHubChengPeng/jMetalPy
/jmetal/util/distance.py
1,344
3.640625
4
from abc import ABC, abstractmethod import numpy from scipy.spatial import distance """ .. module:: distance :platform: Unix, Windows :synopsis: implementation of distances between entities .. moduleauthor:: Antonio J. Nebro <antonio@lcc.uma.es> """ class Distance(ABC): @abstractmethod def get_distan...
840d5e8dda838e69cfa76457bc18676bd5fe7e43
Krista-Pipho/BCH-571
/Lab_3/Lab_3.2.py
747
3.546875
4
# Imports Biopython function that we will use from Bio import SeqIO # Uses the Biopython function to open and process the sequence fasta for seq_record in SeqIO.parse("seq.txt","fasta"): # Sets string sequence equal to one of the output variables from the function containing the sequence from the fasta ...
f39aa64260dbce9cbe7d34c12129b2427f91a2f8
Krista-Pipho/BCH-571
/Lab_5/Lab_5.2.py
811
4.4375
4
# Declares an initial list with 5 values List1 = [1,2,3,4,5] # Unpacks this list into 5 separate variables a,b,c,d,e = List1 # Prints both the list and one of the unpacking variables print(List1) print(a) # Changes the value of a to 6 a = 6 # Prints both the list and a, and we can see that changing a d...
d8ad953d84ebda514f7548fec47612d18b8118b3
KrithikNaralasetty/CodeForces
/Codes/betweenoffices.py
296
3.578125
4
#867A in codeforces n = int(input()) stof = 0 ftos = 0 days = list(char for char in input()) city = days[0] for nextcity in days: if city != nextcity: if city == "S": stof += 1 elif city == "F": ftos += 1 city = nextcity if stof>ftos: print("YES") else: print("NO")
7205c93937188c27a7147940ed2d9dcfed808e84
KrithikNaralasetty/CodeForces
/Codes/GoodMatrixElements.py
460
3.796875
4
#177A1 in codeforces n = int(input()) matrix = [] for _ in range(n): matrix.append(list(map(int,input().split()))) elements_sum = 0 #sum of middle row elements_sum+=sum(matrix[n//2]) #sum of middle column for i in range(n): elements_sum+=matrix[i][n//2] #sum of first diagonal for i in range(n): elements...
bb575aed84b6b01cfd5da8efc4d83d7dfcf52765
KrithikNaralasetty/CodeForces
/Codes/BachgoldProblem.py
222
3.65625
4
#749A in codeforces n = int(input()) if n%2 == 0: print(n//2) for i in range(n//2): print("2",end = " ") else: print((n-3) // 2 + 1) for i in range(((n-3)//2)): print("2",end = " ") print("3",end = " ")
045708390a1d1addc53a55b4a4279e1a0b5cd66b
qvil/Python
/Class/18week(Class)/class_practice.py
498
3.84375
4
class Calculator: def __init__(self): self.result = 0 def plus(self,num): self.result += num return self.result def minus(self,num): self.result -= num return self.result def times(self,num): self.result *= num return self.result def divided_by(self,num): self.result /= num return self.result...
b48c13b98a3e1d79f0a1ace60eccac877a48edf2
qvil/Python
/Project/BFinder_Class.py
1,063
3.609375
4
# -*- coding:utf-8 -*- Bible_read = open('Bible_NASB.TXT','r') NASB_read = (Bible_read.readlines()) class BFinder: # def __init__(self): def start(self): self.ui() def ui(self): print("\n#########################") print("# Bible Fineder v1.0 #") print("# 1. Find Word ...
95970481d5d58f446da698907114d9180dc8f257
qvil/Python
/Class/9week(error,bmi)/20150529gugudan.py
130
3.546875
4
for index1 in range(2,10): for index2 in range(1,10): result = index1 * index2 print("%d * %d = %d" % (index1,index2,result))
2cc8613ea9c08d0ef0292a605c61162333e4765d
qvil/Python
/Project/calculator.py
904
3.53125
4
# Date : 150504 # Author : tshyeon # file name : calculator.py ########### Function ############ def add(a,...): return a+b def sub(a,b): return a-b def mul(a,b): return a*b def div(a,b): print("share : %d" % (a/b)) print("rest : %d" % (a%b)) ########### Function ############ ########### Interface ###########...
9a4c5f4999f5b83cf3353c48979acece7113a8ca
qvil/Python
/Class/11week(file)/readfile.py
441
3.546875
4
#!/usr/bin/python # # -*- coding: utf-8 -*- # ######### first step f = open("newfile.txt", 'r') line = f.readlines() print(line[0],line[2]) f.close() # ######### # ########## second step # f = open("newfile.txt", 'r') # lines = f.readlines() # # # print(lines) # for line in lines: # print(line) # # f.close() # #...
fd6ea0573edf7b1dc44e1165252d1e47e6370322
ahviplc/pythonLCDemo
/com/lc/demo/TkinterDemo/9_Radiobutton_Demo.py
493
3.53125
4
import tkinter """ Radiobutton单选框 """ win = tkinter.Tk() win.title("9_Radiobutton_Demo.py By LC") win.geometry("400x400+200+50") def updata(): print(r.get()) # 绑定变量,一组单选框要绑定同一个变量,就能区分出单选框了 r = tkinter.IntVar() radio1 = tkinter.Radiobutton(win, text="one", value=1, variable=r, command=updata) radio1.pack() ra...
6a675878e4a0aa6a6ce8713a05ef8802e95d4a13
ahviplc/pythonLCDemo
/com/lc/PythonForAllTheAlgorithms/MyLCLintCodeKu_Python/0002.Add Two Numbers/test_main.py
584
3.703125
4
from Solution import Solution # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None # 这个使用from Solution import Solution引入 # main方法 if __name__ == '__main__': slt = Solution() listnode1 = ListNode(2) listnode1.next = ListNode(4) ...
787945ae054102017b040df48dabb1d4291aafb0
ahviplc/pythonLCDemo
/com/lc/demo/TkinterDemo/8_Checkbutton_Demo.py
988
3.5
4
#!/usr/bin/env python # -*- coding:utf-8 -*- import tkinter """ Checkbutton多选框控件 """ win = tkinter.Tk() win.title("8_Checkbutton_Demo.py By LC") win.geometry("400x400+200+50") def updata(): message = "" if hobby1.get() == True: message += "money\n" if hobby2.get() == True: message += "pow...
176d6966c4b1eecdbc408aa79d4f93c4f990de34
ahviplc/pythonLCDemo
/com/lc/demo/TkinterDemo/32_Combination_Key_Demo.py
537
3.546875
4
import tkinter ''' 组合按键事件 Control-Alt-a按键时间 ''' win = tkinter.Tk() win.title("32_Combination_Key_Demo.py By LC") win.geometry("400x400+200+50") # <Control-Alt-a> # <Shift-Up> # 只是control+alt不行 label = tkinter.Label(win, text="*********", bg="red") # 设置焦点 label.focus_set() label.pack() def func(event): print("e...
c13d3cac0505f26aed1fff7ee8c559ebc7380859
ahviplc/pythonLCDemo
/com/lc/demo/fireDemo/fireDemo.py
292
3.59375
4
import fire class Calculator(object): """A simple calculator class.""" def double(self, number): print("fire-i am ok!~LC") print("2倍为") return 2 * number def qiuhe(self, a, b): print('求和为') return a+b; if __name__ == '__main__': fire.Fire(Calculator)
db7597ec7a93e90a44ec8498b0af1a2252858cc3
JeromePrevotat/ProjectM
/Client/change_username.py
2,395
3.75
4
"""Module to build the gui of the Change Username Dialbox.""" import tkinter as tk def build_frames(dialbox): """Add Frames to the gui.""" #Buttons Frame dialbox.button_frame = tk.Frame(dialbox.master_frame) dialbox.button_frame.grid(row=3, column=1) #Output Frame dialbox.output_frame = tk.Fra...
a996edb7e58a1c3d6efae4d221007baed2d047b2
salimfadhley/python_hackerrank
/src/hackerrank/coin_change/impl.py
746
3.90625
4
# https://www.hackerrank.com/challenges/ctci-coin-change/problem import functools def readints(inputlines): text = next(inputlines) try: return tuple(int(x) for x in (text.split(" "))) except ValueError: raise ValueError("Cannot convert %r" % text) @functools.lru_cache(maxsize=None) def ...
a0fbb2b6a3254d952add29d63a60e3fcc3bb2876
tsr10/filmlocations
/map/utils.py
490
3.609375
4
def create_bitmask(films, all_films): """ Creates the bitmask off of a query and all the films in the DB. The films are fetched from the DB in map/views.py. """ bitmask = [] while len(films) > 0: if all_films[0] == films[0]: bitmask.append(1) films.pop(0) ...
a36beb973cde948874fe4de8de8038b30a7a1d06
ShenghanGao/291submit
/song_poem_classify.py
2,941
3.625
4
# coding: utf8 import operator import string ''' preprocess the poems in song_poem.txt initially in the form as: 艾丑?登立鱼山 杳杳灵岩洞府深,有人岩下振潮音。 龙天耸听生欢喜,留得神鱼立到今。 convert a poem into a line, and get rid of the title as: 杳杳灵岩洞府深,有人岩下振潮音。龙天耸听生欢喜,留得神鱼立到今。 collect and classify poems according to their format, and p...
91a39bef2542f18cb3b74307c2d5bd0339f24fae
leoleo-7/Pyrhon
/第二期作业.py
789
4.09375
4
#!/usr/bin/env python # _*_ coding: utf-8 _*_ #@Time : 2020/1/8 #@Author: Leo ''' 1. age = int(input("用户输入年龄:")) if str(age).isdigit(): #.isdigit() 前面要用str长转 if age >= 18: print("恭喜你,成年了!") else: print("你好,小朋友") else: print("您的输入有误!") ''' ''' 2. ''' name ...
818419b58c97f19a98ff7492056dcbabd0705a0e
hamburgcodingschool/L2CX-November
/lesson 1/p1-variables.py
152
3.5625
4
# VARIABLES # Assignment operator = number1 = 89 number2 = 10 print(number1) print(number2) number1 = 5 print(number1) number3 = 9 print(number3)
55acb6b47df4162021ee9c8c49b296d2bf24283f
hamburgcodingschool/L2CX-November
/lesson 2/p3_format.py
150
4
4
name = "Helder" age = 37 finalSting = "Hello my name is {} and I am {} years old. Did I mention I am {}?".format(name, age, name) print(finalSting)
d9fbf08a599b0a04491081eece5292114ba12039
hamburgcodingschool/L2CX-November
/lesson 6/dashes.py
413
4.21875
4
# ask the user for a word # seperate the letters with dashes: # ex: banana becomes b-a-n-a-n-a def dashifyWord(word): dashedWord = "" firstTime = True for letter in word: if firstTime: firstTime = False else: dashedWord += "-" dashedWord += letter retur...
81a73d7802acb9db07a2def5e7381d843664d2e5
hamburgcodingschool/L2CX-November
/lesson 3/p3-primenumber.py
314
4.03125
4
number = 7 #ask user for input counter = 2 isPrime = True while counter < number: # print(counter) # print(number % counter) if number % counter == 0: isPrime = False break counter = counter + 1 if isPrime: print("YO IT IS A PRIME!") else: print("NO PRIME HERE SUCKA!")
6a79b8a8424d83855aa72aefdf873be19b1a9ecd
manishg2015/python_workpsace
/python-postrgress/main.py
1,625
4.25
4
from sqlitedatabase import add_entry,get_entries,create_connection,create_table menu = """ Welcome to the programming diary! Please select one of the following options: 1) Add new entry for today. 2) View entries. 3) Exit. Your selection: """ welcome = "**Welcome to the programing diary!**" # entries = [ # {"c...
586f89c0535c7bf97f26885e44cf334e3d036aed
jlkazan/pfr-scraper
/scraping/scraper.py
3,297
3.8125
4
from typing import List from bs4 import BeautifulSoup, Comment import pandas as pd from urllib.request import urlopen class Scraper: """ General class for scraping data from pro-football-reference.com Methods were inspired by the following source: https://towardsdatascience.com/scraping-nfl-...
cf02450afe9e1dd0f02b14033b9732cf74b0d5b7
Narasimhag/MarsExplorationMission
/pathfinder.py
8,580
3.625
4
from queue import PriorityQueue import math in_path = 'testcases/input1.txt' out_path = 'output.txt' size = [] landing = [] targets = [] area = [] num_targets = 0 max_elevation = 0 # class Node: # def __init__(self, coordinates, value, parent=None, cost=0): # self.coordinates = coordinates # sel...
8ec7580c5186f18c65e60a4987c5daabe89d441a
ss807/PythonforBeginners
/regularexpressions.py
905
4
4
# Finding Numbers in a Haystack # In this assignment you will read through and parse a file with text and numbers. # You will extract all the numbers in the file and compute the sum of the numbers. # Data Files # We provide two files for this assignment. One is a sample file where we give you the sum for # your testing...
7403672c0becb381b7fd8f4d08e85209f46a50ef
klimmerst/py111-efimovDA
/Tasks/b2_Taylor.py
887
3.921875
4
""" Taylor series """ from typing import Union def ex(x: Union[int, float]) -> float: """ Calculate value of e^x with Taylor series :param x: x value :return: e^x value """ res = 1 denominator = 1 numerator = 1 for i in range(1, 10): numerator = numerator * x deno...
b2b2230412faa43088955792d580ab99b14aff03
ccondon894/Algorthims-Practice
/KMPPatternMatch.py
1,678
3.65625
4
#Improve time efficiency of patternMatch to search for pattern = p in string = s in O(m+n) time #Make arr to to find longest prefix that is also a suffix at each index in pattern #Use arr during mismatches to see if a prefix exists at suffix before mismatch #This lets us continue matching at current index in s be...
f5f31f81696693dee3a60ce0907f23eea8b3d341
Arun97-creator/Deep-Learning--ANN
/Bank(Y N).py
4,654
3.5625
4
#!/usr/bin/env python # coding: utf-8 # In[2]: # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # In[1]: get_ipython().system('pip install pandas') # In[3]: pwd # In[5]: cd/Users/HP/Desktop/Data Science/Project # In[7]: # Importing the dataset dataset =...
40517c133d45bb746897b2a3c2b674d43d92d2e3
Pigot12/SelfTaughtPython
/29122020203.py
413
4.03125
4
#The most basic Program print ("Hello,World") value = "5 + 5" print(value) value2 = 5 + 5 print(value2) value3 = 5 print(value2 + value2) print(value2 - value2) print(value2 * value2) print(value2 / value2) print(value2 % 100) print(value3 ** 2) print(value3 // value2) print(value3 + value2) pr...
01c6eb174e571bfd3b79900ab6909f146cfe49cd
samandeveloper/image-processing
/main.py
2,000
3.578125
4
#In this project we want to do image processing from PIL import Image,ImageFilter img = Image.open('./Flowers/flower2.jpg') print(img) #image object print(img.format) #image format print(img.size) #image size print(img.mode) #image mode print(dir(img)) #image dir #Adding "BLUR" Filter to Image filtered_img = img.filte...
1249e335e9423ea3a89511117b359d44226c39a8
lnetza/DevFBatch1
/clasePerro.py
538
3.640625
4
class Perro(object): def __init__(self, edad,nombre, peso,raza,color): self.edad=edad self.nombre=nombre self.peso=peso self.raza=raza self.color=color def ladrar(self): print('Wuaa wuau!!!') def correr(self): print (self.nombre + ' Esta corriendo') ...
7f4c789b286cf820a1b3ebe528de3837b0173137
afzalali27/Python
/task1/question4sol.py
197
4.1875
4
char = input('Enter a character to check it is vowel or not : ') vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'] if char in vowels: print('vowel') else: print("constant")
2ce56dc77cdb1704e940c0a20f045a2d7b6e6c3d
sslshuanglong/Learn-Python
/daily_contact/date.py
449
3.53125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from datetime import datetime,timedelta dt = datetime(2019,3,26,8,20) print(dt.timestamp()) t = 1553559600.0 print(datetime.fromtimestamp(t)) print(datetime.utcfromtimestamp(t)) cday = datetime.strptime('2019-3-26 8:10:00','%Y-%m-%d %H:%M:%S') print(cday) now = datetim...
193142d135df8065ab879ceb81184c8fda26d93a
adxpillar/Expense_tracker
/Build-1/entry.py
353
3.5
4
class Entry(): """ Each record entry should have following attributes: * title (string) * amount (float) * created_at (date) * tags (list of strings) """ def __init__(self,title,amount,created_at,tags): self.title = title self.amount = amount self.created_at = cre...
66703e13e0e831b7472ac1d5bb3df64e0af61a59
RobRoseKnows/umbc-cs-projects
/umbc/CMSC/2XX/201/Homeworks/hw8/hw8_part1.py
685
4.4375
4
# File: hw8_part1.py # Author: Robert Rose # Date: 11/24/15 # Section: 11 # E-mail: robrose2@umbc.edu # Description: # This program takes a list from user input and outputs it in reverse using # recursion. def main(): integers = [] number = int(input("Enter a number to append to the list, or -1 to st...
51d440399a0ab235eefd5fce507c982c72dbe665
RobRoseKnows/umbc-cs-projects
/umbc/CMSC/2XX/201/Homeworks/hw6/hw6_part1.py
504
4.03125
4
# FIle: hw6_part1.py # Author: Robert Rose # Date: 10/22/15 # Section: 11 # E-mail: robrose2@umbc.edu # Description: # Program reads an arbitrary number of names and prints them into a file. def main(): # Get first name nameIn = input("Insert name: ") # Create file printFile = open("names.t...
e97487959ffb477fed5bb5dde9019144a7f6536b
RobRoseKnows/umbc-cs-projects
/umbc/CMSC/2XX/201/Homeworks/hw2/hw2.py
2,425
4.34375
4
# File: hw2.py # Author: Robert Rose # Date: 9/12/15 # Section: 11 # Email: robrose2@umbc.edu # Description: # This file contains mathmatical expressions as # part of Homework 1. print("Robert Rose") print("Various math problem solutions as part of Homework 1.") # Question 1: # Expected output: 24 num1 = (7 ...
85cbf841a375c5789e69572a85d051546227bf49
RobRoseKnows/umbc-cs-projects
/umbc/CMSC/2XX/201/Labs/Lab10/lab10.py
1,115
4.09375
4
# File: lab10.py # Author: Robert Rose # Date: 11/5/15 # Section: 11 # E-mail: robrose2@umbc.edu # Description: # De/encyphers words def main(): print("""What would you like to do? 1. Encrypt String 2. Decrypt String""") choice = int(input("Enter 1 or 2: ")) shiftBy = int(input("How much would you ...
d6b8badd9aee2e685f6ba7cf2ba27fc742703cc2
bktaha/exercism-python-track-solutions
/binSearch.py
469
3.6875
4
def binSrch(can, vals): lvals = len(vals) if vals == []: return -1 elif can == vals[lvals //2]: return lvals //2 elif can > vals[lvals //2]: return binSrch(can, vals[lvals //2:]) else: return binSrch(can, vals[:lvals //2]) def binSearch(nval, ncan, vals, cans): i...
df9378ab7327ba551694a21283449b4e390a54e5
jpeone/cs-module-project-algorithms
/single_number/single_number.py
1,024
4.03125
4
''' Input: a List of integers where every int except one shows up twice Returns: an integer ''' def single_number(arr): # Your code here # Firstpass: would be to make a hash table, iterate through the array # and count the values in the hash table, then traverse the hash table and # output the value wit...
120b363afdecbbc5f67640a53cad242b5c97ad01
huangdaweiUCHICAGO/CAAP-CS
/Assignment 1/cash.py
890
4.1875
4
# Dawei Huang # 07/17/2018 # CAAP Computer Science Assignment 1 # Programs for Part 1 of the assignment is contained in the file hello.py # Programs for Part 2 of the assignment is contained in the file cash.py # Part 2 print("Part 2: Change Program\n") print("This program will prompt user for the amount of change an...
2f00b3c538dabb87b825a75e145a5a96b254db31
315025222/TallerDeHerramientasComputacionales
/Clases/Programas/Practica/ej2.py
404
3.75
4
def sumaCuadrada(n): # calcula la suma sumando sumita = 0 while n > 0: sumita += n ** 2 n -= 1 return sumita def formulaCuadrada(n): # calcula la suma con fórmula r = (n*(n+1)*(2*n + 1))/6.0 return r print("Comparando la suma con la fórmula:") # los muestro en la consola for i...
d8c21ad821c3b12982f0c5ca2d14b3e6cdb83a4d
315025222/TallerDeHerramientasComputacionales
/Clases/Programas/pythonFacil/problema01.py
392
3.796875
4
# Programe una función que determine si dos listas son iguales. Dos listas se consideran iguales # si tienen igual longitud y sus elementos en cada índice también lo son. def listasIguales(lista1, lista2): if len(lista1) == len(lista2): for i, j in zip(lista1, lista2): if i != j: ...
d88cc89f980f962e0301b19fb52d9a9c7e4dca82
315025222/TallerDeHerramientasComputacionales
/Clases/Programas/Tarea05/Problema03s.py
403
3.53125
4
import Tarea05.Problema03 as p3 lista = [] for i in range(0, 11): lista.append(i) fahrenheit = 234 for i in lista: celsius = p3.FaC(fahrenheit) print("{} F es igual a {} C".format(fahrenheit, celsius[0])) fahrenheit += 10 print("=" * 50) celsius = 353 for i in lista: fahrenheit = p3.CaF(celsius) ...
89bf9b42e70d2a885ad6fa99428f71b0e611b8a7
315025222/TallerDeHerramientasComputacionales
/Clases/Programas/Listasdelistas.py
1,071
3.546875
4
def mostrarAlumnos(listaA): contador = 1 print("Las calificaciones aprobatorias de los alumnos son:") for sublista in listaA: impresion = "" alumno = "alumno #%d: " % contador for valor in sublista: impresion += str(valor) + " " print(alumno + impresion) ...
1be18bf135359cecf60f0513b21b51feb33923cd
BrianSeong99/thu-cryptography-enigma
/question_two/q1_21_1.py
1,803
3.625
4
from collections import defaultdict import re alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ciphertext = 'EMGLOSUDCGDNCUSWYSFHNSFCYKDPUMLWGYICOXYSIPJCKQPKUGKMGOLICGINCGACKSNISACYKZSCKXECJCKSHYSXCGOIDPKZCNKSHICGIWYGKKGKGOLDSILKGOIUSIGLEDSPWZUGFZCCNDGYYSFUSZCNXEOJNCGYEOWEUPXEZGACGNFGLKNSACIGOIYCKXCJUCIUZCFZCCNDGYYSFEUEKUZCSOC...
85d1c470228d5cd83fe60d94c531a78dbb00ae34
BBQlettuce/aoc_2020
/day_08/day8.py
1,870
3.640625
4
with open("./day8.txt") as f: steps = f.read().strip().split("\n") accumulator = 0 current_step = 0 visited_steps = set() while current_step not in visited_steps: print(current_step) print(accumulator) visited_steps.add(current_step) # execute step step = steps[current_step] [operation, u...
8ac69fd42a73a139f79461f8ca91dbc850f4dbd6
Avyansh0001/Iphone-Game
/Iphone Game.py
738
3.953125
4
from random import randint print('Iphone XII Pro Max Game') feeling_brave=True score=0 while feeling_brave: ghost_door = randint(1, 3) print('Three doors ahead') print('Iphone XII Pro Max is behind one of these three doors.') print('Which door do you open?') door = input('1, 2, or 3?') ...
0cb85650bed1507c5b909d7e4cf24ee0d30ca032
BugDiver/learnPython
/classes/points.py
490
4.09375
4
from math import sqrt class Point(object): def __init__(self, start,end): self.__x =start; self.__y = end; def __repr__(self): return "[Point @x:"+str(self.__x)+",y:"+str(self.__y)+"]"; def equals(self,point): if isinstance(point ,Point): return self.__x == point.__x and self.__y == point.__y; else: ...
7fd2c204e6e9f1d3e7536e23a78d26908539bee7
BugDiver/learnPython
/arrayUtil/map_reduce_filter_test.py
1,275
3.5625
4
import unittest from map_reduce_filter import my_filter from map_reduce_filter import my_map from map_reduce_filter import my_reduce list = [0,1,2,3,4,5,6,7,8,9,10] def is_even(arg): if arg % 2==0: return True def is_odd(arg): if arg % 2 != 0: return True def increment(arg): return arg...
93e3d9fe8b9a096e6c0e2a0bd83a59b1ff5075b9
rshah918/ForestAdventure
/ForestAdventure.py
9,514
3.8125
4
last_scene = [] def trail(): print '-' * 20 print 'Your car broke down and are now walking down a dark forest \n' print 'There is a fork in the trail. Do you go "left" or "right"?' direction = raw_input('>').split() if 'left' in direction: last_scene.append(0) return goon1() ...
10184d742b11dbb36f0b90268773c4290c902ede
josh314/euler
/python/prob07.py
507
3.75
4
import math def f(max): """Project Euler, problem 7""" primes = [] pctr = 0 done = False num = 2 while not done: is_prime = True sqrt_num = math.sqrt(num) for p in primes: if p < sqrt_num: is_prime = is_prime and (num % p != 0) els...
910e6cb2bbe99468f51699ccef91214dc155ca9f
CTISM-Prof-Henry/python-two-torturador-de-mentes
/project/tarefa_01.py
439
3.984375
4
def tarefa_1(N): lista_de_fora = [] for i in range(N): lista_de_dentro = [] for j in range(N): lista_de_dentro.append(0) lista_de_fora.append(lista_de_dentro) return lista_de_fora def main(): """ Use esta função para testar como você está resolvend...
daabf510c6a6fd05ec5338da302af3c071c34015
bogdanlungu/learning-python
/rename_files.py
727
4.21875
4
""" Renames all the files from a given directory by removing the numbers from their names - example boston221.jpg will become boston.jpg """ import os from string import digits # define the function def rename_files(): # get the file names from a folder file_list = os.listdir(r"C:\Python\tmp\prank") ...
1e38094a5fa47b540c7a5350010c74bc389ab13c
bogdanlungu/learning-python
/combinations.py
752
4.46875
4
"""This programs computes how many combinations are possible to be made from a collection of 'n' unique integers grouped under 'g' elements. You need to specify the length of the collection and how many elements at a time you want to group from the collection. The number of possible combinations will be printed.""" # p...
95d7adc19ad69d487ddc62b396fc94055fd6f2da
YanWanquan/handpose
/examples/quat_ops.py
668
3.71875
4
""" Operations of quaternion. """ import numpy as np import time from handpose.utils import Quaternion # Quaternion as numpy array angle = 0.5*np.pi # Angle for rotation c = np.cos(0.5*angle) s = np.sin(0.5*angle) q_array = np.array([c, 0.0, s, 0.0]) # Rotate about the y axis # Convert the quaternion a...
f59a50d4c5a1d9fdf489097819905c086ee06df5
CoranC/Algorithms-Data-Structures
/Cracking The Coding Interview/Chapter Nine - Recursion and Dynamic Programming/9_2__xy_grid.py
734
4.25
4
""" Imagine a robot sitting on the upper left corner of an X by Y grid. The robot can only move in two directions: right and down. How many possible paths are there for the robot to go from (0,0) to (X,Y)? """ #Workings """ Grid [ [0, 0, 0], [0, 0, 0], [0, 0, 0] ] Answer [ [6, 3, 1], [3, 2, 1], [1, 1, 0]...
c467b8ed83abd69af47a1722cb3b2ed8c73baa9c
afiqmuzaffar/Python-Jarvis
/weather.py
1,840
3.671875
4
import requests, json import math import config class Weather: weatherURL = "http://dataservice.accuweather.com/forecasts/v1/hourly/1hour/" currentCity = "Ahmedabad" locationKey = "202438" def __init__(self, cityName="Ahmedabad"): self.currentCity = cityName def getLocationKey(self): ...
4ef0fe0dfebb3c739f8d52ea017b78b75a4076a0
shadman19922/Algorithm_Practice
/H_Index/h_index_sorted_array.py
783
4.21875
4
def compute_h_index(Input): #Input.sort() left = 0 right = len(Input) - 1 h_idx = -2 while left < right: middle = (int)(left + (right - left)/2) middle_element = Input[middle] remaining_elements = right - middle + 1 if middle_element <= remaining_elements: ...
960193cfd0b8b547b061a366ffc13253929831a6
wiktoriapanasinska/panasinska
/5/sketch_5/sketch_5.pyde
1,610
3.703125
4
class Kolo(): kolor = False def __init__(self, arg_1, arg_2, arg_3): #lepiej gdy nazwy wskazują na to czym są, lepiej się wóczas korzysta z kodu self.arg_1 = arg_1 self.arg_2 = arg_2 self.arg_3 = arg_3 def mydraw(self): # stosowanie nazw wbudowanych może mieć nieprzewidziane ...
2df17ff7150595ce053100197f6f854e90b4886c
CameronDevine/mr_sim
/mr_sim/__init__.py
1,727
3.90625
4
from .shapes import * from .types import * from .pressure import * from .models import * def create_simulation(*classes): """A helper method to combine classes. This method combines classes representing different elements of a material removal simulation. This allows different simulations to be easily co...
657d1a6da81ddbb5a38f5795d6690d38fc08df5d
bilginyuksel/flow-gann
/factory/job.py
1,244
3.765625
4
import logging from typing import List class Job: """ Job will have process time for each machine """ def __init__(self, id, process_times) -> None: self.id = id self.curr_handler = 0 self.process_times = process_times def is_done(self, machine_id): return self.pr...
cdd25397c65edd5ad86fb61006e158b8896934e4
bilginyuksel/flow-gann
/genetic_algorithm/utils.py
306
3.765625
4
from random import sample def create_population(arr, population_count): """ creates a population from given arr. it will shuffle the original arr multiple times and creates a population based on shuffled arrays. """ return [sample(arr, len(arr)) for _ in range(population_count)]
64b2ceb33f41d2ea1a949fb291b4fd747cdbdc2d
catch0/python_may_2017
/spence_peacock/Car.py
913
3.84375
4
class Car(object): def __init__(self,price,speed,fuel,mileage,tax=0): self.price=price self.speed=speed self.fuel=fuel self.mileage=mileage if price>10000: self.tax=1.15 else: self.tax=1.12 def display_all(self): print "Price: {}".f...
e07031abb9c65f3964221c712eace4c8adb9f2f9
catch0/python_may_2017
/spence_peacock/dictionaries.py
302
4
4
spence={ "first_name": "spence", "age" : 32, "birthplace" : "provo", "language" : "python", } print "my name is " + spence["first_name"] print "my age is {}".format(spence["age"]) print "my city of birth is " + spence["birthplace"] print "my favourite language is " + spence["language"]
ab1fa26c56d1131e47f65166faf65281f02e614c
Kevinwty0107/Data-Scraping
/dataframe/web spider2.py
486
3.515625
4
from urllib import request import urllib from bs4 import BeautifulSoup url = 'http://example.webscraping.com/places/default/view/China-47' html = urllib.request.urlopen(url).read() soup = BeautifulSoup(html, 'html.parser') # locate the area row tr = soup.find(attrs={'id':'places_area__row'}) print (tr) # locate the a...
8baedc624426f76f3d0fefc27f8ac65167a7a26d
uebling/Foobar
/Level 4/foobar4_2.py
3,592
3.671875
4
from itertools import permutations from copy import deepcopy def solution(times, times_limit): n = len(times[0]) #note to myself: times[a][b] is the time from a to b all_bunnies = [j for j in range(n-2)] #ID of all bunnies all_bunny_positions = [j+1 for j in range(n-2)] #Nodes where they sit d...
ca66f03d8a33f2f47a3f21d1ca44aa4c410ac644
ebagos/python
/p023/main.py
1,699
4.125
4
""" 完全数とは, その数の真の約数の和がそれ自身と一致する数のことである. たとえば, 28の真の約数の和は, 1 + 2 + 4 + 7 + 14 = 28 であるので, 28は完全数である. 真の約数の和がその数よりも少ないものを不足数といい, 真の約数の和がその数よりも大きいものを過剰数と呼ぶ. 12は, 1 + 2 + 3 + 4 + 6 = 16 となるので, 最小の過剰数である. よって2つの過剰数の和で書ける最少の数は24である. 数学的な解析により, 28123より大きい任意の整数は2つの過剰数の和で書けることが知られている. 2つの過剰数の和で表せない最大の数がこの上限よりも小さいことは分かっているのだが,...
7fae9cf25af10d6fd1685e70f9e8e5542ec41776
ebagos/python
/p053/main.py
1,230
3.625
4
""" 12345から3つ選ぶ選び方は10通りである. 123, 124, 125, 134, 135, 145, 234, 235, 245, 345. 組み合わせでは, 以下の記法を用いてこのことを表す: 5C3 = 10. 一般に, r ≤ n について nCr = n!/(r!(n-r)!) である. ここで, n! = n×(n−1)×...×3×2×1, 0! = 1 と階乗を定義する. n = 23 になるまで, これらの値が100万を超えることはない: 23C10 = 1144066. 1 ≤ n ≤ 100 について, 100万を超える nCr は何通りあるか? """ dicto = {1: 1} d...
1fdfb0964ec9ab2cba3d5a5e1901dd162255e325
ebagos/python
/p019/main.py
1,608
3.8125
4
""" 次の情報が与えられている. 1900年1月1日は月曜日である. 9月, 4月, 6月, 11月は30日まであり, 2月を除く他の月は31日まである. 2月は28日まであるが, うるう年のときは29日である. うるう年は西暦が4で割り切れる年に起こる. しかし, 西暦が400で割り切れず100で割り切れる年はうるう年でない. 20世紀(1901年1月1日から2000年12月31日)中に月の初めが日曜日になるのは何回あるか? """ def isUruu(year): result = False if year % 4 == 0: result = True ...
f1057679dfb7cbab8a32e64cc31d9ab313998661
atomic-binary/100-days-of-code
/code-snippets/day-3-learnings.py
7,609
4.59375
5
#!/usr/bin/env python3 # if condition: # do this # else: # do this #draw.io is a great website draw flowchart diagrams. #Rollercoaster ride exercise: print("Welcome to the rollercoaster!") height = int(input("What is your height in cm?\n")) if height >= 120: print("You can ride the Rollercoaster!") else:...
bc0b9eeec731507c7ead7eac16290838f62da183
anna-mikhalchuk/beetroot_course
/task2.py
586
3.8125
4
# Create a python program named “task2”, and use the built-in function `print` in it several times. # Try to pass “sep”, “end” params and pass several parameters separated by commas. # Also, provide a comment text above each print statement, mentioned above, # with the expected output after execution of the particular ...
5de2d831b631bf1d32c4da5f8fec3a41d4f6f8d8
anirban2304/Python
/Book_Store/backend.py
1,553
3.921875
4
import sqlite3 def connect(): conn = sqlite3.connect("Book_Store/books.db") cur = conn.cursor() cur.execute("CREATE TABLE IF NOT EXISTS book (ID INTEGER PRIMARY KEY, title text, author text, year integer, isbn integer)") conn.commit conn.close connect() def view_all(): conn = sqlite3.connect(...