blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
490670c182bdf614606a62f297d821fcfdfce6c1
arunkumar27-ank-tech/Hackerrank_PYTHON
/3.Strings/Solutions/text-wrap.py
176
3.5
4
import textwrap string = str(input()) n = int(input()) print(textwrap.fill(string,n)) #import textwrap #string = str(input()) #n = int(input()) #print(textwrap.wrap(string,n))
6ab32c0b166365154634a12d2c2b2ca35b52a6b9
harsh-vish14/python-codes
/college start/patterns/pattern_2.py
639
3.890625
4
def Fibonacci(n): if n < 0: print("Incorrect input") elif n == 0: return 0 elif n == 1 or n == 2: return 1 else: return Fibonacci(n - 1) + Fibonacci(n - 2) def priramidfibo (n): if n>0: fiboCounter = 0 for x in range(0, n): for j in range(...
b806412a6bbaaa198d542cdd9387879e634eaecd
deepthi2105/HackerRank
/InterviewPreparationKit/Warm-upChallenges/RepeatedString
587
3.71875
4
#!/bin/python3 import math import os import random import re import sys # Complete the repeatedString function below. def repeatedString(s, n): c=0 ch=0 l=len(s) q=n//l r=n%l li=list(s) for i in li: if(i=='a'): ch=ch+1 c=ch*q if(r!=0): for i in range(r):...
c44e6f0cccee9236c18e767210870616fe27e20a
nirav-Hub4yoU/14-Days-Internship-AkashTechnolabs
/Day 4/seven.py
186
3.921875
4
x = 2 y = 80 print('x > y is ', x > y) print('x < y is ', x < y) print('x ==y is ', x == y) print('x != y is ', x != y) print('x >= y is ', x >= y) print('x <= y is ', x <= y)
5aebe246c2803b847581128cd275bb9e3caec7c6
bidulkin/Havard-CS50--2019-Solutions
/Pset6/hello/Hello.py
105
3.859375
4
#get and ask for the user name s = input("what is your name?\n") #print the message print(f"hello, {s}")
7996a3170b54121180b87e8b92967957d52fa516
Mayank2134/100daysofDSA
/Recursion/first_index1.py
220
3.609375
4
def firstindexbetter(a,si,k): l=len(a) if l==si: return -1 if a[si]==k: return si smallerlist=firstindexbetter(a,si+1,k) return smallerlist a=[1,2,3,4,5] print(firstindexbetter(a,0,1))
5fdfd19366e69ce4f6d38a4fe3aa289881847a5f
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/Algorithms in Python Live Coding & Design Techniques/002_backtracking/004_word-search-puzzle/Boggle.py
770
3.59375
4
my_dict {'RAY', 'APPLE', 'FAKE', 'BOOKS'} m 4 n 4 ___ find_words(boggle, visited, i, j, word visited[i][j] 1 word ''.j..([word, boggle[i][j]]) __ word __ my_dict: print(word) ___ row __ ra__(i-1, i+2 ___ col __ ra__(j-1, j+2 __ is_valid(row, col, visited ...
1a7f81e0417ed1318f2f1b3d1ba965feeff73c3d
vladan-jovicic/SimplexMethod
/main.py
1,191
3.703125
4
from fractions import Fraction from Simplex import * import argparse from Read import * def main(): parser = argparse.ArgumentParser() parser.add_argument("-f", "--file", help="The input file") parser.add_argument("-v", "--verbose", help="Print dictionary at each iteration") parser.add_argument("--iter-num", hel...
643970df3034185370c08ba3e8372587526b7f1d
hashbanger/Python_Advance_and_DS
/BasicAlgorithms/BubbleSort.py
402
4.15625
4
#Bubble Sort def bubbleSort(arr, n): for i in range(0, n): for j in range(0, n-i-1): if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], arr[j] return arr if __name__ == '__main__': n = int(input("Enter number of elements ")) arr = [x for x in map(int, ...
a27b5c1cb805cf65130e3ea3a7e2d21de8d07863
rohangurubhaiye/Python
/sideangledpattern.py
183
3.765625
4
g=3 for i in range(0,4): k=0 while k<g: print(" ",end=''); k=k+1 g=g-1; for j in range(0, i + 1): print("*", end=''); print("");
8d1cf3dc8a47c69d4ef41b067609ec55c07aaea4
ryan-blunden/intro-python
/code-samples/code-samples/nihar.py
368
3.96875
4
print('Hello World') # print('Hello World' -- SyntaxError: invalid syntax # print('Hello World) -- SyntaxError: EOL while scanning string literal name = input('What is your name?\n') print('Hi, %s.' % name) friends = ['Rohit', 'Mandira', 'Toan', 'Zach'] for i, name in enumerate(friends): print("iteration {iterat...
438db99bbe68108b3a7051acf3d431e15136d018
9host1st/CTFCryptoChallenge
/WaniCTF/2020/crypto/exclusive/solve.py
419
3.59375
4
smallEnc = open("output.txt", "r").read()[0:3] flag = "FLA" key = "" def encrypt(s1, s2): assert len(s1) == len(s2) result = "" for c1, c2 in zip(s1, s2): result += chr(ord(c1) ^ ord(c2)) return result for i in range(0, 3): key += chr(ord(smallEnc[i]) ^ ord(flag[i])) key = key * 19 f = ...
e0c67c2f8e126f143234b56248f146558066a5ff
suptaphilip/python_tutorials
/exercises/ex3.py
599
4.46875
4
#!/usr/bin/env python #print tells the python engine to do something in the console print "I will now count my chickens." #adding and dividing, then subtracting, multiplying and percentage? print "Hens", 25.0+30 /6.0 print "Roosters", 100-25 * 3.0 % 4 print "Now I will count the eggs:" print 3+2+1-5+4%2-1/4+6 print...
ecc84ae2762348c71b53668bef9b6d6a2335a410
Matt9172/PythonWorkUni
/Week03/average_student_mark_basic.py
427
4.15625
4
name = input('Enter the student\'s name: ') mark_1 = int(input('Enter first result: ')) mark_2 = int(input('Enter second result: ')) mark_3 = int(input('Enter third result: ')) mark_4 = int(input('Enter fourth result: ')) mark_5 = int(input('Enter fifth result: ')) total_marks = mark_1 + mark_2 + mark_3 + mark_4 + ma...
0bcfcee97fe18a1d863c933db1b0eee8a1ad2a7f
erikliu0801/leetcode
/python3/solved/P682. Baseball Game.py
2,968
3.59375
4
# ToDo: """ 682. Baseball Game Easy You're now a baseball game point recorder. Given a list of strings, each string can be one of the 4 following types: Integer (one round's score): Directly represents the number of points you get in this round. "+" (one round's score): Represents that the points you get in...
a149a46786c6bbba6696e3f0d200c12a74f72695
AdmiralVanko/Python-Default
/src/utils/sample.py
855
4.3125
4
from typing import List """ Example function. Take a closer look at the following details: - typing of arguments, return value(s) - use self-explanatory variables, function names - describe function in detail at the beginning - for cleaner code it is sometimes useful to compress for loops into one line - handle possib...
48b7dbb3e6fdb9de431dcf311492558bb2f90609
KelineBalieiro/Python
/Restaurante.py
618
3.734375
4
class Restaurant(): def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type def describe_restaurant(self): print(self.restaurant_name.title()) print(self.cuisine_type.title()) def open_restaurante(self): ...
5253b81e8a30a92aaf4303b83a041760c8468853
Alex-ZL/MyPythonCode
/2012/October/6.00x_p2.py
602
3.796875
4
#!/usr/bin/env python balance = 5000 annualInterestRate = .18 monthlyPaymentRate = .02 monthlyInterestRate = .18/12 total_paid = 0 for i in xrange(1,13): print "Month: %d" %i mini_monthly_payment = balance * monthlyPaymentRate print "Minimum monthly payment: %.2f" %round(mini_monthly_payment) balance = (balance - m...
5aa7b0a91207d597970f5bee32e363c51c4ca0fc
ivens-da-silva-brito/S8
/S8 T1 Q3.py
983
3.5
4
posicoes = int(input('posicoes:')) qtd_notas = int(input('n° notas:')) letra = int(input('numero de letras: ')) lista_1 = [] lista_2 = [] lista_3 = [] def letra_a(posicoes): for i in range(posicoes): r = float(input('valores:')) r = round(r, 4) lista_1.insert(0, r) return list...
46546e4f7768b59a42139ec47d5db2a6534f9260
asherthechamp/Coding-Problems
/Problem Set Two/maximum_stack.py
567
3.921875
4
# Returns The Maximum value in a stack class MaxStack: def __init__(self): self.Stack = [] # Fill this in. def push(self, val): self.Stack.append(val) def pop(self): if (len(self.Stack) != 0): self.Stack.pop(-1) def max(self): maximum = self.Stack[0] for i in range(1, len(sel...
9c3eba03089f21c5475c64b8fab7851d0f5138d2
MartaDobrocinska/Kurs_python
/homework/homework_day02/kalkulator celsjusz na fahrenheit.py
588
3.921875
4
celsjusz = input("Podaj temperaturę w stopniach Celsjusza ") wzor = '''Wzór na przeliczanie stopni Celsjusza na stopnie Fahrenheita: [\u00b0F] = [\u00b0C] * 9/5 + 32''' if type(celsjusz) == int: temperatura = int(celsjusz) else: temperatura = float(celsjusz) print() print(wzor) print() krok1 = temperatura * 9 p...
1408a260e2a862a97f42453cb9f6255633a23a54
trueazp/Python
/Basic/Median.py
630
4.1875
4
# python program to print # median of a list of number(s) # define median function def median(list_of_num): list_of_num.sort() if len(list_of_num) % 2 == 1: return list_of_num[int((len(list_of_num) - 1) / 2)] elif len(list_of_num) % 2 == 0: middle_index_1 = int(len(list_of_num) / 2) ...
121cd462315ac595b74398100dfcfe3c778b1e1a
BeaImeLm/ejif
/assignments/00Sistema/src/exercise.py
700
3.796875
4
import os def main(): #escribe tu código abajo de esta línea os.system('clear') a = float(input("Ingrese el valor de a: ")) b = float(input("Ingrese el valor de b: ")) c = float(input("Ingrese el valor de c: ")) d = float(input("Ingrese el valor de d: ")) e = float(input("Ingrese el valor ...
7a4d24c3be5553407bb4343501b536f7aaafdd70
luciomoran/Automatas2
/Listas.py
1,938
4.125
4
# Nombre: Listas.py # Objetivo: Muestra el funcionamiento de las listas en Python # Autor: Lucio David Morán Brizuela # Fecha: 2 de julio 2019 import os #Declaramos de manera global la lista lista=[] #--------------------------------------------- #Función para agregar items a la lista #------------------------------...
678a67ecf432a81dcfa776781d53f8007b3eaa31
ruslan-rv-ua/python-starter
/source/loop_while/problems/problem_loops_7primes_solution.py
857
4.21875
4
''' "Прості числа" Просте число - це число, яке ділиться націло тільки на 1 і на себе. Напишіть функцію is_prime() яка отримує натуральне число. Функція повертає True, якщо передане їй число є простим, і False в іншому випадку. Використовуючи написану функцію виведіть у стовпчик перші 7 простих чисел починаючи з числа...
b6b5a0bebc996916a472a20ac73ae545beffbd8e
krnets/codewars-practice
/7kyu/Find Factors Down to Limit/index.py
632
3.734375
4
# 7kyu - Find Factors Down to Limit """ In this Kata you have to find the factors of integer down to the limit including the limiting number. There will be no negative numbers. Return the result as an array of numbers in ascending order. If the limit is more than the integer, return an empty list As a challenge, se...
e1c4702fa8455dc061e83caabb3b3bd8a398202e
babywithahat/csf
/python/hw/hw1/hw1.py
1,075
4.09375
4
# Name: alejandro chavez # Evergreen Login: chaveza chaale04 # Computer Science Foundations # Programming as a Way of Life # Homework 1 # You may do your work by editing this file, or by typing code at the # command line and copying it into the appropriate part of this file when # you are done. When you are done, ru...
c7fd972036e49b692060d6d047321d3e69f15230
qianyukun/PythonTest
/Test/com/python/interincluded/dateTime.py
533
3.78125
4
# -*- coding:utf-8-*- import time from datetime import datetime, timedelta print datetime.now() print type(datetime.now()) print datetime(2018, 3, 5) dt = datetime.now() print dt print time.time() print dt.utcfromtimestamp(time.time()) print datetime.fromtimestamp(time.time()) print "str to datetime " + datetime.st...
c97dfd8abc9dbc5968c8883adde9d3c5e71e84fe
AmitM0287/ProblemsSolvedUsingPython
/object_oriented_programs/inventory_data_management/inventory_data_management_main.py
837
3.78125
4
""" Q. JSON Inventory Data Management of Rice, Pulses and Wheats Desc -> Create a JSON file having Inventory Details for Rice, Pulses and Wheats with properties name, weight, price per kg. I/P -> read in JSON File Logic -> Get JSON Object in Java or NSDictionary in iOS. Create Inventory Object from ...
8dcbe193b375f8cdff1ab9abbcd1a01b68669547
kawinm/chess
/chess.py
1,858
3.578125
4
import string from functions import * a = [[' ','1','2','3','4','5','6','7','8'],['1','R','P',' ',' ',' ',' ','p','r'],['2','N','P',' ',' ',' ',' ','p','n'],['3','B','P',' ',' ',' ',' ','p','b'],['4','Q','P',' ',' ',' ',' ','p','q'],['5','K','P',' ',' ',' ',' ','p','k'],['6','B','P',' ',' ',' ',' ','p','b'],['7','N','...
919c867a2cada5630ec4dcc484b6ada284cf0238
minzhou1003/intro-to-programming-using-python
/practice5/11_7.py
1,047
3.90625
4
# minzhou@bu.edu # Compute the distance between two points (x1, y1, z1), (x2, y2, z2) def distance(x1, y1, z1, x2, y2, z2): return ((x2 - x1)**2 + (y2 - y1)**2 + (z2 - z1)**2) ** 0.5 def nearestPoints(points): # p1 and p2 are the indexes in the points list p1, p2, p3 = 0, 1, 2# Initial two points s...
b182e1e6efe21dbaa7a893b72de669f7396b8e7a
cogzoid/PersistenceOfVision
/POV_slicing_5bit.py
2,787
3.5
4
# This is python program to create images for a POV display # This program will load in an image, convert it to a usable format, # dice it up into smaller regions, and average the RGB values. The # output will be a file that can be read in by an Arduino # The dicing will dice the image into a radius, theta base...
b54bf762022ca92b01e4137ef64ee746f1d86450
dmitriyanishchenko/Teach_My_Skills_Python_base
/src/Home-_and_classworks/Work_3[conditional statements]/cw_3_task_3_4.py
367
4.34375
4
# Ввести предложение. Если число символов в предложении # кратно 3 - добавить ! к концу строки. Вывести строку на экран some_sentence = input('Enter some sentence \t') len_sentence = len(some_sentence) if len_sentence % 3 == 0: some_sentence += '!' print(some_sentence)
629ced3def6be3e3c6a0e225f6fb58b2bccf0a2a
ajayk01/Python-Programing
/Inhertiance/hie.py
802
3.765625
4
class RC: def set1(self): self.dis=int(input("Enter the discount ")); def get1(self): print("The discount is ",self.dis); class PC: def set2(self): self.mtype=input("Enter the membership type"); def get2(self): print("The discount is ",self.mtype); class Cus(RC,PC): d...
87a2999c5c6c46b9703c59c46764fe599d44cb57
bharathanr/A-Simple-Ray-Tracer-written-in-Python
/sphere.py
1,891
3.640625
4
from math import sqrt from primitive import Primitive from vector3 import dot_product class Sphere(Primitive): def __init__(self, center, radius, material): super(Sphere, self).__init__(material) self.center = center self.radius = float(radius) def find_intersection(self, ray): ...
c585d30b49db10f3bae177d7388a94268b1ca578
CarlosCea/Curso-de-Python
/diccionarios.py
954
4.15625
4
# un diccionario esta compuesto de llaves, valor(key,value) diccionario = { "IDE":"Integrated Development Enviroment", "OOP":"Object Oriented Programming", "DBMS":"Database Managment System" } print(diccionario) #largo print(len(diccionario)) #acceder a un elemento print(diccionario["IDE"]) #otra forma, mi...
080fbbd0afc778a5fe863239f8876c1573482165
Nora-Wang/leetcode
/leetcode-questions/stack&queen/901_online_stock_span.py
824
3.5
4
class StockSpanner: def __init__(self): self.prices = [] self.dp = [] def next(self, price: int) -> int: length = len(self.dp) if length == 0 or price < self.prices[-1]: self.dp.append(1) else: i = length - 1 while i >= 0 and ...
4a73bcd9da3d37113579d3f78bc34286af3fa7ed
daniel-reich/ubiquitous-fiesta
/QcswPnY2cAbrfwuWE_2.py
171
3.890625
4
def is_factorial(n): m, i = 1, 2 while m < n: m *= i i += 1 return m == n ​ def filter_factorials(numbers): return list(filter(is_factorial, numbers))
ca07fd255093a2fa8fe8f10a0802e6f2892c11f3
Noboomta/ISP-SKE-KU-2020
/movierental-Noboomta/rental_test.py
1,287
3.78125
4
import unittest from customer import Customer from rental import Rental from movie import Movie class RentalTest(unittest.TestCase): def setUp(self): self.new_movie = Movie("Mulan", Movie.NEW_RELEASE) self.regular_movie = Movie("CitizenFour", Movie.REGULAR) self.childrens_movie = Movie("Frozen", Movie.CHILDRE...
7ecc79a0e37caeba1e72e8632f89911339e807bd
duderman/geek_brains
/python/6/4_test.py
2,674
3.921875
4
import unittest m = __import__('4') class TestCar(unittest.TestCase): def build_car(self, klass=m.Car, speed=4): return klass(speed, 'red', 'my car') def test_attributes(self): """ Test that attributes are properly set """ car = self.build_car() self.assertEqual(car.speed, 4) ...
59470d44ce13d81a109f85b04b908ad876e0fda1
rafaelwitter/UFSC
/ESTRUTURA_DADOS/arvore_binaria/teste.py
1,726
3.59375
4
import random from arvora_binaria import ArvoreBinariaBusca def random_tree(size=10): random.seed(5) values = random.sample(range(1, 1000), size) arv = ArvoreBinariaBusca() for v in values: arv.inserir(v) return arv def arvore_exemplo(): valores = [61, 89, 66, 43, 51, 16, 55, 11, 79,...
12c308de6270c9901deadf3eb10ff1085c5d09c1
fsufitch/movie-memes
/moviememes/preprocessor/structs.py
1,331
3.609375
4
""" This file contains "container" dataclasses used for organizing the program's data """ from typing import List from dataclasses import dataclass @dataclass class MovieInput: """ MovieInput is one of the movie specs given by the CLI user """ movie_id: str movie_title: str video_file: str sub_file...
9bec7c6299516727834f66c278e136141f130436
Jay-Minton/python-syntax-exercises
/words.py
369
4.28125
4
words = ["can","i","Ethan","live","toast","eVen"] starts = ["l", "t"] def print_upper_words(words, starts_with): """Print each word that starts with the given letters, in uppercase on seperate lines """ for word in words: for start in starts_with: if word.startswith(start): prin...
c9cbd571418dcf2a11718b57fa8d0199ad4a5c54
Ardra/Python-Practice-Solutions
/chapter2/pbm.py
291
4.21875
4
'''Write a function invertdict to interchange keys and values in a dictionary. For simplicity, assume that all values are unique. >>> invertdict({'x': 1, 'y': 2, 'z': 3}) {1: 'x', 2: 'y', 3: 'z'}''' def valuesort(dictionary): return [dictionary[x] for x in sorted(dictionary.keys())]
bef907d990fcaca1784b2ddf42676de530b035c1
FaeLeFly/Programming
/Practice/04/Python/1способ.py
67
3.546875
4
a= int (input()) b=int (input()) a=a-b b=a+b a=b-a print (a,b)
265fd713f37edb8522dedd165270b45a9e0e6a4e
m-note/100knock2015
/SatoTaka/04knock.py
435
3.640625
4
#!/usr/bin/python # _*_ coding: utf-8 _*_ #元素記号 original = "Hi He Lied Because Boron Could Not Oxidize Fluorine. New Nations Als Sign Peace Seburity Clause. Arthur King Can." o_e_word = original.split() print o_e_word my_dict = {} for index in range(len(o_e_word)): if index in [0,4,5,6,7,8,15,18]: my_di...
87a32e31869b8a4a72dd9275da0f1b92ee141763
jerold/sudoku
/py/sudoku.py
16,510
3.625
4
#!/usr/bin/python class Sudoku: def __init__(self, board): # self.board = board self.col = [['1', '2', '3', '4', '5', '6', '7', '8', '9'] for _ in range(9)] self.colBlocked = [[[], [], []] for _ in range(9)] self.row = [['1', '2', '3', '4', '5', '6', '7', '8', '9'] for _ in r...
eb9c9c1179cdb3b4ed03adadb5895efc42e45740
Sumedh-kul/python-basic
/special email generator.py
173
3.765625
4
first_name= "sumedh" last_name= "kulkarni" fav_no= input("please enter your favourate no") print("your mail address will be", first_name + last_name +fav_no + "@gmail.com")
74b1674a2baa706b54553c0ba86881f4079bb258
yogeshrnaik/python
/linkedin/Ex_Files_Python_EssT/Exercise Files/Chap07/decorator-example.py
1,330
4.78125
5
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ def printSeparator(): print('*****************************************************************') def f1(): print('this is f1') x = f1 x() print(f'Type of x is: {type(x)}') # type is 'function' printSeparator() def function1(func): y = 10 ...
272128a5267310928bf93968c9731c289b63081e
ruibofeng/DeepLearningStartUp
/LPTHW/ex33.py
580
4.28125
4
# -*- coding: utf-8 -*- def make_lists(max, step): i = 0 numbers = [] while i < max: print "At the top i is %d" % i numbers.append(i) i = i + step print "Numbers now: ", numbers print "At the bottom i is %d" % i return numbers #numbers = m...
59f31102d333bdcb3da072f8d3d8a93f37d6a961
raulgranja/Python-Course
/PythonExercicios/ex059.py
1,065
3.796875
4
from time import sleep n1 = float(input('Digite o primeiro valor: ')) n2 = float(input('Digite o segundo valor: ')) menu = 0 while menu != 5: print('''===== MENU ===== [1] SOMAR [2] MULTIPLICAR [3] DIVIDIR [4] DIGITAR NOVOS NÚMEROS [5] SAIR''') menu = int(input('Digite o número que deseja: ')) if menu == 1:...
b0daefd38a6a39c74e864ca10c4acec0cee41ddb
TashanM/Programs
/C6 Exercise 12.py
482
3.703125
4
# Exercise 12 # Tashan Maniyalaghan # 693776 # ICS3U0-B # 6 November 2017 # Mr. Veera num1 = int(input('Enter the first starting number:')) num2 = int(input('Enter the second starting number:')) numstore1 = num1 numstore2 = num2 while (True): print(str(num1), str(num2), '', end='') num1 ...
9c3c71e65c5affa830136133692115b662a797ea
SaraMWillis/OverlappingGenesProject
/ArtificialFrameshifter/ArtificialFrameshiftProgram/Excess_Nucleotide_Trimmer.py
899
4.6875
5
# The purpose of this program is to write two functions which take in a nucleotide # sequence and determine whether its length is a multiple of three. If it is not, # frontTrimmer will take off enough nucleotides from the start of the sequence so # that the sequence's length is a multiple of 3. # backTrimmer will also...
3eddead2b10ad5edb99ff5ecc67b3606e17093ac
MichelleZ/leetcode
/algorithms/python/countandSay/countandSay.py
590
3.59375
4
#! /usr/bin/env python3 # -*- coding: utf-8 -*- # Source: https://leetcode.com/problems/count-and-say/ # Author: Miao Zhang # Date: 2021-01-08 class Solution: def countAndSay(self, n: int) -> str: if n == 1: return '1' prestr = self.countAndSay(n - 1) count = 1 ...
5bf52bba08c55b2935cfc45040f5ad7bfae4fbf3
c-steindl/adventcoder-2015
/C.py
1,002
3.578125
4
import sys import math class slope(object): length = 0 width = 0 inclination = 0 def getValues(self): values = self.arg.split(",") self.length = float(values[0]) self.width = float(values[1]) self.inclination = float(values[2]) def calc(self): total_lengt...
6ecc477868e4e3c9a06f8d93c2afd158bf74db6b
Hamooud92/Hamoud
/homework.py
424
3.671875
4
class Line(): def __init__(self,coor1,coor2): self.coor1=coor1 self.coor2=coor1 def distance(self): x1=self.coor1 y1=self.coor1 x2,y2=self.coor2 return ((x2-x1)**2 + (y2-y1)**2)**0.5 def slope(self): x1,y1=self.coor1 x2,y2=self.coor...
191ae63110ff58dd0287176edeaded2023e6dccd
zhanglintc/leetcode
/Python/Merge Intervals.py
1,515
3.984375
4
# Merge Intervals # for leetcode problems # 2015.03.20 by zhanglin # Problem Link: # https://leetcode.com/problems/merge-intervals/ # Problem: # Given a collection of intervals, merge all overlapping intervals. # For example, # Given [1,3],[2,6],[8,10],[15,18], # return [1,6],[8,10],[15,18]. # Definition for an int...
60b82dda2d87ff855451ed11d6611de9905d3a16
dsemi/web-ai
/games/tictactoe.py
1,292
3.625
4
#!/usr/bin/python2 class TicTacToe: units = [ (0,1,2), (3,4,5), (6,7,8), (0,3,6), (1,4,7), (2,5,8), (0,4,8), (2,4,6) ] def __init__(self): self.board = [0 for i in range(9)] def update(self, data, player): # should add o...
40b2d72e9528e5408ab42296d6c133ac38274685
benjaminjennings/educube
/Thermal Experiment.py
7,399
3.703125
4
#!/usr/bin/env python # coding: utf-8 # # EduCube # ## Thermal Experiment # #### Kate Kiernan # The following code reads the temperature data from telemetry packets obtained using EduCube and plots the temperature increase and decrease over time. From this data, the power usage of the two aluminium panels is calculat...
e6e3695d87f40f93d291e90ca468ecb8090c36f1
EswarDamam/D-Eswar
/finding a percentage.py
260
3.703125
4
n = int(raw_input()) total = dict() for i in range(0, n): tokens = raw_input().split() name = tokens[0] total[name] = float(tokens[1]) + float(tokens[2]) + float(tokens[3]) student = raw_input() print "{0:.2f}".format(total[student]/3)
eff788ebd75842d3a59177f35c6b0fd02e214baf
ShwetaD123/MyPythonDOC
/Fibonesis.py
266
3.984375
4
'''--------------------------FIBONESIS SERIES FOR N NUMBERS-------------------''' def fibonesis (): a,b = 0,1 while True: yield a a,b = b,a+b for n in fibonesis(): print("---",n) if n>10: break print(n) fibonesis()
01c7d3d9f16e843b1b67b18eb0ffab1cf7a6fde9
miky-roze/Python-exercises
/exercise_31.py
479
3.53125
4
# Transform data from CSV file to a Python dictionary. Keys are values from 'Id' column # and values are dictionaries containing the rest of the data in format — ColumnName: Value. import csv with open('CSV_files/Customers.csv', 'r', encoding='UTF-8', newline='') as csvFile: csvFileReader = csv.DictReader(csvFile...
5a5aee1776e531992f5235705f2293b01cb16881
disaisoft/python-course
/project15/main.py
736
3.640625
4
""" Escribe un programa en Python que dados el nombre de una criptomoneda y su monto inicial para un usuario, genere un porcentaje aleatorio entre 0 y 3%, además puede ser de alza o baja, asociado a esa criptomoneda e imprima el porcentaje diario durante una semana, si es alza o baja, el saldo diario de la billeter...
b00ec5ce38636abf4bd52985a2f99fc29b45462f
fendull-streamer/fendull
/challenges/data_interface.py
1,608
3.65625
4
import sqlite3 from sqlite3 import Error import json import datetime DATABASE_FILE = "challenges.db" class DataInterface: def __init__(self): self.is_connected = False try: self.conn = sqlite3.connect(DATABASE_FILE) self.is_connected = True self.create_db() ...
815b504bebc5b3703d903c8b6b8aa368b28bc391
humblefo0l/DataStructure
/Trees/BreadthFirstTraversal.py
1,441
4.15625
4
""" Level Order Tree Traversal Level order traversal of a tree is breadth first traversal for the tree. Level order traversal of the above tree is 1 2 3 4 5 METHOD 2 (Use Queue) Algorithm: For each node, first the node is visited and then it’s child nodes are put in a FIFO queue. printLevelorder(tree) 1) Create an ...
7da58f312d77630e3dec67d5086f47839aef61be
KodKardesim/python-ile-lokanta-takip-uygulamasi
/lokanta.py
1,414
3.78125
4
from os import system masalar = {} # Masa sözlüğünü oluşturduk. for i in range(1, 11): masalar[i] = 0 # Her masaya başlangıç olarak 0 tl atadık. while True: system("cls") # While tekrar döndüğünde önceki herşeyi silecek # Bu sayede anlık olarak güncellenen bir listeye sahip olacağız. print("Lo...
b009fc690d8cb9dcfa576c5ade925db52029d122
heymrtoufiq/uri-online-judge
/problemas/1100/1159.py
147
3.5625
4
while (n := int(input())) != 0: soma = 0 if n % 2 != 0: n += 1 for i in range(5): soma += n + i * 2 print(soma)
f72df70ef1ac6994f3b9bd0fd07a40a477724c11
AlgorithmLibrary/Basic-Data-Structures
/Deterministic Selection.py
1,776
3.6875
4
# -*- coding: utf-8 -*- """ Created on Mon Jun 15 14:37:20 2020 @author: Grant """ from random import randrange unsorted_list = [35, 1, 8, 2, 6, 11, 15, 9, 7, 25, 66, 88] order_statistic = 6 result = 0 def ChoosePivot(left, right): global unsorted_list n = len(unsorted_list[left:right])...
c3d25a442a686d1d418c0c2f67b03845c428f189
rene150390/AlgorithmsPython
/org/mariano/sanabria/functions/FiboIte.py
195
3.75
4
#Modulo FiboIte.py def fibIte(n): a=0 b=1 if n is 0: return 0 elif n is 1: return 1 else: for i in range(2, n+1): c=a+b a=b b=c return b
66d29a78537ac6a6a83cc1a5354de842f748b34c
JeroenSchmidt/spark-df-profiling
/spark_df_profiling/lookup_object.py
1,694
3.71875
4
class BaseLookupObject(object): """ Base class for a lookup object, its a class that takes in a dataframe column, and looks up all its values in an external database or DataFrame. """ def __init__(self): """ Define Database object or DataFrame path here """ pass ...
b8af22eb2eaee40a6444b826939143ce460cb8f2
alcoccoque/Homeworks
/hw4/ylwrbxsn-python_online_task_4_exercise_6/task_4_ex_6.py
977
4.34375
4
""" Task04_6 Implement a function get_longest_word(s: str) -> str which returns the longest word in the given string. The word can contain any symbols except whitespaces (`,\n,\tand so on). If there are multiple longest words in the string with a same length return the word that occurs first. Example: get_long...
34745f61bdb793c728c34bdddd6d72480be6aeb2
presstwice/Python-
/data_camp/pandas_iterrows.py
1,078
4.15625
4
# import pandas as pd import pandas as pd # Take the cars dataset names = ['United States', 'Australia', 'Japan', 'India', 'Russia', 'Morocco', 'Egypt'] dr = [True, False, False, False, True, True, True] cpc = [809, 731, 588, 18, 200, 70, 45] # Create dictionary my_dict with three key:value pairs: my_dict my_dict = ...
40844d2635f2e8d13af1c620cc586e0d084e51d0
rhea2801/tuktuktuk
/DSA/Dynamic Prg/Min-coins-for-change.py
999
3.9375
4
"""Min Number Of Coins For Change - Given an array of positive integers representing coin denominations and a single non-negative integer n representing a target amount of money, write a function that returns the smallest number of coins needed to make change for (to sum up to) that target amount using the given coin d...
a6ee007357df70783c9a3c690a717bf13a6f1c84
s-nc/100-days-of-code
/Day86-Breakout/paddle.py
602
3.8125
4
# File to create functionality of paddle. from turtle import Turtle class Paddle(Turtle): def __init__(self, co_ord): super().__init__() self.shape("square") self.shapesize(stretch_wid=1, stretch_len=5) self.color("white") self.penup() self.goto(co_ord) ...
fc2d4a0139ec3a882240d34fa9266ed5fc05f7d6
mattvenn/python-workshop
/tutorial/quiz.py
814
4.09375
4
total_questions = 2 current_question = 1 score = 0 #introduction print "welcome to Matt's quiz!" print "there are", total_questions, "questions in the quiz" #function to ask the questions and get the answers def ask_question(question,answer): print "-" * 20 print "question", current_question, "of", total_ques...
8e0d2885a2253abd052aa2bfa78b8ac07b77214c
emmadeeks/CMEECourseWork
/Week2/Code/tuple.py
1,053
4.75
5
#!/usr/bin/env python3 #Author: Emma Deeks ead19@imperial.ac.uk #Script: tuple.py #Desc: Script to show use of tuples #Arguments: No input #Outputs: Prints the latin name, common name and mass of a list of birds on separate lines #Date: Oct 2019 birds = ( ('Passerculus sandwichensis','Savannah sparrow',18.7), ...
3173dcf63122bf15df21c682ae834b42745e529a
Anewnoob/Leetcode
/mergeTwoLists.py
1,731
4
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None #将两个升序链表合并为一个新的升序链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。  #示例: #输入:1->2->4, 1->3->4 #输出:1->1->2->3->4->4 class Solution: def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode: ...
820ebcb041f7496a191ced1d1df2ebf05c846122
yangzhao5566/go_study
/metaclass_study.py
1,319
3.90625
4
# 元类的学习 type # 动态语言和静态语言最大的不同,就是函数和类的定义, # 不是编译时定义的,而是运行时动态创建的。 # https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/0014319106919344c4ef8b1e04c48778bb45796e0335839000 # 通过type 创建一个类 def fn(self, name="world"): print("hello, %s" % name) Hello = type("Hello",(object,), dict(hello=...
bf282792aa09e9a2bcdb73e5c33744e460937062
ruiyanc/py
/算法/quick_sort.py
347
3.859375
4
def quick_sort(arr): if len(arr) < 2: return arr else: pivot = arr[0] left = [i for i in arr[1:] if i <= pivot] right = [i for i in arr[1:] if i >= pivot] return quick_sort(left) + [pivot] + quick_sort(right) print(quick_sort([25, 10, 29, 1, 8, 7, 13, 56, 23, 49, 20, ...
d492434f260e9d56bb7d1351d26831e4cced530d
arjunrautela/Introduction-To-Python
/Day1/Loops/Continue_in_loop.py
407
3.890625
4
#Usage of continue in loops #Continue in for loop name = 'Captain' for ch in name: if ch == 'p': continue print("Ch is : ", ch) else: print("For loop exit") #Continue in while loop index = 0 while index < len(name): if name[index] == 'p': index = index + 1 continue p...
a9048af1bbc6398c4cbf9225ce90565fa9892ba9
doomspec/Mizore-dev
/src/mizore/Benchmark/node.py
1,025
3.890625
4
class Node: def __init__(self, name): """ Constructor for node Args: name: name of node """ self.name = name self.weight_map = {} self.neighbors = set() def add_neighbor(self, node, weight): """ Build Edge Args: ...
1ba7fa42696191b686bbb2d7b893be7d611b601b
leoIMartins/aulaPython
/Aula 1 - Exercícios/Exercicio3.py
342
4
4
menor = 0 maior = 0 a = int(input("Informe o primeiro numero: ")) menor = a maior = a b = int(input("Informe o segundo numero: ")) if b < menor: menor = b if b > maior: maior = b c = int(input("Informe o terceiro numero: ")) if c < menor: menor = c if c > maior: maior = c print("\nMaior: ", maior) p...
a9c8d169e32bce3f6ed18bb5ef3d6e165da78c85
MadhubanKhatri/runner-up
/runnerup_score.py
516
4.0625
4
# Create a Score List score_lis = [1,2,3,4,5,6,6,6,7,8,9,9,9,10,10,10,10] # Print the List print('Current Scores: ', score_lis) # Get Max Number from the list max_num = max(score_lis) # Count the Max Number max_num_count = score_lis.count(max_num) # Apply for loop and remove Max Number from the list f...
1988c5ad97fe257590c00a503c09a23e7f55b6bb
Xalitor/Gilyazor_Emil
/lesson_08/Ex_01.py
280
4.0625
4
sentence = input("Enter your sentence ") def repLace(sentence): if (" " not in sentence): return sentence else: return sentence[0: sentence.index(" ")] +"_"+ repLace(sentence[sentence.index(" ")+1 : len(sentence)]) print(repLace(sentence))
b0d86d6ad46454ae6e0ad353ef0d0aad35934323
Kudin-dima/-Python_6
/Многоуровневая нейронная сеть.py
1,587
3.75
4
""" создаем многослойную нейронную сеть, состоящую из более чем одного слоя, для извлечения базовых шаблонов из обучающих данных. Эта многослойная нейронная сеть будет работать как регрессор. Мы собираемся сгенерировать несколько точек данных на основе уравнения: y = 2x2+8. """ import numpy as np import matpl...
575e04d648032ef353e4331a14e4a26a20913ff5
MiniPa/python_demo
/advanced/03 numberDateAndTime 数字日期和时间/3.13 datetime 计算最后一个周五的日期.py
1,553
3.828125
4
# 计算最后一个周五的日期 #!/usr/bin/env python # -*- encoding: utf-8 -*- """ Topic: 最后的周五 Desc : """ from datetime import datetime, timedelta weekdays = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] def get_previous_byday(dayname, start_date=None): ''' 1.将开始日期、目标日期映射到星期数组位置上(星期一索引为0) ...
fa61c5c0e7638d414d4b6621c665ca6d9a26a8f9
Taoge123/LeetCode
/Array/LargestSubarrayWithEqual01.py
673
3.625
4
def findSubArray(arr, n): sum = 0 maxSize = -1 #Pick a starting point as i for i in range(0, n-1): sum = -1 if (arr[i] == 0) else 1 #Consider all subarray starting from i for j in range(i+1, n): if arr[j] == 0: sum -= 1 else: ...
a1012b9c1993c4ec1007561303b01d403428bb13
nsyng/pythonKNUlabs
/Homework 1/Task11Force.py
317
4.09375
4
""" 1.1. Обчислити силу притягання F між двома тілами, що мають маси m1,m2 , на відстані r """ m1 = float(input('m1: ')); m2 = float(input('m2: ')); r = float(input('r: ')); y = 6.673*10**-11; result = y*m1*m2/(r**2); print('Result: ', result)
428e43e6101594f0f55f7957db47aa92cf17a8d9
reouno/swpdl
/utils/user_interfaces.py
395
3.609375
4
from typing import Text def get_user_confirmation(confirmation_msg: Text, refused_msg: Text) -> bool: '''require YES/NO answer on console ''' while True: choice = input('{} [y/N]: '.format(confirmation_msg)) if choice.upper() in ['Y','YES']: return True elif choice.upper...
5bd9c7c06496ee2b4d1027761dd4af83c3a0465b
jayeshd7/AIBasicFundamental
/MLR.py
2,710
3.53125
4
# -*- coding: utf-8 -*- """ Created on Sat May 5 15:09:56 2018 @author: Jayesh """ # Multiple Linear Regression # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('50_Startups.csv') X = dataset.iloc[:,[0,2]].v...
cbd9ebfc6b3470a61c93ca1bfafd191e01746494
Jaime-Gil/CIS-2348
/Homework/2.19.py
1,304
4.1875
4
''' Jaime Gil 1788946 ''' lemon = float(input("Enter amount of lemon juice (in cups):\n")) water = float(input("Enter amount of water (in cups):\n")) agave = float(input("Enter amount of agave nectar (in cups):\n")) servings = float(input("How many servings does this make?\n")) print("") print("Lemonade ingredients - ...
8e1f2d268317488ee0063cca9c386d96e144f4b0
PashaLevkovic/Python
/ch1/testing_ball.py
514
3.6875
4
# -*- coding: utf-8 -*- # Программа для вычисления положения мяча при вертикальном движении #привет v0 = 5 # Начальная скорость g = 9.81 # Ускорение свободного падения t = 0.6 # Время y = v0*t - (1/2)*g*t**2 print y # SyntaxError: invalid syntax # SyntaxError: invalid syntax # SyntaxError: invalid syn...
4985f2e08b4f00e0c2702902d00b75c85d071aef
wojsikora/ASD_2020
/Linked_lists/Bubble_sort.py
2,015
3.78125
4
class Node(): def __init__(self,value=0,next=None): self.value=value self.next=next class LinkedList(): def __init__(self,first=None,last=None): self.first=first self.last=last def make_from_array(self,tab): if len(tab)==0:return self.first=Node(tab[0]) ...
ac223f7958b5dd9892b06914e389193e9d55ceb6
sahilgupta2001/python_dictionary
/dict_popitem.py
224
3.71875
4
# popitem() : popitem() method removes the last inserted item. car = {"brand":"aston martin", "model": "V8 Ventage", "year": 2005 } car.popitem() print(car) # {'brand': 'aston martin', 'model': 'V8 Ventage'}
b3f8c8cda1e9ab0f136d3091654a12313af7497b
mohsenrajabpour/Algorithmic-Toolbox
/Algorithmic_Toolbox_122.py
533
3.515625
4
# Uses python3 # Week 5, 1 Money Change Again import sys def get_change(m): #write your code here coins = [1, 3, 4] minCoin=[0]*1000 minCoin[0] = 0 if m == 0: return 0 for i in range(1, m+1): minCoin[i] = float('Inf') for j in coins: if j <= m: ...
053bd8a8cec1802cc1a6d39619c01c6ce37c5680
JennyCCDD/fighting_for_a_job
/LC 合并两个有序数组.py
1,107
4
4
# -*- coding: utf-8 -*- """ @author: Mengxuan Chen @description: 合并两个额有序数组 @revise log: 2021.02.10 创建程序 """ class Solution(object): def merge(self, nums1, m, nums2, n): """ :type nums1: List[int] :type m: int :type nums2: List[int] :type n: int :rtype: None ...
2ff780da722c615dec06a6a7f3dffde66d4b72c0
eduardosacra/learnpython
/semana4/exercicios/5ex.py
193
3.734375
4
x = int(input("entre com um numero ")) test = False div = 0 i = 1 while i <= x: if x % i == 0: div += 1 i+=1 if( div == 2): print("primo") else: print("não primo")
a07efb49ea2201baa4ae7e744f47c75c06ea766e
Edudeiko/cs-sprint-challenge-hash-tables
/hashtables/ex2/hashtable.py
5,134
4.09375
4
class HashTableEntry: """ Linked List hash table key/value pair """ def __init__(self, key, value): self.key = key self.value = value self.next = None myEntry = HashTableEntry('hello', 'world') # creates an object in memory print(myEntry.key) print(myEntry.value) print(myEnt...
b73a57192f8aeedf2e2da7dab50f7d17c5f37902
Anthima/Hack-CP-DSA
/URIOnlineJudge/Triangle/solution.py
381
3.890625
4
def solution(): # taking asked inputs A, B, C = map(float, input().split()) #check triangle inequality conditions if (A + B) > C and (A + C) > B and (B + C) > A: perimeter = (A + B + C) print(f"Perimetro = {perimeter:0.1f}") else: area = 0.5 * (A + B) * C print(f"Are...
e101f8fcd87a7bc1e79d547df807fa8ee2be8450
ankushbanik1/-DataStructures-Algorithm-
/Array Problems/merge two array.py
194
3.53125
4
#User function Template for python3 class Solution: def merge(self, arr1, arr2, n, m): # code here arr1[:]=sorted(arr1+arr2) arr2.clear()