blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
304031c43b782e87103ef0ac275e6d2fa550a1f8
Calvin98/Iowa_PythonProjects
/Flower Real.py
1,241
3.625
4
import turtle def draw_arc(t): t.right(18) for count in range(10): t.forward(10) t.left(4) t.right(4) t.right(18) def draw_squiggle(t): t.right(90) for count in range(10): t.forward(10) t.left(4) t.right(4) t.right(18) t.left(10) ...
760ab7c54cae4c13ae6b43d6bfe1e2fa0cd300eb
svaccaro/codeeval
/overlapping_rectangles.py
511
3.9375
4
#!/usr/bin/env python from sys import argv input = open(argv[1]) def overlap(a1,a2,b1,b2): if a1 > b2 or a2 < b1: return False else: return True for line in input: line = line.rstrip() coords = map(int,line.split(',')) x_overlap = True y_overlap = True x_overlap = overlap(...
b56f6a2c017da7a95241a857d224c8cec50c1a63
AnimeshSinha1309/terminal-joyride
/firebeam.py
2,249
3.53125
4
""" Implements the obstacles (beams of fire) hanging in the air """ import numpy as np import colorama as cl import container from spawnable import Spawnable class FireBeam(Spawnable): """ The FireBeam obstacles that destroy the player if colliding """ def __init__(self): self._type = np.ran...
505d55c4b03b3cbfc56fccf1e126ab28930e34c2
patnev/GM1_G3
/read_serial.py
1,242
3.65625
4
""" Class to read sensor data from serial port (via USB) """ import serial from constants import * class SerialReader: """ SerialReader: class to read sensor data Methods: readline, readline_multi, isButtonPressed """ def __init__(self): """ Initialise serial reader from serial por...
e7c4151acf27d25e1cd1afb7affa86ccec6cedb4
cynthia8863/test
/ex/ex25_sample.py
1,017
3.609375
4
import ex25 sentence = "All good things come to those who wait" words = ex25.break_words(sentence) print words print "-"*30 sorted_words = ex25.sort_words(words) print sorted_words print "-"*30 print ex25.print_first_word(words) print ex25.print_last_word(words) print "-"*30 print ex25.print_first_word(sorted_words...
e3da65a2517a2fccbf79fbfc0ecd0b208efb3a1b
jgingh7/Problem-Solving-Python
/Inter/MinimumHeightTrees.py
1,354
3.6875
4
# https://leetcode.com/problems/minimum-height-trees/ # Time: O(V) # Space: O(V) - edges + leaves from collections import defaultdict class Solution: def findMinHeightTrees(self, n: int, edges: List[List[int]]) -> List[int]: # base cases if n <= 2: return [i for i in range(n)] ...
dad078e3463e155e5ac368b2de398ee2d57497be
clarkwalcott/CSPractice
/Easy/checkNums.py
425
4.125
4
# Have the function CheckNums(num1,num2) take both parameters being passed and return the string "true" # if num2 is greater than num1, otherwise return the string "false". If the parameter values are equal # to each other then return the string "-1". # Problem Credit: Coderbyte.com def CheckNums(num1,num2): i...
5cebbbd34f6d67c25c69ba9eac50a44836a9ea64
DevproxMeetup/TicTacToe-Python
/board.py
1,011
3.578125
4
# Our Game Class class GameBoard: def __init__(self, cols, rows=None): if rows is None: rows = cols self.cols = cols self.rows = rows self._matrix = [None] * (rows*cols) def _convert_to_pos(self, key): if isinstance(key, int): return ...
4331adac75ddea1b1dc88ea2aa21d89e5ce2db39
harrifeng/Python-Study
/Leetcode/ZigZag_Conversion.py
1,211
4.375
4
""" The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) ``` P A H N A P L S I I G Y I R ``` And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take a string and make this...
c0e31502d9694c5220f0ca0e899f9b8e3137b853
SillyHatsOnly/Python-Education-Experiments
/Homework files/Homework_4_test_2.py
739
3.84375
4
''' Написать функцию moar(a, b, n) от трёх параметров — целочисленных последовательностей a и b, и натурального числа n. Функция возвращает True, если в a больше чисел, кратных n, чем в b, и False в противном случае. Input: print(moar((25,0,-115,976,100500,7),(32,5,78,98,10,9,42),5)) Output: True ''' def moar(a, b, n...
ed468f962989c19655c152748b4a443f8d574917
ManullangJihan/Linear_Algebra_Courses
/CH 1/CH 1 Sec 7 Part 1/part55.py
208
3.796875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Sep 16 18:52:55 2020 @author: hanjiya """ import numpy as np r = np.array([[2,1,0]]) A = np.array([[1,2,-3],[-2,1,1],[3,1,4]]) print(r@A)
59427c6db6e5fc4e674371eea1f58834591878c2
yckfowa/codewars_python
/7KYU/Reverse words.py
84
3.640625
4
def reverse_words(text): return ' '.join(text[::-1] for text in text.split(" "))
9c61d83ff1568391796df9bb3dfeea09f9bd6a43
profarav/python101
/002_kmtomiles.py
204
4.34375
4
print("This program converts kilometers into miles. You get to choose the number for the kilomter.") km = float(input ("Please enter your number for the kilometer:") ) print(km, "km =", km/1.6, "miles")
092909badd9beeb0a2a2d12baf6aa411a695d722
n8hanwilliams/pdsnd_github
/bikeshare.py
7,532
4.21875
4
import time import pandas as pd import numpy as np CITY_DATA = {'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv' } MONTH_DATA = {'january': 1, 'february': 2, 'march': 3, 'april': 4, 'may': 5,...
8bad99423f390221a6eab31195669e9ce9a08d6b
Olga2344/pythonProject
/2 ex.py
567
3.84375
4
# 2. Пользователь вводит время в секундах. # Переведите время в часы, минуты и секунды и выведите в формате чч:мм:сс. # Используйте форматирование строк. sec = int(input('введите количество секунд: ')) hour = ((sec // 3600)) % 24 minuets = (sec // 60) % 60 seconds = sec % 60 print(f"вы ввели количество секунд {sec}, ...
2d99ebfdce4345f44ee622cab045193ecd5ba2a4
coryplusplus/PythonMusicConverter
/convertABC.py
866
3.578125
4
from music21 import * songName = raw_input("Please enter the name of the song: ") musicFile = open("textfiles\\" + songName + ".txt", 'w+') abcScore = converter.parse("abcfiles\\" + songName + ".abc") flat = abcScore.flat measures = abcScore.getElementsByClass(stream.Part)[0].getElementsByClass(stream.Measure) if(len(...
086cca562bfe70cd29bb9b594b9afdc8113df06f
nielsbijl/ML
/Perceptron/PerceptronNetwork.py
1,308
4.21875
4
class PerceptronNetwork: """ The PerceptronNetwork class is a network of perceptrons, this contains layers which contains perceptrons """ def __init__(self, layers: list): """ This function initializes the PerceptronNetwork object :param perceptrons: The list of layer(s) for the...
a06757353abe4cec3149868402f4b04fdfa385eb
yeghia-korkejian/Aca_python
/Week2/Homework_2/problem2.py
569
4.28125
4
import argparse parser = argparse.ArgumentParser() parser.add_argument("text", help="Add text which is 7 or more characters long and has an odd number of characters", type=str) args = parser.parse_args() if len(args.text) % 2 == 0 or len(args.text) < 7 : print ("Add text which is 7 or more characters long and has ...
bad58f65ab58881e92dccf862475200c3c5c5e60
kindlychung/pyQCDH
/build/lib/pyQCDH/BimFamReader.py
2,557
3.8125
4
import pandas def count_lines(filename): """ Count the number of lines in a file. :param filename: :type filename: str :return: :rtype: int """ n = 0 with open(filename, "rb") as fh: for line in fh: n += 1 return n # a mix-in class for reading bim and fam...
ba15ab403bcdb2ad7972758ece7f0afa9e5ee7f3
gwendalp/Machine_Learning
/Week_7/aralsea_main.py
2,575
3.5
4
#%% Machine Learning Class - Exercise Aral Sea Surface Estimation # package import numpy as np import matplotlib.pyplot as plt plt.ioff() # to see figure avant input # ------------------------------------------------ # YOUR CODE HERE from preprocessing import preprocessing # ----------------...
2642537498d52d98390e8b1b82bf4d314ec5e81f
hazamp01/Algorithms
/Array_with_duplicates.py
805
3.96875
4
import collections array = [2, 3, 5, 3, 7, 9, 5, 3, 7] Out = [3, 3, 3, 5, 5, 7, 7, 2, 9] output = {i: array.count(i) for i in array} for key, value in sorted(output.iteritems(), key=lambda (k, v): (-v, -k)): print "%s: %s" % (key, value) a = [] # Remove duplicates in array for element in array: if element no...
f0a909ca5858215c7001a0ceeb0fc4ee93eddcb0
HBinhCT/Q-project
/hackerearth/Math/Number Theory/Primality Tests/Does it divide/solution.py
438
3.96875
4
def is_prime(x): if x <= 1: return False if x == 2 or x == 3: return True if x % 2 == 0 or x % 3 == 0: return False for i in range(5, int(x ** .5) + 1, 6): if x % i == 0 or x % (i + 2) == 0: return False return True t = int(input()) for _ in range(t): ...
af0bb7fd0e86af2cafbeb32f0795ebc8473248e1
milenatteixeira/cc1612-exercicios
/exercicios/lab 2/testeRelacionais9.py
318
3.5
4
# coding: utf-8 # In[1]: a = 4 b = 10 c = 5.0 d = 1 f = 5 print("A = C?:", a==c) print("A < B?:", a<b) print("D < B?:", d<b) print("C != F?:", c!=f) print("A = B?:", a==b) print("C < D?:", c<d) print("B > A?:", b>d) print("C >= F?:", c>=f) print("F >= C?:", f>=c) print("C <= C?:", c<=c) print("A <= F?:", a<=f)
ba291f8843538abc1f8cdef1c0c7207c337d4df3
juliethrallstewart/Data-Structures-Julie
/binary_search_tree/dll_stack.py
1,041
3.609375
4
import sys sys.path.append('../doubly_linked_list') from doubly_linked_list import DoublyLinkedList #last in first out class Stack: def __init__(self): self.size = 0 # Why is our DLL a good choice to store our elements? #Answer: Memory, for a queue we have to add and remove from the fron...
0f5e86a7e85d6f10eb5c3400d6d7ac206878462a
anthonybgg/Coding-Challenges
/reverseWord.py
599
4.4375
4
""" Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: "The cat in the hat" Output: "ehT tac ni eht tah" Note: In the string, each word is separated by single space and there will not be any extra space...
16ad91f6e6452bd77f78d2083ffb5d54f140044a
belwalter/clases_programacion_i
/clase_poo.py
5,245
3.875
4
#! Programación orientada a objetos #! Componentes: Clases, Objetos y Mensajes #! Caracteristicas: Encapsulamiento, Herencia, Polimorfismo #! Sobrecarga, Constructor, Ocultamiento de la informacíon class Persona(object): """Clase que representa a una persona.""" def __init__(self, apellido, nombre, edad=...
7e42dee69a19b39f18b9819803280048954ef773
jan25/code_sorted
/leetcode/weekly150/max_level_sum.py
905
3.765625
4
''' https://leetcode.com/contest/weekly-contest-150/problems/maximum-level-sum-of-a-binary-tree/ ''' # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def maxLevelSum(self, root: TreeNode...
699954e0445c600703c7f43420eb3423135bb6bd
QuentinDuval/PythonExperiments
/arrays/CardFlippingGame.py
1,535
4.09375
4
""" https://leetcode.com/problems/card-flipping-game/ On a table are N cards, with a positive integer printed on the front and back of each card (possibly different). We flip any number of cards, and after we choose one card. If the number X on the back of the chosen card is not on the front of any card, then this n...
b57d366c74737cccf8e7dcfc29c5def49fe3d250
sneidermendoza/Ejercicios-ciclo-for
/ejercicio_7.py
1,045
3.890625
4
# En un supermercado una ama de casa pone en su carrito los artículos que # va tomando de los estantes. La señora quiere asegurarse de que el cajero # le cobre bien lo que ella ha comprado, por lo que cada vez que toma un # artóculo anota su precio junto con la cantidad de artículos iguales que ha # tomado y determina ...
c22614cafa045ab7288ab4969b0414c046144af5
automoto/python-code-golf
/arrays_and_lists/all_unique_subsets.py
507
4.09375
4
""" Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. """ import itertools def subsets(nums): subsets = [] for i in range(len(nums)): combinations = [list(i) for i in itertools.combinations(nums, i)] ...
a5b568d4b513754b15132e086038549abbeaf87d
JPeck567/MazeScape
/inputbox/inputbox.py
1,995
3.640625
4
""" by Timothy Downs, input_box written for my map editor This program needs a little cleaning up It ignores the shift key And, for reasons of my own, this program converts "-" to "_" A program to get user input, allowing backspace etc shown in a box in the middle of the screen """ import pygame from pygame.locals ...
d1fcb8c9d08d53ea2076807f90b44cf47a291cb2
Jackroll/aprendendopython
/exercicios_udemy/Programacao_Procedural/dictionary_comprehension_63.py
701
4.125
4
#comprehension dictionary lista = [ ('ch1', 'valor ch1'), ('ch2', 'valor ch2'), ] print('-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=') #covertendo a lista 1 em dicionário com comprehension d1 = {c: v for c, v in lista} #chave : valor para cada chave, valor na lista print(d1) print('-=-=-=-=-=-=-=-=-...
edd1592df02faaee5fa507cf31a5f4928a68271c
yousuf1318/hypervage
/DSA_step_7/check if the srt palindrome.py
191
4.15625
4
inp=input("Enter Your Word : ") palindrome ="" for i in inp: palindrome= i+palindrome if inp==palindrome: print("It's a palindrome") else: print("it's not a palindrome.")
1bc367a6672e528a4d1eee45488e6b6ac150c6e4
SenJia/Reinventing-the-wheel
/LinkedList.py
359
3.8125
4
# When writing sorting toy examples, a linked list can be used to insert an element # into a sorted sublist. # I just add a simple implementation of Linked List for later use. # A linked list consists of a list of nodes. # # Author: Sen Jia # class Node: def __init__(self,data,nextNode=None): self.data ...
c98e39e027b67a40fe065f0c7593114c2d9b4523
Akhila098/test
/strings.py
192
3.59375
4
varOne="hello" varTwo="world" varThree="Hey" #Concat print(varOne+varTwo) #Repetition print(varThree * 3) #Slice print(varOne[1:3]) print(max(varOne)) print(min(varTwo)) print(len(varOne))
b1e1ae69a0cfc858692705cce7b993acaab2496d
kolyasalubov/Lv-585.2.PythonCore
/HW4/Viktor/4_3.py
316
3.828125
4
fibonacci1 = 1 fibonacci2 = 1 user_number = int(input("Enter a last Fibonacci number: ")) print(0, fibonacci1, fibonacci2, sep=', ', end=', ') for i in range(2, 50): fibonacci1, fibonacci2 = fibonacci2, fibonacci1 + fibonacci2 if fibonacci2 > user_number: break print(fibonacci2, end=', ')
873c5c2cfcb30ae1bc96269a47988f0b560992f6
Heidyrh13/DataChallenge365FEM-HR
/Challenge_1/pythonIf-Else.py
373
3.625
4
#!/bin/python3 import math import os import random import re import sys if __name__ == '__main__': n = int(input().strip()) i = n % 2 if i != 0: print("Weird") elif (i == 0) and (2 <= n <= 5): print("Not Weird") elif (i == 0) and (6 <= n <= 20): print("Weird") el...
151a28b2ad46d04beec6d61992618d423aa39866
hemma/aoc2020
/aoc2020/day7.py
1,219
3.5625
4
# https://adventofcode.com/2020/day/7 import re def get_color_rules(lines: list[str]) -> dict[str, list]: color_rules = {} for line in lines: outer_color = line.split("bags")[0].strip() inner_colors = re.findall("\\d ([a-z ]* )", line.split("contain")[1]) color_rules[outer_color] = [x....
185f6591b1eaf4e9b74d8b38adfbc4189ed56455
rafaelperazzo/programacao-web
/moodledata/vpl_data/380/usersdata/343/102866/submittedfiles/principal.py
114
3.5625
4
# -*- coding: utf-8 -*- #COMECE AQUI ABAIXO notas = [8.0, 9.5, 10.0] notas.append(float(input('Digite a nota: '))
a7879e0e1d5f1946447ac1403e55bf7b3afbdae2
shivanshthapliyal/Algorithms
/day-1-sorting/merge-sort.py
924
4.1875
4
# Author => Shivansh Thapliyal # Date => 1-Jan-2020 def merge(left_arr,right_arr): output=[] #adding to output till elements are found while left_arr and right_arr: left_arr_item = left_arr[0] right_arr_item = right_arr[0] if left_arr_item < right_arr_item: output.append(left_arr_item) left_arr.pop(0...
2e4674422197e61f9548e949c2835538c40bd981
Sergey0987/firstproject
/Функции 4/Поиски возвышенного.py
348
3.796875
4
def findMountain(heightsMap): row = 0 column = 0 for i in range(len(heightsMap)): for j in range(len(heightsMap[i])): if heightsMap[i][j] > heightsMap[row][column]: row = i column = j return (row, column) row, column = findMountain([[1,3,1],[3,2,5],[2...
a9b0021b7d93459f98bf274130d094734624960d
erikaosgue/holbertonschool-higher_level_programming
/0x06-python-classes/100-singly_linked_list.py
1,784
4.03125
4
#!/usr/bin/python3 """ 7. Singly linked list """ class Node: """ Creates A New Node """ __data = 0 def __init__(self, data, next_node=None): self.data = data self.next_node = next_node @property def data(self): return (self.__data) @data.setter def data(self, val...
5592a1e3ea539b753573f20b818f885d8536b71c
donutdaniel/Python-Challenge
/p0-9/p0/p0.py
107
3.859375
4
x = 2**38 print("2 to the 38th power is %i" % x) print("http://www.pythonchallenge.com/pc/def/%i.html" % x)
5c826df0cf051c98c9bdc051459d53737389446f
Aasthaengg/IBMdataset
/Python_codes/p02552/s759343030.py
76
3.796875
4
x = float(input()) if float(x) == 0: print(1) elif float(x)==1: print(0)
be222de45118408627f45871074f5dbdc7c6855e
jandres9102/ejercicios-1-a-34
/ex34.py
290
3.9375
4
animals=['cat','dog','pig','kangaroo'] print"what animal go you want to see?" animal=raw_input() if animal=='1': print animals[1] elif animal=='2' print animals[2] elif animal=='3' print animals[3] elif animal=='0' print animals[0] else: print "this animal isn't in this position"
82f5cf39c269039d9cd02d066096d17c0241499c
longgb246/MLlearn
/leetcode/dynamic_programming/152_max_product.py
931
3.5625
4
# -*- coding:utf-8 -*- # @Author : 'longguangbin' # @Contact : lgb453476610@163.com # @Date : 2019/2/3 """ Usage Of '152_max_product.py' : """ class Solution(object): def maxProduct(self, nums): """ :type nums: List[int] :rtype: int """ # 28 ms - 99.66% # 计算从...
88f2765d809edce83f4fde919c812586b8570cda
VStavinskyi/codewars-solutions-in-python
/033-6kyu-Replace With Alphabet Position.py
373
3.9375
4
def alphabet_position(text): text = text.lower() print text res = "" index = 0 while index < len(text): item = text[index] if ord(item) > ord("z") or ord(item) < ord("a"): index += 1 continue # print item,ord(item)-ord("a") res += str(ord(item)-ord...
26b6f603b5ac82afb11754fdf176c898fca9e06e
TheVille415/list_loops
/list_loops.py
490
3.84375
4
songs = ["ROCKSTAR", "Do It", "For The Night"] print(songs[0]) print(songs[2]) print(songs[1:3]) songs[2] = "Beauty & Essex" print(songs) songs.extend(["Nasty", "Untitled (How Does It Feel)", "Amphetamine"]) songs.pop(1) # Option 1 for song in songs: print(song) # Option 2 for i in range(len(songs)): print(so...
21a214d2c57b34d745aa3190477336889bc15cd2
rflban/sem_04
/CompAlgo/lab_06/main.py
2,077
3.8125
4
import sys import derivative def foo(X): YY = [] for x in X: YY.append(-3 * x / (2 + 3*x)**2 + 1 / (2 + 3*x)) return YY def toStr(num): if (num != '-'): num = '{:9.5f}'.format(num) return num def main(): argc = len(sys.argv) fname = '' if arg...
0e873b33df30835731220f03dfa0c5ff88bfbea1
monburan/pythongit
/file.py
1,029
4.34375
4
#coding:UTF-8 filename = raw_input('Enter file name:') #fileobj = open(filename,'r') #for eachline in fileobj: # print eachline, #fileobj.close() #filewriteobj = open(filename,'w') #ͨwģʽļ #filewriteobj.write("writing in this txt file!") #ֱ֮ʹreadlineļ #ֱʹreadlineᱨIOError: File not open for reading #filewri...
8a8caf230e6351aa634a8ef03020933cc94d7d0c
duongdo27/geeks-for-geeks
/tests/search/algorithms/test_interpolation_search.py
971
3.515625
4
from search.algorithms.interpolation_search import interpolation_search def test_empty_array(): array = [] value = 4 assert interpolation_search(array, value) == -1 def test_not_found(): array = [1, 2, 3] value = 4 assert interpolation_search(array, value) == -1 def test_middle(): arra...
5be1f6c47b18f28383dfbf48fc760dd771734318
aarshita02/Mini-Python-Projects
/e-mail Slicer.py
298
4.25
4
# The strip function will remove any trailing spaces on both the sides email = input("Enter your e-mail: ").strip() username = email[:email.index('@')] domain = email[email.index('@') + 1:] # f-string is an alternative to format function print(f"Your username is {username} & domain is {domain}")
adbc826175ac3061a371e066215717c62c40bd06
William-Zhan-bot/2021_Python_Class
/6.17 extra 參考解答/數字和.py
269
3.625
4
# 數字和 # 輸入為一字串 任意數字構成 # 輸出他們的總和 a = input() num = [] for i in a: num.append(int(i)) # 以整數形式逐個儲存列表 total = 0 # 列表中的整數逐個相加 for k in num: total += k print(total)
8a96a34f7d1cd5ae08feea1fb1c210c76ca2d377
yyeonhee/9th_ASSIGNMENT
/19_최연희/session 04/Q_1.py
249
3.515625
4
list = [500,100,50,10,5,1] money = int(input()) price = 1000 result = price - money # 거스름돈 개수 count = 0 # 리스트에 있는 잔돈의 개수만큼 반복문 실행 for i in list: count += result // i result %= i print(count)
8e99efa0a888c77a59b95dd3f77676a298b6e161
olotintemitope/Algo-Practice
/nested_listed_weighted_sum.py
410
3.6875
4
def nested_listed_weighted_sum(nestedList, depth=1): sum_up = 0 for num in nestedList: if isinstance(num, int): sum_up += num * depth if isinstance(num, list): sum_up += nested_listed_weighted_sum(num, depth + 1) return sum_up print(nested_listed_weighted_sum([1, [...
4f4efd32ccdd3b77b53fca2dfcfc982b539caf6f
microgold/Becca35
/becca_test/grid_1D_noise.py
4,925
3.734375
4
""" One-dimensional grid task with noise In this task, the agent has the challenge of discriminating between actual informative state sensors, and a comparatively large number of sensors that are pure noise distractors. Many learning methods make the implicit assumption that all sensors are informative. This task is i...
f330239ad8b218f2b447b24623064bcaf1d52aca
N3mT3nta/ExerciciosPython
/Mundo 2 - Estruturas de Controle/ex043.py
440
3.59375
4
from time import sleep peso = float(input('Quantos Kg você pesa: ')) altura = float(input('Qual a sua altura em metros: ')) imc = peso / (altura**2) print('Analisando dados...') sleep(1) print('Seu IMC é {:.1f} e seu status é:'.format(imc)) if imc < 18.5: print('Abaixo do peso') elif imc < 25: print('Peso ideal...
98586ea6502cec6b7f480e376836ae8602bc5f52
sawani02/CodePath-PreWork
/checkpoint3/kth_smallest_element.py
385
3.515625
4
#Question: Find the kth smallest element in an unsorted array of non-negative integers. #Problem link: https://www.interviewbit.com/problems/kth-smallest-element-in-the-array/ class Solution: # @param A : tuple of integers # @param B : integer # @return an integer def kthsmallest(self, A, B): #...
7994fd395b83858a2190400b63acc28711636288
faturita/python-scientific
/scientificnotation.py
389
3.6875
4
# coding: latin-1 import pandas as pd import numpy as np import matplotlib.pyplot as plt # Algo de programación científica y métodos numéricos val = (0.1)**2 print (val == 0.01) # Numpy da una funcion para chequear valores en punto flotante print (np.isclose (0.1**2, 0.01)) # Ojo al sumar valores en punto flotan...
8dc2ec58104b4dce62a818c453de72987bf58900
Harsh1347/Matplotlib-python
/bar_chart.py
356
3.5
4
from matplotlib import pyplot as plt import numpy as np plt.style.use('fivethirtyeight') x = [i for i in range(5)] x_ind = np.arange(len(x)) width = 0.25 y1 = [i+2 for i in range(5)] y2 = [i+4 for i in range(5)] y3 = [i for i in range(5)] plt.bar(x_ind,y1,width=width) plt.bar(x_ind+width,y2,width=width) plt.bar(x_...
55a74ab647fb5b20b58ac55852a388a95d759ba6
zhenyulin/mlcoursework
/ex2/sigmoid.py
384
3.765625
4
import numpy as np def sigmoid(z): """computes the sigmoid of z.""" # ====================== YOUR CODE HERE ====================== # Instructions: Compute the sigmoid of each value of z (z can be a matrix, # vector or scalar). z = np.negative(z) g = np.exp(z) g = 1 / (g + 1) # ==========...
a362103f14ee2281057ea3939dcb37af389814eb
udhayprakash/PythonMaterial
/python3/09_Iterators_generators_coroutines/03_generators/03_fibonacci_generator.py
1,081
4
4
#!/usr/bin/python3 """ Purpose: Fibonacci Series - first two values are 0 & 1 - subseqeunt values are summation of previous two values - 0, 1, 1, 2, 3, 5, 8, 13, ... """ # Method 1 -- using functions -- you get all values at a time def fib_series(num): if num < 0: return "Invalid Input" fi...
a9005f8fc3b61e1826e6da7ae55c0563456418ec
Michaelndula/Python-Projects
/pset6/Bleep/bleep/bleep.py
894
3.640625
4
from cs50 import get_string from sys import argv word = set() def main(): if not len(argv) == 2: print("Usage: python bleep.py dictionary") exit(1) else: ban = set() # open banned words file to read with open("banned.txt", "r") as f: # copy words to the se...
8102eba968786e055b08aceeb54db1c35da15b3e
previsualconsent/projecteuler
/p044.py
508
3.765625
4
from itertools import count def pentagon(n): return n*(3*n-1)/2 n = 3000 print "making lists" pentagons =[ pentagon(n) for n in range(1,n+1)] pns = set(pentagons) print "running over lists up to",pentagons[-1] end = False for i in count(1): if not i % 100: print i for j in xrange(0,n-i): if pentago...
abd7f76fbca841e2a852299135d29727a7d5c809
gedoensmanagement/transkribus_rest_api_client
/astronauts.py
990
3.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ List the astronauts that are currently on the ISS using the Open Notify API: http://api.open-notify.org/ """ import requests import json # Build the URL using the "astros.json" endpoint: api_base_url = "http://api.open-notify.org/" endpoint = "astros.js...
8117a8cf205e19ce2a77f954e93513c7e9245e26
aspferraz/FuzzyInference
/controller/knowledge/fuzzy_rule.py
3,119
3.796875
4
from controller.knowledge.fuzzy_clause import FuzzyClause ''' author: https://github.com/carmelgafa ''' class FuzzyRule(): ''' A fuzzy rule of the type IF [antecedent clauses] THEN [consequent clauses] ''' def __init__(self): ''' initializes the rule. Two data structures are necessary: Antecedent clauses ...
5a0c9b8b5bb0acda50a4298b910522974c1d7729
PrestonFawcett/Pig_Game
/pig.py
1,851
4.125
4
#!/usr/bin/env python3 """ Pig game written in Python. """ __author__ = 'Preston Fawcett' __email__ = 'ptfawcett@csu.fullerton.edu' __maintainer__ = 'PrestonFawcett' import time from player import Player from functions import error from functions import rearrange from functions import start_turn def main(): """ ...
17aa3633a2dff1f3a6286a1b9a99e0927349d62b
Linusrbk/prog1-ovn
/4,4.py
194
3.65625
4
höjd=float(input('hur långt ifråll golvet är din boll i meter?')) varv = 0 while höjd >= 0.01: höjd = höjd * 0.7 varv = varv+1 print('din boll har stutsat ',varv ,'gånger ')
28c085d1f18ca8841dbd6e548fff929e094a53be
vivek07kumar/Number-Sorting-Algorithm-2-Inefficient-Version-
/Number Sorting Algorithm 2 (Inefficient Version).py
2,777
4.0625
4
# Removing Duplicates # 1. step 1 -: Take a number from user given list and place it in a new list. # 2. step 2 -: The take another number from user list and try matching its equality with elements of new list. If it matches then don't place it in new list. If it matches then place it in user list. # 3. ...
6d329837a1af32abea5cc84d3ec9a1eb219aed61
mjadair/intro-to-python
/intro-to-python/mixing-types.py
672
4.1875
4
# Navigate to intro-to-python folder and type python mixing-types.py to run # * ----- MIXING TYPES 🕺 ------ * # * 🦉 Practice # ! ⚠️Remember to comment out your practice code before attempting below, "cmd" + "/" # ? Declare two varialbes, "numOne" and "numTwo", set their values to strings of number characters '1...
2dc3bd63a7438f8619d4086e50ec41ba086adfc2
onehao/opensource
/pyml/tools/onedrive/removedup/removeduplicatefiles.py
877
3.671875
4
# -*- coding:utf-8 -*- ''' Created on 2015年3月23日 @author: wanhao01 ''' import os def remove_recrusive(folder): size = 0.0 count = 0 for root, dirs, files in os.walk(folder): for f in files: if('(1)' in f or '(2)' in f): filename = root + os.sep + f ...
ad19f51aa86c71d221216cf6710bde9a8e1f66f2
dkcaliskan/Projects
/Random_Password_Generator.py
756
4
4
import random import string print('Hello Welcome to Password Generator') def password_generator(): try: length = int(input('\nEnter the length of password: ')) where = input('\nPlease enter the name of website trying to create password for it: ') lower = string.ascii_lowercase u...
3faaac34fabaf98dd0f7db9e49cb8a39fb0175c1
steiryx/raspberrypi-app
/strobe.py
1,863
3.703125
4
# Import the GPIO and time library import RPi.GPIO as GPIO import time # First we initialize some constants and variables TRANSISTOR = 17 BTN_SPEED_UP = 27 BTN_SLOW_DOWN = 22 DELAY_CHANGE = 0.005 # Never use a strobe light any faster than 4 flashes per sec DELAY_MIN = 0.125 # 1/8 = '4 on 4 off' flashes delay = 0.2 d...
8d194ac62b7e64d937171827f26568bd157d34b7
Nihadkp/MCA
/Semester-01/Python-Programming-Lab/Course-Outcome-1-(CO1)/15-List-Intersection/Colors_list_inbuilt.py
424
3.90625
4
colorList1 = [] colorList2 = [] colorList1Count = int(input("Total elements in list one :")) for i in range(colorList1Count): value = input("Enter a color") colorList1.append(value) colorList2Count = int(input("Total elements in list two :")) for i in range(colorList2Count): value = input("Enter a color : ...
19b23d50fbd5ca40e6d2826c7b7ba793922b16f6
Gpopcorn/3D-Graphics-Engine
/functions.py
995
3.609375
4
from random import randint from colors import * # random color function def random_color(): color_choice = randint(0, 5) if color_choice == 0: return RED if color_choice == 1: return YELLOW if color_choice == 2: return GREEN if color_choice == 3: ret...
7266bfb61fd9cae61aa452177664e411c3785b94
Molo-M/Arithmetic-Formatter
/Arithmetic Formatter.py
1,636
3.734375
4
def arithmetic_arranger(problems, solve=False): answ = '' fst_line = '' scnd_line = '' dash = '' for prbm in problems: prb = prbm.split(' ') try: v1 = int(prb[0]) op = prb[1] v2 = int(prb[2]) if op == "+": val = str(v1 ...
dc2e92101ea33caf4de43f16412d9b8c68a012ea
larusarmann/Forritun
/FORR1FG05AU/skilaverkefni/Tímapróf 3 endurtaka.py
2,040
3.671875
4
#Lárus Ármann Kjartansson #10/12/2019 #Tímapróf 3 import random on = True while on == True: print("1. sléttar tölur") print("2. Randomtölur") print("3. Texti") print("4. samanburður") print("5. hætta") val = int(input("Veldu hvað þú villt gera")) if val == 1: for n i...
8cddba6dc5d267858a3e81f15dd309ca381e9edf
Hammer2900/minipoker
/minipoker/logic/deck.py
1,173
3.828125
4
from random import shuffle SUITS = ("Hearts", "Diamonds", "Clubs", "Spades") symbols = {"Spades": u'♠', "Hearts": u'♥', "Diamonds": u'♦', "Clubs": u'♣'} class Card(object): def __init__(self, value, suit): self.value = value self.suit = suit def __gt__(self, other): if not isinstance...
8d9d1bb6f00f24f93f5dc2ae9eb83b7386813b63
SalimRR/-
/5_4.py
267
3.875
4
x = float(input('Введите значение x: ')) k=4.0 f = () def info(f, x, k): if -2.4<=x<= 5.7: j = x**2 print("Функция f равна = ", j) elif k: print("Функция f равна = ", k) info(f, x, k)
3912181a2af5303f13408f579e7c59f2095ddfd8
chethanagopinath/DSPractice
/Ch2-LinkedLists/2.5.py
1,586
3.9375
4
#Sum of two lists class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def print_list(self): current_node = self.head while current_node: print(current_node.data) current_node = current_node.next def append(self, data): ...
981ac3b25cd072ef564b5075289149b94f2745bc
Rivarrl/leetcode_python
/leetcode/offer/45.py
1,138
3.546875
4
# -*- coding: utf-8 -*- # ====================================== # @File : 45.py # @Time : 2020/5/2 14:44 # @Author : Rivarrl # ====================================== # [面试题45. 把数组排成最小的数](https://leetcode-cn.com/problems/ba-shu-zu-pai-cheng-zui-xiao-de-shu-lcof/) from algorithm_utils import * class Solution: ...
ce05ac96bf04d20f8ab5da5e4842076ecdf31288
Aasthaengg/IBMdataset
/Python_codes/p03777/s038429276.py
82
3.625
4
a, b = list(input().split()) if a == 'D': b = 'D' if b == 'H' else 'H' print(b)
0bd8229097b2fa64b67ce8146811a0ac532e20d7
Chikus9/Fibonacci
/Fibonaci.py
328
3.859375
4
def fib(n): a = 0 b = 1 if n < 0: print('Enter a valid number') elif n == 1: print('Enter a no greater than one') else: for i in range(2,n): c= a+b if c<n: a = b b = c print(i) ...
aae3202871db7cac051c6d13cb9c2a4a46a63956
pankajcoding/source
/learnpython/linkedlist.py
2,659
3.921875
4
class Node: def __init__(self,data,nxt=None): self.data=data self.next=nxt class LinkedList(object): """docstring for LInkedList""" def __init__(self): self.begin=None self.end=None def push(self,data): if self.end==None: n1=Node(data,None) self.begin=n1 self.end=n1 elif self.end!=None: n...
a8a1038b1c148aab8833c2bcd9bb63b4d5cdbf99
xiaoshenkejiushu/chapter07
/0703.py
4,120
3.703125
4
# -*- coding: utf-8 -*- import pandas as pd import numpy as np from pandas import DataFrame from pandas import Series data = DataFrame({'k1':['one']*3+['two']*4, 'k2':[1,1,2,3,3,4,4]}) print(data) print(data.duplicated()) data.drop_duplicates() print(data) #去除指定列的重复 data['v1'] = ra...
f39c789e8ba91acf4898a0809dcc59277b0c273c
Kawser-nerd/CLCDSA
/Source Codes/AtCoder/abc105/B/4914621.py
259
3.703125
4
N = int(input()) for cake in range(26): flag = False for donut in range(15): if 4 * cake + 7 * donut == N: print('Yes') flag = True break if flag: break else: print('No')
0fe17804540f07f2e2d8316479d9b9d3e3644aa9
TryImpossible/Python-Notes
/python/basic/while.py
1,302
3.59375
4
#coding=utf-8 # count = 0; # while (count < 9) : # print 'The count is:', count; # count += 1; # print 'Good bye'; # i = 1; # while i < 10: # i += 1; # if i % 2 > 0: # continue; # print i; # i = 1; # while 1: # print i; # i += 1; # if i > 10: # break; # var = 1; # whi...
af26b72bee59c984337d6b52d3792cd0960c3c70
Peng-Zhanjie/The-CP1404-Project
/Work4/list_exercises.py
1,157
3.9375
4
usernames = ['jimbo', 'giltson98', 'derekf', 'WhatSup', 'NicolEye', 'swei45', 'BaseInterpreterInterface', 'BaseStdIn', 'Command', 'ExecState', 'InteractiveConsole', 'InterpreterInterface', 'StartServer', 'bob'] def main(): numbers=[] Count=0 read=True while (read!=False): try: number...
410a1ba553f4ee638bb14661c16d67c875ad3513
rdepiero218/math3340-python
/dataFit-testQF.py
516
3.53125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on %(date)s @author: %reggie """ import numpy as np import matplotlib.pyplot as plt import dataFit as df # data to fit x = np.array([0, 1, 2, 3, 4]) y = np.array([0.68, -1.37, -1.25, 0.78, 4.75]) # gives coefficients of quadratic fit [A, B, C] = df.quadratic...
bc47c5079248eee78d3279ff2f067e5f96e7a49c
ashukedar/ComputerOrientedNumericalMethods
/Thomas Method for tridiagonal system of Linear Equations/main.py
1,483
3.96875
4
def getIntGreaterThan1(inputText): while True: try: n = int(input(inputText)); if(n >= 1): return n else: raise Exception() except: print("Invalid Input. Expected input: Integer greater than 0") def getFloat(inputText):...
d22c410622d5b6181c480e9f46f9f66e42ab0ca1
Shalom5693/Data_Structures
/Sort/Bubble_sort.py
298
4.09375
4
def bubbleSort(array): # Write your code here. is_sorted = False counter = 0 while not is_sorted: is_sorted = True for i in range(len(array) - 1 - counter): if array[i] > array[i+1]: array[i],array[i+1] = array[i+1],array[i] is_sorted = False counter += 1 return array
b597809c23f9cde0b57dcab1d66817dea5fc97ee
phoebepx/Algorithm
/LeetCode/Word Ladder II.py
2,641
3.703125
4
# coding:utf-8 # created by Phoebe_px on 2017/3/16 ''' Description: Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence(s) from beginWord to endWord, such that: Only one letter can be changed at a time Each transformed word must exist in the word list. ...
ea84d83db6a672ef7a015ef0fec2f0af48368284
sukhvir786/Python-DAY-4
/fun12.py
525
4.25
4
""" Problem: Heron's formula a,b,c are length of sides of a triangle s = semi circumference s = (a+b+c)/2 area = sqroot(s(s-a)(s-b)(s-c)) """ # %% def FUN(): """ computes area of triangle using Heron's formula. """ a = float(input("Enter length of side one: ")) b = float(inp...
41294564ced5a5aad8c72064eaf39e389f7a921c
luamnoronha/cursoemvideo
/ex.005.py
151
3.84375
4
n1 = int(input('digite um nuemro!: ')) s = (n1 - 1) ss = (n1 + 1) print('o antecessor do numero é {} e o sucessor {} '.format(s, ss))
f4a1fd8a3e11a0cb37f60c8e967075381005e171
Laurence84/adrar
/Algo/Arrays/incomplete_functions.py
2,050
3.796875
4
def swap_v1(): a=1 b=999 print("a vaut {} et b vaut {}".format(a,b)) # a vaut 1 et b vaut 999 a=b b=a print("a vaut {} et b vaut {}".format(a,b)) # a vaut 999 et b vaut 1 # ? def swap_v2(): a=1 b=999 c=a a=b b=c print("a vaut {} et b vaut {}".format(a,b)) def min_value(array): result = arra...
1832c705d5ce2565e3a613503f29af8f91ab5859
kevinczhong/Python_Exercises
/Lvl. 1 Exercises (Cont.)/isalphanum.py
304
3.671875
4
class Solution(): def isalphanum(self, c): if c.isalpha() is True: return True elif c.isnumeric() is True: return True else: return False s = Solution() print(s.isalphanum("a")) print(s.isalphanum("3")) print(s.isalphanum("!"))
c28fce9081887bcf5350456edf0f111d8add42de
hon9g/Text-to-Color
/deepmoji/sentence_tokenizer.py
5,225
3.671875
4
''' Provides functionality for converting a given list of tokens (words) into numbers, according to the given vocabulary. ''' from __future__ import print_function, division import numpy as np from deepmoji.word_generator import WordGenerator from deepmoji.global_variables import SPECIAL_TOKENS from copy import deepco...
6b9a3431c98d7f5f6a5e2323d8571a763b0a3e76
200202iqbal/game-programming-a
/Paiza/D111.py
176
3.578125
4
number = int(input()) words = input() rule = number>=1 and number<=100 and len(words) >=1 and len(words) <=100 if(rule): x =words[:number] x = str(x) print(x)
42cce5dca3892d7925713f75f8326fd32c7570e8
MastersAcademy/Programming-Basics
/homeworks/olha.bezpalchuk_olhabezpalchuk/homework-4/inquestWithArraysAndIFs.py
1,017
4
4
print("Hello!") answer = 'n' data = {} while answer != 'y': data['name'] = input("What is your name?") data['age'] = int(input("How old are you?")) data['phone'] = input("Tell me your phone number?") data['email'] = input("Input your email address: ") data['place'] = input("Where do you live?") ...
c35d177e407be5583030cf91a23c4dad8964568a
Saketh7382/neural-encryption
/Project/installation.py
4,648
3.515625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Mar 23 19:18:02 2020 @author: cp """ from os import path from tkinter import * from encryptor import Encryptor class Gui: flag = 1 window = Tk() window.geometry("430x450") window.resizable(0, 0) window.title("Installation Wizard")...