blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
f67473adfd19b3970bff592ccbd9cfe165e15341
Jason171096/Udemy_Python
/20-Proyecto/login.py
1,570
3.515625
4
import bd import menu import getpass import datetime date = datetime.datetime.now() def loguear(op): if op == 1: print("¡Ok, vamos a registrarte!") nom = input(" Nombre: ") ape = input(" Apellido: ") email = input(" Introduce Email: ") password = getpass.getpass(" ...
6f5d24b8fae1750836b9092d832ec7906db27995
GwenStacey/DBScan
/dbscan.py
3,382
3.90625
4
from scipy.spatial.distance import cdist import numpy as np class DBScan(): """This is a simple implementation of clustering using the DBScan algorithm. My algorithm will return labels for clusters, -1 indicating an outlier""" def __init__(self, max_dist, min_pts): self.data = None ...
d433900396d4fecd6631b5756518e22f4787e8f6
hrssurt/lintcode
/lintcode/628 Maximum Subtree.py
1,438
3.703125
4
"""*************************** TITLE ****************************""" """628 Maximum Subtree.py""" """*************************** DESCRIPTION ****************************""" """ Given a binary tree, find the subtree with maximum sum. Return the root of the subtree. """ """*************************** EXAMPLES...
b5fd1d2c7f48c4e0cc234e0ffbf9066336d888b8
Coliverfelt/Desafios_Python
/Desafio010.py
281
4.125
4
# Exercício Python 010: Crie um programa que leia quanto dinheiro uma pessoa tem na carteira # e mostre quantos dólares ela pode comprar. reais = float(input('Quantos R$ você possui na carteira?\n')) print('Com R${:.2f} você pode comprar U${:.2f}.'.format(reais, reais/3.27))
567c180c33b1909937b58e3810b5b9d70d96cd0c
Rowlandgh/python
/python_study/测试用例/name_function.py
512
3.921875
4
def get_formatted_name(firstname,lastname): full_name = firstname + ' ' + lastname return full_name.title() def get_formatted_name_2(firstname,middlename,lastname): full_name_2 = firstname + ' ' + middlename + ' ' + lastname return full_name_2.title() def get_formatted_name_3(firstname,lastname,m...
3a8936ce1b627ad70cec7c5ab1f962eab754a526
leohong1106/my_python
/gugudan.py
191
3.703125
4
#구구단 2단 for i in range(1,10): print('{}x{}={}'.format(2,i,2*i)) #구구단 2~9단 for x in range(2,10): for y in range(1,10): print('{}x{}={}'.format(x,y,x*y))
37ccf299958755d6d94c0900d567f2d584527df2
jonathangriffiths/Euler
/Page1/CollatzSequence.py
1,309
4
4
__author__ = 'Jono' #iterative: n even --> n/2; n odd --> 3n+1 #ends at 1 #which number under 1,000,000 has longest chain #Thoughts: whenever we hit an a number we know (3n+1 or n/2) can simply refer back to the known chain length def max_length_collatz(n): #create list of numbers that need testing num_to_te...
bea91c2ceaaee796479797ce0dda05ae270f10a7
tangjikuo/studentsmanage
/common/database.py
1,917
3.515625
4
import pymysql from common.Config import config class Database: """ this class is defined a database connection which can execute QUERY INSERT UPDATE DELETE options """ def __init__(self): self.db = pymysql.connect(host=config["host"], port=config["port"], user=config["username"], ...
30fed9007f137e81267b412d32b04ccc00f9de55
Potatology/coding
/sorting/merge_sort.py
667
3.609375
4
A = [4,8,2,7,5,5,5] def merge_sort(A): if len(A)>1: left = merge_sort(A[:len(A)//2]) right = merge_sort(A[len(A)//2:]) merge(A, left, right) return A def merge(A, Aleft, Aright): i = 0 j = 0 k = 0 while i < len(Aleft) and j < len(Aright): if Aleft[i] < Aright[j]...
1206e1c8500de540d8f92986d8fcc913864b0a8a
KLDistance/py3_simple_tutorials
/Fundamentals/OOM/inheritance.py
601
3.890625
4
class BaseClass : base_var = 100 def __init__(self, input_var) : self.base_var += input_var print("base class constructor is called!") def BaseFunc(self) : print("base member function is called!") class SubClass(BaseClass) : sub_var = 400 def __init__(self) : ...
b70b3b8141f71fc342a4e3c0bddbf6335f93b3b7
mydios/Dollar-Cost-Averaging
/graphs.py
559
3.53125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Module containing graphing functions """ __author__ = 'Dylan Van Parys' __copyright__ = 'Copyright 2020' __license__ = 'MIT' import pandas as pd import seaborn import matplotlib.pyplot as plt def graph_lineplot(df, xn=None, yn=None): seaborn.lineplot(data = df, x...
e8fe7f6f2559b455eb01681fac442095f45e60e1
guynaor05/Snake
/main.py
8,310
3.53125
4
import pygame import random import tkinter as tk from tkinter import messagebox pygame.init() screen_width = 1000 screen_height = 1000 display = pygame.display.set_mode((screen_width, screen_height)) snake_block = 25 red_color = (255, 0, 0) rows = screen_height // snake_block running = True def draw_b...
40e678b0644215dceac1b83cdc41d3816c7a6904
ArmandoRuiz2019/Python
/POO/POO03/cuenta.py
343
3.546875
4
''' Created on Agosto,2019 @author: Armando Ruiz ''' class Cuenta: def __init__(self, valor): self.cantidad = valor def depositar(self, valor): if valor > 0: self.cantidad = self.cantidad + valor else: print ("El valor para depositar es erroneo::") def mostrarDetalles(self): print ("La cantidad de...
437e06511357f23b243a6b47cdda7c3fcf0bcd00
mzamanian/Rosalind-problems
/ros03_REVC.py
341
4.03125
4
#!/bin/python DNA = raw_input("> Enter Sequence ") DNAb = list(DNA) DNAr = DNAb[::-1] DNAc = [] for base in DNAr: if base == 'A': DNAc.append('T') elif base == 'C': DNAc.append('G') elif base == 'G': DNAc.append('C') elif base == 'T': DNAc.append('A') else: print "non-DNA character in string!" exit()...
d52bdbd1ee5f5d3fd9bd747f1c5b6eb2b43619e4
Meercat33/hailstone_sequence
/hailstone.py
304
4.03125
4
userNum = int(input("Enter a number: ")) def hailstone(num): if num % 2 == 0: num //= 2 elif num % 2 == 1: num*=3 num+=1 return num while userNum != 1: print(hailstone(userNum)) userNum = hailstone(userNum) print("Press enter to close") input()
5b0afac17e63474f608ad990ca306f06f080e6e7
uniqueDevelop/Introduction-to-Computer-Science-and-Programming-Using-Python-MIT-
/Bisection Search
598
4.03125
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Tue Jul 10 10:33:14 2018 @author: elenachumakova """ # Bisection search # Compute square root of a number using bisection search x = 25 epsilon = 0.01 numGuesses = 0 low = 1.0 high = x ans = (high + low)/2.0 while abs(ans**2 - x) >= epsilon: print('lo...
64db7ee4d6cf1d36c60a49f289875b5215de2653
zackcpetersen/data_structures_algorithms
/graphs/implement_graph.py
1,154
3.765625
4
class Graph: def __init__(self): self.number_of_nodes = 0 self.adjacent_list = {} def add_vertex(self, node): self.adjacent_list[node] = [] self.number_of_nodes += 1 def add_edge(self, node1, node2): keys = self.adjacent_list.keys() if node1 in keys and node...
d4a27ffdb924664f2f33cb2bc05a990b36d17d31
ewuerfel66/DS-Unit-3-Sprint-1-Software-Engineering
/SC/acme_test.py
1,489
3.546875
4
# Imports import unittest from acme import Product from acme_report import generate_products, prefix, suffix # Test my Product class class AcmeProductTests(unittest.TestCase): """Making sure Acme products are the tops!""" def test_default_product_price(self): """Test default product price being 10.""" ...
096eb2df71222bceb4377ef851d078fcfbe84488
gonghuiyun/Baimian-camp
/week1/2_fix.py
1,543
3.546875
4
''' 快速选择、堆排序(题号:215): https://leetcode.com/problems/kth-largest-element-in-an-array/description/ ''' from collections import deque from math import log L = deque([50, 16, 30, 10, 60, 90, 2, 80, 70]) L.appendleft(0) L2 = deque([3,2,1,5,6,4]) L2.appendleft(0) def swap(L,i,j): L[i], L[j] = L[j],L[i] return L ...
2058542d0ce11a22833198088cf4f58e0d627d94
7er/gfx
/exercises.py
1,002
3.796875
4
import sys def print_starline(number): for each in '*' * number: sys.stdout.write('%s ' % each) print def print_numberline(number): for each in range(number): sys.stdout.write('%s ' % each) print def print_static_numberline(number): for each in range(10): sys.stdout.writ...
1e76003e158483555c8535dd765a5c9534e6d587
oksmina/hyperskill
/Problems/Searching in a descending-sorted list/main.py
364
3.71875
4
numbers = [int(n) for n in input().split()] target = int(input()) left, right = 0, len(numbers) - 1 result = -1 while left <= right: middle = (right + left) // 2 if target == numbers[middle]: result = middle right = middle - 1 elif target < numbers[middle]: left = middle + 1 else...
783a01add026b5ac57dedba409ad5e1e061e5751
hydraer/Python_stydy
/fx/fx_10_公共方法1.py
1,097
4.03125
4
# 公共方法、顾名思义、容器共有的方法 str1 = 'namez' list1 = [1, 2, 3] tuple1 = (4, 5, 6) set1 = {7, 8, 9} dict1 = {'name': 'circle', 'age': 19} # 1、运算符 + * in not in str2 = ' circle' str3 = str1 + str2 print(str3) # 2、公共方法len()、del或del()、max()、min()、range(start,end,step)、enumerate() # len() print(len(str1)) print(len(list1))...
d7f229ff6f972a4129995f3a1682de12217bc976
shrividhatri/bio231-computational-biology
/Sequence-Analysis-and-Alignments/section3-q1.py
1,742
4.125
4
''' Naive Pattern Matching - PYTHON Implement naive pattern matching for DNA sequences in Python/Perl using for/while loops. Do NOT use regular expressions. Text should be read from a file whereas the pattern should be read from standard input. Your programme should identify all occurrences of the pattern in the...
f7793e64da8f93753566f552cdaa95c51cdae26e
SOFIAGYRYKOVYCH/lab_alghoritms
/lab2/2.9/2_9.py
223
3.734375
4
import random def search(array, x): for i in range(len(array)) : if x <= array[i] : return i return -1 array = [1,2,3,4,6,10] x = random.randint(0,10) print(x) print(search(array,x))
495c1de80bea1e48413152256efe806cec57c020
ayush-programer/pythoncode
/compositioninheritance.py
1,299
4.25
4
# Using composition to build complex objects class Tractor(): def __init__(self, model, make, engine=None): self.model = model self.make = make # Use references to other objects, like Engine and Implement self.engine = engine self.implements = [] def addimplement(self, ...
e4d28860dd1fe0bf41ef5e57584e55f77c7df1ca
jfarizano/LCC
/1_año/ProgII/Python/p1/ej1.py
140
3.59375
4
def primeros25(n = 1): if n < 25: print(n*2) primeros25(n+1) else: print(n*2) primeros25()
3b982596e998ab21438fae28cb97a79fe2c8e433
cdelachica/Requirments
/string manipulation.py
347
4.34375
4
your_name = input ("enter your name:") name = "" based_name = "Christian" print("Your name should not have the same letter with Christan") for letter in your_name: if letter not in based_name: name += letter print("\nAnalyzing letters at your name :", name) print("\nYour new name is :", name) ...
586fdfb3baa2f8d4b7ade513e01ae84265a4a7cc
besmelh/international-schools-scraper
/dataToCsv.py
1,781
3.734375
4
import csv class NESA_CSV: #create the csv file, and write the info of all the advisors to it def writeFile(self, advList): fileName = 'NESA.csv' try: with open(fileName, 'w+', newline='') as csvfile: fieldnames = ['name','title' ,'location', 'email'] ...
96428f70379cbea3ff44130a007b1e1afc32c5db
leemutai/google_opener
/main.py
675
3.515625
4
#importing web browser module import webbrowser #importing tkinter from tkinter import * #creating root root = Tk() #setting a GUI title root.title("webBrowser") #setting GUI geometry root.geometry("300*200") #function to open copyassignmet.com in browser def copyassignment(): webbrowser.open("www.copyassignment.co...
03d69ff98fa7cc04897e64232c3d8eb9da868209
Covax84/Coursera-Python-Basics
/power_of_2.py
355
4.15625
4
# По данному числу N распечатайте все целые степени двойки, # не превосходящие N, в порядке возрастания. # Операцией возведения в степень пользоваться нельзя! n = int(input()) m = 1 while m <= n: print(m, end=' ') m *= 2
6e4ed1c01c7d0eefd315405f6179f2a5574b796d
KarthikUdyawar/Bubble-Sort
/bubblesort.py
455
4.15625
4
# Main function def bubblesort(list): for i in range(len(list) - 1,0,-1): for x in range(i): if list[x] > list[x+1]: temp = list[x] list[x] = list[x+1] list[x+1] = temp return list # Input loop sort = [] num = int(input("Enter number of inputs...
28f839e5953efd90b971b7d8fa00b8a6130206a9
0885872/INFDEV02-1_0885872
/drawFigures/drawFigures/drawFigures.py
1,628
4.15625
4
import sys star = "*" space = " " saveWidth = "" saveWidthSec = "" enter = "\n" print "Let's get happy, let's draw figures!" figureChoice = raw_input("""Choose what kind of figure you want to draw: 1square, 2square, 1triangle, 2triangle, circle or smiley? : """) # Let's draw a square of stars if figureChoice =...
0b0e6da8c4826b8af42e4fd4876b846333f3da46
MerinAlex23/PythonProject
/largestnumber.py
120
4.0625
4
numbers =[0,2,3,8,9,6] max = numbers[2] for number in numbers: if number > max: max = number print(max)
44852cd79d0797c0dda575e47ff13fd9d74c5df0
Swiftal13/Tkinter-Projects
/Daniel_or_Elyas.py
884
3.8125
4
from tkinter import * root = Tk() root.title("Who is the smarter brother?") root.geometry("400x200") root.configure(bg = "#cedbdb") label_1 = Label(root, text = "Who is smarter Daniel or Elyas:", bg = "#cedbdb" ) label_1.place(x = 120, y = 25) stringvar = StringVar() displaylabel = Label(root, text...
344cdb802f7fb423d0d20fcc5bd32f04fc3443d8
Fu-James/AI-Project-1
/repeated_Astar.py
6,749
3.734375
4
from func_Astar import * from gridworld import Gridworld class Repeated_Astar(): """ Create a Repeated A* agent with the given unexplored maze, dimension, start, and goal cell. Parameters: ---------- dim : Dimension of the gridworld as a int. start : cell to start from. goal : goal cell to...
2f1cf4ef6f61b3f91f0d077d4e9dc50630b34e0d
HLozano12/holbertonschool-higher_level_programming
/0x0F-python-object_relational_mapping/4-cities_by_state.py
598
3.78125
4
#!/usr/bin/python3 """List all cities from DB""" if __name__ == "__main__": import MySQLdb from sys import argv db_connection = MySQLdb.connect("localhost", argv[1], argv[2], argv[3]) with db_...
6925f3c71330c3c6dd5a1e899ddff9d51dffc94c
Aasthaengg/IBMdataset
/Python_codes/p02993/s452232855.py
131
3.6875
4
lst = input().split() if lst[0][0]==lst[0][1] or lst[0][1]==lst[0][2] or lst[0][2]==lst[0][3]: print('Bad') else: print('Good')
982ef78cc9b7632eb39ab4a7dac0c165db639f6c
dipanjan44/Python-Projects
/ProgramPractise/find_element_rotatearray.py
1,196
4.28125
4
def find_element (arr, size, element): pivot = get_pivot_element (arr,size - 1); # If we didn't find a pivot, # then array is not rotated at all if pivot == -1: return binarySearch (arr, 0, size - 1, element); if arr[pivot] == element: return pivot if arr[0] <= element: ...
501637cf5248b4aa6cdbeabe4a6a15a753baad52
toberge/python-exercises
/warmup/beautiful.py
1,131
3.625
4
#!/usr/bin/env python3 ''' https://www.youtube.com/watch?v=OSGv2VnC0go just some notes about sweet&consise things in Python ''' # after 6:43 # Using iter() with a sentinel (stop) value! # partial() takes function with many args + those args and creates function with no args! things = [] for thing in iter(partial(f...
07da7d5d3a8ca8efa1619ec26f9e9687f4e2c0b7
ReDi-school-Berlin/git_intro
/my_first_assignment.py
455
3.796875
4
############################### ## # ## MY FIRST PYTHON ASSIGNMENT # ## # ## \o/ # ############################### # YOUR ASSIGNMENT: # 1. Change the code below to print "Hello, I am {your_name}. Nice to meet you!" print("Hello, I am ReDi Sc...
9f88403bd09b969be0ebb948fe791942ebca62ba
nitarsh/PycharmProjects
/testPython/myarrays/test.py
2,526
3.578125
4
def fact(n): if n == 0: return 1 else: return n * fact(n - 1) def multiple(n, m): if (n % m != 0): return False else: return True def cheeseshop(kind, *arguments, **keywords): print "-- Do you have any", kind, "?" print "-- I'm sorry, we're all out of", kind ...
c98c36155d81c0ce5c19e473ae8b3a72fdbeca9b
ryanfwy/sudoku
/recognition.py
2,790
3.59375
4
'''Number recognition model.''' from keras.models import model_from_json, Model from keras.layers import Input, Dense, Dropout, Flatten import numpy as np import cv2 class _NumberModel(object): '''The recognition model for number 0-9. Instance Methods: load_model: Load the model. predict_num...
5a59bdaa5167abfd4df17577d10ba2ba89dec233
jabzer/pyCode
/系统/读取txt变成1行/readtxt.py
295
3.59375
4
#!/usr/bin/python3 import sys with open('txt.txt', 'r',encoding='utf8') as f: allline = f.readlines() linestr = [] for line in allline: line = "'{}'".format(line.replace('\n', '').replace(' ','')) if len(line) > 2: linestr.append(line) out = ",".join(linestr) print(out)
5eb1e07984b772b88295f825b9e18da5954dc5ae
YuyaKagawa/random_public
/string_manipulation/alternate/alternate.py
1,033
3.875
4
import numpy as np # 行列操作 def main(): print("交互にかみ合わせたい複数の文字列を入れてください: ") n=int(input("文字列は何個ですか: ")) string_list=[] # 元の文字列のリストの初期化 # n個の文字列を入力してもらう for i in range(n): string_list.append(input("{}番目の文字列を入力してください: ".format(i+1))) # 元の文字列のリストに追加 maxlen=len(max(string_list,key=len)) #...
cd785fed4a5ad72579cb00897f8110fe5ff4161e
sn003/python-learning
/named_tuple.py
980
4.90625
5
""" Below examples discusses about namedtuple from collections module """ import collections #Declaring a namedtuple employee = collections.namedtuple("Employee", ["Name", "Age", "DOB"]) #Adding Values emp = employee("Johnny Depp", "35", "02011983") #initializing iterable ex_list = ["Abraham", "24", "20091994"] #in...
7c28e8ef75cae9770f139cc1e13f1e8e19060418
ahridin-synamedia/intro-to-python-typing
/examples/15_static_duck_typing.py
298
3.5625
4
""" MyPy can duck-type objects, regardless of inheritance! """ from typing import Sized # Has no superclass, or metaclass! class Foobar: # But does has a __len__() method that returns ints def __len__(self) -> int: return 5 def print_length(object: Sized): print(len(object))
cb191704b41164f485bfebafdaa99b9090b2516d
flatironinstitute/spikeforest2
/working/website_upload/make_website_data_directory.py
2,271
3.515625
4
#!/usr/bin/env python import argparse import os import json help_txt = """ This script saves collections in the following .json files in an output directory Algorithms.json Sorters.json SortingResults.json StudySets.json StudyAnalysisResults.json """ def main(): parser = argparse.ArgumentParser(description=hel...
d77ee68b8954b48bb5d02b1b1f2dda633b370cb0
kmkkj/store
/猜数.py
977
4.125
4
''' 猜字游戏 需求: 1、猜的数字是系统产生的,不是自己定义的 2、键盘输入的 操作完填入:input(“提示”) 3、判断 操作完填入:if判断条件 elif 判断条件。。。。。。Else 4、循环 操作完填入:while 条件循环 任务:你的初始资金为100 每猜一次减10 资金为0时或者猜成功游戏结束 猜大 如果你输入的数字和随机数对比 大于随机数 打印一句话为 猜大了 猜小 如果你输入的数字和随机数对比 小于随机数 打印一句话为 猜小了 ''' import random num=random.randint(0, 1000) i = 100 while 1: i = int...
5681620657df5fb5d9b5f5cdf496210eb0be52e4
UCMHSProgramming16-17/final-project-anqi1999
/idea-two/map.py
3,006
3.96875
4
# How much longer am I expected to live, given my sex, age, and country? import requests import csv import datetime import math # PARAMETERS: # sex s = ['male', 'female'] sex = input('Are you male or female? Apologies for the forced gender norms. :( ') while sex not in s: sex = input('Male or female? ') # country...
b246434bf6dfb82f2a5c01174548b5d711ff52cc
marcheliks/EDIBO
/Python/milzigs_skaitlis.py
951
3.765625
4
#!/usr/bin/python3.6 print("Ievadiet skaitli") # a=2**2000000 #te ir trīs darbības - vertības sagadīšana, # vērtības pārveidošanas piešķiršinas #argument = input() #int(arguments) #a = int(arguments) #pildot int(input()) "bez izmeiģinājuma" programma var vienkārši izlidot... # tāpēc, lai "nelidotu" mēs izmantosim tr...
c0cebd1a4f7be8d299c333a8cb3fc2aa92c91742
adii1207/family-tree
/relation_maternal_aunt.py
329
3.6875
4
def maternal_aunt(name): #looks for sibling of mother with gender female if len(name.parent) > 0 and len(name.parent[1].parent) > 0: for i in name.parent[1].parent[0].child: if i.gender == "female" and i != name.parent[1]: print(i, end=" ") else: print("PERSON NO...
9e6b8101bf0ffd61d5d4299c01087b2387505f77
jlalford/scripts
/googlecsvuploader.py
544
3.5
4
import argparse parser = argparse.ArgumentParser() parser.add_argument('csv',type=str,help='The name of the file we are importing into Google') args = parser.parse_args() mypath = args.csv myfile = open(mypath) mytext = myfile.read() myfile.close() thelines = mytext.split("\n") for line in thelines: thisline = l...
d9fa057a1505721ac91a1903110a9a62c1e92ef3
TitanicThompson1/FPRO
/Testes/PE2/201706860/caesar.py
788
3.953125
4
# -*- coding: utf-8 -*- """ Created on Sun Nov 25 11:36:48 2018 @author: Ricardo Nunes """ import math def caesar(message): alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ" result="" for i,letter in enumerate(message): if letter in alphabet: swift=int(((...
ef57ad55510a50cd075c2afefc0457182d45e908
lisaover/MITxCompSciPython
/SimplePrograms/wk2_recursion.py
2,849
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def iterPower(base, exp): ''' base: int or float. exp: int >= 0 returns: int or float, base^exp ''' # Your code here power = 1 if exp == 0: return 1 else: for i in range(exp): power *= base return po...
ee1eadf0938f0dff9726eba33c38509956cf0165
Nataliia-L/python_course
/lesson2.py
218
3.671875
4
import random integer = random.randint (1,100) print("Integer number: " ,integer) float = random.uniform (1,50) print ("Float number: " ,float) answer1 = integer > float print("Is integer bigger than float?", answer1)
33246ea00c6a42a19999ef17623c341f9beda3d7
habibor144369/python-all-data-structure
/list-even_odd.py
273
4.15625
4
# find out even number and odd number in list---- list = [11, 45, 41, 60, 66, 10, 20, 13, 14, 26] even_list = [] odd_list = [] for even in list: if even % 2 == 0: even_list.append(even) else: odd_list.append(even) print(even_list) print(odd_list)
11d0f691006699d08f35c17c1bd396f1b80ea111
LourdesOshiroIgarashi/algorithms-and-programming-1-ufms
/Lists/Listas e Repetição - AVA/ThiagoD/04.py
448
3.625
4
lista = list(map(float, input().split())) media = sum(lista) / len(lista) menorQueMedia, maiorQueMedia = 0, 0 for i in lista: if i > media: maiorQueMedia += 1 else: menorQueMedia += 1 print("O valor médio da lista: ", end="") for i in lista: print(i, end=" ") print(f" é: {media:.6f}") pr...
9ac8cfe4a901becf50f94ef10fbe96a2e7e66677
anmolrajaroraa/python-wknd-sept
/patterns.py
9,874
3.796875
4
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 16:52:21) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license()" for more information. >>> list(range(10)) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> list(range(0,10)) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> list(range(0,10,1)) [0, 1, 2, 3, 4, 5, 6, 7...
7f1089706138fbf006a6df8df26f3d73ee918091
willtuna/Python_Folder
/OpenCourse/UdemyPython/tkinter_Action.py
242
3.875
4
#! /usr/bin/env python3 from tkinter import * root = Tk() def printName(): print("Hello there, this is Will.\n Welcome to login") button1 = Button(root, text="Click Me", command=printName) button1.grid(columnspan=2) root.mainloop()
c000241bd810c5656c19e573880039caa1f5d4df
DanielMalheiros/geekuniversity_programacao_em_python_essencial
/Exercicios/secao07_colecoes_python_parte2/exercicio20.py
1,395
4.28125
4
"""20- Faça um programa que leia uma matriz 3x6 com valores reais. a) Imprima a soma de todos os elementos das colunas ímpares. b) Imprima a média aritmética dos elementos da segunda e quarta coluna. c) Substitua os valores da sexta coluna pela soma dos valores das colunas 1 e 2. d) Imprima a matriz modificada. """ ma...
de25784b3ef0c51d252667541ac09709e196bc05
pandorakgz/python_itc
/day2/day24/class_1.py
767
3.90625
4
class Panda: name = input('Введите имя Панды: ') weight = int(input('Введите вес Панды: ')) age = int(input('Введите возраст Панды: ')) color = input('Введите цвет Панды: ') speed = int(input('Введите скорость Панды: ')) power = int(input('Введите мощность Панды: ')) def to_walk(self): ...
79c80d6076569641eb605a3aeab7075de87178a9
alperencucen/GlobalAIHubPythonHomework
/odev2.py
410
4
4
list1 = [] firstname = str(input("Firstname:")) lastname = str(input("lastname:")) age = int(input("Age:")) dateofbirth = int(input("Date of birth:")) list1.append(firstname) list1.append(lastname) list1.append(age) list1.append(dateofbirth) for i in list1: print(i) if (age < 18): print("You c...
fdbc25c269bc8c29e8b2d3ea981a66bdf51e79c0
gyang274/leetcode
/src/0600-0699/0663.equal.sum.partition.bt.py
871
3.828125
4
from config.treenode import TreeNode, listToTreeNode class Solution: def recursive(self, node): xl = self.recursive(node.left) if node.left else 0 xr = self.recursive(node.right) if node.right else 0 xs = xl + xr + node.val # in case xs == 0 and node is root.. if node is not self.root: self...
e34c12cea0dd7b2d4555c3edb0268c1a33c46ebf
jmuguerza/adventofcode
/2017/day2.py
3,662
3.828125
4
#/usr/bin/env python3 # -*- coding: utf-8 -*- """ PART 1 We have to repair the corruption in a spreadsheet. The spreadsheet consists of rows of apparently-random number. To make sure the recovery is possible, we need to calculate the CHECKSUM. For each row, determine the difference between the largest number and ...
70bba8b2c468b287caba595e29b4f55a950d1c32
hmanjarawala/Python
/Functional Programming/Recursion/Sum Of Fibbonacci Nos.py
433
4.1875
4
""""" This script will calculate nth fibbonacci numbers """"" def fibbonacci(n): if n == 0 or n == 1: return 1 else: return fibbonacci(n-1) + fibbonacci(n-2) intNumber = 5 try: intNumber = int(input("Enter the number: ")) except ValueError: print("Entered value is not valid integer number") print("continue pr...
0315f76992f821d0b3deb93f80a0f5694c939865
alexrogeriodj/Caixa-Eletronico-em-Python
/capitulo 04/capitulo 04/capitulo 04/exercicio-04-04.py
1,031
4.40625
4
############################################################################## # Parte do livro Introdução à Programação com Python # Autor: Nilo Ney Coutinho Menezes # Editora Novatec (c) 2010-2017 # Primeira edição - Novembro/2010 - ISBN 978-85-7522-250-8 # Primeira reimpressão - Outubro/2011 # Segunda reimpres...
660adb39836155ea79f2d76ed330fe8c8df59a6b
Nikolas2001-13/Universidad
/Nikolas_ECI_191/AYED/ultra.py
642
3.71875
4
from sys import stdin def insertionSort(alist): p=0 for index in range(1,len(alist)): currentvalue = alist[index] position = index while position>0 and alist[position-1]>currentvalue: alist[position]=alist[position-1] position = position-1 p+=1 ...
1d3693ecff3945901e5bb8a8fa6bc8d765457237
darkknight161/crash_course_projects
/favorite_languages1.py
432
3.5
4
favorite_languages = { 'jen': 'python', 'sarah': 'c', 'edward': 'ruby', 'phil': 'python' } polling_list = ['jen', 'sarah', 'edward', 'phil', 'josh', 'brandie',\ 'jonas', 'ian', 'sunny', 'natalia'] for invitee in sorted(polling_list): if invitee not in favorite_languages.keys(): print(f'{invitee.tit...
b20a4be156bc635062b928b3e7b307f0ec1e16e0
remir88/leetcode_cn
/(TLE)~5.最长回文子串.py
545
3.546875
4
# # @lc app=leetcode.cn id=5 lang=python3 # # [5] 最长回文子串 # # @lc code=start class Solution: def isPalindrome(self, s: str) -> bool: for x in range(0, len(s)//2): if s[x]!=s[len(s)-(x+1)]: return False return True def longestPalindrome(self, s: str) -> str: f...
544caf69be49399b3cc7cac471458504ad59cbac
aishwarya34/Python
/numpy/sum_numpy.py
1,044
3.703125
4
import numpy as np # need sum s+b as scalar W = np.random.randn(4, 4, 3) b = np.random.randn(1, 1, 1) s = np.sum(W) # np.sum() gives integer print(s) print(b) # b is still array print(s+b) #will result in an 3D array output of this sum print(float(s+b)) # need to use float to cast array to scalar prin...
352c985ddce5f567f3a60218679253f077168936
erkin98/Python-ile-Veri-Bilimi-Uygulamalar-
/veri_manipulasyonu_Numpy.py
5,298
3.921875
4
# Numpy (Numerical Python) ''' # Döngülerden Vektörel Operasyonlara # Array ve matrisler üzerinde yüksek performanslı çalışma imkanı sağlar # Python'ın analitik dünyasının zeminidir. Ana kütüphane olarak nitelendirilebilir ''' a = [1,2,3,4] b = [2,3,4,5] ab = [] for i in range(0, len(a)): ab.append(a[...
e5dc836a7dda9daa6f8e96304fb845a4fca8b7c5
mida-hub/hobby
/atcoder/python/beginner/abc243/C/main.py
1,456
3.53125
4
#!/usr/bin/env python3 import sys YES = "Yes" # type: str NO = "No" # type: str def solve(N: int, X: "List[int]", Y: "List[int]", S: str): check_dict = {} for i in range(N): if check_dict.get(Y[i]) is None: check_dict[Y[i]] = {S[i]: [X[i]]} elif check_dict[Y[i]].get(S[i]) is no...
75473d0a1399179e16a9db8b48cfb6259618b546
yfractal/cs61a
/labs/lab4.py
2,179
3.96875
4
def make_rat(num, den): return (num, den) def num(rat): return rat[0] def den(rat): return rat[1] def mul_rat(a, b): new_num = num(a) * num(b) new_den = den(a) * den(b) return make_rat(new_num, new_den) def div_rat(a,b): new_num = num(a) * den(b) new_den = den(a) * num(b) return make_rat(new_num, new...
65379d76926e65d25ab0b165b0e80513f70984fc
thosamanitha/python
/python/accpractice.py
1,825
3.59375
4
class Employee: raise_amt=1.04 def __init__(self,first,last,pay): self.first=first self.last=last self.pay=pay self.email=first+ "."+ last+ "@gmail.com" def fullname(self): return "{} {}".format(self.first,self.last) def apply_raise(self): self.pay=in...
36a69c724fb6f3bf6128e9522fe51b2de9653144
pecata83/soft-uni-python-solutions
/Programing Basics Python/While Loop Exercise copy/06.py
394
4.09375
4
width = int(input()) length = int(input()) cake_peaces = width * length while True: if cake_peaces >= 0: _input = input() if _input == "STOP": print(f"{cake_peaces} pieces are left.") break else: cake_peaces -= int(_input) else: print(f"No...
5baf5eedb19409f8f1c79f59b649bb53c31586d3
kvoss/trie
/trie.py
1,633
3.5625
4
""" Trie in Python based on dict author: K.Voss """ class Trie(object): MAGIC_KEY = 'value' def __init__(self): self.tree = dict() def __str__(self): return str(self.tree) def insert(self, key, val=None): node = self.tree for c in key: parent = node ...
0d7a542492e499b1f25f397cd42434a58b6fcaf1
HenryHdez/ASIGNATURAS
/Diseño_Digital_Avanzado/Python_proyectos/Python_Unicamente/Interfaz-Grafica/Cambiar_Tamana.py
950
3.71875
4
#Asignar una función a los botones import sys from Tkinter import* app=Tk() #Tamano en pixeles app.geometry("400x800") app.title("Función en Python") #Configurar la ventana principal vp=Frame(app,background="yellow") vp.grid(column=10, row=20) vp.columnconfigure(0,weight=1) vp.rowconfigure(0,weight=1) #Establecer Va...
a12612eb23899fc04071cf3a1c571b269d046c8c
ynskardas/university_projects
/IE 310/Assignment3/main3.py
10,837
4.40625
4
from sys import exit import sys import math # Python 3 program to find rank of a matrix class rankMatrix(object): def __init__(self, Matrix): self.R = len(Matrix) self.C = len(Matrix[0]) # Function for exchanging two rows of a matrix def swap(self, Matrix, row1, row2, col):...
2cc3e9393a9b70734f8c68b6de8bb1caa0f1513f
kq-li/stuy
/pclassic/2016f/stubs/Treasons.py
1,423
4.03125
4
def getCharIndex(c): return ord(c) - ord('a') def anagram_tester(word_list): """ :param word_list: list of words :return: largest set of words that are all anagrams in alphabetical order """ # TODO: implement primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37...
e7d22d823a46bd592eab454dee667a287ad56fbd
Rusty89/Encrypt
/encrypt.py
9,654
3.796875
4
import re import random def main(): try: def encrypt(string,level,degree): if level==0: return(string) new_string="" alphabet=("abEFefghABCDmnopq&*()tuvwxy_+{}rszGHIJKLM"+ "RSTU3NOPQ45678VWXY90~!@#$%|Zi `12:<c>?[jkld];,\/.'""^")...
f6e422b07c5e5445758ad9a4a66328dccb437bf2
aadilmeymon/100-days-of-python
/100 days of python day 4/day4_project.py
1,032
4.125
4
import random rock = ''' _______ ---' ____) (_____) (_____) (____) ---.__(___) ''' paper = ''' _______ ---' ____)____ ______) _______) _______) ---.__________) ''' scissors = ''' _______ ---' ____)____ ______) __________) (____) -...
083467be8d67bc4fcf1a9788d690fa0fdf3b364b
fanliu1991/LeetCodeProblems
/2_Add_Two_Numbers.py
3,852
3.640625
4
''' You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself. Ex...
98c8b2df121d693f02d9de3f82f93e643e143553
aktech/pydsa
/pydsa/insertion_sort.py
416
4.0625
4
def insertion_sort(a): """ Sorts the list 'a' using insertion sort algorithm >>> from pydsa import insertion_sort >>> a = [3, 4, 2, 1, 12, 9] >>> insertion_sort(a) [1, 2, 3, 4, 9, 12] """ for i in range(1, len(a)): element = a[i] j = i while j > 0 and a[j - 1] >...
ad079284a2450708838d462bedc41c35fcabecd2
rigratz/rigratz-linkedin
/Portfolio/Blackjack/main/Players.py
1,224
3.53125
4
class Player(object): def __init__(self): self.hand = [] def getTotal(self): sum = 0 aces = 0 for c in self.hand: if c.getName() == "Ace": aces += 1 sum += 11 elif c.getName() == "Jack" or c.getName() == "Queen" or c.getNa...
d256e3af8b9eab3c140e876fb01ac2a998fee656
eprj453/algorithm
/프로그래머스(자료구조, 코딩테스트)/LinkedList/LinkedList1.py
5,192
4.09375
4
# Node # - data (어떤 데이터를 가지고 있는가) # - link (다음 데이터와 이어지는 link가 무엇인가) class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.nodeCount = 0 self.tail = None # Dummy node 전 # self.head = No...
df2628336a415e07b38f1b1bed611f2484128ba3
srishtishukla-20/function
/Q3(String reverse).py
357
4.0625
4
def string_reverse(n): str1='' index=len(n) while index>0: str1+=n[index-1] index-=1 return str1 print(string_reverse('abncgu123')) #reverse def var(): print("welcome") if len(a)>len(b): print(a) elif len(a)==len(b): print(a) else: print(b) a=input("en") b=input("en") var() #p...
d4d7440b7fb85dc1b09458a75f8c78da2aee6b93
HYnam/MyPyTutor
/W6_dict_iterate.py
989
4.875
5
""" Iterating Over a Dictionary A dictionary is an iterable object and so a for loop can be used to iterate over the entries in a dictionary. The loop for k in dict: body_code will iterate over the keys of the dictionary dict setting k in turn to each key of dict. Consider a dictionary that has st...
1c4a8547faa4121529cea99b6972f16a448ff855
lapnd/fuzzingbook
/code/core/convertOperatorsEBNF.py
2,256
3.5
4
import re from .grammarUtils import * # # function to __convert_ebnf_parentheses def __convert_ebnf_parentheses(ebnf_grammar): """Convert a grammar in extended BNF to BNF""" grammar = extend_grammar(ebnf_grammar) for nonterminal in ebnf_grammar: expansions = ebnf_grammar[nonterminal] for i...
7075c6827792d06a58220de0a2b1e42a562041ee
kabilasudhannc/Python-Turtle-Programs
/HexagonSpiral.py
213
3.5
4
from turtle import * colors = ['red', 'purple', 'blue', 'green', 'yellow', 'white'] speed(0) bgcolor('black') for x in range(200): pencolor(colors[x % 6]) width(2) forward(x*1.2) left(59)
7d95d2a7fa5849841f65b29e6caf193a0d0b011b
MariaLuiza17/PEOO_Python
/Lista_06/Luis M_Guilherme Melo/Questao_03.py
1,468
4.28125
4
""" 3. Crie um diagrama de classes que represente uma classe Pessoa com os atributos privados identificador, nome e CPF, e uma classe Endereço com os atributos número da casa, rua, cidade, estado e pais. Nesse caso uma pessoa deve “agregar” um ou vários endereços. Implemente métodos para representar esse relacionamento...
8f9549e7d2b40ea8a746f9c7c02f7a3cbc854fa0
XyliaYang/Leetcode_Record
/python_version/L23.py
1,907
3.609375
4
# @Time : 2020/3/30 19:48 # @Author : Xylia_Yang # @Description : class ListNode: def __init__(self, x): self.val = x self.next = None class Solution_1: def mergeKLists(self, lists): if not lists: return node=None min_node=None min_index=-1 ...
84f254d48a3c4ae59040b9a7cf57b75d9700fb77
prem4589/competetive_programming
/week-1/Day_1/threeproduct.py
1,911
3.640625
4
import unittest def pro3(array): highest_number = max(array[0], array[1]) lowest_number = min(array[0], array[1]) pro2 = array[0]* array[1] lpro2 = array[0]* array[1] pro3 = array[0]* array[1] * array[2] for i in xrange(2, len(list_of_ints)): current = list_of_ints[i] pro3 =...
fe44723e18928ed08a4c5c22d80e6d630e8d4c16
apdaza/bookprogramming
/ejercicios/python/ejercicio073.py
360
3.90625
4
def contador_recursivo(numero): if (numero == 0): return 0 else: return 1 + contador_recursivo(int(numero/10)) if __name__ == "__main__": numero = int(input("ingrese el numero : ")) if (numero >= 0): print(str(numero)+" tiene "+str(contador_recursivo(numero))+" digitos") else: pr...
f8a3a84e08ccdba5e50dce2a5767c3ee5decd2ea
sarahvbogaert/blackjack
/black_jack.py
1,954
3.6875
4
from card_game import Deck from player import Player, Dealer class BlackJack: def __init__(self, name, balance, bet): """ :param: name: name of player :param: balance: initial balance of player :param: bet: bet per play """ self.player = Player(name, balance) ...
14361bd8ab8b360068fa0a3e6d4539687d1697af
teperwoman/DevOps0909
/class_1/homework/answer_class_1.py
933
4.03125
4
# ANSWER A. # 1. Create a variable name first with value 7. # 2. Create a variable name second with value 44.3. # 3. Print result of adding first to second. # 4. Print result of multiplying first by second # 5. Print result of dividing second by first first = 7 seconde = 44.3 print(first + seconde) print(first * seco...
ea75c3eebf1c72e9ce4d7cb67c09469e63ab076f
geekzeek/Artificial_Intelligence
/Assignment 2 - Pentago Vs AI/AI.py
8,059
3.578125
4
""" # File: AI.py # Author: Zeeshan Karim # Date: 5/15/2017 # Course: TCSS 435 - Artificial Intelligence # Purpose: Implementation of Search Tree, and Minimax / Alpha-Beta Algorithms """ import random from copy import deepcopy import pentago # Depth limit of search tree maxDepth = 3 # Search method to ...
d980c79d96e944d9a091f8b94fbc1a4e1132b38e
Python-lab-cycle/Akhila-P-M
/CO4_03_RectangleAreaOperatorOverloading.py
668
3.96875
4
class area: def __init__(self, m1, m2): #initialization self.l = m1 self.b = m2 def __gt__(self, other): #comparing the two objects r1 = self.l * self.b r2 = other.l * other.b if(r1 > r2): return True else: r...
7e19fe8b29163701bb2b74ed2f9b9e586932df79
samuelpordeus/algorithms-lib
/dynamic/box_stacking.py
2,517
3.5625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import unittest from collections import namedtuple from itertools import permutations dimension = namedtuple("Dimension", "height length width") # Gera dimensões usando como base permutações das # dimensões com comprimento maior que altura def rotations(dimensions): ...
6ef3c777cdc45ef7beb62085fcc9ac596228a3e1
stuart727/edx
/edx600x/L04_Functions/l4_p8_fourth_power.py
223
3.578125
4
''' Created on Feb 21, 2013 @author: ira ''' def square(x): ''' x: int or float. ''' return x*x def fourthPower(x): ''' x: int or float. ''' return square(x)*square(x) print fourthPower(5)
08d4a0efc9bbcb3d0043f8a6385d985d77daaf5f
Faraaz54/python_training_problems
/hacker_earth/python_problems/factorial.py
174
3.703125
4
inp = raw_input() fact = 1 for i in range(1, int(inp)+1): fact = fact * i print fact '''a = int(raw_input()) b=1 for i in range(1,a+1): b = b*i print b'''