blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
fd277ea33f7b15547cc64be2d7fc7b0a11cf18bd
ElaynaRidley/caeser-and-vignere-encrypt-decrypt
/EBox.py
5,424
4.09375
4
class EBox: '''This class encrypts and decrypts messages using a password. Users can specify if they want to encrypt or with Vignere of Caeser algorithms. If they choose Vignere, they can choose to work at level 0 (simpler) or level 1 (more complex).''' ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" de...
0c4ead7364f6725cb503fc55d778d9f4efb786e1
katoluo/Python_Crash_Course
/chapter_04/pizza.py
213
4.03125
4
# pizzas列表 pizzas = [ 'pizza1', 'pizza2', 'pizza3'] # for 循环打印 for pizza in pizzas: print(pizza) message = "I'like " for pizza in pizzas: print(message + pizza) print("I really love pizza!")
760f09d49e79f68e5fd30edf7a36819fc326a3d2
paatrycjaa/PSZT_search
/test.py
2,320
3.546875
4
from timeit import default_timer as timer import numpy as np def sum_to_n(n, size, limit=None): """Produce all lists of `size` positive integers in decreasing order that add up to `n`.""" if size == 1: yield [n] return if limit is None: limit = n start = (n + size - 1) // si...
b6d560f1e201af9bdfa0f78e058b6908891f6782
masabumair023/Virtual-Assistant-Python
/Togo (Virtual Assistant).py
4,497
3.859375
4
import pyttsx3 # text to speech converter, offline module import datetime # to get the time import wikipedia # to get something from wikipedia import webbrowser # to work with browsers import os # to deal with files and directories import random # to generate random numbers import speech_recognition as sr # it will und...
57026beeec2497c2bd879114cae2d5b503ae47c2
joonluvschipotle/baekjoon
/10992.py
345
3.6875
4
a = int(input()) if a > 1: for i in range(1,a): for j in range(0,a-i): print(" ", end="") print("*",end="") print(" ",end="") for k in range(2,i): print(" ", end="") if i != 1: print("*",end="") print("") for i in range(0,(a*2)-1...
babf8f7771f62fb06cb4e5b4b913ba527af4f445
vans0123/password
/password.py
261
3.640625
4
password = 'a123456' while true: pwd = input('請施入密碼:') if pwd == password: print('登入成功') break else: x = x-1 print('密碼錯誤!還有',x,'次機會!) if x == 0: break
e5cc7e82694cd72109f43dec79559e8e6e28eb91
HarshKohli/leetcode_practice
/facebook/sorting_and_searching/intersection_of_two_arrays.py
336
3.8125
4
# Author: Harsh Kohli # Date created: 10/28/2020 def intersection(nums1, nums2): unique = set() for num in nums1: unique.add(num) inter = set() for num in nums2: if num in unique: inter.add(num) return list(inter) nums1 = [4, 9, 5] nums2 = [9, 4, 9, 8, 4] print(interse...
5d941b2128668ba71ad408bd166b37dfaf8d92e0
ypycff/pythonClass
/PythonDev/Demos/06-OOP/accounting.py
862
3.625
4
class BankAccount: """Simple BankAccount class""" __nextId = 1 __OVERDRAFT_LIMIT = -1000 def __init__(self, accountHolder="Anonymous"): self.accountHolder = accountHolder self.__balance = 0.0 self.id = BankAccount.__nextId BankAccount.__nextId += 1 def deposit(...
048685459d268eccdd74129e2d08eb364cb669bf
ryanhanli/Talking-Python
/ch11 - Connect Four/disc_fall.py
2,232
4
4
import turtle as t from time import sleep # Set up the screen t.setup(700,600,10,70) t.hideturtle() t.tracer(False) t.bgcolor("lightgreen") t.title("Connect Four in Turtle Graphics") # Draw six thick vertical lines t.pensize(5) for i in range(-250,350,100): t.up() t.goto(i,-350) t.down() t.goto(i,350...
ccf330abfea161543bdf6318c6abbe6e5fa3ff29
juancarvajaling/nba_player_heights
/player_heights/search.py
1,330
3.859375
4
from sys import argv from itertools import combinations from raw_data import HTTPGetter def search_player_pairs(input_height: int) -> str: '''Returns a string of all pairs of players whose height in inches adds up to the integer input If no matches are found, the application will return "No matches ...
255cf54629ee31650beb5e29c039d5d62c748d31
macrocj/Python
/Linked_list/Test_for_Cyclicity.py
2,628
3.734375
4
#Author: JC #Date: 9/8/2018 #Version: 1.0 class ListNode: def __init__(self,data): self.data = data self.next = None class Node: def __init__(self, data, next=None): self.next = next self.data = data class Linklist: def __init__(self): self.head = None def append...
a14e488c852cbcf78436aaa8bab4afc23bfde8b7
AlexAbades/Python_courses
/2 - Python Bootcamp/Lesson_6_Decorators&Generators/Decorators.py
3,691
4.59375
5
""" Functions & Decorators """ def func(): return 1 print(func()) def hello(): return 'Hello' print(hello()) # Functions are objects that can be passed to other objects greed = hello print('\nTesting the hello function: ') print(hello) print(hello()) print('\nTesting the gr...
40e0804714a8af3281502056706463d866459e78
JianghaoPi/LeetCode
/201-300/232.py
1,026
4.3125
4
class MyQueue(object): def __init__(self): """ Initialize your data structure here. """ self.s = [] self.reverse = [] def push(self, x): """ Push element x to the back of queue. :type x: int :rtype: void """ self.s.append(...
289de2a3c6a23a971795592a23cf1a60e356f286
klbfs/PROYECTOIG
/Curva de Aprendizaje/EtiquetasyColor.py
407
4.28125
4
from Tkinter import * # Se importa la libreria de TKINTER root=Tk() # Root muestra la ventana principal one= Label(root, text="One",bg="red",fg="white") one.pack() two= Label(root, text="two",bg="green",fg="black") two.pack(fill=X) three= Label(root, text="three",bg="blue",fg="black") three.pack(side=LEFT, fill=Y) ...
3f6147c6ee930a376638483492216b42b214c2de
wprudencio97/csc121
/wprudencio_lab7-10.py
1,422
3.953125
4
#William Prudencio, Chapter 7 - lab 10, 9/8/19 ''' This program allows the user to enter the name of a team and it then displays the times that team has won the world series and the corresponding years. The time period range for the results is 1903 - 2018. The program's input is non-case sensative and will loop unt...
749b5359fdd1322d43ffb3b09182507740411ca9
iannak/curso-em-Python
/Python Basico(Logica da programacao)/aula13/aula04/aula04.py
705
4.34375
4
""" Tipos de dados primitivos str - string - textos 'Assim' "Assim" int - inteiro - 123456 0 -10 -20 float - real / ponto flutuante - 10.50 1.5 -10.5 bool - booleano / logico - True/False # Ele so tem dois valores Ex: 10 == 10 """ # O pai entao e uma linguagem interpretada e uma linguagem de tipagem dinamica #print(t...
f3fa285b8c95a198d50c6a44f0a5cee1d380c4cc
hkngitworkshop/welcome-to-git
/introduction.py
3,128
3.78125
4
# HKN Git Workshop Python Demo # Author: HKN import hashlib from random import * # Used to create a grocery store. class Inventory: def __init__(self, items=[]): self.items = items def add(self, item): self.items.append(item) def rem(self, id): self.items = [item for item...
0042d3c87ad675d56bb4c712315982dbeabb05e9
2RMalinowski/algorithms-and-katas
/rot_13_func.py
977
3.8125
4
""" Caesar cipher (with using ord() and chr(), instead defined dictionary) """ def rot_as_many_as_wish(sentence, rotation): letter_list = [] for letter in sentence: if ord(letter) >= ord('a') and ord(letter) <= ord('z'): # number in alphabet: a = 0, b = 1, ... letter_number = o...
b45a568ceabf89dbed6028101e386b6fc9d38b2d
TechInTech/algorithmsAnddataStructure
/stackandqueue/interview30.py
2,011
3.78125
4
# -*- coding:utf-8 -*- """包含min函数的栈 """ class Solution_30(object): def __init__(self): self.cursor = -1 self.m_data = [] self.m_min = [] def push(self, value): if self.cursor == -1: self.m_data.append(value) self.m_min.append(value) else: ...
e30328ed03365b187facfbdfe837c2bc22971f83
weizt/python_studying
/元组、字典、集合/07-字典的遍历.py
862
4.125
4
person = {'name': 'zhangsan', 'age': 18, 'height': '180cm'} # 列表和元组是一个单一的数据,字典是键值对的形式 # 第一种遍历方式: # for...in循环获取的是key for x in person: print(x) print(x, '=', person[x]) # 第二种遍历方式 # 将key-value以元组的形式填入列表中 # 获取每一对键值对 print(person.items()) for item in person.items(): print(item[0], '=', item[1]) # 以折包的方式真接获取键值对...
fb2639cb97846b6648f9e3e6d501b48ac20d1195
infinity906/p-snake
/python project/weather.py
3,478
3.734375
4
import random import datetime import infinity123 as i def weatherlib(date): if date.lower() == 'january': num = list(range(-12, 10)) temp = random.choice(num) temp1 = temp * 1.8 + 32 # January = print("-4.6 degree celcius") elif date.lower() == 'february': num = list(ran...
dfb28b55bf8805d73eb29fbdf9ecff0418309853
labulakalia/note
/classnote/code/insert_sort.py
419
3.734375
4
import random def insertsort(lst): for i in range(1, len(lst)): # j = 0 for j in range(i): if lst[i] < lst[j]: data = lst.pop(i) print(lst[j]) lst.insert(j,data) break return lst a = [2,1,3] # for i in ...
f5edfe34e10d69825125b811e97f011b3a487874
Aayush-Kasurde/python-attic
/regex/Exercise6.py
426
4.1875
4
#!/usr/bin/env python # Exercise 6 - repeatition cases import re line = "123456" #matchObj = re.search(r'\d{3}', line, re.M|re.I) # Match exactly 3 digits #matchObj = re.search(r'\d{3,}', line, re.M|re.I) # Match 3 or more digits matchObj = re.search(r'\d{3,5}', line, re.M|re.I) # Match 3, 4, or 5 digi...
809857c8441dba03d937192605e4ee51a3451d5f
daniel-reich/ubiquitous-fiesta
/xPmfKHShmuKL5Qf9u_19.py
221
3.546875
4
def scale_tip(l): ii = l.index('I') a = (list(l[:ii])) b = (list(l[ii+1:])) if sum(a)== sum(b): return "balanced" elif sum(a) > sum(b): return "left" else: return "right"
2e03b2b0e6e2410bb8c313c3f678018c610eb4ed
caprapaul/assignments
/semester_1/fp/assignment_06-08/src/person.py
551
3.625
4
class Person: def __init__(self, uid: str, name: str, phone_number: str): self.__uid = uid self.__name = name self.__phone_number = phone_number @property def uid(self): return self.__uid @property def name(self): return self.__name @property def ph...
ee9ba0ef537aa4b45c4606ed97ee9c93d3352803
Evaldo-comp/Python_Teoria-e-Pratica
/Livros_Cursos/Nilo_3ed/cap09/Exercicio_09-03.py
1,156
3.609375
4
""" * Crie um programa que leia os arquivos pares.txt e imapres.txt e que crie um só arquivo * pareseimpares.txt com todas s linhas dos outros arquivos, de forma a preservar a ordem * númerica. """ def lê_número(arquivo): while True: número = arquivo.readline() # Verifica se conseguiu ler algo ...
3c0450a7838b1df2eb0a838b69fb194f431c057f
fowzy/pythonSummer2021
/3_LogicalOperators/love_calculator.py
1,344
4.0625
4
# 🚨 Don't change the code below 👇 print("Welcome to the Love Calculator!") name1 = input("What is your name? \n") name2 = input("What is their name? \n") # 🚨 Don't change the code above 👆 #Write your code below this line 👇 #Hints : # 1. The lower() function changes all the letters in a string to lower case. # 2....
5512c266097c6df543e0ffb772b27ee969cfce5c
abuss/300CIP001
/examples/orden.py
741
3.546875
4
import random x = [5,4,6,2,8,4,7,2,1,9,3] y = list(range(10,0,-1)) # y = list(range(20)) def quicksort(l): print(l) if len(l)<2: return l pivote = l[0] menores = [x for x in l[1:] if x < pivote] mayores = [x for x in l[1:] if x >= pivote] return quicksort(menores) + [pivote] + quicks...
a543747d6fcf7d497553b0d2b9dafa2bdfab90ce
akumaraswamy/Python-projects
/Data Wrangler/sqlite_example.py
440
3.59375
4
# -*- coding: utf-8 -*- """ Created on Sat May 27 09:26:15 2017 @author: aruna """ import pandas as pd import sqlite3 # Read sqlite query results into a pandas DataFrame con = sqlite3.connect("../data/hatecrimes.db") df = pd.read_sql_query("SELECT state as State, agtype as Agency_type, agName as Agency_name,vRace,vR...
d5e553d84e41e80fd1adee20d1d4ff18bededc10
hanjiwon1/pythonDjango
/d02/ex03/machine.py
1,009
3.671875
4
#!/usr/bin/env python3 # coding: utf-8 import random from beverages import * class CoffeeMachine: def __init__(self): self.use = 0 class EmptyCup(HotBeverage): def __init__(self): self.name = "empty cup" self.price = 0.90 def description(self): return "An empty cup?! Gimme my money back!" class...
483047cbc5773024cc2540d493ea25d637812a1d
mohamed-said-ibrahem/Forming-Magic-Square
/magic_square.py
4,795
4.40625
4
check_error = 1 def check_valid_input(square_side_length): """ Check the input number and valid it to be only positive odd number. :param int square_side_length: The magic square side length (input number from the user). :return: The method will return (0) if the input is valid and will return (1) ...
31445248a04cb9975f1403fdd6f9fcff71cfd054
faceface2/my_algorithm
/栈和队列/逆序栈.py
861
3.859375
4
from typing import Any, List Stack = List def get_and_remove_element(stack: Stack) -> Any: """ 递归查找栈底元素并返回 :param stack: :return: """ result = stack.pop() if not stack: return result else: last = get_and_remove_element(stack) stack.append(result) return...
56f741603db972a88ebef94a6a2bb1b869f9af74
mariapapag95/Python-Exercises
/String Reverse.py
134
3.734375
4
def reverse_my_string(string): string=string[::-1] return string print(reverse_my_string("Stop it mom, this is not a phase!"))
f83e2ca8ca5de26de4ca8c1941ecf9a6d2075a3a
sgh304/YouTube-to-Podcast
/yagui/element.py
1,500
3.640625
4
import pygame class Element: '''An object that represents some grouped logic within an App, likely containing Drawables''' # INIT def __init__(self): self.frame = 0 self.update_functions = [] self.cleanup_functions = [] # APP def set_app(self, app): '''Associates an...
f70d24f7aa0d389b3fa66d98544695116da56280
namatigi/pythontuts
/employee.py
3,020
3.609375
4
class Employee: raise_amount = 1.04 num_emps = 0 def __init__(self,first,last,pay): self.first = first self.last = last self.pay = pay self.email = first + '.' + last + '@phronetech.com' Employee.num_emps +=1 def fullname(self): return self.first +' '+ self.last def apply_raise(self): self.pay ...
5bd7a670543aea712f7e856eb709b993235dd323
antonioazambuja/study
/exercpythonbrasil/2.exerc_decisao/exerc13.py
362
3.9375
4
def main(): dias_semana = ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'] while True: dia = int(input("digite o numero do dia: ")) if dia not in range(1, 8): print('dia inválido, informe novamente.') else: break print(f'O dia corresponde...
ca899cf66b409b754f4ce3cd57ddcc1720e81a16
shreyash05/python_programs
/ImportArithmatic.py
227
3.71875
4
from Arithmatic import * def main(): no1 = int(input("Enetr first number:")) no2 = int(input("Eneter second number:")) ans = Arithmatic.Addition(no1, no2) print("Addition is",ans) if __name__=="__main__": main()
8fdb0dc609c071faebf67d33b34a26770cc6e9f4
crabreactorfuture/tol
/donuts.py
682
3.6875
4
import matplotlib.pyplot as plt # The slices will be ordered and plotted counter-clockwise. labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' sizes = [15, 30, 45, 10] colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral'] explode = (0, 0, 0, 0) # explode a slice if required plt.pie(sizes, explode=explode, labels=labe...
037f25459819c35522b73fe3b76089a137d913ac
goncalocarito/leetcode
/414.py
956
3.828125
4
# Description: https://leetcode.com/problems/third-maximum-number/description/ # Code import unittest class Solution: def thirdMax(self, nums): """ :type nums: List[int] :rtype: int """ snums = set(nums) firstmax = max(snums) second = snums - set([firstmax...
79e037d344c6d01f4491b536d7251c824602d3cd
BrianUribe6/Google-Foobar-Challenge-2019
/Google Foobar/Lovely Lucky Lambs/solution.py
157
3.6875
4
def fib(n): a, b = 0, 1 i = 0 while i <= n: i += 1 a, b = b, a + b return b for i in range(10): print(fib(i))
dec50a6df92e8aec0f36f98dd8b5dc55a379fc5c
Nehajha99/Python
/function/que8.py
128
3.765625
4
def squre(a): i=0 while i<=a: print(i,":",i**2) i=i+1 x=int(input("enter the number")) squre(x)
a27c02a470a76e0cd41215283d3d7f34b696e65d
sbudhram29/python_learning
/algo/avl/6_avl.py
4,400
3.78125
4
class TreeNode: def __init__(self, value, parent = None): self.value = value self.parent = None self.left = None self.right = None self.height = 1 class Avl: def __init__(self): pass def insert(self, root, value): if not root: return Tre...
8d3ec001d592566624767e34f44f49af7df7d20a
Shuricky/Creative-Problem-Solving-Computing
/Mock Exam 2.py
942
3.609375
4
def mismatchedPairs(s1,s2): c=0 if len(s1)!=len(s2): return "DNA string don't have same length" for num in range(0,len(s1)): if s1[num]=='A' and s2[num]!='T': c=c+1 elif s1[num]=='T' and s2[num]!='A': c=c+1 elif s1[num]=='C' and s2[num]!='G': ...
97b1629b2da11d59d70240457391dc8139c5e584
mateusmarinho/afrodev2-python
/aula090421/Exercicio04.py
1,247
4.28125
4
'''Fazer um algoritmo para identificar se um aluno passou de ano dada a nota e o número de faltas: nota entre 0 e 6 ou faltas maior que 9 então Reprovado, nota entre 6 e 8 e faltas menor que 10 então Aprovado com restrição, nota entre 8 e 10 e falta menor que 15 então Aprovado, nota 10 então aprovado com mérito''' de...
24978a4584db942798ba5f028b5b626db179e008
ashraf-amgad/Python
/Python Basics/numbers/numbers.py
899
4.0625
4
my_age_in_string = '23' my_age_in_numbers = 23 print('\n-->','my age in string is :- ', my_age_in_string) print('-->','my age in numbers is :- ', my_age_in_numbers, '\n') # print('-->','my age in numbers is :- ', str(my_age_in_numbers), '\n') first_number_in_string = input('please enter your first number :- ') seco...
dd9465a121133819495fc40aa98bc6d8d5d247c5
manikandan12629/Exercise
/venv/swapExercise.py
396
3.65625
4
x = [12, 35, 9, 56, 24] def approach1(): x.reverse() print(x) def approach2(): x = [12, 35, 9, 56, 24] myList=[] i = len(x) while i > 0 : myList.append(x[i-1]) i-=1 print(myList) def approach3(): x = [12, 35, 9, 56, 24] i = len(x) while i > 0 : y = lis...
95e880c2432c9d21ea0a00a03a2fd90a4dd6bf01
Amoursol/dynamoPython
/concepts/membershipBoolean.py
805
3.65625
4
""" MEMBERSHIP / BOOLEAN OPERATORS """ __author__ = 'Sol Amour - amoursol@gmail.com' __twitter__ = '@solamour' __version__ = '1.0.0' # Default list list = [1, 2, 3, 4] inCheck = 4 in list # Membership check to see if the number '4' is 'in' our # default list: Results in True as membership test is true no...
b257320836503dd0689f521922ec62d0a2c89175
Gabrielganchev/Programming0
/week1/thefirst_week/sundayweekend/sum_of_evens.py
86
3.75
4
a=int(input("number")) b=1 while b<=a: if b % 2 == 0: print(b+a) b+=1
dd205f38a19058c41f19c17a5b8e31abefe427f6
mnickey/change_maker
/change_maker.py
424
4
4
def make_change(amount, currency_list): my_change_list = [] for coin in sorted(currency_list, reverse=True): coin_count = amount // coin my_change_list += [coin] * coin_count amount -= coin * coin_count return my_change_list total_amount = 687 # Can use any currency denominations a...
c2d34ef56c7b75c0b8b369bd2523c7f2ebf20016
smilodon410/Python_code_study
/Project01/main06.py
2,126
3.796875
4
# Function : 함수 # # 1번째 함수 생성 # print(99) # def func01(): # print(1) # print(2) # print(3) # # func01() # print(100) # # func01() # # # 2번째 함수 형식 : 전달 인수 # def func02(num): # print('A') # print('B') # print('C') # # func02(50) # # # 3번째 함수 형식 : Return 이 있는 형식 # def func03(): # return 100 # #...
3d32598f29f27feb0c1c796093a1cdb945d271d8
cnrooofx/CS1117
/Sem2/CA1/functions.py
4,312
4.21875
4
# Script Name: functions.py # Author: Conor Fox 119322236 # Semester 2 - Continuous Assessment 1 # 1 def fractions(DNA): """gives fraction of DNA in the overall string :param DNA: input string or list to check :returns: fraction of C, G, T, A in the input """ # Checks that DNA is a non-empty stri...
3d67d667f7c635238b62f637bbb7bca5a7604a8d
k8godzilla/-Leetcode
/1-100/L250.py
2,115
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Jul 28 17:29:57 2019 @author: sunyin """ ''' 给定一个二叉树,统计该二叉树数值相同的子树个数。 同值子树是指该子树的所有节点都拥有相同的数值。 示例: 输入: root = [5,1,5,5,5,null,5] 5 / \ 1 5 / \ \ 5 5 5 输出: 4 来源:力扣(LeetCode) 链接:htt...
03138c1891c9b35e8daf1ba3acb660debfaa59f6
namrmino/Python_Basic_SelfStudy
/라이브러리 정리요약/String-Data-Type.py
4,130
3.734375
4
def printPicnic(itemsDict, leftWidth, rightWidth): print('PICNIC ITEMS'.center(leftWidth + rightWidth, '-')) for k, v in itemsDict.items(): print(k.ljust(leftWidth, '.') + str(v).rjust(rightWidth)) picnicItems = {'sandwiches': 4, 'apples': 12, 'cups': 4, 'cookies': 8000} printPicnic(picni...
a301f82dfd8b16e63f794faefbad97bc6e40a415
adhebbar/webapp
/webapp/airbnb.py
4,643
3.609375
4
# This python script performs two main functions: # 1) Formats data in CSV files for various functions of the webapp # (creating graphs, optimaization), and stores them as arrays in # javascript files. # 2) Computes linear regression coefficient paramters to model # price prediction. import numpy as np import csv...
ab77d2cb799bb4097596d78fdcb9a89a241e4177
PallaviRoy/HackerRankSolutions
/Day5-Loops.py
268
3.5625
4
#!/bin/python3 import math import os import random import re import sys if __name__ == '__main__': n = int(input()) for multiplier in range(1,11): stringPrint = str(n) + " x "+ str(multiplier)+ " = "+ str(n*multiplier) print(stringPrint)
02f2f7736ef3b3d244cb17f64bdca270f39f7436
daniel-reich/turbo-robot
/egHeSWSjHTgzMysBX_20.py
464
4.25
4
""" Create a function that takes a number as an argument and returns half of it. ### Examples half_a_fraction("1/2") ➞ "1/4" half_a_fraction("6/8") ➞ "3/8" half_a_fraction("3/8") ➞ "3/16" ### Notes Always return the simplified fraction. """ def half_a_fraction(fract): num, div = fract....
82ade6b3cbc6b249046b2e255c68067e777529eb
EliMendozaEscudero/ThinkPython2ndEdition-Solutions
/Chapter 6/Exercise6-4.py
581
4.34375
4
def is_power(a,b): """Returns true if a is power of b and return False otherwise""" if b==1 and a!=b: return False elif a%b==0 and is_power(a/b,b) or a==b: return True else: return False if __name__=='__main__': while(True): a = int(input("a:")) b = int(inp...
86e095b904d35955f396ff24dee2797ffa98fd88
fmardadi/basic-python
/nested_loop.py
367
4.1875
4
# for i in range(3): # print("i: {}".format(i)) # for j in range(3): # print("j: {}".format(j)) # for baris in range(5): # for kolom in range(5): # print("{}.{}".format(baris+1,kolom+1), end=" ") # print() count = 1 for baris in range(5): for kolom in range(5): print(count,...
e327c70d7107b4a9658a70ba15b222b1b5d890dd
sgupta25/IT-Academy-2019
/Lab5 IntegerSort-Gupta.py
375
3.9375
4
# Sarvesh Gupta # Integer Sort program # 9/18/2019 import random unordered = list(range(10)) ordered = [] random.shuffle(unordered) i = 0; print(unordered) while len(unordered) > 0: lowest = unordered[0] for i in unordered: if i < lowest: lowest = i ordered.append(low...
1ce0827402bda710f5c96b9f4f36cd156c455825
D3DeFi/playground
/OpenWeatherMap-Python-Docker/app/getweather.py
2,252
3.59375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Retrieves weather data fromm openweathermap.org for a provided city. This module doesn't accept any command line arguments, required input is provided via ENV variables. Where OPENWEATHER_API_KEY holds an API key for the openweathermap.org service and CITY_NAME specif...
700c68c4fdd338b9332191699056dfc2a3891906
bfknisely/Intro-to-Python
/src/02_lists_and_for_loops.py
2,904
4.3125
4
""" Created on Fri Jan 19 19:13:04 2018 @author: Brian Knisely The purpose of this code is to learn about assigning variables, displaying them, doing basic math, and importing modules This part at the top is called the docstring, where you can put relevant details about the code like when it was made, who made it, a...
ae63735040691e45ca61888c33314d6b13a77852
perogeremmer/MachineLearning-TIK_PNJ
/problem-generator.py
407
3.765625
4
import random def generator(num): points = 0 N = 1 while(N <= num): print "" if(N == num): return "---------" else: x = str(random.randint(N+1,num)) print "Jarak Kota Ke-" + str(N) + " Ke Kota " + str(x) + " adalah " + str(random.randint(1,10)) print "Jarak Kota Ke-" + str(x) + " Ke Kota " + str(N...
6ecb2f07fbfbb46388c4fbd0687f1efa223e7854
lisomartinez/Algorithms
/data-structures/DoublyLinkedList.py
1,703
3.640625
4
# -*- coding: utf-8 -*- """ Created on Fri Mar 20 10:13:42 2020 @author: lisan """ class Node(): def __init__(self, val): self.prev = None self.next = None self.value = val class DoublyLinkedList(): def __init__(self): sentinel = Node(None) sentinel.prev = se...
f5a0f3caa744497c43927ddfe193f540b5ee0ca6
qsctr/google-foobar
/bomb-baby/solution.py
231
3.6875
4
def solution(x, y): x = int(x) y = int(y) if y > x: x, y = y, x r = 0 while y != 1: if not y: return 'impossible' r += x / y x, y = y, x % y return str(r + x - 1)
9a8edee6756592e1ccf16e128d7ef9aaa964bf9f
TheoVerhelst/The-Great-Unicorn-Hunt
/code/dataPrep/clean.py
1,261
3.5
4
import pandas as pd import numpy as np def main(input_file, output_file): """ expected input_file : {train/test}_merged.csv expected output_file: {train/test}_merged.csv """ dataset = pd.read_csv(input_file) if 'trip_duration' in dataset: # Clean up trip duration in train data ...
6afc70ccbb31562c3664d86b4bd202d848be0bc2
CateGitau/Python_programming
/LeetCode/1281_subtract_prod_sum_of_digits_of_integer.py
420
4.125
4
""" Given an integer number n, return the difference between the product of its digits and the sum of its digits. """ n = 234 def subtractProductAndSum(n): temp = n prod = 1 sums = 0 while(temp != 0): prod *= temp % 10 sums += temp % 10 temp = int(temp /10) pr...
8028c5fb67f539bcc5a1fa778bebb6a9d3662087
CantOkan/Python
/Generator/fibo.py
269
3.9375
4
def fibo(): x=1 yield x y=1 yield y while True: x,y=y,y+x yield y generator=fibo() iterator=iter(generator) while True: ans=input("go:(Y/N):") if(ans.upper()=="Y"): print(iterator.__next__()) else: break
be244cf115e86b1732833a7fa98bcb076e0f8066
junbinding/algorithm-notes
/dp.best-time-to-buy-and-sell-stock-ii.py
833
3.65625
4
from typing import List class Solution: """ 122. 买卖股票的最佳时机 II https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-ii/description/ 给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。 设计一个算法来计算你所能获取的最大利润。你可以尽可能地完成更多的交易(多次买卖一支股票)。 注意:你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。 """ def maxProfit(self, price...
f6f8ae9f77e1c4fc2c12ca48cbf368f3d620c37b
zoown13/codingtest
/src/travel_route.py
1,040
3.625
4
routes = [] def solution(tickets): answer = [] airports = set() for ticket in tickets: airports.add(ticket[0]) airports.add(ticket[1]) for index, ticket in enumerate(tickets): # 항상 출발하는 공항은 ICN if ticket[0] != 'ICN': continue visited = [] v...
e21f8287f9ff46078646a2c2264649bb8650c608
yangxi5501630/pythonProject
/study/study/18_函数.py
3,105
4.21875
4
''' 函数格式: def 函数名(参数列表): 语句 return 表达式 ''' #1.定义无参无返回值的函数 def printinfo(): print("hello,world") #调用函数 printinfo() #2.定义有参函数 def printinfo1(name, age): print(name, age) printinfo1("youcw", 18) #3.函数返回值 def mysum(num1, num2): return num1 + num2 sum = mysum(100, 200) print(sum) #4.函数传参之:值传递 #值传...
743b83bf07fff19d5018a5e10b0d8ca873b07868
mr-zhouzhouzhou/LeetCodePython
/剑指 offer/全排列/字符串的排列.py
1,010
3.609375
4
""" 题目描述 输入一个字符串,按字典序打印出该字符串中字符的所有排列。 例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和cba。 """ # def perm(ss, res, path): # if ss == '': # res.append(path) # else: # for i in range(len(ss)): # perm(ss[:i] + ss[i + 1:], res, path + ss[i]) # # # ss = "abcd" # res = [] # # path...
5cfe054f5d0fba25835da0b27bc5817ac9b8ab96
StevenLdh/PythonStudyOne
/PythonExercise.py
1,882
3.953125
4
#!/usr/bin/python3 # -*- coding: UTF-8 -*- # 九九乘法表 """ for i in range(1,10): for j in range(1,i+1): print("{}*{}={}\t".format(j,i,i*j),end="") print() """ # 用户输入摄氏温度 """ # 接收用户输入 celsius = float(input('输入摄氏温度: ')) # 计算华氏温度 fahrenheit = (celsius * 1.8) + 32 print('%0.1f 摄氏温度转为华氏温度为 %0.1f ' % (celsius, f...
49bf4daaec1dd464f270f88a6eb2ff3c61d3dcff
HamPaz/PyForca
/Forca.py
3,176
3.8125
4
# Jesus é meu Senhor e Salvador. Glória e Honra ao Filho de Deus!!! # # Jogo da forca para exercício de aprendizado de Python # Autor: Hamilton Paz # Versão 2.0 a partir da versão de demonstração do professor # Total permissão para efetuar qualquer alteração e/ou distribuição # Passo 01: Importações das palavra...
920a95e4f1c5434f20b3e68cb8a2e527aa211c98
Ulisesuarez/proyectos
/Ejercicios_Python/ejercicio22.py
929
4
4
print("Introduzca cuántos números tienen que leerse por teclado:") Positivo=False while not Positivo: veces=int(input()) if veces<=0: print("este no es un numero valido de numeros") Positivo=False else:Positivo=True print("Introduce "+str(veces)+ " numeros enteros positivos") Done=False...
c20a60b35b4c5048b1a953df1e8bc7a0085254ff
FelipeAlves99/Reverse_Polish_notation
/src/Extensions.py
1,312
4.28125
4
# Arquivo de extensão para separar o calculo do processo principal # Extension file to separate the calculation from the main process def CalculateRPN(char, list): if char is '+': Add(list) elif char is '-': Subtract(list) elif char is 'x' or '*': Multiply(list) elif char is '/':...
a381ac7be64025a05bf5fe616157a439469d5757
Mobinul341/Journey-To-Pythonist
/variable&input.py
539
4.1875
4
''' #User Input by input() newVar = input() #Printing the output with Type () print(newVar, "\n", type(newVar))''' ''' #Integer input with int() newVar1 = int(input("Enter a Number: ")) print(newVar1, "\n", type(newVar1)) ''' ''' #Float input with float() newVar2 = float(input("Enter a Float number: ")) ...
5b1c5d0c4fb74de3532754a44af5e792e4f42587
nirmalnishant645/Python-Programming
/Practice-Problems/File-Handling/Copy.py
202
3.671875
4
a = input("Enter the file name to be copied from: ") b = input("Enter the file name in which to be copied: ") A = open(a, 'r') B = open(b, 'a') for i in A.readlines(): B.write(i) A.close() B.close()
68facb03c7eea61d229b7c41320c62de6fe26682
faisalkhanshah0/pythonpractise
/advmath.py
226
3.953125
4
#!/usr/bin/env python #some eg of mathematical functions import math; x=int(input('enter any no. to calculate factorial: ')); fact = math.factorial(x); print('factorial of given no. : ',fact); # print('pi value: ', math.pi)
17edb2f2340a918f90293af2d40b2063dce707fa
Amit3200/Python_Programming_Simple-Account-Program-
/Problem.py
3,857
3.8125
4
class Bank: __acc_name = [] __acc_id = [] __acc_bal = [] __acc_intrest = [] __intid=0 def addacc(self): z = input("Enter the account name : ") self.__acc_name.append(z) z = int(input("Enter the id : ")) self.__acc_id.append(z) print("Account Hol...
f3f52ff538d53f1ad766f9a267655d5728143788
tianhaomin/algorithm4
/Digraph/Topological.py
1,016
3.53125
4
# !/usr/bin/python # -*- coding: UTF-8 -*- # 优先级限制下的调度问题其实就是计算有向无环图的所有顶点的拓扑顺序 # 只有有向无环图才能进行拓扑排序 import DirectedCycle import DepthFirstOrder class Toplogical(object): def __init__(self,g): self.G = g self.finder = DirectedCycle.DirectedCycle(self.G) if not self.finder.hasCycle(): #...
a9fc1496327ead678d3bad7ca7955a3cbd1f53fb
mattyhempstead/policy-gradients
/weighted-features.py
2,410
4.0625
4
""" This program successfully demonstrates the converging properties of the policy gradient algorithm Given N actions, each with different reward values, and algorithm is able to correctly determine which is worth the most reward and converge to this action. This true for all cases, even if the algorithm begins highl...
09aabd848809012f0447bbed9174de58808fe8e1
AbhishekSV/100daysofcode
/Day 24/Snake Game Project/snake_module/scoreboard.py
1,158
3.609375
4
from turtle import Turtle from os import path, sys ALIGNMENT = "center" FONT = ("Courier", 24, "normal") class Scoreboard(Turtle): def print_score(self): self.clear() self.write(f"Score: {self.score} High Score: {self.highscore}", False, align = ALIGNMENT, font = FONT) def __ini...
93185710f6e2ad6c2aa7d2800c3eccf59f643870
linkel/algorithm-design-manual
/Chapter3_DataStructures/test_3-2_reversell.py
689
3.875
4
class ListNode: def __init__(self, val=None, next=None): self.val = val self.next = next arr = [1,2,3,4] def make_list(arr): next_node = None while len(arr) > 0: node = ListNode(arr.pop()) node.next = next_node next_node = node return node def print_list(node): ...
046d453c6767ff0d893ec0f3532da549fa5a13c8
shubhamkanade/all_language_programs
/Employee.py
600
3.8125
4
class Employee: Empcount = 0 def __init__(self,name,salary): self.name = name self.salary = salary Employee.Empcount += 1 def display(self): print("name is {} and salary is {}".format(self.name , self.salary)) @classmethod def displaycount(cls): ...
3a4567591a37d09f4792108f6a4c4e4d8224ef4c
eminem18753/hackerrank
/Mathemetics/stepping_stones_game.txt
554
3.65625
4
#!/bin/python from __future__ import print_function import os import sys import math # Complete the solve function below. def solve(n): if math.floor(math.sqrt(1+8*n))==math.ceil(math.sqrt(1+8*n)): return "Go On Bob "+str(int((-1+math.sqrt(1+8*n))/2)) else: return "Better Luck Next Time" if __...
229fdfc0fb91965a559273cfaa1375341e9a8889
jonathanlev/cs21
/youngest_child.py
1,470
4.375
4
#Jonathan Leventhal #cs21 assignment3 #youngest child #intro print('Please enter the three ages, in any order.') #get ages first_child = int(input('What is the age of the first child? ')) second_child = int(input('What is the age of the second child? ')) third_child = int(input('What is the age of the third...
7e3b682d268d553dda8ce8c3cbe07fc3bff101b2
florian-corby/Pylearn
/hanoi_curse_version/pretty_term.py
289
3.796875
4
#!/usr/bin/env python3 # Function to print a line in the center of screen def print_menu(scr, menu): h, w = scr.getmaxyx() for idx, row in enumerate(menu): x = w//2 - len(row)//2 y = h//2 - len(menu)//2 + idx scr.addstr(y, x, row) scr.refresh()
750f8bd067379b3d28970397d47adc6a919c295c
henrimory/D3-idade-POO
/idade.py
1,922
3.65625
4
from datetime import date class Idade: # definindo a classe def __init__(self, anoNasc, mesNasc, diaNasc): # inicializando self.anonasc = anoNasc # passando o raio pra váriavel self.mesnasc = mesNasc # iniciando minha area sem valor self.dianasc = diaNasc # iniciando meu perimetro sem ...
a0610cbd1f74fff54fdc5abbe602a41e0e753d64
c0ns0le/HackBulgaria
/week03/week03_02/p03_test_pandaSocialNetwork.py
1,588
3.546875
4
import unittest from p03_pandaSocialNetwork import Panda, PandaSocialNetwork class TestPandaSocialNetwork(unittest.TestCase): def setUp(self): self.socialNetwork = PandaSocialNetwork() self.panda1 = Panda("Gogo", "gogo@mail.bg", "male") self.panda2 = Panda("Pepa", "pepa@mail.bg", "female...
009ccb7d06f5231e6e07d68d4b5ae9f2ff686e2e
JagritiG/DS-Algorithm-Python3
/infix-prefix-postfix/infix_to_prefix.py
5,512
3.71875
4
# Infix to prefix conversion using two Stack # Pseudo code: # InfixToPrefix(expr) # # Create a stack S1 for operand # Create another stack S2 for operator # result <-- empty string # for i <-- o to length(expr)-1 # { # # # If current character is an operand # # then push it into operands stack. # ...
4f2d6f4df4c162f200e3f34d6fd2b413a594cc90
maxenceblanc/simple-platformer
/simple-platformer/main.py
5,569
3.609375
4
#! /usr/bin/env python #-*- coding: utf-8 -*- ######################## # Python 3.6.9 # Author : Maxence Blanc - https://github.com/maxenceblanc # Creation Date : 11/2019 ######################## # IMPORTS import os import sys import pygame from pygame.locals import * # EXTRA FILES import config as cfg import functi...
5c6ed832e37ef6fd90a4ce402dd7700ed21e40f3
eswartzendruber1/linux_setup
/bin/src/sandbox/vid_16.py
345
3.703125
4
def dumb_sentence(name='Bucky', action='ate', item='tuna'): print("%s %s %s" % (name, action, item)) print("{0} {1} {2}".format(name, action, item)) # use defaults dumb_sentence() # pass in all arguments dumb_sentence("Sally", "farts", "gently") #pass in some arguments and/or out-of-order dumb_sentence(item=...
1c05288007035d5dc8fb2b1053f0994a260e5915
arnabs542/interview-notes
/notes/algo-ds-practice/problems/dp/rod_cut/cut_rod_max_segments.py
1,455
3.84375
4
""" Given an integer 'length' denoting the length of a line segment. You need to cut the line segment in such a way that the cut length of a line segment is among the set of numbers 'segments' and the total number of cutted segments must be **maximum**. Input 2 4 2 1 1 5 5 3 2 Output 4 2 In first test case, total ...
abeb1b3cbb295b1ba39b578d552dd03f3faf8d18
Uthaeus/codewars_python
/7kyu/count_number.py
559
3.859375
4
# You are given a positive integer x. Your task is to count the number of cells in a table that contain number x. # sum(x.count('foobar') for x in list) def count_number(n, x): # count = 0 # Matrix = [[0 for i in range(n)] for j in range(n)] # for d1 in range(n): # for d2 in range(n): # ...
068e2adf082b8c295213bf0de944ee227e3088ce
Undiscovered-Data/pyautogui_cool
/pyauto/poly_a_tail.py
1,742
3.671875
4
#!/usr/bin/python3 open_file = open('./dest/comp3.fasta', 'r') writ_file = open('./dest/data.txt', 'w') #Gets the Covid Name def get_name(line): s_line = line.lstrip('>') a_list = s_line.split() the_name = a_list[0] return the_name ################################################################...
88e14bd555bc20f2fd874a17b8e0757d7370549f
l3ouu4n9/LeetCode
/algorithms/784. Letter Case Permutation.py
800
4.15625
4
""" Given a string S, we can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible strings we could create. Examples: Input: S = "a1b2" Output: ["a1b2", "a1B2", "A1b2", "A1B2"] Input: S = "3z4" Output: ["3z4", "3Z4"] Input: S = "12345" Output: ["123...
794f944906bb346a18f1aa23f9d9e47e691e4c8f
nchapin1/codingbat
/list-2/sum13.py
445
4.0625
4
def sum13(nums): """Return the sum of the numbers in the array, returning 0 for an empty array. Except the number 13 is very unlucky, so it does not count and numbers that come immediately after a 13 also do not count.""" if len(nums) == 0: return 0 for i in range(0, len(nums)): if n...
871df7db96f6a86ce05e4fc968f94f7cd2c61b58
HabibRh26/leetcode-solution-curation
/Algorithms/Hard/23_MergeKSortedLists/Solution.py
1,314
3.96875
4
#Merge Sort approach class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def mergeKLists(self, lists: List[Optional[ListNode]]) -> Optional[ListNode]: if not lists: return None def mergeSort(list...
1db478218ad450b7df8c66aca53abd02ca8fc221
ankur-0697/first-repository
/t3.2q6.py
69
3.5
4
for i in range(1,102): if (i%3==0) and (i%2==0): print(i)
dc343c20417625325369af28a3c91c37ee9830c2
anupa11/Scraping2
/IPHONE_sellingprice_Flipkart.py
511
3.65625
4
# Let us work through an example of web scraping the price information off of a flipkart page. import requests from bs4 import BeautifulSoup r = requests.get('https://www.flipkart.com/apple-iphone-12-pro-max-pacific-blue-128-gb/p/itmd89812b558a03').text soup = BeautifulSoup(r, 'lxml') # print(soup.prettify()) match1 =...