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
263a6ff0c63f5ea01dcf5a6a3a1801bae300a2f5
Baeth/CeV-Python
/Desafio043.py
679
3.96875
4
# Ler o Peso e a Altura; Calcular IMC e mostrar o status conforme lista: # Abaixo de 18.5: Abaixo do Peso; # Entre 18.5 e 25: Peso ideal; # Entre 25 e 30: Sobrepeso; # Entre 30 e 40: Obesidade; # 40+: Obesidade mórbida; peso = int(input('Digite seu peso em Kg: ')) altura = float(input('Digite sua altura em metros: ')) ...
f82def080f581d4e76df983968fc1b72fdd82eeb
Baeth/CeV-Python
/Desafio056.py
1,710
3.78125
4
# ler NOME, IDADE e SEXO de 4 pessoas. Output: # Média de idade do grupo; # Nome do HOMEM mais velho; # Quantas mulheres tem menos de 20 anos; nome = [] idade = [] sexo = [] # Nesse exercício resolvi colocar algumas validações para os campos a serem preenchidos. # Vou usar o método do "TRY", que aprendi estudando nun...
7606b38d5ea916bc8fded2afc26e8c3b4d323dcf
Baeth/CeV-Python
/Desafio051.py
286
3.84375
4
# ler o Primeiro Termo e a Razão de uma PA. Mostrar os 10 primeiros termos dessa progressão. pa = [int(input('Digite o primeiro termo de sua PA: '))] r = int(input('E qual seria a razão?: ')) for f in range(1, 10): pan = pa[0] + f * r pa.append(pan) print(f'Números da PA: {pa}')
150126d068ff2411895b3b44d8012a9eb91c65e2
Baeth/CeV-Python
/Desafio038.py
706
3.875
4
# Programa que peça dois números inteiros, compare-os e mostre a seguinte mensagem: # - O primeiro valor é maior. # - O Segundo valor é maior # - Não existe valor maior. Os dois são iguais. fimc = '\033[m' azul = '\033[34m' roza = '\033[35m' amarelo = '\033[33m' vermelho = '\033[31m' v1 = int(input('Digite o {}{}{} val...
6a923b07f5c2e95841ba63c998ba2f5f35c7e6ce
msilvestro/dupin
/interactive_story/story_graph.py
5,570
4.28125
4
"""Extend a directed graph to handle a story graph.""" import csv from interactive_story.graph import Graph class StoryGraph(Graph): """Extend the Graph class to create a story graph. A story graph is simply a directed graph in which each node (from now on called unit) is annotated in some way (e.g. emot...
92a884304c5eeba0db74e583ec1061c1c39ed171
consulo/consulo-python
/plugin/src/test/resources/inspections/PyUnusedVariableTupleUnpacking/test.py
589
3.5
4
def foo(): for x, y in [(1, 2)]: print x def test_vlu(): <error descr="Python version 2.6 does not support this syntax. Starred expressions are not allowed as assignment targets in Python 2">*<weak_warning descr="Local variable 'h' value is not used">h</weak_warning></error>, <weak_warning descr="Local...
95ce7a8effb5bd507090daa6a52f259fcb5b68a9
abhi9321/python_repo
/swap_case.py
328
3.828125
4
""" input : AbhIShek output: aBHisHEK """ def swap_case(s): swap = [] for i in s: if i.isupper(): swap.append(i.lower()) else: swap.append(i.upper()) return ''.join(swap) if __name__ == '__main__': s = "AbhIShek" # input() result = swap_case(s) print(...
7527a83b4822c4c55a1228e37fdeaa8bc3af3e94
abhi9321/python_repo
/pandas_map_values.py
681
4.09375
4
import pandas as pd """ # change the values in Marks column, Pass as Passed and Fail and Failed """ df = pd.DataFrame([['Uma', 'Science', 'Pass'], ['Priya', 'Maths', 'Fail'], ['Abhi', 'Social', 'Fail']], columns=['Name', 'Subject', 'Marks']) print(f'before changing values : \n{df}') df['Marks'] = d...
ae3f9a2736ae3a92b0a641f44d487602725ef327
pcunhasilva/PythonCourse2017
/Day03_Aug11/Exercises/ordinaltest.py
678
3.546875
4
import unittest from ordinal import myfunction class ordinal_Test(unittest.TestCase): def setUp(self): pass def test_is_equal_to_1(self): self.assertEqual(myfunction(1), "1st") def test_is_equal_to_2(self): self.assertEqual(myfunction(2), "2nd") def test_is_equal_to_3(self):...
ef6362e2f6f5abcf2ff0df1cc2265f6ca39205ab
murffious/pythonclass-cornell
/coursework/programming-with-objects/samples/unit6/pfuncs.py
961
4.09375
4
""" Module to demonstrate the Point class This module has a few simple functions that show how to use the Point3 class in the introcs module. Author: Walker M. White (wmw2) Date: May 24, 2019 """ from introcs import Point3 def copy2d(p): """ Makes a 2d copy of the point p This function makes (and ret...
c3bce9a9f83075deeb2e20c609676b26e669840e
murffious/pythonclass-cornell
/coursework/working-with-data-file/samples/unit4/convert.py
956
4.15625
4
""" Module showing the (primitive) way to convert types in a CSV files. When reading a CSV file, all entries of the 2d list will be strings, even if you originally entered them as numbers in Excel. That is because CSV files (unlike JSON) do not contain type information. Author: Walker M. White Date: June 7, 2019 "...
830b696b5b5fa08fc1a32ffe1368ead485c55f76
murffious/pythonclass-cornell
/coursework/using-recursion/exercise2/tests.py
1,514
3.953125
4
""" A completed test script for the recursive functions. Author: Walker M. White Date: July 30, 2019 """ import funcs import introcs def test_prod(): """ Test procedure for the function prod() """ print('Testing prod()') result = funcs.prod((5,)) introcs.assert_equals(5,result) ...
5916e4f112523f2fd4ea286648533b514ec5a7a6
murffious/pythonclass-cornell
/coursework/programming-with-objects/samples/unit1/bad.py
1,420
3.921875
4
""" Module with a function to compute the distance between two points. This version of the function shows why it is so unwieldy to rely on the primitive types (and why we want more complex types) Author: Walker M. White Date: May 24, 2019 """ import math def distance(x0,y0,z0,x1,y1,z1): """ Returns the di...
30be17d0390482768e1351980180136f55087a9e
murffious/pythonclass-cornell
/coursework/programming-with-objects/exercise2/funcs.py
1,793
4.15625
4
""" Module demonstrating how to write functions with objects. This module contains two versions of the same function. One version returns a new value, while other modifies one of the arguments to contain the new value. Author: Paul Murff Date: Feb 6 2020 """ import clock def add_time1(time1, time2): """ Re...
1444be4162dd25c2d84440bc1d250d1f4d93c5f5
alice19-meet/meet2017y1lab5
/stringfun.py
95
3.546875
4
def string_test(s): return len(s)>2 and s[0]==s[-1] def add_x(s): return('x'+s+'x')
5d5b9fec07f164f107d9556d29188cd12b181265
bishkou/leet-code
/Arrays 101/findMaxConsecutive1.py
388
3.546875
4
from typing import List def findMaxConsecutiveOnes(nums: List[int]) -> int: one = 0 maxi = 0 for i in range(0, len(nums)): if nums[i] == 1: one += 1 if one > maxi: maxi = one else: one = 0 return maxi if __name__ == '__main__': ...
139a31604f0da4849a087d0c09ce2460b76a9c14
bishkou/leet-code
/Linked list/linkIntersection.py
1,067
3.53125
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode: first = headA second = headB i = 1 j = 1 while first o...
a0a9e07b94e7d2559d8c21ca078c2149034cfc39
bishkou/leet-code
/Arrays 101/thirdMaxSearch.py
434
4.0625
4
from typing import List def thirdMax(nums: List[int]) -> int: nums.sort() if len(nums) < 3: return max(nums) count = 1 maxi = nums[-1] for i in range(len(nums)-1, -1, -1): if nums[i] < maxi: maxi = nums[i] count += 1 if count == 3: ...
5aa45d78764eb9ca62abc1f4d6bfd82b7056d90d
ellafrimer/shecodes
/lists/helper.py
549
4.46875
4
print("Accessing just the elements") for letter in ['a', 'b', 'c']: print(letter) print("Accessing the elements and their position in the collection") for (index, letter) in enumerate(['a', 'b', 'c']): print("[%d] %s" % (index, letter)) print("A string is also a collection...") for (index, letter) in enumerat...
2883dec0109abec67805f361b8bc7c8748b70a7f
ellafrimer/shecodes
/loops/geometric_shape.py
282
4.1875
4
""" making a triangle """ def print_asterisks(num): print("*" * num) # for number in range(1, 6): # print_asterisks(number) """ making a trapeze """ a_number = 8 for number in range(int(a_number/2), a_number+1): print_asterisks(number) """ making a diamond """
df6d702f6d6ce9e27aedaaeef60224e5616b50b8
ellafrimer/shecodes
/recrusion/mit16.py
898
4.09375
4
def two_numbers(x, y): """taking tow numbers that will recursively multiply""" if y == 0: return 0 return two_numbers(x, y - 1) + x def times(base, exp): """a recursive that takes a base and ** with the exp""" if exp == 0: return 1 return times(base, exp - 1) * base def ...
6c55ea3296d824f23139c0077ba8d071531391c8
cadelaney3/Design-Analysis-Algorithms
/brute_force/commonelems.py
502
3.71875
4
list1 = [2, 5, 5, 5] list2 = [2, 2, 3, 5, 5, 7] def commonelems(l1, l2): shortlist = [] longlist = [] commonlst = [] if len(l1) < len(l2): shortlist = l1 longlist = l2 else: shortlist = l2 longlist = l1 for item1 in shortlist: for item2 in longlist: ...
df3f60d1f8d5a34b7d4fa6425147424441f09aaa
cadelaney3/Design-Analysis-Algorithms
/brute_force/floorsqrt.py
267
3.5625
4
def floorsqrt(n): floor = 0 while floor * floor < n: floor = floor + 1 if floor * floor == n: return floor else: return floor - 1 print(floorsqrt(16)) print(floorsqrt(18)) print(floorsqrt(25)) print(floorsqrt(2)) print(floorsqrt(5)) print(floorsqrt(45))
41b93187b51716c631a504a1879bbaea81fb5d3a
jobliz/montante
/montante/operations/files/csv.py
657
3.5625
4
import os import csv from typing import Union, List def csv_headers_from_path(path: str) -> Union[None, List[str]]: """ Gets the list of CSV headers name from the file at the given path, or None if they are not present. """ if not os.path.isfile(path): raise FileNotFoundError('CSV file not...
f49f833604f4d43520a1b63a5e1766c122f9223f
mango0713/Python
/20191231- 하노이 탑.py
299
4.0625
4
def hanoi(n, from_pos, to_pos, aux_pos) : if n == 1 : print (from_pos, "->", to_pos) return hanoi (n-1, from_pos, aux_pos, to_pos) print (from_pos, "->", to_pos) hanoi (n-1, aux_pos, to_pos, from_pos) print ("n=8") hanoi (8, 1, 3, 2)
240c2ebc7ab3bfae9031a763b911f0a5f3ce0dd5
mango0713/Python
/20191022-삼각형.py
304
3.5625
4
a1 = input ("정삼긱형의 한변의 길이를 입력 하세용") a2 = int (a1) a3 = input ("정삼각형의 높이를 입력하세요") a4 = int (a3) print (a2) print (a4) print ("정삼각형의 둘의 합은 ",3*a2,"cm 입니다") print ("정삼각형의 면적은 ", 1/2 * a2 * a4,"")
8ff7a90b0ed005770b6d6515b3a4d3bd67c7458a
mango0713/Python
/20191022-직사각형.py
343
3.515625
4
a1 = input ("직사각형 가로변의 길이를 입력하세요") a2 = int (a1) a3 = input ("직사각형 세로변의 길이를 입력하세요") a4 = int (a3) print (a2) print (a4) print ("직사각형의 둘레의 합은 ", 2*(a4+a2),"cm 입니다") print ("직사각형의 넓이의 합은 ", a4 * a2,"제곱 cm 입니다")
677dc67a4978ac1a1727eb0e7d9fbadeaa9595da
rpd-tweet/Security-Testing
/UrlManipulation.py
1,412
3.5625
4
# URL Manipulation (request parameters and URL path) import requests from urllib.parse import urljoin import json def get_info(): global url, manipulated_string, username, password, data, method url = input("URL : ") manipulated_string = input("Manipulated String : ") method = input("Req...
7d5743ff0112b2a8455d891fdd80e289f9ac2956
leonardo111003/infosatc-lp-avaliativo-03
/exercicio5.py
667
3.703125
4
m = 0 mediaM = 0 f = 0 mediaF = 0 idgeralM = 0 idgeralF = 0 pessoas = int ( entrada ( "Escreva o total de pessoas" )) enquanto ( f + m < pessoas ): sexo = entrada ( "M para masculino e F" ) if ( sexo == "M" ): m = m + 1 idM = float ( input ( "Escreva sua idade:" )) idger...
7ae2ec9d4397bc58e45c4af8dfbe28722aa55cb1
atchu1/player
/play3.py
93
3.53125
4
num=int(input()) rev=0 while num>0: rem=num%10 rev=(rev*10)+rem num=num//10 print(rev)
8ca9a07e1babcacad463270efdd19114d4508597
ra2003/address_book_app
/addpeople.py
3,868
3.5
4
from tkinter import * from tkinter import messagebox import sqlite3 con = sqlite3.connect('database.db') cur=con.cursor() class AddPeople(Toplevel): def __init__(self): Toplevel.__init__(self) self.geometry("650x750+550+200") self.title("Add People") self.resizable(False, False) ...
202e227d9ec97d81f3ac76caf9d66760952a30b5
ypmoraes/Curso_em_video
/ex003.py
183
3.765625
4
n1 = int( input('Insira N1:') ) n2 = int( input('Insira N2:') ) s = n1 + n2 #print ('A soma entre' , n1 , n2 , 'vale' , s) print ('A soma entre {} e {} vale {}' .format(n1, n2, s))
5787938ccb07ebc168673e0b85ad33a021012094
ypmoraes/Curso_em_video
/ex067.py
373
3.828125
4
''' Criado 15/06 ''' n = int(input('Digite um numero para fazermos a tabuada:')) c = 1 while True: if n < 0: break print(f'{n} x {c} = {n * c}') c=c+1 if c == 11: print('=' * 15) n=int(input('Digite um numero para fazermos a tabuada:')) c = 1 if n < 0: ...
37d94b5fd1695014117f8a68fe741b836f29cd8f
ypmoraes/Curso_em_video
/ex020.py
305
3.625
4
import random aluno1=str(input('Insira o nome do aluno 1:')) aluno2=str(input('Insira o nome do aluno 2:')) aluno3=str(input('Insira o nome do aluno 3:')) aluno4=str(input('Insira o nome do aluno 4:')) lista=[aluno1, aluno2, aluno3, aluno4] random.shuffle(lista) print('A ordem eh: {}' .format(lista))
a70a764342bea69b653d9e19be822b01e67b0855
ypmoraes/Curso_em_video
/ex045.py
1,862
3.859375
4
from random import choice print('Vamos jogar jokenpo??\n' 'Acha que consegue me vencer?') jogador=str(input('Joookeenpoo!! Qual opcao voce jogou:')).upper() computador=['PEDRA','PAPEL','TESOURA'] computchoice=choice(computador) if jogador == 'PAPEL' and computchoice == 'PEDRA': print('Voce ganhou!!\n' ...
7377fcfaa49549ddffa2c153e39137f093587f7a
ypmoraes/Curso_em_video
/ex068.py
1,077
3.71875
4
''' Criado 15/06 ''' from random import randint print('Vamos jogar par ou impar?') vitorias=0 resultado='' while True: print('=' * 15) jogador=str(input('Voce quer par ou impar?')).upper().strip()[0] while jogador not in 'PI': print('Opcao invalida') jogador = str(input('Voce quer par ou i...
51a451d2c6c29c95d0d9860cbd57c5c5715c7e39
ypmoraes/Curso_em_video
/ex059.py
2,854
4
4
''' ######################################################################################## ## Enunciado: Crie um programa que leia dois valores e mostre um menu na tela: ## ## [1] - Somar ## ## [2] - Multiplicar ...
5e82dbc818936d6c511aa86c9c0a6421d261c1af
ypmoraes/Curso_em_video
/ex070.py
710
3.59375
4
total = milreais = menor = cont = 0 barato='' while True: nomeprod=str(input('Informe o nome do produto: ')) preco=float(input('Informe o preco do produto: R$ ')) total+=preco cont+=1 if preco > 1000: milreais+=1 if cont == 1 or menor > preco: menor = preco barato = nome...
b549a5802eee644367931836597348c179f0ce8f
ypmoraes/Curso_em_video
/ex012.py
160
3.765625
4
var1=float(input('Insira o valor do produto: R$ ')) desconto=var1 * 0.05 print('Este eh o valor do produto com 5% de desconto: R$ {}' .format(var1 - desconto))
6117b109e205ca8bfaeead20dd569e34983c079f
ypmoraes/Curso_em_video
/ex044.py
915
3.875
4
preco=float(input('Informe o preco do produto em R$:')) print('Escolha uma opcao de pagamento:\n' '1 - Dinheiro/cheque\n' '2 - A vista no cartao\n' '3 - 2x no cartao\n' '4 - 3x ou mais no cartao') pagamento=int(input('Digite o numero da opcao desejada:')) if pagamento == 1: desconto=preco * ...
8ca71292e8b076b3b9f1fa5c85cc68cc8c286aea
gaurishankara/elements
/graphs/solve_maze.py
1,405
3.953125
4
from collections import namedtuple Coordinate = namedtuple('Coordinate', ('x', 'y')) BLACK, WHITE=range(2) def search_maze(maze, S, E): if not (0 <= R.x <= len(maze) and 0 <= E.y <= len(maze[E.x]):) return [] def search_maze_helper(S): #if a square we are visiting is not white or x and y coor...
6276c03f5933147d623376818f96cfa35f07f8e8
shahamran/intro2cs-2015
/ex3/findLargest.py
410
4.46875
4
#a range for the loop riders=range(int(input("Enter the number of riders:"))) high_hat=0 gandalf_pos=0 #This is the loop that goes through every hat size and #checks which is the largest. for rider in riders: height=float(input("How tall is the hat?")) if height>high_hat: high_hat=height ganda...
b823418e4c7c6d275651442f175af0d46e1cdb4e
shahamran/intro2cs-2015
/ex3/decomposition.py
423
4.03125
4
gimli= int(input("Insert composed number:")) #gets Gimli's input stop= False day= 0 goblets= 0 #this loop decomposes the input number for it's decimal figures by division #(reads the composed number, figure by figure and prints each figure) while stop == False: if gimli// 10 == 0: stop= True goblets= gimli % 10...
2e553ea20b0f5e1d4b377f9764f551f422142c27
Lumexralph/python-algorithm-datastructures
/max_num_2_digit_integer/solutions.py
664
3.65625
4
"""There are 90 cards with all two-digit numbers on them: 10,11,12,...,19,20,21,...,90,91,...,99.10,11,12,...,19,20,21,...,90,91,...,99. A player takes some of these cards. For each card taken she gets $1. However, if the player takes two cards that add up to 100 (say, 23 and 77), at the same time, she loses all the mo...
9464770e05bf4bd58659953b756c084fe72d96c0
Lumexralph/python-algorithm-datastructures
/recursion/filesystem.py
979
4.03125
4
"""Algorithm DiskUsage(path): Input: A string designating a path to a file-system entry Output: The cumulative disk space used by that entry and any nested entries total = size(path) {immediate disk space used by the entry} if path represents a directory then for each child entry stored within directory path do total =...
5b3da0240ff975ec287e181799f30f149fe11b15
Lumexralph/python-algorithm-datastructures
/tutorial.py
563
3.859375
4
# def fib(n): # write Fibonacci series up to n # a, b = 0, 1 # while a < n: # print(a, end=' ') # a, b = b, a+b # print() # def fib2(n): # return Fibonacci series up to n # result = [] # a, b = 0, 1 # while a < n: # result.append(a) # a, b = b, a+b # ret...
795a1c3115d688c8a465f3659c576901c17366d9
Lumexralph/python-algorithm-datastructures
/dijkstra/dijkstra_2.py
3,251
4.40625
4
"""Module for dijkstra's algorithm breadth first search helps to know the path with the fewer segments or nodes or hops but if the time to travel through those points are included we can't use the algorithm to get that which brought about the need for dijkstra's algorithm to help determine the faster path from one poi...
8552969c9e3f4e2764951ac3914572d1b9744a36
Lumexralph/python-algorithm-datastructures
/trees/binary_tree.py
1,471
4.28125
4
from tree import Tree class BinaryTree(Tree): """Abstract base class representing a binary tree structure.""" # additional abstract methods def left_child(self, p): """Return a Position representing p's left child. Return None if p does not have a left child """ raise Not...
d9bd03ba664009e5e367a827e48a886af18a2b74
Kwaz990/TerminalTrader
/schema_KO.py
1,015
3.546875
4
#!/usr/bin/env python3 import sqlite3 #this is a data base manager that is included in the standad library connection = sqlite3.connect('example.db', check_same_thread = False) cursor = connection.cursor() # four types of operations we can do Create Read Update Delete # #this is create cursor.execute( """CR...
8215f0ddd48753b187bccb3ccd163e271478cf2a
CarlosUlisesOcampoSilva/Python
/ejemploObjetos.py
318
3.65625
4
class Persona: def __init__(self): self.edad=18 self.nombre="juan" print("Se ha creado a",self.nombre,"de",self.edad) #Metodo nuevo "hablar" def hablar(self, palabras): print(self.nombre,':',palabras) juan=Persona() juan.hablar("Hola, estoy hablando")
b4f50ebc1ce9800b62c775a924cba1deba0f72e6
Hipkevin/pat
/test/test_tree.py
1,131
3.546875
4
import unittest from dataStruct.tree import BinaryTree, BinaryLinkNode class BinaryTreeTest(unittest.TestCase): def setUp(self) -> None: self.tree = BinaryTree() nodeSet = [BinaryLinkNode(1), BinaryLinkNode(2), BinaryLinkNode(3), BinaryLinkNode(4)] self.tree.makeTree(self.tree.root, nodeS...
21ef066f3461592c7bf8f30dbbc3d81c23a6c96c
saukin/console_banking_in_python
/banking.py
1,174
3.625
4
import sqlite3 import account from cards import create_card import menu_messages try: connection = sqlite3.connect("card.s3db") cursor = connection.cursor() # cursor.execute("DROP TABLE card") cursor.execute( """CREATE TABLE card ( id INTEGER NOT NULL PRIMARY KEY, number T...
fe4b51c5fb55a458352dbed7e79c132d35eaa421
Gbemmiii/Python-task
/Area.py
158
4.28125
4
import math radius = float(input('Enter the radius of the circle')) area = math.pi * radius * radius print ('Area of the cicrle = {}'.format(area))
ccccb39e313823930bb2dd19225f153cedd3b85c
Kevinvanegas19/lps_compsci
/class_samples/lists.py
123
3.546875
4
teachers = ["Ms. T Raubert", "Ms. Wyatt", "Ms.Estrada", "Mr. Perkins"] print(teachers) teachers[2] = "Mr. Flax" print(teachers)
caf308fc4385c102d25e0dd35bd132017822a166
Kevinvanegas19/lps_compsci
/misc/calculateDonuts.py
360
4.15625
4
print("How many people are coming to the party?") people = int(raw_input()) print("How many donuts will you have at your party?") donuts = int(raw_input()) donuts_per_person = donuts / people print("Our party has " + str(people) + " people and " + str(donuts) + " donuts.") print("Each person at the party gets "...
8acc7456b244c00a202fcfcf39e57445afce4ab0
CodeMinge/syntax_algorithm_of_python
/语法学习/function/def_fun.py
218
3.78125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import math def quadratic(a, b, c): x1 = (-b + math.sqrt(b * b - 4 * a * c)) / (2 * a) x2 = (-b - math.sqrt(b * b - 4 * a * c)) / (2 * a) print(x1, x2) return x1, x2
d64d339ab2800064a7882951c68885b4211d4de0
cwmaguire/genetic_algorithms_book
/escape.py
834
3.703125
4
import turtle def escaped(position): x = int(position[0]) y = int(position[1]) return x < -35 or x > 35 or y < -35 or y > 35 def draw_bag(): turtle.shape('turtle') turtle.pen(pencolor='brown', pensize=5) turtle.penup() turtle.goto(-35, 35) turtle.pendown() turtle.right(90) tu...
a8b4d8ba60a960228c83a93363ebef1220e1b1c7
sanderheieren/in1000
/oblig4/funksjoner.py
1,509
3.765625
4
# Dette programmet skal lage to ulike funksjoner som vil returnere et tall, # og en annen skal telle antall forekomster av en bokstav # 1 Definerer funksjon, og sørger for riktig input def adder(tall1, tall2): if(isinstance(tall1, int) and isinstance(tall2, int)): print(f"Resultatet av {tall1} + {tall2} e...
6b42eec520480ce69836b6b68aa3bf2044c4b20d
dongyeon-0822/JumpToPython
/Chapter4/Q6.py
393
3.828125
4
# 사용자의 입력을 파일(test.txt)에 저장하는 프로그램을 작성해 보자. # (단 프로그램을 다시 실행하더라도 기존에 작성한 내용을 유지하고 새로 입력한 내용을 추가해야 한다.) str=input('test.txt에 저장할 내용을 입력하세요:') f1=open('test.txt','a') f1.write(str+'\n') f1=open('test.txt','r') print(f1.read()) f1.close()
8470784183b85d1632f1cdaaf3cf1ce6bd00cfed
dongyeon-0822/JumpToPython
/CodingDojang/unit18.py
96
3.6875
4
i = 0 while True: if i<0 or i>73: break if i%10==3: print(i, end=' ') i += 1
7c6c1f522b7dbc2e3dadc7c88dc95af97ee03dc6
dongyeon-0822/JumpToPython
/Chapter3/Q6.py
406
3.9375
4
# 리스트 중에서 홀수에만 2를 곱하여 저장하는 다음 코드가 있다. # 위 코드를 리스트 내포(list comprehension)를 사용하여 표현해 보자. if __name__=='__main__': numbers = [1, 2, 3, 4, 5] result = [] for n in numbers: if n % 2 == 1: result.append(n*2) print(result) result1=[n*2 for n in numbers if n%2==1] print(result1)
0cdc9fa2474800c4609237789950cc7c08b2b752
shellnoq/Hill-Cipher
/src/Hill_Cipher.py
2,703
3.78125
4
# coding: utf-8 import numpy as np def shape_key(): input_key = input("Enter key: ") i_key = [] for ch in input_key: if ch.isalnum(): i_key += [ord(ch)] all_cell = len(i_key) row_cell = int(all_cell**0.5) key_matrix = [] if (row_cell*row_ce...
ae5c343719328d4d27d47f6da4751956ab4d5c18
lparguin/stoch_calculus
/Python/SimpleBrownianMotion.py
1,893
3.515625
4
from bokeh.plotting import figure, show import random import numpy as np class BrownianMotion: def __init__(self, num_vectors, num_points): self._vectors = num_vectors self._points = num_points self._std_normal = np.random.standard_normal((self._vectors, self._points)) # generates...
7607d16293ac70b69b50198fd7161c066acb89d9
Sergvh/Python
/hw_3/2/duplicates_remove.py
357
3.625
4
import random count = int(input("Enter amount of list elements:")) a = [random.randint(1, 10) for i in range(0, count)] print("generated list:" + str(a) + "\n \n") for i in range(0, count, 1): j = i + 1 while j <= len(a)-1: if a[i] == a[j]: a.pop(j) else: j += 1 prin...
1c1ea140577b5fe6f070cedd6dad27873794160e
Sergvh/Python
/hw2/bubble_Sort.py
356
3.765625
4
import random count = int(input("Enter amount of list elements:")) a = [random.randint(1,200) for i in range(0, count)] print("generated list:"+str(a)+"\n \n") for i in range(0,count, 1): for j in range(0,count-1, 1): if (a[j]>a[j+1]): tmp = a[j] a[j] = a[j+1] a[j+1] ...
88d9507c00e3b36c41e61ea21965e7a97bd506dc
Sergvh/Python
/hw_3/3/Fibonacci_numbers.py
202
3.6875
4
num = int(input("Enter number please:")) a = [] def fib(n): if n == 1 or n == 2: return 1 return fib(n-1) + fib(n-2) while num > 0: a.append(fib(num)) num -= 1 print(a[::-1])
723f3f96ef4de201813c34b231bdd42815d600e4
Sergvh/Python
/hw2/bubble_sort_optimized.py
401
3.78125
4
import random count = int(input("Enter amount of list elements:")) a =[random.randint(1, 200) for i in range(0, count)] print("generated list:"+str(a)+"\n \n") for i in range(0,count, 1): swapped = 0 for j in range(0, count-i-1, 1): if a[j] > a[j+1]: a[j], a[j+1] = a[j+1], a[j] ...
8ca7fa0e9e96c5da48f13ff2596c0f62a9101eb1
Sergvh/Python
/hw3/dividers_list.py
179
4.09375
4
count = int(input("Enter amount of list elements:")) a = [] for i in range(1, count, 1): if i % 3 == 0 or i % 5 == 0: a.append(i) print("generated list:" + str(a))
37ed7787f0739479530520413c6b3c650dcd626e
hercules261188/ai_batch10
/Data_Visualization/Ex1.py
182
3.640625
4
import matplotlib.pyplot as plt x = [1,2,3,4,5,6,7,8,9] y = [2,5,6,7,5,4,1,2,9] plt.plot(x,y) plt.xlabel('x-axis') plt.ylabel('y-axis') plt.title('Line Plot') plt.show()
24d255116d34bbc7cdf67c0ef91dd2b5090a23f2
Jovanio-Junior/Py
/URI/1021.py
927
3.875
4
valor = float(input()) print("NOTAS:") #notas n100 = valor/100 print("%d nota(s) de R$ 100.00)" % n100) valor = valor%100 n50 = valor/50 print("%d nota(s) de R$ 50.00)" % n50) valor = valor%50 n20 = valor /20 print("%d nota(s) de R$ 20.00)" % n20) valor = valor%20 n10 = valor/10 print("%d nota(s) de R$ 10.00)" % n10) ...
89ed99dc709734d30ba5e0acffaa807b7d642404
brenopolanski/labs
/python/basic/readfile.py
192
3.625
4
# f = open('simple.txt', 'r') # print(f.read()) # lines = f.readlines() # for line in f: # print(line) # f.close() with open('simple.txt', 'r') as in_file: txt = in_file.read() print(txt)
385cab8c3ac04b9e51867d3c7a0bf897f6afe2e9
brenopolanski/labs
/python/basic/logger.py
599
3.78125
4
import logging # 1 debug - informacao detalhada # 2 info - confirmacao de que as coisas sairam como planejado # 3 warning - alguma coisa nao esperada aconteceu # 4 error - alguma funcao falhou # 5 critical - alguma falha na aplicacao aconteceu e fez a aplicacao cair logging.basicConfig(filename='log.log', level=l...
7fbf6cd46de28b683586a3e0d21dfeea6c2c142d
KivenCkl/DataStructures_Python
/Common_Algorithms/fibonacci.py
842
3.796875
4
""" Fibonacci sequence 斐波那契数列 F0 = 0 (n=0) F1 = 1 (n=1) Fn = F[n-1]+ F[n-2] (n=>2) """ import numpy as np def fib_1(n): # 递归 if n <= 0: return 0 elif n == 1: return 1 else: return fib_1(n - 1) + fib_1(n - 2) def fib_2(n): # 循环 re...
9dc1ce6aeb11b4834060d1781e47024346dac519
KivenCkl/DataStructures_Python
/Binary_Tree/btree.py
4,278
3.78125
4
from queue import Queue class _BinTreeNode: def __init__(self, data, left=None, right=None): self.data = data self.left = left self.right = right class BinTree: def __init__(self, root=None): self.root = root @classmethod def built_from(cls, node_list): """ ...
4af28b78e1fe33a89dc95f662bf9611bd83349c3
yariksimakov/Python
/home.work_6.2.py
215
3.546875
4
class Road: def __init__(self, length, width): self.__a = length self.__b = width def wigtht(self): return self.__a * self.__b * 30 * 0.1 print('{} kg'.format(Road(20, 2).wigtht()))
4c64c991a2e57cb9a809714f97a0dcef94e90f4c
ChristophWuersch/dsutils
/src/dsutils/cleaning.py
6,856
3.640625
4
"""Data cleaning * :func:`.remove_noninformative_cols` * :func:`.categorical_to_int` """ from hashlib import sha256 import numpy as np import pandas as pd from sklearn.base import BaseEstimator, TransformerMixin def remove_duplicate_cols(df): """Remove duplicate columns from a DataFrame. Uses hashing to...
f889bc8aeb17d70e414f269bdf18352ffc6ea9b9
pk10080615/pihat
/magic_8_ball.py
589
3.953125
4
#!/usr/bin/env python # this code works like a magic 8-ball, with 6 random responses! import sys import random ans= True while ans: question = raw_input("Ask the magic 8-ball a question: (press enter to quit)") answers = random.randint(1,8) if question == "": sys.exit() elif answers == 1: print ("Absolute...
91a7de3b5fc5f1321ed22021360ebdf8c02f38b3
fieldsparrow2629/guess-a-number
/guess_a_number_ai.py
4,971
4.09375
4
# Guess a number ai #by Erik B. import random import math # config num_guess = 0 name = 'null' intelligence = 0 # helper functions def show_start_screen(): print(""" ╔═╗┬ ┬┌─┐┌─┐┌─┐ ┌─┐ ┌┐┌┬ ┬┌┬┐┌┐ ┌─┐┬─┐ ╔═╗ ╦ ║ ╦│ │├┤ └─┐└─┐ ├─┤ ││││ ││││├┴┐├┤ ├┬┘ ╠═╣ ║ ╚═╝└─┘└─┘...
5c30a50ffccf7db8bdb9b2aac389c287a6bf8442
AvengerDima/Python_Homeworks
/Homework_5(17-20).py
4,383
3.671875
4
import math import random #Задача №17 print("Задача №17 \n Задание: Написать функцию решения квадратного уравнения. \n Решение:") def solve_quadratic_equation(a, b, c): discriminant = b**2 - 4*a*c if discriminant > 0: x1 = (-b + math.sqrt(discriminant)) / (2 * a) x2 = (-b - math.sqrt(discrimina...
c15eea81addc2367469b2a3203b910d6bfec5a51
D4nfire/Dissertation
/daf16_mmp.zip/Python_Code_Files/Rank_On_Expression_Value.py
5,779
3.84375
4
# web sources for some parts of the code. # Sorting a list in python used in sortAndPrintRanking: # http://pythoncentral.io/how-to-sort-a-list-tuple-or-object-with-sorted-in-python/ # This file will give the ranking of the KO gene based on the absolute # or actual expression change values for each gene. The file n...
dc75922ccd5788412b0a0142058ea6ac41332f99
mlastovski/kse-numbers-transform
/to_binary_and_to_decimal.py
1,356
3.8125
4
def transform(x, user_input): output = '' if x == 2: user_input = int(user_input) while user_input != 0: number = user_input % 2 output = str(number) + output user_input = int(user_input) // 2 output = '0b' + output print(output) eli...
0c461810c2e4f5d692c9a736ca6377fec520f85c
Nitesh-james/my-project
/GuessGame.py
683
4
4
# Author :- Nitesh # A beginer python learner from Youtube "CodewithHarry" rule = '''There are number between 1 to 100 , the number is hiden. lets guess it ''' print(rule) import random randomNumber =random.randint(1,100) userGuess = None gusses = 0 while(userGuess != randomNumber): userGuess = int(input("entr...
4050d4e88e470ffdbd58e8c99bb4cc916b79b8f7
TreyMcGarity/Graphs
/projects/ancestor/ancestor.py
997
3.9375
4
from graph import Graph ancestors = [(1, 3), (2, 3), (3, 6), (5, 6), (5, 7), (4, 5), (4, 8), (8, 9), (11, 8), (10, 1)] def earliest_ancestor(ancestors, starting_node): # Using graph object be able to add "nodes" to structure # and "edges" between nodes to connect them graph = Graph() # traver...
5fbf527a7a1db546225574466a7a702f6c038dff
m-alsaad/AcesUp-Test
/src/AcesUp/TestSuitsClass.py
595
3.609375
4
## # ## import unittest from Suits import Suits class TestSuitsClass(unittest.TestCase): def test_HEART(self): HEART = Suits.HEART self.assertTrue(HEART.value == u"\u2665") def test_DIAMOND(self): DIAMOND = Suits.DIAMOND self.assertTrue(DIAMOND.value == u"\u2666") d...
1f61f3195881e8e121c07c6eb45d110299a2cafa
Dhrumil-Zion/Competitive-Programming-Basics
/LeetCode/Backtracking/Subsets.py
554
3.6875
4
def subsets(nums): def dfs(nums, target, path, res): if target > 0: target -= 1 elif target == 0: res.append(path) for i in range(len(nums)): dfs(nums[i+1:], target, path + [nums[i]], res) res = [[]] dfs(nums, 1, [], res) return res from itert...
ac6986b4a74b62a5aaa13a45cb69b30a8e8baea3
Dhrumil-Zion/Competitive-Programming-Basics
/LeetCode/String/Find_and_Replace_Pattern .py
443
3.78125
4
words = ["abc","deq","mee","aqq","dkd","ccc"] pattern = "abb" def findAndReplacePattern(words, pattern): pattern = word2Num(pattern) print([word for word in words if word2Num(word) == pattern]) def word2Num(word): ch2Digit = {} digits = [] for ch in word: if ch not in ch2Dig...
1933c890b6006b04854c1ef51d444535bcd707ff
Dhrumil-Zion/Competitive-Programming-Basics
/Halloween Sale.py
564
3.65625
4
def howManyGames(p, d, m, s): budget = s price = p deduction = d minprice = m c=0 while 1: budget = budget - price if budget>=0: price = price -deduction if price>minprice: c+=1 continue else: if ...
cd28dfecbe926cab34ede4d9275871e9b619866b
Dhrumil-Zion/Competitive-Programming-Basics
/Codechef/Complexity Analysis + Basics Warm Up/Life_ the_Universe_and_Everything.py
162
3.84375
4
# Problem Name: Life, the Universe, and Everything # Problem Code: TEST while 1: num =int(input()) if num==42: break else: print(num)
1ce2bc3329f7763f3dfe97fa94448fdc95bef43c
Dhrumil-Zion/Competitive-Programming-Basics
/LeetCode/Arrays/median_of_two_arr.py
253
3.78125
4
nums1 = [] nums2 = [2] final_arr = nums1+nums2 final_arr.sort() index = int(len(final_arr)/2) print(final_arr) if len(final_arr)%2==0: print("{:.5f}".format((final_arr[index]+final_arr[index-1])/2)) else: print("{:.5f}".format(final_arr[index]))
025928f2be36acbe23c3b1aaaa3c99f2805685a3
Dhrumil-Zion/Competitive-Programming-Basics
/permute_arry.py
662
3.5625
4
import random def twoArrays(k, A, B): A.sort() B.sort(reverse=True) if (any(a+b<k for a,b in zip(A,B))): return "NO" else: return "YES" A =[84 ,2 ,50 ,51 ,19, 58, 12 ,90 ,81 ,68 ,54 ,73 ,81 ,31 ,79 ,85 ,39 ,2] B =[53 ,102, 40 ,17 ,33 ,92 ,18 ,79 ,66 ,23 ,84 ,25 ,38 ,43, 27, 55, 8, 19] K...
548f54d3de1f50339c31a458d68472183650b1b3
Dhrumil-Zion/Competitive-Programming-Basics
/LeetCode/Arrays/third_max.py
130
4.03125
4
nums= [2,2,3,1] temp = list(set(nums)) if len(temp)<3: print(max(list(set(nums)))) else: temp.sort() print(temp[-3])
30d24fdc40873778849232f15b4a20069547a568
Dhrumil-Zion/Competitive-Programming-Basics
/LeetCode/String/check_panagram.py
159
3.71875
4
sentence = "abcdefghijklmnopqrstuvwxyz" print(True if len(set(sentence))==26 else False) ## optimized in terms of memory usage print( len(set(sentence))==26)
316a67da99b5b2d7a692b504b4edccc9af77fd80
Dhrumil-Zion/Competitive-Programming-Basics
/LeetCode/Math/sign_of_product_of_array.py
120
3.640625
4
nums = [-1,-2,-3,-4,3,2,1] if 0 in nums: print(0) elif sum(c<0 for c in nums)%2==0: print(1) else: print(-1)
536e3dc3994fec3c23b25cd8169ee16224f09bc2
Dhrumil-Zion/Competitive-Programming-Basics
/Codechef/Easy Problems to Get Started/Is_Both_Or_Not.py
229
4.0625
4
# Problem Name: Is Both Or Not # Problem Code: ISBOTH ## getting input num = int(input()) ## checking conditions if num%5==0 and num%11==0: print("BOTH") elif num%5==0 or num%11==0: print("ONE") else: print("NONE")
baac38ff3147019531940c6902a2eebf93e9bb4d
Dhrumil-Zion/Competitive-Programming-Basics
/LeetCode/Math/plus_one.py
141
3.515625
4
digits = [1,2,3] string_ints = [str(int) for int in digits] s = "".join(string_ints) c = int(s)+1 temp = [int(v) for v in str(c)] print(temp)
056b6116c9f07e19d98ec9f39ea1dc11158f78d6
Dhrumil-Zion/Competitive-Programming-Basics
/LeetCode/Arrays/check_for _doubles_in_array.py
151
3.703125
4
arr = [3,1,7,11] flag = 0 for a in arr: temp = a*2 if temp in arr: flag=1 print("True") if flag==0: print("false")
81315b6bce5b9d5d768a4bb07ef5b2002d71f8f3
Dhrumil-Zion/Competitive-Programming-Basics
/Codechef/Easy Problems to Get Started/Raju_and_His_Trip.py
123
3.890625
4
# Problem Name:Raju and His Trip # Problem Code: VALTRI num = int(input()) print("YES" if num%5==0 or num%6==0 else "NO")
b315746ca72159f86601ac96fd2a6b771af91823
Dhrumil-Zion/Competitive-Programming-Basics
/Codechef/Practice/Primality Test.py
236
3.671875
4
import math def prime(n): if(n==1): return 'no' for i in range(2,int(math.sqrt(n))+1): if(n%i==0): return 'no' return 'yes' for _ in range(int(input())): ans=prime(int(input())) print(ans)
9023484b560b910a3ec23243755eaa4d84b54d65
Dhrumil-Zion/Competitive-Programming-Basics
/LeetCode/Math/Reverse_integer.py
904
3.53125
4
import math x = 120 ########################## Optimized one by @LebronZheng res = 0 sym = 1 # neg. cases if x < 0: # symbol to -1 sym = -1 # value to positive x *= -1 while x: # find remainder rem = x % 10 # add up to result res = res * 10 + rem # check former digit x = int(...
2ff0e351f226c9a1d5210b37248244637a9c02f3
Dhrumil-Zion/Competitive-Programming-Basics
/Codechef/LET'S CODE DSC GGV/Help Suraj.py
449
3.84375
4
# https://www.codechef.com/LETS2021/problems/LETSC001 def primecount(n): prime = [True]*(n+1) i = 2 while i*i <= n: if prime[i]: for j in range(i*i, n+1, i): prime[j] = False i += 1 primenumbercount = 0 for j in range(2, n+1): if prime[j]: ...