blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
f1afd9de63b4c778d4c7be5994d259bcb99b823a
marcelomatz/py-studiesRepo
/python_udemy/introducao-python/comportamento-geradores.py
990
3.96875
4
# lists, tuples, str -> Sequences -> Iterável nome = 'Marcelo Matzembacher' iterador = iter(nome) gerador = (letra for letra in nome) print(next(gerador)) print(next(gerador)) print(next(gerador)) print(next(gerador)) print(next(gerador)) print(next(gerador)) print(next(gerador)) for letra in gerador: print(letra...
44069ebdc2ccc6a9e0b13cd5e67b0539b20a8bc5
marcelomatz/py-studiesRepo
/python_udemy/introducao-python/funcao-2.py
535
3.859375
4
# def funcao(var): # return var # variavel = funcao('Valor que eu quero') # print(variavel) # if variavel: # print(variavel) # else: # print('Nada a retornar') # def divisao(n1, n2): # if n2 > 0: # return n1 / n2 # else: # print('Não posso dividir um número por zero') # divide =...
78238441fc78c9fe1c1ba488dc2db3120ed9a3fd
marcelomatz/py-studiesRepo
/python_udemy/introducao-python/dictionary-comprehension.py
494
4.15625
4
lista = [ ('chave', 'valor'), ('chave2', 'valor2'), ] d1 = {x.upper(): y.upper() for x, y in lista} print(d1) print() print('# OU USANDO UM JEITO MAIS SIMPLES \t dict \t PORÉM SEM ALGUNS RECURSOS DE USAR OUTRAS FUNÇÕES NATIVAS') print() d1 = dict(lista) print(d1) # Usando enumerate para criar uma chave - mei...
0a719a2a7ca51c934d4d37861238d51cd08faa5c
marcelomatz/py-studiesRepo
/python_udemy/metodos_magicos/main.py
314
3.671875
4
class A: def __init__(self): pass def __setattr__(self, key, value): if key == 'nome': self.__dict__[key] = 'Operação inválida.' else: self.__dict__[key] = value a = A() a.nome = 'Marcelo' a.qualquer_coisa = 'ISSO PODE' print(a.nome, a.qualquer_coisa)
11d61fa58038c3e79014caf950f9575522104906
marcelomatz/py-studiesRepo
/python_udemy/introducao-python/combinations-permutations-product.py
633
4.0625
4
""" Combinations, Permutations e Product - Itertools Combinação - Ordem não importa Permutação - Ordem importa Ambos não repetem valores únicos Produto - Ordem importa e repete valores únicos """ from itertools import combinations, permutations, product # pessoas = ['Marcelo', 'André', 'Ana', 'João', 'Larissa', 'Silv...
40836d6ef03d53ffb58056150c265ec687fa64ef
marcelomatz/py-studiesRepo
/python_udemy/introducao-python/tuplas.py
452
4.21875
4
""" O que difere Tuplas de Listas é que nas Tuplas não é possível: - alterar o valor das tuplas - alterar o índice - alterar porra nenhuma """ # t1 = 1, 2, 3, 'a', 'Marcelo Matzembacher' # print(t1) # t1 = (1, 2, 3, 4, 5) # t2 = (6, 7, 8, 9, 10) # t3 = t1 + t2 # print(t3, type(t3)) # UMA TUPLA NÃO ACEITA TER SEU ...
2ed50a00186dd9a89b56972ec9bcc92cc9b8fd22
marcelomatz/py-studiesRepo
/python_udemy/programa/mapeamento.py
427
3.5
4
from dados import produtos, pessoas, lista # print(lista) # print() # nova_lista = map(lambda x: x * 2, lista) # print(list(nova_lista)) # nova_lista = [x * 2 for x in lista] # print(nova_lista) # for produto in produtos: # print(produto) def aumenta_preco(p): p['preco'] = round(p['preco'] * 1.05, 2) r...
f789e28a327e721a117fcdcbd4496c62fc5da425
marcelomatz/py-studiesRepo
/python_udemy/introducao-python/list-comprehension.py
425
3.8125
4
""" Otimização Escrever menos linhas de código """ l1 = [1, 2, 3, 4, 5, 6, 7, 8, 9] l2 = [variavel for variavel in l1] ex2 = [v * 2 for v in l1] ex3 = [(v, v2) for v in l1 for v2 in range(1, 11)] l3 = ['Marcelo', 'Nico', 'Gabi'] ex4 = [v.replace('a', '@') for v in l3] # print(ex4) # print(l1) # print(ex2) # print(ex...
80f52074fba8c5eaaa3f3a2a6ece631c33542c6f
FabianOrecchia/basico-python-platzi
/exercises/33_generadorcontrasenas.py
623
3.578125
4
import random def generate_password(): mayusculas = ['A','B','C','D','E'] minusculas = ['a','b','c','d','e','i','o','u'] simbolos = ['!','"','#','$','%','&','/'] numeros = ['1','2','3','4','5','6','7','8','9','10'] caracters = mayusculas + minusculas + simbolos + numeros password = [] ...
5f7c4b34d1211802b3a8eb13dfe2b37544e5b60f
Cakarena/CS-2
/sum_double_f.py
279
4.125
4
def sum_double(a,b): a=int(a) b=int(b) if a == b: sum = (a + b) * 2 print (sum) elif a != b: sum = (a + b) print (sum) sum_double(1,2) sum_double(3,2) sum_double(2,2) sum_double(-1,0) sum_double(3,3) sum_double(0,0) sum_double(0,1) sum_double(3,4)
36028b8aae863b3c6de5d5e1e76f32c6037c7d7f
Cakarena/CS-2
/numprint.py
235
4.15625
4
##Write a Python program that prints all the numbers from 0 to 6 except 3 and 6. ## Note : Use 'continue' statement. Name the code. Expected Output : 0 1 2 4 5 for i in range(0,7): if i==3 or i==6: continue print(i,end='')
1b53d33f11fb4137e0325b0a0592e36fe04562c0
thygu21/algorithm
/16675.py
1,213
3.765625
4
a = input().split() if a[0] == a[1] or a[2] == a[3]: if a[0] == a[1] and a[2] == a[3]: if a[0] == a[2] and a[1] == a[3]: print("?") elif a[0] == "R" and a[2] == "S": print("MS") elif a[0] == "R" and a[2] == "P": print("TK") elif a[0] == "P...
097b292ea5a0d040181ec80c9beb3965f1cacb93
JohnKlaus-254/python
/Python basics/String Operations.py
1,105
4.28125
4
#CONCACTINATION using a plus #CONCACTINATION using a format first_name= "John" last_name = "Klaus" full_name = first_name +' '+ last_name print(full_name) #a better way to do this is; full_name = "{} {}".format(first_name, last_name) print(full_name) print("this man is called {} from the family of {} ".for...
ae35dcbe3b634b1f58cb11b67568619939a3a4d1
JohnKlaus-254/python
/Python basics/Hello_World.py
223
3.828125
4
# the line below will print "hello world" on the console print("Hello World") # the line below calculates # the total of three numbers and stores # the result to variable total. total = 40 + 50+ 32 print(total)
7dd6519daded48e31f9c24276fee8f1c51a19623
GuptaNaman1998/DeepThought
/Python-Tasks/Rock-Paper-Scissors/Code.py
999
4.21875
4
""" 0-Rock 1-Paper 2-Scissor """ import random import os def cls(): os.system('cls' if os.name=='nt' else 'clear') Options={0:"Rock",1:"Paper",2:"Scissor"} # Created Dictionary of available choices poss={(0, 1):1,(0, 2):0,(1, 2):2} # Dictionary of possibilities and the winner value # print("Hi User!") player...
af8a9e968edf794c8ce127194329bf513bad2e10
schw240/07.27-12.1_CLOUD
/python/practice01/model_hero.py
1,067
3.515625
4
class HeroModel: #생성자 메서드 def __init__(self, _nation, _name, _age, _armor, _ishero): self.nation = _nation self.name = _name self.age = _age self.armor = _armor self.ishero = _ishero #클래스 안에다가 메서드를 만듬 def ShowProfile(self): #클래스 안에있는 인스턴스이기 때문에 self를 넣어줘야함...
fe5c215e49b975dcef1005b56325d84434b73e12
Trishuvermatv/Project5-Data-processing-system
/Project 5.py
5,457
3.5
4
from tkinter import * from tkinter import messagebox from db import Database db=Database("Data.dat") def populate_list(): ID_NUMs_list.delete(0,END) for row in db.fetch(): ID_NUMs_list.insert(END, row) updateTextFile() def add_item(): if ID_NUM_text.get()=='' or Name_text...
4e6d021b216d71ac1521e09be3102c79036aa8ff
MrAlpha786/SpaceInvaders
/src/modules/enemy.py
1,198
3.75
4
import pygame from pygame.sprite import Sprite class Enemy(Sprite): """A class to represent a single enemy in the fleet.""" def __init__(self, ai_settings, screen): """Initialise the enemy and set its starting position.""" super().__init__() self.screen = screen sel...
2a8544462102faf24b5c2efca8f591640e496490
darubioc/Misi-nTIC2022
/ActividadesRefuerzo/refuerzoListas.py
5,398
3.921875
4
import random lista = [0] lista_copia =[-1] #Creación de método que llenará la lista de manera manual o automática con números al azar def llenar_lista(): ciclo=True cont = 0 while ciclo: llenado = input("Digite 1 si desea llenar la lista manualmente. \n" "Digite 2 si desea g...
2988301ee396a8c911d2e5ee982dbfd603362444
evansnyds/UPE-Coding-Challenge-Fall-2018
/source.py
4,208
3.78125
4
'''Every maze is zero-indexed in the API, current_location is [x, y]''' import requests def mazeConstructor(size): '''Takes the size of a maze [width, height] and outputs a 2d array representing the maze, The maze is also surrounded by walls, making point (0, 0) in the original maze becomes (1, 1) where an 'x...
820e118f01caca0753e44222e9f1e0d796792cd0
ssiedu/python-string
/string-5.py
486
3.984375
4
#string-operators s1="python" s2="program" s3=s1+s2; #concatination s4=s1*3; #replication print(s1); print(s2); print(s3); print(s4); s5="indore"; s6="india"; s7="India"; b1=s5==s6; b2=s5>s6; b3=s5<s6; print(b1); print(b2); print(b3); s8="this is java"; b4="is" in s8; b5="is" not in s8; print(b4); print(b5); res...
65cf3d90567d24fef3c7e4adc2c04e12675859da
ShaotuJia/CMSC421_Project2
/initial.py
1,382
3.53125
4
#!/usr/bin/env python3 import json import random import time random.seed(time.time()) # The random seed is the current system time # randomly generate binary operation def binary_operator() -> object: b_list = ["+", "-", "*"] b_index = random.randint(0,2) return b_list[b_index] # randomly generate u...
bad781573af3ef5c833594f5f68bdae9782937a5
znehraks/backjoon_algorithm
/PythonDS/Sort/bubble_sort.py
346
3.90625
4
''' Bubble Sort 학번:60152572 이름:유정민 ''' def bubble(data): for i in range(len(data)): for j in range(len(data)-i-1): if data[j] > data[j+1]: data[j], data[j+1] = data[j+1], data[j] # print(data) return data data = [5, 9, 6, 1, 3, 2, 7, 4, 8] data = bubble(data) ...
1cab5ebdc6f62a74d76e5f6387271a40330cc449
znehraks/backjoon_algorithm
/PythonDS/linked_list.py
7,024
3.953125
4
""" 아래에 학번과 이름을 꼭 적으세요. 학번:60152572 이름:유정민 """ class LinkedList: class Node: def __init__(self, value): self.value = value # 받은 value를 self.value에 저장 self.next = None # 받은 next를 self.value에 저장 self.prev = None # 받은 value를 self.val...
0684a0d2f45a589feca0e0a6adbd6921792f1aa0
znehraks/backjoon_algorithm
/PythonPractice02/bracket.py
663
3.90625
4
from stack import Stack def check(mul): stack = Stack() for i in mul: if i == "(": stack.push(i) elif i == "{": stack.push(i) elif i == "[": stack.push(i) elif i == ")": if stack.pop() == "(": pass else:...
5eff44185b95a9aa4e473cd03b9569c679ca6c8f
znehraks/backjoon_algorithm
/PythonDS/Sort/selection_sort.py
384
3.796875
4
''' Selection Sort 학번:60152572 이름:유정민 ''' def selection(data): for i in range(len(data)): min_idx = i for j in range(i+1, len(data)): if data[j] < data[min_idx]: data[j], data[min_idx] = data[min_idx], data[j] # print(data) return data data = [5, 9, 6, 1, ...
9cc11d0af34b22f74c360be588013b9a2bbc8331
znehraks/backjoon_algorithm
/PythonPractice02/No1874.py
1,115
3.625
4
# class Stack: # items = [] # def push(self, item): # self.items.append(item) # def pop(self): # return self.items.pop() # def is_empty(self): # return not self.items # def peek(self): # return self.items[-1] # case = int(input()) # num_list = [int(input()) for _...
72afb1ab861e05134b4e3bc6a7b33f40c7648b16
znehraks/backjoon_algorithm
/PythonPractice01/func01.py
1,736
3.828125
4
def simple_adder(a, b, c): result = a+b+c return result print(simple_adder(1,2,3)) def func1(var1, var2): result = var1**2 - var2**2 return result print(func1(4,3)) def input_sum(*numbers): sum = 0 print(numbers) for i in numbers: sum += i return sum print(input_sum(1,2,3,4,...
ce4fe060c3a35b03a49650e8aa385dc68d42715d
alexhohorst/MyExercises
/ex3.py
844
4.28125
4
print "I will now count my chickens:" print "Hens", 25 + 30 / 6 #adds 25 and 30 and divides this by 6 print "Roosters", 100 - 25 * 3 % 4 #substracts 25 from 100, multiplies with 3 and divides by 4, returning the remainder print "Now I will count the eggs:" print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 #adds 3 and 2 and 1,...
3ed2cb834bd6d838c585d8d0d5fd53b47f5649fc
JYS1/Test02---Python
/Admenu/sum.py
1,383
3.515625
4
#!python import sys # 한글 출력하기 위해서 import codecs # 한글 출력하기 위해서 sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach()) print("Content-Type: text/html;charset=utf-8\r\n") name = open('order_name', mode='r', encoding='utf-8') money = open('order_money', mode='r', encoding='utf-8') name_split = name.read().split(',')...
3d020fff3a2d03f34bf6618a66dfb3b95284b5d4
Falakwaraich123/Data-Display-on-Piechart
/Dataplot1.py
339
3.515625
4
from matplotlib import pyplot as plt import numpy as np # Creating dataset labels = ['Cookies', 'Jellybean', 'Milkshake', 'Cheesecake'] cars = ['WINDOW-OS', 'ANDROID-OS', 'LINUX-OS', 'MAC-OS'] data = [77.74, 74.43, 65.5,53.33] # Creating plot fig = plt.figure(figsize=(10, 7)) plt.pie(data, labels=cars) # sh...
61334b27b44a82dbceac57194b67e915fd739337
MatthewHawkins/SWE2_HW4
/Part_3/test_names.py
417
3.578125
4
import generate_name as names import unittest class test_names(unittest.TestCase): def test_name_1(self): self.assertEqual(names.create_name("Matthew", "Hawkins"), "Matthew Hawkins") def test_name_2(self): self.assertEqual(names.create_name("123", "456"), "ERROR") def test_name_3(self): ...
4679540092a7c6d0ef1ff4fcfe7028fe32147cfb
rodrigolins92/exercicios-diversos
/AnaliseTexto.py
447
4.0625
4
seu_nome = str(input("Digite o seu nome completo: ")).strip() print("Seu nome em maiúsculas é: {}" .format(seu_nome.upper()) ) print("Seu nome em minúsculas é: {}" .format((seu_nome.lower())) ) print("Seu nome ao todo tem {} letras" .format(len(seu_nome) - seu_nome.count(' ')) ) ...
aefb2fff5928c98a5caaa76310127c48ee3eadd5
rodrigolins92/exercicios-diversos
/fibonacci.py
213
3.5625
4
lista_fibo = [] auxiliar1 = 1 auxiliar2 = 1 lista_fibo.append(auxiliar1) for i in range(10): auxiliar1 = auxiliar2 - auxiliar1 auxiliar2 += auxiliar1 lista_fibo.append(auxiliar2) print(lista_fibo)
e74345c6e58a594de71afcdf721a9ac179462da9
mgonzalez14291/EjerciciosPython
/Ejercicios/Python1.py
159
3.71875
4
print ("Excelente, empezamos") num1 = 1 num2 = 2 suma = num1 + num2 print ("Los mejores numeros son:" , suma , " ") print ("YAy! Me pegue en los meniscos!!!")
9e9bebf932ce79a915cc002529250388da67478b
Dalliya/Home_Work
/Task_3.py
205
3.6875
4
a = 5 b = 12 c = 89 result = (a + b) / 12 * c % 4 + b print("Результат выражения (a + b) / 12 * c %% 4 + b при a = %d , b = %d и c = %d равен: %.3f" % (a, b, c, result))
e2af010191abd7e3549a9a682a376ca1e519f224
Dalliya/Home_Work
/Task_16.py
858
3.9375
4
#Два поезда движутся на скорости V1 и V2 навстречу друг другу. Между ними 10 км. пути. Через 4 км пути первый поезд может свернуть на запасной путь. #При заданных скоростях узнать столкнутся ли поезда. #def have_trains_crashed(v1, v2): # returns boolean value # pass v1 = int(input("Введите скорость первого поезда:...
0a5a7f572a8f7f69d180963f5e60c71d941922d7
sptechguru/python-Core-Interview
/Array/sumArray.py
217
3.8125
4
def sum(arr): sum = 0 for i in arr: sum =sum + i return(sum) # driver functions is run this code arr = [] arr = [12,3,4,1] n = len(arr) ans = sum(arr) print('sum of the array is ',ans)
e460f508e81e02bed05092b2f1b6a731785f9f48
sptechguru/python-Core-Interview
/Datastructure/Bubble_sort.py
339
3.953125
4
def bubble_sort(arr): for i in range(len(arr)): for j in range(len(arr)-i-1): if arr[j] > arr[j+1]: arr[j],arr[j+1] = arr[j+1],arr[j] return arr mylist = [85,56,3,20,7,6,2,1,0,1000] alist = ['s','a','n','t','o','s','h'] print(bubble_sort(mylist)) print(bubb...
8feadece0e5459fa7c9323550be42e5d88c14da1
sptechguru/python-Core-Interview
/Factorial.py
257
4.25
4
def factorial(n): if(n<=1): return 1 else: return(n*factorial(n-1)) n = int(input("Enter an Number:")) print("Factorial number is:", factorial(n)) # Output is: # Enter a Number : 5 # 1x2x3x4x5 =120 # Factorial number is: 120
0cd84863162f0a3e030a62dbcf0598fc48901b8a
sptechguru/python-Core-Interview
/Fibronics_series.py
209
3.859375
4
def fab(n): if(n<=1): return n else: return(fab(n-1) + fab(n-2)) n = int(input("Enter an Number:")) for i in range(n): print( fab(i),end=",") # Output is: # Enter a Number : 5
a2423e5fcf4a1eb291cf066c94b140023fd3bc83
xiaoli777/PLForecastingPlatform
/ForcastingAlgorithm/diagram_test_1.py
773
3.75
4
import pandas as pd import seaborn as sns import matplotlib.pyplot as plt data = pd.read_csv('Advertising.csv') print(data.head()) #create a python list of feature names feature_cols = ['TV', 'Radio', 'Newspaper'] # use the list to select a subset of the original DataFrame X = data[feature_cols] # equivalent command ...
f42baa940f6d4b76b0928c77ceedf697b16257c5
xiaoli777/PLForecastingPlatform
/test/TryExceptError.py
832
3.90625
4
#ValueError while True: try: x = int(input("number:")) print(x) break except ValueError as VE: print("ERROR: {0},\n" "ERRORType: {1},\n" "ERRORArgs:{2},\n" "Try again".format(VE,type(VE),VE.args)) #raise NameError('HiThere1') class MyEr...
becf36f2796312caf28b3dafabed7f5b49e1c14b
xiaoli777/PLForecastingPlatform
/test/String.py
759
3.75
4
#String print('spam eggs') print('doesn\'t') print("doesn't") print('"Yes," he said.') print("\"yes,\" he said.") print('"Isn\'t," she said.') s = 'First line.\nSecond line.' print(s) print('C:\some\name') print(r'C:\some\name') print("""\ Usage: thingy [OPTIONS] -h -H hostname """) print(3 * 'un' + 'ium') ...
890693be3645df45ce25bde8b6b44b64681f58aa
Supasiti/problem_manager
/services/setting_parser.py
784
3.5
4
from abc import ABC, abstractmethod import json class SettingParser(ABC): # based setting parser to read/write configuration on loading / change def load_config(self, filepath:str) -> object: with open(filepath, 'r') as fid: raw_data = json.loads(fid.read()) fid.close() ...
521bc3eae05a203c517834f77287bbdeb9bd9d29
guswns00123/Start
/Dynamic Programming(Fabonichi).py
212
3.59375
4
import sys num =int(sys.stdin.readline()) def fib(n): f = [0] * (n+1) f[0] = 1 f[1] = 1 for i in range(2,n+1): f[i] = f[i-1] + f[i-2] return f[n-1] print(fib(num))
e829451b472d9d77673732afa4d675ec83c85309
mastoltejr/advent_of_code_2020
/day2/Michael/answer2.py
1,072
3.640625
4
import re regex = re.compile('^([0-9]+)-([0-9]+) ([a-z]{1}): ([a-z]+)') def sledPolicy(): correct_count = 0 with open('input2.txt', 'r') as policies: for policy in policies: (min_count, max_count, letter, password) = regex.search(policy).groups() count = password.count(letter)...
c00f26a40237c576be71cb16bc5b5a02d9ec9b90
mastoltejr/advent_of_code_2020
/day1/Michael/answer1.py
1,157
3.765625
4
def twoSum(): options = {} with open('input1.txt', 'r') as numbers: for number in numbers: number = int(number) if options.get(number, None) is not None: print('{}+{}=2020'.format(number, options[number])) print('{}*{}={}'.format(number, ...
ed76b7dcff3983ff603e48aed141c17bd6c78639
mmidzik/CVND_Exercises
/Project1/models (2).py
3,637
3.53125
4
## TODO: define the convolutional neural network architecture import torch import torch.nn as nn import torch.nn.functional as F # can use the below import should you choose to initialize the weights of your Net import torch.nn.init as I class Net(nn.Module): def __init__(self): super(Net, self).__init_...
43b4fc0e2f49e76d5acfe39660b8c7f0b1798b51
rishabh0102/Python-Programming
/Connect Four/Main.py
3,363
4.1875
4
import random def create_grid(height, width): """ creates and returns a 2-D list of 0s with the specified dimensions. inputs: height and width are non-negative integers """ grid = [] for r in range(height): row = [0] * width # a row containing width 0s grid += [row] return...
df8a62b173429411483b6b4f8fbbc413d8f0e107
iamJohnnySam/WebScraping
/02_ScrapingUniversityCourses/BaseCode2.py
647
3.609375
4
# https://johnsamarasinghe.blogspot.com/2020/12/scraping-university-courses-part-1.html from selenium import webdriver from bs4 import BeautifulSoup as BS driver = webdriver.Chrome("chromedriver.exe") courses = [] def getSite (name, web, tag, value): driver.get(web) content = driver.page_source soup = B...
868f57a584bde6bbc41ec9d85029d76f5cd7e647
Purcell-Kevingithub/WebScraper
/weather_scrape.py
984
3.59375
4
# Script to pull weather from bs4 import BeautifulSoup import requests import csv # Instantiate variable to access webpage and parser to seperate HTML source = requests.get("https://weather.com/weather/tenday/l/USNJ0524:1:US").text soup = BeautifulSoup(source, 'lxml') # Open csv file to store weather details csv_file...
b50e56e9fb62de721e3c5de29a47664e1a22a43a
thexiang/thexiang.github.io
/udacity/Intro_to_Hadoop_and_MapReduce/reducer4d.py
743
3.53125
4
#!/usr/bin/python import sys # the input is of the format: day_of_week \t sale_amount old_day = None count = 0 sales = 0 for line in sys.stdin: data = line.strip().split("\t") if len(data) != 2: # Something has gone wrong. Skip this line. continue # same day --> add to the sales count ...
36f404f63f43196ad9f95112d5b0785639f75e77
Benature/ToyBox
/宣传部作业点评随机点人.py
1,292
3.5625
4
# author: Benatuer # date: 2018.10 ''' 背景: 给部员安排了PS作业, 需要每个部员随机给另一个部员 点评一下对方作品, 然后再随机一位部长层做最终点评. ''' from random import randint, choice data = { '部员A': '青葱高三骄阳行', '部员K': '国金团委学术部', '部员L': '中珠幻境', '部员N': '中珠排协', '部员E': '街舞社招新', '部员f': '关爱老人', '部员Z': '民乐团招新', '部员C': 'UFO街舞大赛', ...
dda3f19569180b17a1b648538500dacf5dbc4cf1
edithjepletingketer/Shapes
/shapes.py
1,143
4.03125
4
class Circle: def __init__(self,radius): self.radius = radius def area(self): radius = self.radius a = (22/7)*radius*radius print(a) def circumference(self): radius = self.radius C = 2*(22/7)*radius print(C) class Square: def __init...
abe0249fd5c006d2979d15a1e77d66eecdc62023
ascurlock/Scurlock-Math361B
/IntroToProgramming/Calculator_Scurlock.py
622
3.78125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jan 30 12:04:42 2019 @author: Ashley """ #%% #Initialize Values x = 1 y = 1 z = 1 mylist = [] mylist.append(x + y) #first component mylist.append((y * z) + (3 * x)) #second component mylist.append(mylist[0]**2) #third component mylist.append((2*mylist[...
eeb6223cc4d2f1ccf54f44d5b0f4157a2a26712c
Sinedd231/2I013-groupe4
/current/MVC/model/abstract_polygone.py
929
3.625
4
# CLASSE ABSTRAITE class Polygone(object): def __init__(self): pass # retourne a partir d'une liste de vecteurs, les cotes correspondants # vu que le code est le meme peu importe la classe qui l'utilise, on le # factorise ici def getCotes(self): """retourne un tableau ...
3931e91a75192e7918accb5cd5e8128df0334298
Victurker/2143-OOP-Nnabuenyi
/Assignment/fraction_class.py
1,613
3.921875
4
""" Name: Victor Nnabuenyi Email: victurkernabs@yahoo.com Assignment: Homework 2 - Python intro Due: 26 Sep @ 1:00 p.m. """ ```python class fraction (object): def __init__(self, whl=whole, n = None, d = None): if whl: self.whole = whl else: self.whole = 0.0 self.nume = n + self.whole * d self.deno...
987e8cfffe95027b23f15133ae22c855e9888edd
HDU-PanZeyu/CPO-lab1
/src/mutable/mutable.py
6,990
4
4
class Node(object): def __init__(self, data=None, next=None): self.key = None self.data = data self.next = next def __repr__(self): if self.key != None: return "<Node key: %s data: %s>" % (self.key, self.data) else: return "<Node key: %s data: %s>...
36186863d577f93af031b19f34fc7f696b1407ba
sagarrjadhav/Problem-Solving-in-Data-Structures-Algorithms-using-Python
/Collections/Dictionary.py
642
3.890625
4
from collections import OrderedDict class MyClass: @classmethod def main(cls, args): """ generated source for method main """ a = {} a["apple"] = 40 a["banana"] = 10 a["mango"] = 20 print a print a["mango"] print a.get("mango") ...
436f6c265e92ee890a4653f2895c58857bd0d03c
sagarrjadhav/Problem-Solving-in-Data-Structures-Algorithms-using-Python
/IntroductoryChapters/type.py
740
3.609375
4
#!/usr/bin/env python class TypeDemo(object): @classmethod def main(cls, args): value1 = sys.maxint value2 = value1 + 1 value3 = 13.05 value4 = 3.14j value5 = "hello, world!" print type(value1),value2, type(value2), type(value3),...
2ec59d3d71f01698706c24aa14c08ed2f6653bba
sagarrjadhav/Problem-Solving-in-Data-Structures-Algorithms-using-Python
/LinkedList/LinkedList.py
11,596
4.09375
4
#!/usr/bin/env python class LinkedList(object): # Node class representing elements of linked list. class Node: def __init__(self, v, n=None): self.value = v self.next = n # Constructor of linked list. def __init__(self): self.head = None ...
e072eeab6c0bcf647235bf5276f0df22ed9d8337
sagarrjadhav/Problem-Solving-in-Data-Structures-Algorithms-using-Python
/BinaryTree/Tree.py
22,263
3.625
4
#!/usr/bin/env python from collections import deque class Tree(object): class Node(object): def __init__(self, v, l=None, r=None): self.value = v self.lChild = l self.rChild = r def __init__(self): self.root = None def levelOrderBinaryTree(self,...
4c93b4f9832608a8ce13860680116b824693fb70
sagarrjadhav/Problem-Solving-in-Data-Structures-Algorithms-using-Python
/Stack/StackArr.py
885
3.859375
4
#!/usr/bin/env python class Stack(object): def __init__(self): self.data = [] def size(self): return len(self.data) def isEmpty(self): return (len(self.data) == 0) def push(self, value): self.data.append(value) def top(self): if self.is...
253b8e0a3fa120a0ebe6433227786304ab8e5c1e
sagarrjadhav/Problem-Solving-in-Data-Structures-Algorithms-using-Python
/HashTable/HashTableLP.py
2,587
3.515625
4
#!/usr/bin/env python class HashTable(object): EMPTY_NODE = -1 LAZY_DELETED = -2 FILLED_NODE = 0 def __init__(self, tSize): self.tableSize = tSize self.Arr = [0] * (tSize + 1) self.Flag = [self.EMPTY_NODE] * (tSize + 1) i = 0 while i <= tSize: ...
54fb785419f9408bfdc10fae516e5b11e823c19d
EricJohnson101106/InternetProgramming
/ej_rest_client.py
1,544
4.03125
4
# Eric Johnson # CS47220 - Internet Programming - Summer 2019 # Assignment 5 - Simple REST Client # Get current weather data for a zip code and print data to a table. # API Key ERASED # http://api.openweathermap.org # installed the requests library https://2.python-requests.org/en/master/ # https://www.w3schools.com/py...
571ff764386e7575018912297f77f7af1c24f7ff
peiqi2019/hdpython3
/hardway/ex18.py
412
4.09375
4
# coding=utf-8 # 函数定义与调用 def print_two(*args): arg1, arg2 = args print(f"arg1: {arg1}, arg2: {arg2}") def print_two_again(arg1, arg2): print(f"arg1: {arg1}, arg2: {arg2}") def print_one(arg1): print(f"arg1: {arg1}") def print_none(): print("I got nothing.") print_two("Come on", "Baby") p...
706820d849044eea4d1c27ed319e94ea1a607719
Patrali27/Decision-tree
/decisiontree.py
10,098
3.671875
4
import math import sys def select_best_attribute(data, attributes, target): # method to select the best attribute to start a node best_attribute = attributes[0] max_information_gain = 0 for attribute in attributes: # checking for the attribute with highest information gain if attribu...
f494f59caa548f497bd1d3825fd5448ac3cff339
MReeds/Classes-Practices
/pizzaPractice/classes.py
1,021
4.4375
4
#Add a method for interacting with a pizza's toppings, # called add_topping. #Add a method for outputting a description of the #pizza (sample output below). #Make two different instances of a pizza. #If you have properly defined the class, #you should be able to do something like the #following code with your Pizza ...
7d09abb051af825c388fd137262c97f630fa180e
michael-luk-i-man/Michael-Lukiman-Fun-Algos-10
/FA10 1-2.py
1,160
3.625
4
# FA10 1.2 # Find D of a tree graph. def DFS-modified(G): """ Initialize unexplored nodes and search each node. """ for each U \belonging_to G.v: u.color = white # Unexplored u.parent = NIL # \pi t = 0 global largest = -inf # global second_largest = -inf # global depth_counter = 0 # for each u \bel...
4577573df7b0866f4ee5e4fb46d6b4de38fea7c0
11810729/python-programming
/fibonacciseries.py
272
4.125
4
nterms=10 n1=0 n2=1 count=0 if nterms<=0: print("please enter a positive integer") elif nterms==1: print("Fibonacci sequence upto",nterms,":") print(n1) else: print("Fibonacci sequence upto",nterms,":") while count<nterms: print(n1,end=',') nth=n1+n2 n1=n2 n2=nth count+=1
4eace231355bb12862f2a87a94a66cc52be22f5a
pawelgoj/Examples-of-some-algorithms
/dynamic_programing.py/dynamic_programing..py
5,047
4.4375
4
# ----------------------------------------------------------- #Example of dynamic programing #(C) 2021 Paweł Goj, PL # Released under MIT license # ----------------------------------------------------------- import json import numpy as np #Read item list from json file. items have a given value and occupy a certain...
0249afc33daac4153858db1468741a203ec1b30e
hai1992/study_python
/tcp_server.py
3,089
3.515625
4
import socket """ 重点代码 tcp套接字服务器端流程 1创建服务器端套接字 sockfd = socket.socket(family=AF_INET, type=SOCK_STREAM, proto=0) family:网络地址,默认ipv4,用AF_INET表示 type:套接字类型,默认SOCK_STREAM(流式),SOCK_DGRAM(数据报式) proto 通常为0 作用选择子协议 2绑定地址blid sockfd.blid(addr) 地址格式addr (“ip”,端口号) 本地地址:"localhost","127.0.0.1" 网络地址: ifconfig 获取网络地址 自动获取地址:"0.0....
dd74b27735f49f6ecaaf94afb8bc3ead762b6fab
dhruvagnreddy/APS-2020
/Day_of_the_Programmer.py
305
3.765625
4
import sys def solve(year): if(year == 1918): return "26.09.1918" if (((year%4 == 0 and year%100 != 0) or year%400==0) and year>=1917) or (year<=1917 and year%4 == 0): return "12.09.%d" %(year) return "13.09.%d" %(year) year = int(input().strip()) result = solve(year) print(result)
fe6fdaf6c08aef7bee443291e69193b2c1fe1e87
kdeng/python-tutorials
/13.oop/student.py
293
3.828125
4
# -*- coding: utf-8 -*- class Student(object): name = 'Student' def __init__(self, name): self.name = name; s = Student('bob') print("Before delete attribute") print(s.name) print(Student.name) print("After delete attribute") del s.name print(s.name) print(Student.name)
534c453b12c62ec0d22679f3c5471efc6a1029f5
kdeng/python-tutorials
/10.advance_funcs/do_sorted.py
396
3.65625
4
# -*- coding: utf-8 -*- from operator import itemgetter L = [('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88)] def by_name(t): return t L2 = sorted(L, key=by_name) # print(L2) # def by_score(s): # return # L3 = sorted(L, key=by_score) # print(L3) print(sorted(L, key=itemgetter(0))) # print(sorted...
8f6388ecb69e08c78534daf6d4d3af1daa3b52a1
kdeng/python-tutorials
/18.multithprocessing/do_folk.py
706
3.6875
4
# -*- coding: utf-8 -*- ''' this is a demo code for folk a single process folks multiple child processes ''' import os print('Process (%s) start ...' % os.getpid()) pid = os.fork() if pid == 0: print("# I am child process (%s) and my parent is %s." % (os.getpid(), os.getppid())) else: print("* I (%s) just ...
bfee98af27252f8716b67ca693c4e9b530e094e0
SethMiller1000/Portfolio
/Foundations of Computer Science/Practice 3.45.py
196
4.03125
4
weight = float(input("Enter weight in kg: ")) if weight < 0 : print("Error: weight cannot be negative.") elif weight > 10 : print("Error: Weight > 10 kg. ") else: print(weight)
bf49ad63a8611cdbcfc34e384f940d47e9eed772
SethMiller1000/Portfolio
/Foundations of Computer Science/Lab 11- String Contents.py
1,202
4.28125
4
# The String Contents Problem- Lab 11: CIS 1033 # Seth Miller and Kaitlin Coker # Explains purpose of program to user print("Hello! This program takes a string that you enter in and tells you what the string contains.") # Ask user for string userString = input("Please enter a string ---> ") # Tests if it co...
74a25f4969bc732424c26c88dc80441e2f4f499d
SethMiller1000/Portfolio
/Foundations of Computer Science/Lab 17- Training Heart Rate.py
1,034
4.21875
4
# The Training Heart Rate Problem # Lab 17: CIS 1033 # Author: Seth Miller # function that calculates training heart rate # based on age and resting heart rate def trainingHeartRate( age, restingHeartRate ) : maxHeartRate = 220 - age result = maxHeartRate - restingHeartRate result2 = result * 0.60...
86c71879c7acdd3d89ef6bb422301390abd4dd6f
SethMiller1000/Portfolio
/Foundations of Computer Science/countdown.py
177
4.0625
4
n = int(input("Enter a positive integer: ")) message = "" for n in range(n, -1, -1): value = ((str(n)) + "...") message = message + value print(message + "Liftoff")
bd4bf3185496a137ef716b6188082d27b9f084e8
SethMiller1000/Portfolio
/Foundations of Computer Science/Lab 9- Electric Bill.py
1,048
4.25
4
# The Electric Bill Problem- Lab 9 CIS 1033 # Author: Seth Miller # Input: receives the meter reading for the previous # and current month from the user prevMonthMeterReading = int(input("Meter reading for previous month: ")) currentMonthMeterReading = int(input("Meter reading for current month: ")) # Input: ...
e23f24a0ffa6f95427f048eb94c9fd272aa6011b
SethMiller1000/Portfolio
/Foundations of Computer Science/Chapter 4 Practice.py
378
3.921875
4
# Python for Everyone Chapter 4 -Loops- Self Check # Author: Seth Miller RATE = 10.0 INITIAL_BALANCE = 10000.0 TARGET = 2 * INITIAL_BALANCE balance = INITIAL_BALANCE year = 0 while balance < TARGET : year = year + 1 interest = balance * RATE / 100 balance = balance + interest print(bala...
15155716d0578aa3a8ba92f97867655521368133
ThomasPickles/DailyCodingProblem
/ListIntersection/ListIntersection/Problem6.py
1,430
3.796875
4
address_map = dict() class Node: def __init__(self, data: str): # implement using "pointers" to memory self.address = id(data) self.prev = 0 self.next = 0 address_map[self.address] = data def __repr__(self): return self.address def append_to_end(se...
ac1d8c2863e7e6f902c42e9e2dc6fccadf54d4a8
sushantMoon/Personal-Development
/Code Jam 2017/Qualification/Pancakes/panckaes.py
663
3.65625
4
def flipper(line,k): count = 0 pos = 0 while(pos < len(line)): if line[pos] == '+': pos += 1 else: if line[pos] == '-': count += 1 for i in range(k): value = pos + i if value >= len(line): return "IMPOSSIBLE" elif line[value] == '-': line[value] = '+' else: lin...
58e492d032b7c21f7feca06161c9f4ede2f8cc8a
sushantMoon/Personal-Development
/Geeks4Geeks/inplace_quick_sort.py
1,063
3.671875
4
""" * Author Sushant Moon * Email sushant.moon@gmail.com * Create date 2018-07-19 12:29:34 * Modify date 2018-07-19 12:29:34 * Description QUick Sort Inplace As discussed in the class of 19 July 2018, Probability and Stochastic Processes """ from random import randint def swap(A, i , j): A[i], A[j] = A[j], A[...
0387547ae5790689fe384843d71aea1f483b7389
xavieryang/ECE448-CS440
/mp2/search.py
2,194
4.03125
4
# search.py # --------------- # Licensing Information: You are free to use or extend this projects for # educational purposes provided that (1) you do not distribute or publish # solutions, (2) you retain this notice, and (3) you provide clear # attribution to the University of Illinois at Urbana-Champaign # # Created...
85e0ae7bdd426af55011e490eed2155b19d2759b
EdoardoCarlesi/PySpark
/04_dataFrame.py
1,229
3.625
4
import pyspark from pyspark.sql import SparkSession from pyspark.sql.types import StructField, StringType, IntegerType, StructType from pyspark.sql.functions import countDistinct, avg, stddev, format_number, mean spark = SparkSession.builder.appName('aggs').getOrCreate() base_path = '/home/edoardo/Udemy/PySpark/Pytho...
4a0ce8883623346d1e936943596ae65f9f1c451b
riturajreso/Python
/ex33.py
244
3.65625
4
i = 0 numbers = [] def insert_data(n): global i while i < n: print "No at the top is %d" %i numbers.append(i) i = i + 1 print "Numbers are ", numbers print "No at the bottom is %d" %i for x in numbers: print x insert_data(5)
98c095dc1a504fbcc79d3a294a98b91957562ab7
rtk4616/Python3Learn
/wxl_input.py
166
3.640625
4
# 等待用户输入 name = input() # 提示输入 print('你好,', name) name = input("请输入名字:") # 提示请输入名字: print('你好,', name)
9be1d4debe3dace979736706007a4b73ecff34e4
lsqLoveCoding/ecga-tsp
/util/Parser.py
811
3.734375
4
""" Parse data in the data/ directory. Given the filename of a tsp file, return a dictionary containing the data given in the file. """ def parse(file_name): data = {} # data consisting of fields such as NAME, TYPE and the map itself mp = [] # link map to data data['map'] = mp node_section = F...
73a5d09022fb6d2f68ac42c736fa2ab45a7974f5
IrisYanfGuo/dataRep
/Exercise3/stochasticGD.py
3,862
4
4
# Step 1: Load dataset, split into training and test sets, and scale features import numpy as np from sklearn.datasets import load_boston # load boston housing price dataset boston = load_boston() x = boston.data y = boston.target # split into training and test sets, namely 80 percent of examples goes for the traini...
cc359b8a57dd0aee3935d70bb0241f234c0cb754
sskii/DP3-Utilities
/Subtruss Optimisation 1 (input length).py
3,153
3.96875
4
import math stLength = float(input("Please input subtruss length in mm:\f")) # Subtruss length, mm #nTriangles = [int(input("Please input the number of triangles:\f"))] # Subtruss section count, ul nTriangles = [2, 4, 6, 8] # array of possibilities to try outputBuffer = "" # output buffer so...
ba79a21faf47221f7e55e8dd759432ec3253b6c5
AveryMainstone/PythonStudentProjects
/VendingMachine.py
10,738
3.515625
4
# Imports import logging import time; import uuid import datetime; # Global Variables global runDebug runDebug = False; # Names of Items and Price global items; global currentSymbol; # The currency the machine is using currentSymbol = "£"; # The default amount of each item the machine has in stoc...
63093d87eee76816ebf4984012d90af3060fd93f
CatarinaL/python-exercism
/sieve/sieve.py
1,082
4.0625
4
""" The Sieve of Eratosthenes is a simple, ancient algorithm for finding all prime numbers up to any given limit. It does so by iteratively marking as composite (i.e. not prime) the multiples of each prime, starting with the multiples of 2. It does not use any division or remainder operation. Create your range, s...
720f2f16fbf2cf2a5ce4a0284e5b196f631ab399
GalynaM/python-challenge
/PyPoll/main.py
2,723
3.78125
4
#!/usr/bin/env python # coding: utf-8 # In[7]: import os import csv # In[8]: path_input = os.path.join("Resources", "election_data.csv") path_output = os.path.join("Analysis", "election_data_result.csv") # In[9]: # Define variables # Dictionary for all voters all_voters = {} # Set for candidates candidates ...
ad2ab9ae7f7514bd8110f0abb6513bdfae3f812c
luhugerth/amplicons
/validate_sam.py
1,562
3.53125
4
#!/usr/bin/env python """ validate_sam.py: removes records from a sam file with an invalid cigar """ from collections import defaultdict import argparse import csv import re __author__ = "Luisa W Hugerth" __email__ = "luisa.hugerth@scilifelab.se" def get_cigar_len(cigar): cigar = re.sub("M", "_", cigar) ...
c8890b30a5a8ae73fd8bc1465c11fe9feeb8e941
aizhizhe/lcl_home
/homework_10/code_in_class.py
7,047
4.21875
4
class Node: """ Each node in neural networks will have these attributes and methods """ def __init__(self, inputs=[]): """ if the node is the operator of "ax + b", the inputs will be x node , and the outputs of this is its successors. and the value is *ax + b* "...
afe9b039f4416b911936d788bd83da3b6ce22f7a
phlalx/algorithms
/leetcode/373.find-k-pairs-with-smallest-sums.python3.py
674
3.546875
4
# TAGS priority queue # tricky TODO too slow... see how it relates to k-list merge # TODO see 378 too # https://leetcode.com/problems/find-k-pairs-with-smallest-sums/discuss/209985/python-heap-solution-with-detail-explanation import heapq import itertools class Solution: def kSmallestPairs(self, nums1, nums2, k)...
ffb126117aae55a73f0e3f4ebfc2d7e0076368d6
phlalx/algorithms
/leetcode/647.palindromic-substrings.py
1,491
3.9375
4
# # @lc app=leetcode id=647 lang=python3 # # [647] Palindromic Substrings # # https://leetcode.com/problems/palindromic-substrings/description/ # # algorithms # Medium (57.80%) # Likes: 2172 # Dislikes: 104 # Total Accepted: 160.8K # Total Submissions: 269.9K # Testcase Example: '"abc"' # # Given a string, your ...