blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
4eaa30fc02cf526600d74e105e88f3f3cb03e3af
thedzy/Python
/Includes/progress_bar/progress_bar3.py
1,962
3.65625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Script: progress_bar3.py Date: 2018-09-24 Platform: MacOS Description: Creates a text based progress bar Customisable colour, title and header Shows percentage. """ __author__ = 'thedzy' __copyright__ = 'Copyright 2018, thedzy' __license__ = 'GPL' __version__ = '3....
dee61653392f72255d7a7df09f038ee5bcba1ce2
thedzy/Python
/Includes/simple_multitasking2/example.py
2,100
3.546875
4
#!/usr/bin/env python3 import time import random from simple_multitasking2 import ThreadManager start_time = time.time() total_time = 0 loops = random.randrange(5, 25) # Let's create a function to spend time def random_sleep(index, *args, **kwargs): timer_sleep = random.randrange(0, 25) time.sleep(timer_sl...
98d178bc8acdf38dd5ee4d15a41726c687f71c88
shubhransujana19/Python
/greatest_number_among_three_numbers.py
181
3.71875
4
# -*- coding: utf-8 -*- """ Created on Mon Oct 4 10:59:09 2021 @author: shubhransu """ a=[] for i in range(0,5): k = int(input()) a.append(k) print(max(a))
62c70178b6af6ee07c88a0c77b802201603ff5a0
shubhransujana19/Python
/odd_even.py
229
4.03125
4
# -*- coding: utf-8 -*- """ Created on Sun Oct 3 02:47:44 2021 @author: shubhransu """ sum = 0 for i in range(0,101): if(i%2 == 0): sum+=i print(f"sum of even number is {sum}")
68ed7fd0040d185bf566b24c53e97ad7ba78ff0f
shubhransujana19/Python
/Band_name_generator.py.py
325
3.671875
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 30 17:45:28 2021 @author: shubhransu """ print("Welcome to the band name generator.") city_name = input("What's name of the city you grew up in?\n") pet_name = input("What's your pet's name\n") print("Your band name could be " + city_name +" "+ pet_name) ...
1e8e0074ca2ffafcd86ec99861cdd2ddf74703d5
SergayKalashnickov/Bubble_Sort
/Python_Sort.py
540
3.765625
4
def Sorting(ob): sort=ob n=len(sort) for i in range(n-1): for j in range(n-i-1): if sort[j+1]>sort[j]: temp = sort[j] sort[j]=sort[j+1] sort[j+1]=temp return sort def Datain(): data = [] stop=True while stop: try: ...
e8c435dcd3f8ab0edc876c286901c4bdd96382cd
TanaevaSvetlana/Python_tasks
/lesson3/safe_3_6.py
546
4.21875
4
code = int(input('Введите код доступа: ')) first_digit = code // 100 second_digit = (code // 10) % 10 third_digit = code % 10 if first_digit != second_digit and first_digit != third_digit and second_digit != third_digit: print('OK') elif first_digit == second_digit and first_digit == third_digit: print('В числе...
fd320960ac0189f2fd3e746995cf8e0abac29336
TanaevaSvetlana/Python_tasks
/lesson1/horoscope_1_1.py
516
3.828125
4
name = input('Введите имя') surname = input('Введите фамилию') animal = input('Введите свое любимое животное') sign = input('Введите свой знак зодиака') print('Индивидуальный гороскоп для пользователя', name, surname) print('Кем вы были в прошлой жизни:', animal) print(f'Ваш знак зодиака - {sign}, поэтому вы - тонко чу...
16db835e42c09fd96cd5d022471d9714fa739050
TanaevaSvetlana/Python_tasks
/lesson3/plus_minus_3_1.py
127
3.859375
4
num = float(input('Введите число: ')) if num < 0: print('-') elif num > 0: print('+') else: print('0')
d41f9e149366633d3033a7dfaf68cab827a984e9
TanaevaSvetlana/Python_tasks
/lesson6/smarter_than_avg_6_4.py
259
4.0625
4
count = int(input()) total_iq = 0 avg_iq = 0 for i in range(1, count+1): iq = int(input()) if iq == avg_iq or i == 1: print('0') elif iq > avg_iq: print('>') else: print('<') total_iq += iq avg_iq = total_iq/i
42e23f9052b2f8871da7654298d44cc59e80169a
rhiroakidata/MegaSena
/MegaSena.py
2,591
3.640625
4
import numpy as np # Pega as quantidades de dezenas e jogos qtdD = input("Digite a quantidade de dezenas: ") qtdJ = input("Digite a quantidade de jogos: ") # Se for vazio a quantidade de dezenas, serão 6 dezenas e, # se for vazio a quantidade de jogos, serão 10 jogos if qtdD == '': qtdD = 6 if qtdJ == '': qtd...
1a1a26d2817e6e1a1bb0fdcf838a72f893aa6cfd
yangxiaodong1/ygblcrm
/test/day9.5/堆排序.py
752
3.8125
4
''' 初始化堆,交换,再初始化堆 ''' def adjust_heap(arr,i,size): lchild = 2*i + 1 rchild = 2*i +2 if i< int(size / 2): # 不是要循环下去的 max =i if lchild<size and arr[max]<arr[lchild]: max = lchild if rchild<size and arr[max]<arr[rchild]: max =rchild if max !=i: ...
65cbed42db750378274555bc195dd6b009116e18
yangxiaodong1/ygblcrm
/test/day9.5/冒泡1.py
264
3.5
4
def maopao(arr): count = len(arr) for i in range(0,count): for j in range(i+1,count): if arr[i]>arr[j]: arr[i],arr[j] = arr[j],arr[i] return arr if __name__=="__main__": arr = [23,4,235] print(maopao(arr))
54c2533a2449a5c6544a36f37b178dbbd02d3b0e
yangxiaodong1/ygblcrm
/test/常用算法/单例模式.py
610
3.78125
4
# Author : July Yang '''1 使用new''' class Singleton(object): def __new__(cls, *args, **kwargs): if not hasattr(cls,"_instance"): cls._instance = super(Singleton, cls).__new__(cls,*args,**kwargs) return cls._instance class MyClass(Singleton): a=1 one = MyClass() two = MyClass() on...
771a63ce2796714ebc4405276e8aa6bf755f2952
yangxiaodong1/ygblcrm
/test/day9.6晚上/快速排序.py
544
3.921875
4
'''基准点,左右''' def quick_sort(arr,left,right): if left >=right: return arr low =left high = right key = arr[left] while left <right: while left<right and key <arr[right]: right -=1 while left<right and key >arr[left]: left +=1 arr[left],arr[ri...
557c5dae51ca7a6ae09d42348b9f824ba601f534
yangxiaodong1/ygblcrm
/test/day9.4晚上2次/希尔算法.py
528
3.875
4
def shell_sort(arr): count =len(arr) group =int(count / 2) while group>0: for i in range(0,count): j = i+group while j<count : k =j-group key = arr[j] while k>=0 and key<arr[k]: arr[k+group]=arr[k] ...
977442e6530ce4cf2232d26a1d059e559d25d179
yangxiaodong1/ygblcrm
/test/day9.7/二分法.py
454
3.9375
4
'''最小大,中间值''' def Binary_search(arr,key): min = 0 max = len(arr)-1 if key in arr: while True: center = int((min +max ) / 2) if key <arr[center]: max = center - 1 elif key > arr[center]: min = center +1 elif key == arr[...
8a89a31a7607a28f7a8c7e34c86cbb408600e095
yangxiaodong1/ygblcrm
/test/day9.7/快速排序.py
545
4.03125
4
'''左右基准号''' def quick_sort(arr,left,right): if left >= right: return arr low =left high = right key = arr[left] while left <right: while left<right and key <arr[right]: right -=1 while left<right and key >arr[left]: left +=1 arr[left],arr[ri...
2da8703cc9fdc04869b0ef2136921fb25055aefa
yangxiaodong1/ygblcrm
/test/day9.6/直接插入.py
337
3.953125
4
'''抓住一个,向后扫描''' def insert_sort(arr): count =len(arr) for i in range(1,count): j = i-1 key = arr[i] while j>=0 and key <arr[j]: arr[j+1] = arr[j] j-=1 arr[j+1] =key return arr if __name__=="__main__": arr = [89,2,11] print(insert_sort(arr))
8a2fde601bf3bae5fcd0fd763db537ba171b311c
yangxiaodong1/ygblcrm
/test/day9.7/归并排序1.py
583
3.828125
4
'''分治''' def merger(left,right): i,j =0,0 result = [] while i<len(left) and j<len(right): if left[i]<right[j]: result.append(left[i]) i+=1 else: result.append(right[j]) j+=1 result+=left[i:] result+=right[j:] return result def me...
7ddfb0f7ad80a1f52dc9ad8a1760d6338963997c
yangxiaodong1/ygblcrm
/test/day9.4/归并排序1.py
1,554
3.953125
4
# Author : July Yang # 排序 def merge(left,right): i,j=0,0 result = [] while i<len(left) and j<len(right): if left[i]<=right[j]: result.append(left[i]) i+=1 else: result.append(right[j]) j+=1 result +=left[i:] result +=right[j:] re...
96102dd4ac36f73f3ca3d7dc3d9d77d75ff5293a
ilimbyvz/findword
/gui.py
860
3.765625
4
# -*- coding: utf-8 -*- import tkinter as tk import re def find(): filename = 'text.txt' fin=open(filename,'r') word=k.get() for line in fin: line = line.rstrip() worde=re.findall("\S+"+word+"\S+|"+word+"\S+|"+"\S+"+word,line) result.configure(...
3fdce38dba6bc40acf996845d49e5105b955199d
renanMendes11/Python
/CursoemVideo/strings/basico.py
244
3.609375
4
frase = "Curso em Video Python" separado = frase.split() palavra = frase[2] print (separado) print (palavra) print(frase[5]) print(frase[5:3]) ##printfrase[9:] print(frase[9::3]) # num = len(frase) # print(num) # print(frase.count('o', 0, num))
76c617b54e4bcb980f364bf8b2ed620b759fd3cd
renanMendes11/Python
/CursoemVideo/operadores/exe3.py
177
3.890625
4
#Ler duas notas e mostrar a media n1 = float(input('Digite a primeira nota: ')) n2 = float(input('Digite a segunda nota: ')) print('A média desse aluno: {}'.format((n1+n2)/2))
cdd64733071b67927c0ba63b6e3581dbd1fbe0ee
eanderson-skylar/Runaway
/TextProcessing/Support/to_inch.py
4,279
3.984375
4
from text_to_num import text2num import sys import traceback def to_inch(input): ## Define variables ## meter_to_inch = 0 # calcaulated inches from meters feet_to_inch = 0 # calcaulated inches from feet inches = [] # stated inches (Not calcaulated) result = [] # final result string_to_number_list = [] # Convert ...
5efc8b1b90ce6f7df6e050124e14619164f8b61f
spinlockirqsave/python
/newton.py
325
3.65625
4
def factorial(n): if n < 0: return -1 if n == 0: return 1 if n == 1: return 1 return n * factorial( n-1) # numbers lst = list(map(int, input().split())) n = lst[0]; m = lst[1]; # last digit n_ = int(n) m_ = int(m) print(int( factorial(n_) / ( factorial(m_) * factorial(n_ - m_...
476883b2870929863c331213ffa323abf9b3ca70
ClaudioChagas/Introducao-a-Ciencia-da-Computacao-com-Python
/ordem.py
397
4.03125
4
decrescente= True anterior= int(input("Digite o primeiro número da sequencia: ")) valor= 1 while valor != 0 and decrescente: valor= int(input("Digite o próximo número da sequencia: ")) if valor> anterior: decrescente= False anterior= valor if decrescente: print("A sequencia está em ordem decres...
f10ca56bda3134e625a55770a29a8efc030a5432
ClaudioChagas/Introducao-a-Ciencia-da-Computacao-com-Python
/lado.py
128
3.5625
4
lado= input("digite o lado do quadrado: ") temp= float(lado) p= lado * 4 a= lado * lado print(" perimetro: ", p"-aréa: ",a)
237d8e059e9ed497ed5b18cd57661e3971c98de3
ClaudioChagas/Introducao-a-Ciencia-da-Computacao-com-Python
/retang.py
476
3.984375
4
largura = int(input("Digite a largura: ")) altura = int(input("Digite a altura: ")) hasht = "#" def retangulo(largura, altura, hasht): linha_c = hasht * largura if largura > 2: linha_v = hasht + (" " * (largura - 2)) + hasht else: linha_v = linha_c if altura >= 1: ...
d44805033fb4d61611c445183bb81ebffb8bcf28
ClaudioChagas/Introducao-a-Ciencia-da-Computacao-com-Python
/quadrado.py.py
143
3.65625
4
lado=int(input("digite o lado do quadrado:")) perimetro=lado*4 area=lado*lado print("perimetro:", perimetro) print("- aréa:",area)
a0dffec9d13a3a046cf02bd2450575d6e6b809ca
ClaudioChagas/Introducao-a-Ciencia-da-Computacao-com-Python
/nomes.py
310
3.671875
4
def menor_nome(nomes): nomeCurto = nomes[0] comprimentoDoNomeCurto = len(nomes[0]) for nome in nomes: nome = nome.strip() if len(nome) < comprimentoDoNomeCurto: comprimentoDoNomeCurto = len(nome) nomeCurto = nome return nomeCurto.capitalize()
0dabc3dc62ef69356ff2a5435d383952d53abcf6
MShel/py_algorithms
/algos/sorting/MergeSorting.py
4,086
3.796875
4
class MergeSorting: sortedArray = [] resultSplitted = [] splited_groups = [] def __init__(self, array_to_sort: list): self.sortedArray = self.merge_sort(array_to_sort) def merge_sort(self, array_to_sort: list) -> list: # splitting initial list in half's initial_left_group, ...
57a9ce8e245b6ae68e557d5e548f7aae405f8b2c
c-su/python_nlp_100practice
/chapter1/nlp008.py
810
4.0625
4
# -*- coding:utf-8 -*- # 008 暗号文 # 与えられた文字列の各文字を,以下の仕様で変換する関数cipherを実装せよ. # ・英小文字ならば(219 - 文字コード)の文字に置換 # ・その他の文字はそのまま出力 # この関数を用い,英語のメッセージを暗号化・復号化せよ. # 参考資料 # コード変換,文字変換 # http://python.civic-apps.com/char-ord/ def nlp008(): result = cipher('This is a pen.') print(result) print(cipher(result)) d...
ca38cffc288d24342b06f5c695d6f257eb3b8729
Nikhilrao23/LPTHW
/ex19.py
630
3.8125
4
def cheese_and_crackers(cheese_count, boxes_of_crackers): print "You have %d cheeses!" % cheese_count print "You have %d boxes" % boxes_of_crackers print "Mans that enough for a party" print "Get a Blanket. \n" print "We can give the function numbers directly" cheese_and_crackers(25, 10) print "We can...
313c21292bcea736c3a6911f45eb0065f374e5d4
richczhou/Genetic-Algorithm
/geneticAlg.py
6,942
3.59375
4
# By Richard Zhou # An attempt to imitate genetic algorithm based on a binary chromosome. # More information and inspiration can be found at # www.ai-junkie.com/ga/intro/gat1.html import random class chromosome: """A string of N binary 0/1s, with each 4 digit section representing a digit from 0-9 or a basic ...
9f4e7572494ebaf7f0573fc7ba5a95a255665535
p2327/CS61a_Berkeley
/lab05.py
2,885
3.953125
4
def tree(root, branches=[]): return lambda dispatch: root if dispatch == 'root' else list(branches) def root(tree): return tree('root') def branches(tree): return tree('branches') t = tree(1, [tree(2), tree(3, [tree(4), tree(5)]), tr...
1915027e8ee91530f12bd4bff02d422bcde00143
p2327/CS61a_Berkeley
/Link.py
636
4.09375
4
class Link: """A recursive list, with Python integration.""" empty = None def __init__(self, first, rest=empty): self.first = first self.rest = rest def __repr__(self): if self.rest is Link.empty: rest = '' else: rest = ', ' + repr(self.rest) ...
03e388370808fe5e9c204e061f3bff17f0376897
p2327/CS61a_Berkeley
/mergesort.py
1,078
4.21875
4
def merge(lst1, lst2): if lst1 == [] or lst2 == []: return lst1 + lst2 elif lst1[0] <= lst2[0]: return [lst1[0]] + merge(lst1[1:], lst2) elif lst1[0] >= lst2[0]: return [lst2[0]] + merge(lst1, lst2[1:]) def mergesort(seq): """Mergesort algorithm. Mergesort is a type of sort...
73b50db219e096fa5ac4481d7bf9df7ba7e138df
thomascormier/openspace
/demo_streamlit/demo_person_recognition.py
2,092
3.53125
4
import streamlit as st import pandas as pd from random import * import csv import cv2 def display_image(): if number_of_people == 0: st.image("img/ippon_openspace0.jpeg", use_column_width=True) elif number_of_people == 1: st.image("img/ippon_openspace1.jpeg", use_column_width=True) elif nu...
eafeeefe9de4fa343d00b3cbd9bea7544d47bf44
stanislavBozhanov/LearnPythonTheHardWay
/Exercise_03/ex3.py
779
4.03125
4
print("I will now count my chickens:") # Line prints info print("Hens", 25.0 + 30.0 / 6.0) # Line sums Hens print("Roosters", 100.0 - 25.0 * 3.0 % 4.0) # Line sums Roosters print("Now I will count eggs:") # Line prints info print(3.0 + 2.0 + 1.0 - 5.0 + 4.0 % 2.0 - 1.0 / 4.0 + 6.0) # Line sums print("Is it true tha...
784b9a8496c1858d4ddec20e761dd3eef15ec7b5
Dhillan/Type
/Callingwordlist.py
2,146
4
4
# calling words from the individual word lists # # import list import random import linecache def CallWordlist(difficulty): if difficulty == 1: # the difficulty is be chosen in the main game wordfile = "wordlist.txt" numberoflines = 1 wordlistother(wordfile,numberoflin...
f1e05b0248225110f7f00aa8969db59dabe61891
Basicssss/NY-TIMES
/NY-Times.py
4,230
4.0625
4
def call_file(): list = [] #open the file with an error message if the user wants to open a wrong file. #make sure to use the right file path to the bestseller list try: file = open('bestsellers2.txt', "r") except: print("Error could not open file!") #Repeat for each book in the...
aaeab64e04e1dd01d65eb97bded84c6e822abd6e
atmelaku/adventure-game
/math1.py
14,764
4.15625
4
from sys import exit class numbers(object): def __init__(self, ten, one, three, x, y): self.ten = 10 self.one = 1 self.three = 3 self.zero = 0 self.x = x self.y = y def enter(self): return 'evaluating_Variable_Question1' class addingPositiveNumbersQues...
f945669b7cf4c7c41d9903d8c92acbc6b1ac1c60
guilhermealbino33/TECNICO-SENAI
/stringsGuilhermeAlbino.py
324
4.15625
4
frase = input ("Digite uma frase de 7 digitos ou mais, de tamanho impar:") if (len (frase) < 7): print ("Sua frase deve conter 7 ou mais dígitos!") if (len (frase) %2 ==0): print ("Sua frase deve conter um número IMPAR de dígitos!") else: print ("Os três caracteres no meio da frase são: ", frase[3:6])
54cb053907d10e94fb597e093fad518df6501361
Nanomit/Educate-DL-Academy-105
/Lesson3/hw03_hard.py
5,363
3.921875
4
import addition # Задание-1: уравнение прямой вида y = kx + b задано в виде строки. # Определить координату y точки с заданной координатой x. # equation = 'y = -12x + 11111140.2121' # x = 2.5 # вычислите и выведите y print('Start program 1') equation = 'y = -12x + 11111140.2121' x = 2.5 a1 = equation.find('x') a2 =...
360c87e972a1b203e9a1d9c848719949ed61bc9c
Nanomit/Educate-DL-Academy-105
/Lesson7/hw07_easy.py
3,688
4.1875
4
import math # Задача-1: Написать класс для фигуры-треугольника, заданного координатами трех точек. # Определить методы, позволяющие вычислить: площадь, высоту и периметр фигуры. print("\nStart program 1") class Triangle: def __init__(self, A, B, C): def sideLen(dot1, dot2): return math.sqrt(...
a8af2578d0d3ee417a31aa24587c4f2fad64b0cd
jojobabacar/Python-2018
/8.ball2.py
263
3.875
4
import random name=input("type your name here") print("Hello %s" % name) answers = ["yes", "NO", "maybe", "dunno"] while True: question=input("type your question") print(random.choice(answers)) if question=="quit": break
770f48f9955155b85c32f9c19a549df9e3d9ea92
zaid-kamil/scripts_for_930_batch
/vowel_visualizer.py
495
3.578125
4
from reader import read_file import matplotlib.pyplot as plt def visualize(file): vowels= 'aeiou' data = read_file(file).lower() results = {} # empty dict for v in vowels: size = data.count(v) results[v] = size x = list(results.keys()) h = list(results.values()) colors= ['...
06aff0434f54cbcee09d9f355cebdcd4a5bd275a
shreyashPramod/C104
/C104.py
420
3.515625
4
import csv with open('height-weight.csv',newline='')as f: reader=csv.reader(f) file_data=list(reader) file_data.pop(0) #sourting data to get the height of people new_data=[] for i in range(len(file_data)): n_num=file_data[i][1] new_data.append(float(n_num)) #getting the mean n=len(new...
e7caa1c6fccf00bcf57f22863ed3bcca3c2162fe
mdbetancourt/Solved-HackerRank
/Python/marc_cakewalk.py
992
3.921875
4
#!/bin/env python # encoding: utf-8 """ marc_cakewalk.py Marc loves cupcakes, but he also likes to stay fit. He eats cupcakes in one sitting, and each cupcake has a calorie count, After eating a cupcake with calories, he must walk at least 2^j * c (where is the number cupcakes he has already eaten) ...
7f0243730cfc573871a114df2dd3cb738d0cd8b5
HoopCha/Algorithms
/stock_prices/stock_prices.py
1,344
4.09375
4
#!/usr/bin/python import argparse def find_max_profit(prices): #Set the variable for the max profit max_profit = 0 #For each price in the list for i in range(0, len(prices)): #Set the current price of the current object current_price = prices[i] #For each of the remaining price...
8a3e3eeac76eb8f421a77aa51cc635c75856bf63
HEERAMANI26/python-programming
/practise.py
2,051
4.0625
4
#n =int(input("Enter number which you wants to inserted:")) '''a=[] for i in range(5): x =int(input("Enter list which you wants to add:")) a.append(x) y=len(a) avg=sum(a)/y print(avg)''' #lambda '''x=lambda x,y,z:x*y*z print(x(2,4,6)) x=lambda a,b:a+b print(x(5,2)) x=lambda x,y:x**y print(...
1f43bf579845f2ffdbb274e5adc1c3531848f5c5
lauralyeinc/Intro-Python-ll-TK-Lecture
/Python III/Elissa/notes_day_two.py
1,493
3.96875
4
''' # from TK videos inheritance - avoid typing redundant code. python supports multiple inheritance allows us to define hierarchical relationships. is_a type/parent/smaller class --> sub-type/child/larger class child classes are always bigger, has everything the parent has plus can add unqiue methods/attrs to it....
39914df38e532949ffe9bdb99db5b8ae1a6766a4
lauralyeinc/Intro-Python-ll-TK-Lecture
/Python III/My code/store.py
2,545
4.21875
4
class Store(): def __init__(self, name, categories): self.name = name self.categories = categories #abstract list but not formally marked []. def __str__(self): output = f' Hello! Welcome to {self.name}!' for category in self.categories: output += f'\n {str(categ...
fa29a0d95b2ce04d50b1d815dd2565a51477fea1
MohamedAbdelnaby7/CS50-psets
/Pset6/dna py/dna.py
2,095
3.9375
4
import csv import sys import operator def main(): # check if there are three terminal arguments if len(sys.argv) != 3: print("usage error, dna.py sequence.txt database.csv") exit(1) # opens the dna file for someone and save it in a string dna with open(sys.argv[2]) as dnatxt: ...
b868614f25fbea4a05701a414cd8ddf0a5da7832
PythonLearner33/python-crash-course-1st-edition
/data_visualization/TIY/15.3.py
537
3.78125
4
from random_walk import RandomWalk import matplotlib.pyplot as plt #while True: # Make a random walk, and plot the points. rw = RandomWalk(5000) rw.fill_walk() # Set the size of the plotting window. plt.figure(dpi=128, figsize=(22, 11.5)) plt.plot(rw.x_values, rw.y_values, linewidth=1) # Remove the axes. plt.ax...
1f073717fb36f0ac09dba88fe8bfc7756283714e
PythonLearner33/python-crash-course-1st-edition
/data_visualization/TIY/part3_15_10.py
1,426
4.40625
4
from random import choice class RandomWalk(): """Generate a random-walk with direction and distance.""" # Keyword argument contains 1,000 steps as default. def __init__(self, steps=1000): self.steps = steps # Main method to create data of a random walk. def fill_walk(self): # Poin...
3af542a6014dbd1d921ab79bd4bc0d902532fa1e
PythonLearner33/python-crash-course-1st-edition
/data_visualization/TIY/part1_15_10.py
593
3.859375
4
import matplotlib.pyplot as plt from dice15_10 import Die # Game Plan: # Visualize 1000 dice rolls with two D6s. # Instantiate Dice. die_1 = Die() die_2 = Die() # Calculate data from rolling dice. results = [die_1.roll() + die_2.roll() for i in range(1000)] max_result = die_1.num_sides + die_2.num_sides frequency...
9c5bc12f5de81e3160c51a3910f98c66509df4b3
PythonLearner33/python-crash-course-1st-edition
/data_visualization/highs_lows.py
2,049
3.984375
4
import csv import matplotlib.pyplot as plt from datetime import datetime # -------- # Gameplan: # -------- # - Sort dates and high and low temperatures from .csv file. # - Plot dates and high and low temperatures. # -------- # Sort data. filename = r'C:\Users\Alvin\Desktop\Desktop\python_work\Projects\data_visua...
1a2f780153e6e1d77aea04b4d606d93126816394
rauthi07/Modules
/m.py
971
4.21875
4
#Q1 '''A time tuple is the usage of a tuple (list of ordered items/functions) for the ordering and notation of time. Basically, the tuples for time are just a way of ordering the values for any given specific moment in time. month (1 to 12),day (1 to 31), hour (0 to 23), minutes (0 to 59), seconds (0 to 59), day of th...
6365d09b77e170f75161016d435506a8337f72b9
Beefdinner/Python-dailies
/PythonDay1.py
105
3.5
4
#Day 1 of python #print hello world 100 times for i in range (100): print("hello world")
2222173cccb97616e79101067ef43944302f9d9c
FelipeNunes04/URI
/1180.py
256
3.65625
4
n = int(input()) if n>1 and n<1000: vetor = input().split() menor = int(vetor[0]) posi = 0 for i in range(1,n): vetor[i] = int(vetor[i]) if(vetor[i]<menor): menor = vetor[i] posi = i print("Menor valor: %d"%menor) print("Posicao: %d"%posi)
a73136223c531eeb815496c5d2f93267e19e9825
FelipeNunes04/URI
/1115.py
273
3.953125
4
x = 1 y = 1 while(x!=0 and y!=0): entrada = input().split() x = int(entrada[0]) y = int(entrada[1]) if(x==0 or y==0): break elif(x>0 and y>0): print("primeiro") elif(x<0 and y>0): print("segundo") elif(x<0 and y<0): print("terceiro") else: print("quarto")
8994cbe84bafd1e6952ee8f2176d1065d25a6a75
FelipeNunes04/URI
/1117.py
182
3.671875
4
n = 0 sai = 0 media = 0 while sai<2: n = float(input()) if(n<0 or n>10): print("nota invalida") else: media+=n sai +=1 if(sai==2): print("media = %.2f"%(media/2)) break
c0479ca02294e868aacd7ad667d2a52b7114b6da
FelipeNunes04/URI
/1174.py
141
3.5
4
lista = [] for i in range(0,100): x = float(input()) lista.append(x) for i,v in enumerate(lista): if(v<=10): print("A[%d] = %.1f"%(i,v))
064faa0b9eb92631c7d273c91a9c12e2e424bd97
sindhurasyamala/yrtt_entry_katas_python
/tests/test_exercise004.py
469
3.65625
4
# Move the first letter of each word to the end of it, then add "ay" # to the end of the word. Leave punctuation marks untouched. import pytest from tasks.exercise004 import pig_it def test_pig_latin_returns_string(): assert pig_it("Pig latin is cool") == "igPay atinlay siay oolcay" assert pig_it("This is my...
9e5d994c33e7cd0a09e42b6f424cd2577a7c74ad
legolas-zeng/scripts
/随手记/Fibonacci.py
1,412
3.765625
4
# coding=utf-8 def fab(max): n, a, b = 0, 0, 1 L = [] while n < max: L.append(b) a, b = b, a + b n = n + 1 return L # 容器是用来储存元素的一种数据结构,容器将所有数据保存在内存中,Python中典型的容器有:list,set,dict,str等等。 class Fab(object): def __init__(self, max): self.max = max self.n, self.a, self.b...
b2752ab9c6f668d1aed5b7366ba942a20931964d
legolas-zeng/scripts
/随手记/itertools.py
501
3.828125
4
# coding=utf-8 import itertools def get_letter(i): return chr(ord('a')+i) r = range(10) print(list(map(get_letter, r))) print(list((get_letter(i) for i in range(10)))) print(chr(ord('a'+i)) for i in range(10)) sum(range(20, 30)) # 连接多个列表或者迭代器 x = itertools.chain(range(3), range(4), [3,2,1]) print(list(x)) # 累加...
05c76b2605088d2cc7278c70938a5fc226a2610f
legolas-zeng/scripts
/test_1.py
7,231
4.03125
4
# -*-coding:utf-8 -*- # -*- coding:utf-8 -*- # 摇3次骰子,当总数total,3<=total<=10时为小,11<=total<=18为大 import random import time # def enter_stake(current_money): # '''输入小于结余的赌资及翻倍率,未考虑输入type错误的情况''' # stake = int(input('How much you wanna bet?(such as 1000):')) # rate = int(input("What multiplier do you want?你想翻几倍...
b2b9ef732dfc0ef0a3c7f1e04ef439fb30fcadc7
legolas-zeng/scripts
/随手记/6.py
85
3.609375
4
# coding=utf-8 cubic=lambda x: x**3 a = map(cubic,range(5)) for i in a: print(i)
4da9db015c31a69f28eeecc0d34767ee433852b2
legolas-zeng/scripts
/leetcode/初级算法/123.买卖股票的最佳时机 III.py
1,013
3.71875
4
# coding=utf-8 """ 给定一个数组,它的第 i 个元素是一支给定的股票在第 i 天的价格。 设计一个算法来计算你所能获取的最大利润。你最多可以完成 两笔 交易。 注意: 你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。 """ prices = [3,3,5,0,0,3,1,4] if not prices: result = 0 len_prices = len(prices) ''' 分为两部分,第一次收益,和第二次收益。 ''' buy1 = -prices[0] # -3 buy2 = -prices[0] # -3 sell1 = 0 sell2 = 0 for i in ...
0c11d4d48b9677c78bcd9a2c70bdeac101741815
legolas-zeng/scripts
/leetcode/初级算法/数组/移动零.py
665
3.640625
4
# coding=utf-8 # @author: zenganiu # @time: 2019/2/16 17:45 ''' 给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。 输入: [0,1,0,3,12] 输出: [1,3,12,0,0] 说明: 必须在原数组上操作,不能拷贝额外的数组。 尽量减少操作次数。 ''' nums = [0,1,0,3,12] # for index,values in enumerate(nums): # if values == 0: # nums.pop(index) # nums.append(0)...
4bfe04e57752aa666e5f7808ae73f0d2604e1ba8
Sappadilla/Sappadillaku
/check_square/Check_square.py
830
3.953125
4
def main(): def check_square(row,col): row_floor = row//3 col_floor = col//3 print(row_floor) print (col_floor) for i in range(0,3): print("i: "+str(i)) for j in range(0,3): #reverse again? spaghetti code moar plz ...
ef91303da9d0e732d2c8f7f1058473f5d3e7b139
kdvuong/291Project2
/phase2.py
9,559
3.5625
4
from DbConnection import getDb from PostController import PostController from VoteController import VoteController from TagController import TagController # constants MAIN_ACTION_PROMPT = """Available actions: 1. post - post a question 2. search - search for questions by keywords 3. exit - exit program""" QUESTIO...
4c9f843d24f0f66b9ed5f740123b954f0cfa973d
liuyueyi/SwiftProject
/swauth/swauth/tree.py
2,975
3.515625
4
from stack import stack class node: def __init__(self, value1 = '' ,lchild = None, rchild = None): self.value = value1 self.left = lchild self.right = rchild return None def nextAttribute(policy, index): start = index length = len(policy) while index < length : ...
3c3890adecae0fb3548acb742c1735161baa7715
vorpex/qvantum
/build/lib/qvantum/qubit.py
7,135
3.71875
4
'''qubit class''' # pylint: disable=E1101, W1401 from . import check_qubit import numpy import unicodedata class Qubit(object): """qubit class In quantum computing a qubit or quantum bit is the basic unit of quantum information. Every qubit has two clear states such as 0 and 1 but unlike a classical b...
3bd2b2b1a1149045c633a90d70a9efba5d30b558
vorpex/qvantum
/build/lib/qvantum/check_gate.py
9,057
3.640625
4
'''checking functions for gate class''' # pylint: disable=E1101, W1401 import numpy from . import qubit from . import register def gate_call_check(function): """Decorator to check the arguments of call function in gate class. Arguments: function {} -- The tested function """ def wrapper...
04d7fb28b148d6c44da31e7527c6fddac2daafb4
Bugzey/Advent-of-Code-2020
/aoc2020/day_7/__init__.py
3,154
3.5
4
""" Advent of code 2020 - Day 7 Usage: day_7 [options] [-] Options: -t --target-bag=BAG Target bag to look for [default: shiny gold bag] -s, --sum-content Count all possible bags contained in the target_bag -h, --help Print this help message and exit """ from functools import reduce import logging...
9de44638e558bea5c9f5d6e3df1122b954dcdf5a
kjsk22/Python-InheritanceDemo
/InheritanceDemo.py
1,649
4.0625
4
class Car:# Parent class or Super class def __init__(self, color, wheel_count): # initiatlize attributes self.color = color self.wheel_count = wheel_count def validate(self): # method definition if self.wheel_count == 4: return 'This is a car' else: return...
f0c198e58f8f09043f9e4242dd2cea41181b3bbf
AST-Isabella/PyPractice
/textEditor.py
1,430
3.796875
4
# Here is my first try at a GUI in Python, using the YouTube tutorial by DiogoTheCoder # This script can create a new file, save As, open saved files, and Exit(Quit) #modification from tkinter import Tk, scrolledtext, Menu, filedialog, END, messagebox import tkinter.scrolledtext as ScrolledText #root for main window ...
9463970875fc570cd2d65e4cab8ba4d4154fe191
immortalitymodealtf4/NewRepos
/Classes.py
389
3.625
4
class Father: def __init__(self): print("Father class constructor") class Mother: def __init__(self): print("Mother class constructor") class Son(Father, Mother): def __init__(self): print("Here start son") super(Father, self).__init__() print("Son class constr...
68ad8a36c8d4efeb7aada51f840435525fbcee97
NicolaPanozzo/Python-projects
/IncomePredictor.py
6,510
3.625
4
import urllib.request import csv #the following code retrieve the file from the web and split each line using the csv.reader function URL = "http://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data" local_file, headers = urllib.request.urlretrieve(URL) # this is a tuple fh = open(local_file, "r") r...
555435ac2ae8df083c6b9e1e85e6c9af30a71a57
salexus/machine-learning-foundation
/foundation/pandas.py
390
3.640625
4
# -*- coding: utf-8 -*- """ Created on Mon Jan 21 11:47:37 2019 @author: kumar """ import pandas as pd x=pd.read_csv('Book1.csv') x.columns=['a','b','c'] y=pd.read_csv('Book1.csv',header=None) print(x) print(y) a=x.describe() print(a) a.to_csv('Book1.csv') print(x.columns) print(x.head()) print(x.tail()) import mat...
fc1664f03adad64008fe9c13f4530f8a270e639d
Boxxfish/votetool
/get_members.py
839
3.609375
4
#Script to collect congressional data and save it into a file #Data is saved as bill_data.csv import sys from typing import List import requests import json def main(): #Get legislator data print("Collecting legislator data...") senEndpoint = "https://api.propublica.org/congress/v1/116/senate/members.json...
43aa1d9e0f26c4155e290c45ee01ebe7ec18e35e
MarculescuAndrei/Regular-Grammar-Checker
/Regular Grammar.py
1,474
3.609375
4
f = open("Source.txt", 'r') poz = f.readline() poz = poz[:-1] Final = f.readline().split() L = f.readline().split() Adjacency = {} while L: if L[0] not in Adjacency.keys(): Adjacency[L[0]] = [[L[1], L[2]]] else: Adjacency[L[0]].append([L[1], L[2]]) L = f.readline().split() ...
771ccbd1703ad8be852eb10c2a0c031a158037b0
JeffBoo/python_works
/Exercices Python/Exercices apcpedagogie YTB/supprimer_éléments_dupl.py
671
4.09375
4
def supp_doublon(liste): nouvelle_liste = [] for element in liste: if element not in nouvelle_liste: nouvelle_liste.append(element) return nouvelle_liste print("Entrez des valeurs. Appuyez sur Entrée pour terminer") liste_valeurs = [] nb_elements = 0 while True: valeur = input("...
2efd0619bd8608f33eaaed48144767edc1074975
JeffBoo/python_works
/Exercices Python/Exercices Très Facile YTB/longueur_str_sans_len.py
265
3.890625
4
def string_length(texte): longeur_mot = 0 for char in texte: longeur_mot += 1 return longeur_mot mot = input("Entrez une chaine de caractère : ") string_length(mot) print("La longueur de la chaine de caractère est de : ", string_length(mot))
a40b5e421a94dac5a353cc3befa38c5f6c6adcec
JeffBoo/python_works
/Exercices Python/Exercices Très Facile YTB/liste_mot_maj.py
315
3.90625
4
def liste_mot_maj(texte): liste_texte = texte.split() liste_maj = [] for mot in liste_texte: if mot[0].isupper(): liste_maj.append(mot) print("La liste des mots débutant par une majuscule sont : ", liste_maj) message = input("Entrez votre message : ") liste_mot_maj(message)
7df6c85c116153be8de5e1bedfee999628a0671d
JeffBoo/python_works
/Exercices Python/Exercices Très Facile YTB/class_rectangle.py
947
3.84375
4
#1) class Rectangle: def __init__(self, longueur, largeur): self.longueur = longueur self.largeur = largeur #2) def Perimetre(self): return 2*(self.largeur + self.longueur) def Surface(self): return self.longueur*self.largeur #3) class Parallelepipede(Rectangle): def ...
d674ccf75a81c9c4f9516e05da7626f18b1b1413
JeffBoo/python_works
/Exercices Python/Exercices Très Facile YTB/inverser_casse_lettres.py
430
4.40625
4
def inverse_case(texte): inverted_text = "" for char in texte: if char.isupper(): char.lower() inverted_text += char elif char.islower(): char.upper() inverted_text += char else: inverted_text += char return inverted_text ...
95a21235470cfd30b15a845ab4a603f1a9f19a1f
JeffBoo/python_works
/Exercices Python/Exercices Très Facile YTB/liste_mot_commun_deux_fichiers.py
681
3.890625
4
def commom_word_two_files(nom_fichier1, nom_fichier2): file1 = open(nom_fichier1, "r") file2 = open(nom_fichier2, "r") content1 = file1.read() content2 = file2.read() list_content1 = content1.split() list_content2 = content2.split() file1.close() file2.close() mots_communs_liste = ...
a874319e80ca4be80d0e4d740659dc521bb67c17
JeffBoo/python_works
/Exercices Python/Exercices Graven/exercice_boucle_Le_Juste_Prix.py
408
3.90625
4
from random import randint juste_prix = randint(1,1000) print(juste_prix) choix = int(input("Quel est le juste prix ? : ")) while choix != juste_prix: if choix < juste_prix: print("C'est plus !") choix = int(input("Quel est le juste prix ? : ")) else: print("C'est moins !") choi...
7304ed667a59aa55a57b55fc007c8d1759314e6e
JeffBoo/python_works
/Exercices Python/Exercices Graven/exercice_liste.py
299
3.84375
4
from random import shuffle phrase = input("Veuillez entrer une liste de mots séparés par '/' : ").split("/") shuffle(phrase) if len(phrase) <= 10: print("Les deux premiers mots de la liste sont", phrase[:2]) else: print("Les trois derniers mots de la liste sont", phrase[len(phrase)-3:])
e1ef4e1a4a0c0740399d87124133190cbc309ce3
kaitlynbartley/py4e
/homework4.py
753
4.0625
4
# # To run this, you can install BeautifulSoup # # https://pypi.python.org/pypi/beautifulsoup4 # # Or download the file # # http://www.py4e.com/code3/bs4.zip # # and unzip it in the same directory as this file # # this code scrapes and sums numbers from HTML page using Beautiful Soup import urllib.request, urllib.p...
33194b3c843ba460fe309cff4a435f51bf0793af
adrianmikol/2020-11-21-python
/basic_pgg/zad_9_2.py
846
4.1875
4
""" Napisz program, który na podstawie dwóch podanych liczb obliczy wynik zadanej operacji (dodawanie, odejmowanie, mnożenie, dzielenie). W przypadku podania nieprawidłowej operacji program ma wyświetlić odpowiedni komunikat o błędzie. Przykładowy komunikat programu: Podaj pierwszą liczbę: 10 Podaj drugą liczbę: 5 Pod...
711fa07f06c2c7dfe7baf3d362da758914301fbd
adrianmikol/2020-11-21-python
/kolekcje_pgg/zad_4.py
514
3.78125
4
""" Napisz program wypisujący wszystkie liczby od 0 do 100, podzielne przez 3 lub podzielne przez 5. Wypisz także jak dużo takich liczb wystąpiło w tym przedziale. Liczby podzielne przez 3 lub 5: 0 3 5 ... 96 99 100 W przedziale 0-100 jest 48 liczb podzielnych przez 3 lub 5 """ ile_liczb = 0 for liczba in range(0, 1...
5da46bde1c36aa0ea81c9cf59717c2279f0a67dc
adrianmikol/2020-11-21-python
/basic_pgg/zad_3.py
769
4.4375
4
""" Napisz program wyliczający kwotę należną za zakupiony towar na podstawie ceny za kilogram oraz liczby zakupionych kilogramów. Do przechowywania informacji o cenie oraz liczbie kilogramów użyj zmiennych. Wypisz wszystkie informacje na konsolę. Przykładowy komunikat programu: Cena za kg: 10.0 Waga: 2.5 Należność: 25...
a647696e139f590acf008d9515fce7b0d23688de
adrianmikol/2020-11-21-python
/kolekcje_pgg/zad_7.py
977
4.03125
4
""" Napisz program wyliczający kwotę należną za zakupiony towar na podstawie podanej przez użytkownika wagi i nazwy produktu. Do przechowywania informacji o cenie za kilogram danego produktu użyj słownika. Wypisz wszystkie dostępne produkty w sklepie. 1. Robimy słownik z produktami, dodajmy: ziemniaki 1.2 ...
b5776827935dd162406ebfd805897b3a2c512ba3
adrianmikol/2020-11-21-python
/basic_pgg/zad_6.py
393
3.828125
4
""" Napisz program sprawdzający czy podana przez użytkownika liczba: - jest nieparzysta, podzielna przez 3 i większa od 10 - lub jest to liczba 7. Podaj liczbe: Wynik: """ liczba = int(input("Podaj liczbe: ")) # https://docs.python.org/3/reference/expressions.html#operator-precedence wynik = (liczba % 2 != 0 and lic...
97105e60f0e37eff14474eaa2a4b4c4a9849f0dc
owoshch/Cracking_the_coding_interview_5
/chapter_8_recursion/8_7_permutations_without_dups.py
516
3.953125
4
""" 20 minutes. Recursive solution. """ def get_permutations(string, characters, permutations): if len(characters) == 1: permutations.append(string + characters[0]) for i in range(len(characters)): get_permutations(string + characters[i], characters[:i] + characters[i+1:]...