blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
7a5a9941ab3b4295b0e6808c3de6f83ac1f41904
Sturm2002/Kleine-Projekte
/UnterstufenProjekt_FA13_AlexBruksch_NickDziewior_JeanNeumann_DanielPyka_PY/Datenbank.py
8,956
3.59375
4
import os from sqlite3.dbapi2 import connect from typing import Collection, DefaultDict from globalVars import ProtypeDBPath from tkinter import * import sqlite3 GlobalDBPath = ProtypeDBPath GlobalUsername = "" def connection(): #Es gibt nur noch eine Datenbank, welche alle Infos beinhaltet conn = sqlite3.connect...
ecee3c7834b468cec5f437d173b91fc9665f63d1
Git-Pierce/Week8
/MovieList.py
1,487
4.21875
4
def display_menu(): print("MOVIE LIST MENU") print("list - List all movies") print("add - Add a movie") print("del - Delete a movie") print("exit - Exit program") print() def list(movie_list): i = 1 for movie in movie_list: print(str(i) + "- " + movie) i += 1 print()...
05570e1b208a2aced151e29dafb6ae1eb930f6fa
akshaykrishnan003/Maths
/sum.py
3,006
4.0625
4
# A basic code for matrix input from user """ order = int(input("Enter the number of rows:")) """ import sys order = 2 R = order C = order limit = order * order number = 0 # Initialize matrix matrix = [] def numGen(): global number #number = number + 1 number = 2 return (number) # For user ...
5628d55a543c5f500b443535c1f58e60e4bcc82a
Pandinosaurus/pandas_streaming
/pandas_streaming/data/dummy.py
867
3.53125
4
# -*- coding: utf-8 -*- """ @file @brief Dummy datasets. """ from pandas import DataFrame from ..df import StreamingDataFrame def dummy_streaming_dataframe(n, chunksize=10, asfloat=False, **cols): """ Returns a dummy streaming dataframe mostly for unit test purposes. :param n: number of rows :par...
f96136d06049d33906368ebd7f3100b7026602df
renansald/Python
/Apostila/Capitulo2/Exercicio13.py
714
4.09375
4
num1 = int(input("Informe o primeiro número: ")); num2 = int(input("Informe o segundo número: ")); while(((num1 < 0) or (num2 < 0) or (num1 > 10) or (num2>10))): print("\33[1;31;40mERRO os Números tem que está entre 0 e 10\n{:^30}Por favor entre com os novos números\33[m") num1 = int(input("Informe o primeiro n...
50c64c44c8a0344effae9c2d332225e2cba1d81f
renansald/Python
/Apostila/Capitulo1/Exercicio9.py
256
3.953125
4
numero1 = int(input('Digite o primeiro numero: ')) numero2 = int(input("Digite o segundo numero: ")) aux = numero1 numero1 = numero2 numero2 = aux print('A variével numero1 agota contém {}\nE avariável numero2 agora contém {}'.format(numero1, numero2)
046e3af27c4f69fdfe499a8ff07945f49b2bb6d2
renansald/Python
/Apostila/Capitulo2/Exercicio18.py
417
3.796875
4
nota1 = float(input("Informe a primeira nota: ")); nota2 = float(input("Informe a segunda nota: ")); nota3 = float(input("Informe a terceira nota: ")); media = (nota1+nota2+nota3)/3; if(media < 4): print("\33[7;31;40mREPROVADO\33[m"); elif(4 <= media < 5): print("\33[1;31;40mRECUPERAÇÃO\33[m"); elif(5 <= media ...
1a5bd9a59205effea878a1bee98c2ded6a2efe03
renansald/Python
/cursos_em_video/Desafio2.py
141
3.703125
4
dia = input("Dia: ") mes= input("Mes: ") ano = input("Ano: ") print("Voce nasceu no dia ", dia," do mês ",mes," do ano ",ano,", Corrento?")
2dfabe76e6664805f92811f5cd634835354793f6
renansald/Python
/cursos_em_video/Desafio35.py
394
3.9375
4
reta1 = float(input("Informe a primeira reta: ")) reta2 = float(input("Informe a segunda reta: ")) reta3 = float(input("Informe a terceira reta: ")) aux = (reta1 + reta2 + reta3)/2 if((reta1 <= 0) or (reta2 <= 0) or (reta3 <= 0) or (aux-reta1 <= 0) or (aux-reta2 <= 0) or (aux-reta3 <= 0)): print("Não é possível cri...
8232911f8095853d02de93a31620121dd6db2620
renansald/Python
/cursos_em_video/Desafio55.py
332
3.953125
4
for x in range(0, 5): peso = float(input('Informe o peso da pessoa {}: '.format(x+1))) if(x == 0): maiorPeso = menorPeso = peso if(peso > maiorPeso): maiorPeso = peso if(peso < menorPeso): menorPeso = peso print('O maior peso é {:.2f} e o menor peso é {:.2f}'.format(maiorPeso, me...
f5f1786a45dc97d0bd9047c935c971d383e7da5d
renansald/Python
/cursos_em_video/Desafio24.py
229
3.828125
4
cidade = input("informe o nome da cidade: ").strip() cidade2 = cidade.split(); if 'SANTO' == cidade2[0].upper(): print("Existe santo") else: print('Não existe Santo') #Outro metodo print("santo" == cidade[:5].lower())
769acfcd5004ac1e922ae04bc196499addb7cc74
renansald/Python
/Apostila/Capitulo2/Exercicio4.py
137
4.03125
4
num = int(input("Informe um número: ")); if(num%2 == 0): print("Esse número é par."); else: print("Esse número é ímpar.");
750845c87efe9e65c001c95cd24af1e9285fb40f
renansald/Python
/cursos_em_video/Desafio73.py
851
4.125
4
times = ["Plameira", "Santos", "Flamengo", "Internacional", "Atletico Mineiro", "Goiás", "Botafogo", "Bahia", "São Paulo", "Corinthias", "Grêmio", "Athlitico-PR", "Ceará SC", "Fortaleza", "Vasco da Gama", "Fluminense", "Chapecoense", "Cruzeiro", "CSA", "Avaí",]; print(f"Os 5 primeiros colocados são {times[:5]}\nOs 4 ul...
4252da6e82fcdc23dbc976371431a89b517b9ed6
renansald/Python
/cursos_em_video/Desafio13.py
106
3.609375
4
salario = float(input('Informe o salario: ')) print('O novo salário é {:.2f}'.format((salario*(1.15))))
8129f3085e028d4cf50277d65812ff56e26f1f4e
renansald/Python
/Apostila/Capitulo2/Exercicio17.py
410
4.125
4
from math import sqrt a = float(input("Informe o valor de \'a\': ")); b = float(input("Informe o valor de \'b\': ")); c = float(input("Informe o calor de \'c\': ")); delta = (b**2) - (4*a*c); if(delta > 0): print(f"As raízes são {((-b) + sqrt(delta))/(2*a)} e {((-b) - sqrt(delta))/(2*a)}"); elif(delta == 0): pr...
5fb04c050a0021aa2fbcfa2bf87240dd9b6512e3
renansald/Python
/Apostila/Capitulo2/Exercicio15.py
194
3.703125
4
salario = float(input("Informe o salário atual: ")); if(salario <= (750*1.5)): print(f"Novo salário é: {salario*1.30}"); else: print(f"Não tem aumento salario maior que {750*1.5}");
3278c587a6b82c3043348752eb2517f86ac10218
renansald/Python
/cursos_em_video/Desafio78.py
483
3.828125
4
numeros = list(); for x in range(0, 5): numeros.append(int(input(f"Informe o valor {x+1}: "))); print("-"*30); print(f"O maior valor foi {max(numeros)} e sua(s) posição(ções) é(são) ", end=""); for n, v in enumerate(numeros): if v == max(numeros): print(f"{n+1}...", end=""); print(f"\nO menor valor foi ...
7068d725e8cd0caca6df0f4ec8604e5ff9e5493c
renansald/Python
/Apostila/Capitulo1/Exercicio16.py
231
3.9375
4
import math r = float(input('Informe o raio do circulo; ')) area = math.pi*(r**2) perimetro = 2*math.pi*r diametro = 2*r print('O circulo possui:\nPerimetro {:.2f}\nArea {:.2f}\nDiâmetro {:.2f}'.format(area, perimetro, diametro))
27eaeb701676408eda2e6588626204db92a63977
renansald/Python
/cursos_em_video/Desafio5.py
155
4.21875
4
numero = int(input('Informe um número: ')) print("O numero {} tem como antecessoe {} e como sucessor {}".format(numero, numero-1, numero+1), end='>>>>>')
1eee6e0eae2f310af528c58afae34572ff1ceecf
renansald/Python
/cursos_em_video/Desafio66.py
230
3.96875
4
count = soma = 0; while(True): numero = float(input("Informe o valor: ")) if(numero == 999): break; count += 1; soma += numero print(f'Foram digitados {count} números e a soma dos números é {soma:.2f}')
a36fe4d3243415dc6448d7815619117ebdfe4fa6
aloverso/SoftwareDesign
/hw3/gene_finder.py
8,259
3.53125
4
# -*- coding: utf-8 -*- """ Created on Sun Feb 2 11:24:42 2014 @author: Anne LoVerso """ # you may find it useful to import these variables (although you are not required to use them) from amino_acids import aa, codons from load import load_seq, load_salmonella_genome from random import shuffle def collapse(L): ...
fb1d18f8364fc92264023fe6be76d3e963a60cbb
izabelafrydrychowicz/izabelafrydrychowicz
/Zestaw1/Zestaw1_Zadanie1.py
564
3.53125
4
import pandas as pd #Read the file, name the columns. df_two=pd.read_csv("./train.tsv", delimiter='\t', names=['price', 'number_of_rooms', 'size_of_the_apartment', 'floor_number', 'address', 'description']) #Calculate the mean of the 'price' column. The result was in the thousands, so change it to PLN. Changing ...
38f0579b05a0195b60e6fde4ff5b9f3fb6988fd1
BJMX/PythonText
/list_dict_set_tips/dict_1.py
222
3.703125
4
from random import randint data = {x: randint(60, 100) for x in range(1, 20)} print(data) # 字典的意义是学号:分数,要求过滤出分数高于90的 ret = {k: v for k, v in data.items() if v > 90} print(ret)
4b542e2a166a7740354263e9142869559d55447f
LuluFighting/leetCodeEveryday
/TwoPoints/142.py
968
3.703125
4
class ListNode: def __init__(self,val): self.next = None self.val = val class Solution(object): def judgeCycle(self,head): p1,p2 = head,head while p2 is not None and p2.next is not None: p2 = p2.next.next p1 = p1.next if p1==p2: ...
22a2332bff499d797157650a017eb71280e41ef7
LuluFighting/leetCodeEveryday
/BFS/127.py
1,910
3.59375
4
class Solution: def wordDiff(self,word1,word2): count = 0 for i in range(len(word1)): if word1[i]!=word2[i]: count+=1 return count def ladderLength(self, beginWord: str, endWord: str, wordList) -> int: if not endWord in wordList: return 0 ...
1d66b04c774e3346197d17c4ca559a4c5642f3e9
green-fox-academy/Chiflado
/week-03/day-03/horizontal_lines.py
528
4.40625
4
from tkinter import * root = Tk() canvas = Canvas(root, width='300', height='300') canvas.pack() # create a line drawing function that takes 2 parameters: # the x and y coordinates of the line's starting point # and draws a 50 long horizontal line from that point. # draw 3 lines with that function. def drawing_hori...
7a11971c57204ffe508cf28ab8fb44ac34235860
green-fox-academy/Chiflado
/week-04/day-01/petrol_station.py
754
3.671875
4
class Station(object): gas_amount = 100 def refill(self, car): if car.gas_amount > 0: self.gas_amount -= (car.capacity - car.gas_amount) car.gas_amount += (car.capacity - car.gas_amount) return self.gas_amount else: self.gas_amount -= car.capacity...
48e5bec81dc93a4077ba27fee43afb56c59afb27
green-fox-academy/Chiflado
/week-03/day-03/function_to_center.py
864
3.984375
4
from tkinter import * root = Tk() canvas = Canvas(root, width='300', height='300') canvas.pack() # create a line drawing function that takes 2 parameters: # the x and y coordinates of the line's starting point # and draws a line from that point to the center of the canvas. # fill the canvas with lines from the edges...
f9e9910c7b72d5cd5579931f9b583ceb7a7214b8
green-fox-academy/Chiflado
/week-04/day-01/homework.py
2,851
3.90625
4
class Person(object): def __init__(self, name, age, gender): self.name = name self.age = age self.gender = gender def introduce(self): print('Hey, my name is ' + self.name + ' a ' + str(self.age) + ' years old ' + self.gender) def get_goal(self): print('My go...
ce24d25ec40d6891975b94760e863bbeac493e79
green-fox-academy/Chiflado
/week-04/day-02/garden_app.py
1,819
4.03125
4
class Garden(object): def __init__(self): self.plants = [] def add_plant(self, plant): if plant in self.plants: pass else: return self.plants.append(plant) def watering_garden(self, amount): print('Watering with ' + str(amount)) self.to_...
ac58b91e5dedbf08249ca87912da7de5fb05d267
green-fox-academy/Chiflado
/week-03/day-01/copy_file.py
518
3.671875
4
# Write a function that copies a file to an other # It should take the filenames as parameters # It should return a boolean that shows if the copy was successful def copy_a_file(): first_file = open('my-file.txt', 'r') file_content = first_file.read() second_file = open('copy-of-my-file.txt', 'w+') se...
702e9cd9ea05375d1c55873dc55fb254f0f4900b
green-fox-academy/Chiflado
/week-02/day-03/dictionary-01.py
996
4
4
students = [ {'name': 'Teodor', 'age': 3, 'candies': 2}, {'name': 'Rezso', 'age': 9.5, 'candies': 2}, {'name': 'Zsombor', 'age': 12, 'candies': 5}, {'name': 'Aurel', 'age': 7, 'candies': 3}, {'name': 'Olaf', 'age': 12, 'candies': 7}, {'name': 'Gerzson', 'age': 10, 'candi...
95908f7ea38b97f342408bbdeac0b56f276d74d5
green-fox-academy/Chiflado
/week-02/day-02/matrix.py
539
4.125
4
# - Create (dynamically) a two dimensional list # with the following matrix. Use a loop! # # 1 0 0 0 # 0 1 0 0 # 0 0 1 0 # 0 0 0 1 # # - Print this two dimensional list to the output def matrix2d(x, y): matrix = [] for i in range(x): row = [] for j in range(y): if i == j:...
eccb62bc74d79af4e65142572fdb175ff1ca479d
green-fox-academy/Chiflado
/week-02/day-05/anagram.py
395
4.21875
4
first_string = input('Your first word: ') sorted_first = sorted(first_string) second_string = input('Aaaaand your second word: ') sorted_second = sorted(second_string) def anagram_finder(sorted_first, sorted_second): if sorted_first == sorted_second: return 'There are anagrams!' else: return 'T...
e62c9d6e7df9b65a5694ed25053e0c8c4205255d
sharfaraz-lab/Basics
/Ba_26.py
370
3.671875
4
#Given an array of N elements switch(swap) the element with the adjacent element and print the output. #Sample Testcase : #INPUT #5 #3 2 1 2 3 #OUTPUT #2 3 2 1 3 x=input() y=input() count=0 a=x.split() N,K=int (a[0]),int (a[1]) b=y.split() for i in range(0,N): if K==int(b[i]): count = count+1 else: count = co...
fb866fd9c985734014568513f6ed9dc745c738da
VishwaBharati05/Data-Foundations-with-Python
/HW2_lexicon based classification anf feature selection with twitter JSON file.py
8,086
3.5
4
""" hwcode.py Write the code for the HW exercises in this file. """ # Anthony: HW2 Grade - 38/30 import csv import numpy as np from sklearn.model_selection import train_test_split from sklearn.feature_extraction.text import CountVectorizer from sklearn.svm import LinearSVC from sklearn.svm import SVC from sklearn....
70216c28efe6ab9b58694a49875b13a8805c2e42
IWinnik/complete_python_course
/sets.py
409
3.78125
4
group1 = {"Marta", "Basia", "Wanda"} group2 = {"Irek", "Marta", "Wojtek"} g1_but_not_g2 = group1.difference(group2) g2_but_not_g1 = group2.difference(group1) print(g1_but_not_g2) print(g2_but_not_g1) not_in_g1_neither_g2= group1.symmetric_difference(group2) print(not_in_g1_neither_g2) in_g1_and_g2 = group1.inters...
11b99c3fe9168e98e98a9985b740fbf266d2ad7c
dhitalsangharsha/Djangp
/class/classProperty.py
592
3.9375
4
class Student: num_students=0 def __init__(self,name,age,gender): self.name=name self.age=age self.gender=gender Student.num_students+=1 def print_all(self): print("\nname: " + self.name + " \nage:" + str(self.age) + " \ngender:" + self.gender) def add_marks(sel...
87325d830e5fc9b0f8556921e8e288c02dcc6c27
dhitalsangharsha/Djangp
/Comprehension/filter.py
216
3.515625
4
def test(x): if x: return True else: return False print(test(1)) l=[1,2,"",4,False] print(list(filter(test,l))) fib=[0,1,1,2,3,5,8,13] result=filter(lambda x:x%2==0,fib) print(list(result))
f88d264d7f74d79c8e1f11c8e01849d151abf8b1
dhitalsangharsha/Djangp
/oop/Generator1.py
258
4.09375
4
def mathmatics(x): yield x+x yield x-x yield x*x yield x/x y=mathmatics(3) #print(next(y)) 4 times for each in y: print(each) print('other way') def mathmatics2(x): return [x+x,x-x,x*x,x/x] for each in mathmatics(9): print(each)
f0255e0629b522b8babe535ba702ad2aeabe60b8
dhitalsangharsha/Djangp
/morning/printYes.py
90
3.953125
4
test=input("enter a string") if test.lower =='yes': print('yes') else: print('no')
dd717fe216b7ae96f2a3ab2628ccdb7b82e6381c
dhitalsangharsha/Djangp
/untitled4/files.py
189
3.546875
4
f=open('testing.txt','w') f.write('My name is Sangharsha \n') for i in range(1,11): print(i,file=f) f.close() f=open('testing.txt','r') for line in f: print(line.strip()) f.close()
9759edef59a1e74331f567b75a2a2be9c50f678f
dhitalsangharsha/Djangp
/BasicPython/Questions/question2.py
626
3.984375
4
'''Write a password generator in Python. Default password length is 8 and this default length can be modified according to user's choice. Hint: Use the random module by importing it. import random ''' '''questions link goo.gl/KB7d5b''' import random import string s=string.ascii_letters+string.digits+string.punctuatio...
f9f2fd3c8d40d9374fa0ee1cf6dec8aeca3a0ff0
dhitalsangharsha/Djangp
/practice/multiplicationChart.py
97
3.9375
4
n=int(input("enter a number")) for i in range (1,11): print('{} x {} = {}'.format(n, i, n*i))
6f52eeb81dedf18d2dc0b356e818818a953fcad5
alessandraburckhalter/python-rpg-game
/rpg-1.py
2,163
4.15625
4
"""In this simple RPG game, the hero fights the goblin. He has the options to: 1. fight goblin 2. do nothing - in which case the goblin will attack him anyway 3. flee""" print("=-=" * 20) print(" GAME TIME") print("=-=" * 20) print("\nRemember: YOU are the hero here.") # create a main class to ...
e5c043c3a474a51e950a729021d016457f805638
timmahrt/pysle
/examples/textgrid_alignment_example.py
1,625
3.734375
4
# encoding: utf-8 """ An example of using the naive alignment code. There are two functions for naive alignment. naiveWordAlignment and naivePhoneAlignment. They operate at the word and phone levels respectively. Naive alignment is naive because it gives all phones the same length. Word duration is then driven by t...
a63533833220c6e1a76040a06b64b8eb0a395f0a
studiawan/network-programming
/bab01/list.py
369
4
4
# declaration without elements courses = [] # declaration with elements languages = ['python', 'java', 'c'] print(languages) # fill the list courses.append('progjar') courses.append('j2ee') courses.append(2013) print(courses) # remove specific element by element courses.remove('j2ee') print(courses) # remove specif...
3434e043fe213099c3f650dbc801f84db5b6835e
studiawan/network-programming
/pythonSocket/echoServer.py
962
3.5
4
# import socket module import socket import sys # creating socket server object server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # bind socket server to defined server address and port in tuple server_socket.bind(('localhost', 5000)) # listening connection from client, only 1 backlog server_sock...
88561d8cc5a2b0a3778877fbf87a05d0a378d21d
gssasank/UdacityDS
/DataStructures/LinkedLists/maxSumSubArray.py
805
4.25
4
def max_sum_subarray(arr): current_sum = arr[0] # `current_sum` denotes the sum of a subarray max_sum = arr[0] # `max_sum` denotes the maximum value of `current_sum` ever # Loop from VALUE at index position 1 till the end of the array for element in arr[1:]: ''' # ...
562547cb28e651432ca6be189ebd212e0ba50d31
gssasank/UdacityDS
/PythonBasics/conditionals/listComprehensions.py
784
4.125
4
squares = [x**2 for x in range(9)] print(squares) #if we wanna use an if statement squares = [x**2 for x in range(9) if x % 2 == 0] print(squares) #if we wanna use an if..else statement, it goes in the middle squares = [x**2 if x % 2 == 0 else x + 3 for x in range(9)] print(squares) # QUESTIONS BASED ON THE CONCEPT ...
2ed4d6a0de9d5e4782ed18031a0faf2cbe363556
gssasank/UdacityDS
/PythonBasics/PROJECT/Task2.py
1,056
4.03125
4
""" Read file into texts and calls. It's ok if you don't understand how to read files """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 2: Which telephone number spent the ...
e6908a1fede2583910d752dec6b6af8ddf2a0460
gssasank/UdacityDS
/PythonBasics/functions/scope.py
483
4.1875
4
egg_count = 0 def buy_eggs(): egg_count += 12 # purchase a dozen eggs buy_eggs() #In the last video, you saw that within a function, we can print a global variable's value successfully without an error. # This worked because we were simply accessing the value of the variable. # If we try to change or reassign ...
47a9e70b63baf50c39738e7906b34a142ab5f6b9
nyimeh/MIT-6.00.1x-2015-Solutions
/Final Exam/Problem2_1.py
265
3.5625
4
x = [2,1] y = [2,1] z = False if x == y: if sorted(x) == sorted(y): if x.sort() == y.sort(): z = x.sort() == sorted(y) print z print x == y print x.sort() == y.sort() print x.sort() == sorted(x) print sorted(x) == sorted(y)
1a6685ddfc2a8f2341b1c19e1976dedf379131b4
Winry4/-Intelligent-Systems
/src/State.py
4,889
3.78125
4
import hashlib movements = ["UP", "DOWN", "RIGHT", "LEFT"] class State: """ Coordinate system chosen y ^ | | |---------> x """ def __init__(self, rows, cols, x_tractor, y_tractor, k, max, h, terrain_representatio...
006dc8d3d41608e3ecee53ef09350e01428e5f82
faizjamil/learningally-summer-coding-workshop
/helloWorld.py
285
4.15625
4
#!/usr/bin/python3 # prints 'hello world' print('hello world') # var for name name = 'Faizan' #print 'hello' + name print('Hello ' + name) # loop and print 'hello' + name for i in range(0, 5): if (i % 2 == 0): print('hello world') else: print('Hello ' + name)
d819b37affff59780905e2405f6ff803fd03a487
riley-csp-2019-20/final-exam-semester-1-jonathonflorence4
/2019fallfinalexamCSP.py
1,069
3.765625
4
#2019-20 Fall Computer Science Principles Final Exam #Ms. Haubold #Name jonathon florence # #Date # december 18 2019 #### INSTRUCTIONS #### #Create an etch a sketch turtle game #The turtle should move with the arrow keys (up, down, left and right), and draw #Space should clear the screen #o and p should make the p...
3c36493c37d69c232bfb65a84b084ecc9bfc6b31
madvrix/praxis-academy
/novice/01-01/latihan/4.py
1,362
4.09375
4
###########control flow tools############# #4.1 if statment x=int(input("masukan angka : ")) if x < 0: x=0 print('bilangan negatif diubah ke 0') elif x==0 print('zero') elif x==1: print('single') elif: print('more') #4.2 for kata=['kucing','jendela','lantai'] for w in kata: print(w, len(w)) pr...
a1ffff1093053d83c877840e9ab0c1d8024b43e8
M42-Orion/python-data-structure
/归并算法.py
1,482
3.65625
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @File : 归并算法.py @Time : 2020/03/27 13:49:22 @Author : 望 @Version : 1.0 @Contact : 2521664384@qq.com @Desc : None ''' # here put the import lib ''' 归并排序是采用分治法的一个非常典型的应用,另一个可以采用分治法的是快速排序,归并算法比快速排序速度稍低。归并排序的思想就是先递归分解数组,再合并数组。 将数组分解最小之后,然后合并两个有序数组...
183a73d32c52931c1aa6712f7da2f713a287350f
re-do-ne/machine-learning
/linear_regression.py
6,267
3.609375
4
# In this project we'll try to to use a linear regression model to predict housing prices import requests import io import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split from sklearn.ensemble import ...
3ed642d8be4a458df42ed0c817b482dea79f7772
Sean-Eric-Walters/userWithBankAccounts
/awba.py
1,896
3.734375
4
class BankAccount: all_accounts = [] def __init__(self, int_rate, balance = 0): self.int_rate = int_rate self.balance = balance def deposit(self, amount): self.balance += amount return self def withdrawal(self, amount): if self.balance < 0: print('in...
abc95379a000eeb357b8422836a799aa2cebcb0b
aurbano/enigma_py
/enigma/plug_lead.py
1,145
3.859375
4
class PlugLead: """PlugLead Creates a new plug lead for an Enigma machine :param mapping: Character mapping for this lead, specified as a string with two characters """ def __init__(self, mapping: str): if len(mapping) != 2: raise ValueError( 'PlugLead m...
e0df300240e1a65109e680bf01cc24ef2d4ad53d
rakibul-mahin/dice-simulator
/DiceSimulator.py
1,769
3.96875
4
#------------ LIBRARIES ------------# import random #------------ LIBRARIES ------------# #------------ PROJECT TITLE ------------# print("Project-1 | DICE SIMULATOR") #------------ PROJECT TITLE ------------# #------------ DICE SIMULATOR ------------# #GENERATING RANDOM NUMBER FOR OUR DICE dice_number = random.rand...
deb648157e7a95e8625683ff33bfc53b77f347a0
guys79/SAFARI
/DiagnosisData.py
3,029
3.796875
4
class DiagnosisData(): """ This class will contain the diagnoses """ def __init__(self): """ The constructor of the class """ self.dictionary={} # Component name value - list of diagnoses' indexes self.index=0 def add_diagnosis(self,diagnosis): """ ...
3371ee9259ffcf10129443b0f049c5af1d76eb33
JUNGSUNWOO/Algorithm_study
/acmicpc/21년 1월/20210113/두개뽑아서더하기.py
943
3.734375
4
numbers = [2,1,3,4,1] def solution(numbers): numbers.sort() max = numbers[-1] min = numbers[0] min_hat = numbers[1] max_hat = numbers[-2] table = make_table(max,max_hat,min,min_hat) answer = [] for i in range(0, len(numbers)-1): for j in range(i+1, len(numbers)): ...
3aca7ad945ed8477e0421555b42def48624a4fcd
JUNGSUNWOO/Algorithm_study
/acmicpc/21년 1월/20210131/키패드 누르기.py
3,841
3.578125
4
''' 번호판 배열이 존재 for i in numbers동안 i에 해당하는 번호판에 손가락을 위치 answer에 i지나갈때마다 LorR기록 2,4,8,0인 경우의 수에서 default는 더 가까운 손가락 거리가 같으면 왼손잡이냐 오른손잡이냐에 따라 달라짐 ''' def solution(numbers, hand): answer = '' hand_point = [[0]*4, [0]*4,[0]*4] hand_point[0][3] = 1; hand_point[2][3] = 2 for i in numbers : if i in ...
dfd3457733c0bcd06138a04b255ed5720ecd68af
JeahaOh/Python_Study
/Do_It_Jump_To_Python/1_Basic/03_Ctrl/02_While/02_ExitWhile.py
613
3.609375
4
# coding: utf- 8 def title(titl): print('\n'+'>' * 10 + titl + '<' * 10) title( ' while문 강제로 빠져나가기 break ') coffee = 10 while True: money = int( input('\n돈을 넣어라 냥 : ') ) if money == 300: print('커피를 준다 냥.') coffee -= 1 elif money > 300: print('거스름돈 %d과 커피를 준다 냥.' % (money - 300)) coffee -= ...
12d55c04bd6b9faa3fad9fc41780350ca2c7719d
JeahaOh/Python_Study
/Do_It_Jump_To_Python/1_Basic/05_FlyWithPython/05_EmbeddedFunction/map.py
507
3.75
4
# coding: utf-8 ''' map( f, iterable ) 함수 f와 반복 가능한 iterable 자료형을 받는다. 입력 받은 자료형의 각 요소를 f가 수행한 결과를 묶어서 돌려주는 함수이다. ''' def two_times( numList ): result = [] for num in numList: result.append( num * 2 ) return result result = two_times( [1, 2, 3, 4] ) print( result ) def two_timez( x ): return x * 2 result...
e33f2e44c5cd05d1078c1e14d91dd6135632026c
JeahaOh/Python_Study
/Do_It_Jump_To_Python/1_Basic/05_FlyWithPython/05_EmbeddedFunction/str.py
278
3.53125
4
# coding: utf-8 ''' str( object ) 문자열 형태로 객체를 반환항다. ''' print( str( 3 ) ) print( str( 'Python' ) ) print( str( 'Hell the python'.upper() ) ) print( type( str( (3, 2, 4, 1) ) ) ) print( type( str( [3, 2, 4, 1] ) ) ) print( type( str( {3, 2, 4, 1} ) ) )
53efbb7ec617e271f82a475ac41fe2c1163181ee
JeahaOh/Python_Study
/Do_It_Jump_To_Python/1_Basic/05_FlyWithPython/05_EmbeddedFunction/int.py
285
3.5625
4
# coding: utf-8 ''' int( x ) 문자열 형태의 숫자나 소숫점이 있는 숫자를 정수형으로 반환. int( x, radix ) radix 진수로 표현된 문자열 x를 10진수로 반환 ''' print( int( '4' ) ) print( int( 3.4 ) ) print( int( '1A', 16 ) ) print( int( '11', 2 ) )
9d5ffed0062bed15ae172ae26589eb30fee2e74f
JeahaOh/Python_Study
/Do_It_Jump_To_Python/1_Basic/02_Type/02_String/03_IndexingSlicing.py
1,377
4.25
4
# 문자열의 인덱스와 잘라내기 ㅁ = 'Life is too short, You need Python.' print(ㅁ) print('ㅁ -7 : ' + ㅁ[-7]) # 문자열 슬라이싱. b = ㅁ[0:4] print('ㅁ[0:4] : ' + b) ''' 문자열 슬라이싱은 문자열[시작 idx : 끝 idx]으로, 끝 인덱스는 포함하지 않는다. 시작 idx <= 대상 문자열 < 끝 idx ''' # 끝 idx를 생략하면 문자열의 끝까지 뽑아낸다. print('ㅁ[19:] : ' + ㅁ[19:]) # 시작 idx를 생략하면 처음부터 끝까지 뽑아낸다. print('...
336560ef0f143d083b9b985f8f98b59ed91ee114
ropable/udacity
/cs212/cs212_unit2.py
11,555
4.03125
4
#!/usr/bin/env python ''' CS212 Design of Computer Programs Unit 2 scripts ----------------------------------------------------------------- ''' from __future__ import division import string, re import itertools import time def imright(h1, h2): "House h1 is immediately right of h2 if h1-h2 == 1." ...
9bae84789d0aaf127d537f6dbe9c3b20ad7368d6
ropable/udacity
/cs258/exam4.py
2,544
3.796875
4
#/usr/bin/env python # Enhanced Queue class class Queue: def __init__(self,size_max): assert size_max > 0 self.max = size_max self.head = 0 self.tail = 0 self.size = 0 self.data = {} def __str__(self): return str(self.data) def clear(self): ...
bf241454a3f85a4a99c43e4ee0fbb1386fe437ec
omartrausta/rumastermind
/src/main/mastermind.py
3,456
3.859375
4
# encoding: utf-8 import random import copy from main.row import Row """ Mastermind game class, this class provides the most methods which are required for the gameplay. It has colors list for the random generated guess colors. It has rows which provides list of guessed colors and hints. Number of col...
d1f6baa1c5d7198fe31a9997fcd4e51a35773e47
danhnhan54/maidanhnhan-fundamentals-c4e22
/lab3/homework/ex5.py
206
3.734375
4
from turtle import * def draw_star(x,y,length): penup() setx(x) sety(y) pendown() for i in range(5): forward(length) right(144) # draw_star(30,30,100) # mainloop()
2d6ba11531091f8d4090c1f3509bb0861fa17b1d
danhnhan54/maidanhnhan-fundamentals-c4e22
/web1/homework/ex1.1.py
597
3.53125
4
from flask import * app = Flask(__name__) @app.route("/bmi/<int:weight>/<int:height>") def bmi(weight,height): bmi = weight/(height*height/10000) if bmi < 16: return "BMI = " + str(bmi) + " You are Severely underweight" elif 16<= bmi <18.5: return "BMI = " + str(bmi) + " You are Underweight" ...
e770161ddd3121a20c07c55b6e24527654affc84
danhnhan54/maidanhnhan-fundamentals-c4e22
/session3/homework/ex2_4.py
443
3.90625
4
my_sheeps = [5,7,300,90,24,50,75] print("Hi, My name is Nhan and these are my sheep sizes: ") print(my_sheeps) print() print("Now my biggest sheep has size",max(my_sheeps),"let's shear it") print() p = my_sheeps.index(max(my_sheeps)) my_sheeps[p] = 8 print("After shearing, here is my flock") print(my_sheeps) print() f...
98b44712a83651252f38d9572e52fc9c07189a12
danhnhan54/maidanhnhan-fundamentals-c4e22
/session2/homework/se_2.py
84
3.828125
4
n = int(input("Enter a number ")) s = 1 for i in range(1,n+1): s *= i print(s)
a3ac2bee3f4bf937e90b263b2e48aac3e444f803
danhnhan54/maidanhnhan-fundamentals-c4e22
/session2/sum2.py
124
3.921875
4
n = int(input("Enter a number: ")) r = range (1,n+1) s = sum(r) print(s) # a=0 # for i in range(n+1): # a+=i # print(a)
0055e59e3a2fcd867ff49f048dfc109ab31fe912
danhnhan54/maidanhnhan-fundamentals-c4e22
/session3/validate_pwd.py
268
4.0625
4
while True: pwd = input("Enter your password: ") if len(pwd) >= 8: if not pwd.isdigit(): print("Ok") break else: print("Must contain at least an alphabet character") else: print("Not long enough")
79c2240f8a49cd5848572153e2dab47c2de62cfb
danhnhan54/maidanhnhan-fundamentals-c4e22
/session2/homework/se_1.py
298
4
4
W = int(input("Your weight(kg): ")) H = int(input("Your height(cm): ")) BMI = W/(H*H/10000) print("BMI=",BMI) if BMI < 16: print("Severely underweight") elif BMI < 18.5: print("Underweight") elif BMI < 25: print("Normal") elif BMI < 30: print("Overweight") else: print("Obese")
608010efb2c1a631ba83566dfb422dc81ddb69e1
danhnhan54/maidanhnhan-fundamentals-c4e22
/session3/homework/ex2_5.py
730
3.796875
4
my_sheeps = [5,7,300,90,24,50,75] print("Hi, My name is Nhan and these are my sheep sizes: ") print(my_sheeps) print("Now my biggest sheep has size",max(my_sheeps),"let's shear it") p = my_sheeps.index(max(my_sheeps)) my_sheeps[p] = 8 print("After shearing, here is my flock") print(my_sheeps) m = int(input("Enter nu...
3e0f0850784edb28e181107331eb29251642d804
JainVikas/PythonOOP
/PythonOOP.py
3,997
4.34375
4
# -*- coding: utf-8 -*- """ Created on Sat Dec 23 12:27:28 2017 @author: vikas """ class PreciousStones: def __init__(self): #intialize stoneList self.collectionList=[] def addCollection(self, stoneName): #updateList function if len(self.collectionList)>=5: #if more...
188bd91cfa5302a8cc99c2f09e4aa376c35895b7
gredenis/-MITx-6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python
/ProblemSet1/Problem3.py
1,187
4.25
4
# Assume s is a string of lower case characters. # Write a program that prints the longest substring of s in which the letters occur in alphabetical order. For example, # if s = 'azcbobobegghakl', then your program should print # Longest substring in alphabetical order is: beggh # In the case of ties, print the first...
498387fa82c29b745242110959a6fd142c34fb6d
saigoutham235/python
/binary.py
147
3.59375
4
k=input() count=0 for i in range(0,len(k)): if(k[i]=='0' or k[i]=='1'): count=count+1 if(count==len(k)): print("yes") else: print("no")
89a2d56abc5637dafcef8e96d74f5ad0731f531f
saigoutham235/python
/factors.py
157
3.59375
4
n=int(input("")) for i in range(1,n): if(n%i==0): print(i,end=" ") if(i<n-1): k=" " else: k="" print(n,end=k)
392c4054e98c62feb5eb8e594a74150661d8ff2d
saigoutham235/python
/strp.py
100
3.71875
4
s=input() a,b=s.split() if(len(a)>len(b)): print(a) elif(len(a)<len(b)): print(b) else: print(b)
0fabf643e7ee91a53866caae77a799f4b1cb32cc
chrsT/auction-simulation-dissertation
/CD/Code/Experiment0/hypothesis_0_2.py
202
3.5
4
D = 0.7 M = 0.4 print("H | P") H = 0.0 while H <= 1.05: P = 0.0 P += H**2 * (1-M) P += (1-H)**2 * M P += 2*H * (1-H) * (D + M - 2 * D * M) print("{} | {}".format(round(H,2),round(P,3))) H += 0.05
627d80b6bccd62de7003c15335f62d18890681f2
digirati-co-uk/maldives-iiif-generator
/app/column_keys.py
1,212
3.515625
4
from typing import Dict # Type alias for manuscript row ManuscriptRow = Dict class ColumnKeys: """Contains a list of all column names from manuscript spreadsheet.""" NO = "NO" MHS_NUMBER = "MHS NUMBER" ALTERNATIVE_NAME = "ALTERNATIVE NAME" PAPER_NUMBER = "PAPER NUMBER" ASSOCIATED_ATOLL = "ASS...
b48a2f59d17ed9847879941dc9712ae8c017be2d
sunForest/pythonic-code
/flatten.py
118
3.546875
4
matrix = [[1, 2, 3], [4, 5], [6, 7]] flattened_list = [cell for row in matrix for cell in row] print(flattened_list)
57ac7727d2bd8a518ccba8742dcf9cd06fcfd143
coolgreenmint/zeropython
/上下键选择菜单.py
425
3.625
4
# 通过上下键选择菜单, 没有运行出结果,可能需要在idle中运行 import re print(''' --------------------------------------------- 请选择菜单: ---------------------------------------------- 1. 羊蝎子 2. 红烧肉 3. 肉包子 4. 羊肉串 ''') choose = input("请输入数字或者使用箭头选择:") print(re.sub("\D", "", choose))
c2ac433ef0b0d4a2460b15f60b99db5131712ed7
dejoker95/baekjoon
/기초/1929.py
256
3.734375
4
def isPrime(n): if n == 1: return False for i in range(2, int(n**0.5)+1): if n % i == 0: return False return True m, n = map(int, input().split()) for i in range(m, n+1): if isPrime(i) == True: print(i)
7466967250cb5d9d3b6c0b6784323281ae5df408
dejoker95/baekjoon
/기초/2581.py
329
3.671875
4
def isPrime(n): if n == 1: return False for i in range(2, n): if n % i == 0: return False return True m = int(input()) n = int(input()) l = [] for i in range(m, n+1): if isPrime(i) == True: l.append(i) if len(l) == 0: print(-1) else: print(sum(l)) print...
ca9e670c0cc8cbfa3bc0116ad1ea1b2dce9c5398
dejoker95/baekjoon
/기초/11286.py
1,626
3.546875
4
import sys def push(heap, num): heap.append((abs(num), num)) child = len(heap) - 1 while child > 0: parent = (child - 1) // 2 if heap[parent][0] < heap[child][0]: break elif heap[parent][0] == heap[child][0] and heap[parent][1] < heap[child][1]: break ...
e2b0e471e14293690f0e3bf81fdd64b746e45796
dejoker95/baekjoon
/기초/1003.py
472
3.5625
4
import sys T = int(sys.stdin.readline()) def fibonacci(n): global count if n in count: return count[n] else: a1 = fibonacci(n - 1) a2 = fibonacci(n - 2) answer = [a1[0] + a2[0], a1[1] + a2[1]] count[n] = answer return answer test = [] for _ in range(T): ...
a8adb81882e7c9258af1fe23a903aca31f56e8b8
dejoker95/baekjoon
/기초/3053.py
177
3.71875
4
import math def euclidean(x): return x**2*math.pi def taxi(x): return x**2*2 x = int(input()) print('{0:0.6f}'.format(euclidean(x))) print('{0:0.6f}'.format(taxi(x)))
19d990ea9b35b7224bef4f99aa49bee947abd4ef
dejoker95/baekjoon
/기초/11729.py
234
4.125
4
def hanoi(n, start, dest, other): if n < 2: print(start, dest) return hanoi(n-1, start, other, dest) print(start, dest) hanoi(n-1, other, dest, start) n = int(input()) print((2**n)-1) hanoi(n, 1, 3, 2)
ed364a46d7c747091e72553d65f41baede7ab6ae
georgeC0stanza/python-101-class
/graphical_maze.py
4,455
3.640625
4
import pygame # for drawing to the screen #import pdb #-- used for debugging with this method call pdb.set_trace() # Define some colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = (255, 0, 0) pygame.init() # Set the width and height of the screen [width, height] size = (1300, 7...
272f98a3f9f7616fe1227f5866c9276ae3c79c52
xrud/packStructPy
/conditions.py
116
3.5
4
a = 100 b = 20 if a>b: print (a) elif b>a: #Equivale ao elsif print (b) else: print ('não encontrado')
35547b2301e107c5bca790bbffe97b5102a18290
xrud/packStructPy
/tuplePack.py
300
3.984375
4
tupla = (1,'string',2,2,3,3,3,3,3) #Tuplas são imutáveis. Nâo recebem novos valores print(tupla[1]) # informa índice print (tupla.index("string")) # Informa posição de elemento print (tupla.count(3)) # conta quantas vezes um elemento aparece print (dir(tupla)) # Informa atributos possíveis
87dcc59e4b09f5ba34300197edfa0508fd390495
tkb77/deep-learning-from-scratch-by-yuta
/ch03/activation_function.py
593
3.75
4
import numpy as np import matplotlib.pyplot as plt def step_func(x): y = x > 0 return y.astype(np.int) def sigmoid(x): return 1 / (1 + np.exp(-x)) def relu(x): return np.maximum(0, x) fig = plt.figure() x = np.arange(-5.0, 5.0, 0.1) y1 = sigmoid(x) y2 = step_func(x) y3 = relu(x) plt.plot(x, y1, la...