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
cd3c9ab67fffa0784b06e2b08ffd8097a47ceca3
ardaunal4/My_Python_Lessons
/Logging(Hata bulma)/Example_of_logging.py
1,013
3.59375
4
import logging import math #Create and configure logger LOG_FORMAT = "%(levelname)s %(asctime)s - %(message)s" logging.basicConfig(filename="log_example.Log", level=logging.DEBUG, format=LOG_FORMAT, filemode='w') logger = logging.getLogger() def quadratic_formula(a, b, c): """Return solutions to the equation a...
ee6e9248a17fc4ec2426cebf57ec9404dea28955
ardaunal4/My_Python_Lessons
/ClassPython/example_of_properties_of_classes.py
1,459
4.21875
4
# -*- coding: utf-8 -*- """ Created on Wed May 27 02:35:30 2020 @author: ardau """ from abc import ABC, abstractmethod from cmath import pi class shape(ABC): """ Parent class / abstract class example """ # abstract methods @abstractmethod def area(self): pass @...
5d4a00522dbf285a359d4aee0c0d88b2539ea0f2
ardaunal4/My_Python_Lessons
/random_walk.py
1,181
3.96875
4
import random import math # from decimal import Decimal """ def random_walk(n): x = 0 y = 0 for i in range(n): step = random.choice(['N', 'S', 'W', 'E']) if step == 'N': y = y + 1 elif step == 'S': y = y - 1 elif step == 'W': x = x - 1 ...
017ff11f07b55f3ced48b94da94f8af9a29c5047
ardaunal4/My_Python_Lessons
/multiprocessing/intro6.py
801
3.65625
4
# Youtube Link: https://www.youtube.com/watch?v=TQx3IfCVvQ0&list=PL5tcWHG-UPH3SX16DI6EP1FlEibgxkg_6&index=6 # Queue : class to communicate between different processes. from multiprocessing import Process, Queue def square(numbers, queue): for i in numbers: queue.put(i*i) def cube(numbers, queue)...
33c1feb36398f075fc0b1d205803ad901e7366d6
ardaunal4/My_Python_Lessons
/ALGORITHMS/Fundemantals of_Python_Questions/questions3.py
723
4.25
4
# How you can convert a sorted list to random from random import shuffle my_list = [0, 1, 2, 3, 4, 5, 6, 7] print("Sorted list : ", my_list) shuffle(my_list) print("Shuffled list : ", my_list) # How you can make sorted list from random list my_list.sort() print("Sorted list : ", my_list) # What are funct...
5e2eba80e377a1eb7d2fadfe8c52999605fe8e06
ardaunal4/My_Python_Lessons
/ClassPython/abstract_class.py
488
4.28125
4
from abc import ABC, abstractmethod # abc -> abstract base class class Animal(ABC): #super class @abstractmethod # this makes the class abstract def walk(self): pass def run(self): pass # this abstract class is a kind of template for other sub classes class Bird(A...
12d353536efd8d9897b4c4037cafad4915d1b75f
ardaunal4/My_Python_Lessons
/Data_Types/sets.py
370
3.953125
4
import math #You can use methods with set which is finding by writing this : dir(set()) example1 = set(['hale', 45, math.pi, 66.5, 'A']) print(example1) #create three types of set odds = set([1, 3, 5, 7, 9]) evens = set([0, 2, 4, 6, 8]) primes = set([2, 3, 5, 7]) intersection = odds.intersection(evens) union = odds....
d62675037ad512987ae2355bfb5d0a3bfc05a471
ardaunal4/My_Python_Lessons
/map_filter_lambda.py
266
3.640625
4
x = [1, 2, 3, 4, 5, 6, 7, 8] filtered_list = list(filter(lambda x:(x%2 == 0), x)) # first variable is a function in this case it is lambda function and second variable is a list print(filtered_list) mapped_list = list(map(lambda x: x**2, x)) print(mapped_list)
c157d87475752e6da82073f8efbbc7a353abcf60
twistedmove/data-structures
/DynamicArray/dynamic_array.py
2,855
3.796875
4
#!/usr/bin/env python3 class Array(): ar = [] # Pretend this is actually a static array size = 0 # length user thinks array is capacity = 0 # Actual array size def __init__(self, capacity = 16): if capacity <= 0: raise ValueError("Illegal size.") self.ar = [None for _ in range(capacity)]...
fb578003a54b6ccbfff4f2ab2d0cc69c0fbcad8f
balasubramanyam2/Python
/inputmethod.py
453
4.03125
4
#a= input("please enter your name:") #print("your name is"+ " "+ a + ".") #print(type(a)) Name= input("What is your name:") Quest = input("What is your quest:") Colour = input("What is your favourite colour:") #print("your name is"+ " "+ Name + ".") #print("Your quest is" + " " +Quest + ".") #print("Your favourite col...
dc54c5381d477ff6c261b34c2b7b3d8aa5ab91ca
balasubramanyam2/Python
/palindrome.py
183
4.15625
4
N=input("Enter the string") reverse = "" for i in range (len(N) -1, -1, -1): reverse += N[i] print(reverse) if reverse ==N: print("polindrome") else: print("not a polindrome")
e8ff91af8e055ac20c3613fad588c775a010a7d6
arthurnap24/ADragonProjects
/Dragon/DragonAdvantage/Python/utilities/share_calculator.py
676
3.578125
4
# calculate the number of shares to buy and the stop price and take profit price def calculate_share_info( share_price, capital, risk, gain_multiplier ): total_shares = float(capital) / share_price risk_decimal = float(risk) / 100 risk_amount = capital * risk_decimal gain_amount = risk_amount * gain_mu...
90c5712651aa5d3779d35ccb6a64515167b1176c
ideas4u/pythoncentos
/palindromes_v3.py
334
4
4
""" >>>is_palindrome_v3('noon') True >>> is_palindrome_v3('racecar') True >>> is_palindrome_v3('dented') False """ def is_palindrome_v3(s): i = 0 j = len(s) - 1 while i < j and s[i] == s[j]: i = i + 1 j = j - 1 return j <= i print is_palindrome_v3('noon') print is_palindrome_v3('racecar') print is_palindrome_...
e85325c71ca979e3e07f126a6ae740586f0e6410
rjtsg/SimpleSmallPythonGames
/RedAndBlues/SimpleGameV2.py
10,094
3.828125
4
import pygame import random import numpy as np import matplotlib.pyplot as plt pygame.init() """ What I want to create here is the following game: x I want a green background x I want Red Circles x I want Blue triangles x They will both move around randomly (~they should also not move out of the screen) ...
7a74de9f6b5cf45cfba6feeb3ac140d0d4c1e32b
SanjuktaBhatt/G11_C4
/Project_solution.py
770
3.6875
4
import pygame pygame.init() WHITE = (255,255,255) DARKBLUE = (36,90,190) LIGHTBLUE = (0,176,240) RED = (255,0,0) ORANGE = (255,100,0) YELLOW = (255,255,0) size = (500, 500) screen = pygame.display.set_mode(size) pygame.display.set_caption("Project C3") carryOn = True while carryOn: for event in pygame.event.get(): ...
64e8a71e52be33e19fe907dc48eef2faeacd1be4
v1s2k/dopPythoN
/d3/d31.py
950
4.03125
4
# Привести примеры кода, которые соответствуют следующим нарушениям PEP 8: # whitespace before "(" def p1 (x): print (x) # missing whitespace around operator def p2(x): print(x>1) # missing whitespace after "," def p3(x): print(x,x,x) # unexpected spaces around keyword / parameter equa...
6f67e3f8e002aeabb8f4bd8df82f23ec93a400e1
jotajota05/AI_USB
/artificial_intelligence_I/project_3/solitario-cnf.py
3,928
3.671875
4
import sys #Da el valor de la variable dados fila, columna y contenido def variable(m, fila, columna, contenido): return (fila-1)*m*3 + (columna-1)*3 + contenido #Devuelve las dimensiones del tablero def dimension(nombre_archivo): archivo_entrada = open(nombre_archivo,"r") linea = archivo_entrada.readline() m=0 ...
8062a2fc4a55ab2e3acf3e944f80e0e7ae9d5d43
TylerThatcher/Random-Number-Guessing-Game
/random game.py
1,396
4.03125
4
#!/usr/bin/env python # coding: utf-8 # In[5]: import random def guess_game(): game = True while game: number = random.randrange(1, 10) tries = 0 ## Game Start print("I'm thinking of a number between 1 and 10") guess = int(input("Have a guess, you ...
4102d9d2ca48fbe19e9f5017eddaba7862786643
ipung-uhb/data-structures
/nonprimitives/array/array-find.py
540
3.953125
4
# importing array module import array # siapkan array integer arr = array.array('i', [1, 2, 3, 1, 2, 5]) # cetak array asli print ("Array asli adalah : ", end ="") for i in range (0, 6): print (arr[i], end =" ") print ("\r") # Gunakan index() untuk mencetak element dengan nilai 2 print ("Index array ...
66c68ec3eabadf32450698276c8a49401f66cad2
ipung-uhb/data-structures
/nonprimitives/array/array-basic.py
1,828
3.640625
4
beli1 = 'Tomat' beli2 = 'Kangkung' beli3 = 'Bayam' beli = ['Tomat','Kangkung','Bayam'] cetak = beli[0] #ambil value di index ke 0 print(cetak) #output 'Tomat' #perulangan untuk akses array for x in beli: #tercetak semua value print(x) beli = ['Tomat','Kangkung','Bayam'] panjang = len(beli) print(panjang) ...
5fbdce4933a7dfdac428d1123bc6aec245acf80c
ipung-uhb/data-structures
/nonprimitives/array/remove-array.py
779
4
4
# importing "array" module import array # inisialisasi array # array dengan tipe integer arr = array.array('i', [1, 2, 3, 1, 5]) # cetak array pertama print ("Array pertama : ", end ="") for i in range (0, 5): print (arr[i], end =" ") print ("\r") # menggunakan fungsi pop() untuk menghapus elemen pada...
dd7b9421cab22c4056cc4584e2695e27a55b3bb3
jtwilliams17/python-challenge
/PyPoll/main.py
2,620
3.828125
4
import os import csv voterid = [] county = [] candidate = [] # import csv file and skip headers with open('Resources/JamesWilliams_election_data.csv') as csvpath: csv_reader = csv.reader(csvpath, delimiter=",") next(csv_reader, None) # add to predefined lists from csv columns for row in csv_reader: ...
f22e0fd7160a01ecc2285e016d261e14a89f308a
rogelioLpz/CodingChallengue
/app/puzzle_queens.py
2,415
3.84375
4
def puzzle_queens(size): reinas=[-1]*size #Reinas inizcializadas en fila -1 solucion= algoritmo(size,reinas,0,[]) solucion_format=[] for sol in solucion: d={i:sol[i] for i in range(len(sol))} solucion_format.append(d) return solucion_format """---------------------------...
6421bd469e371aa256b634c344f81c71072ff336
dailycodemode/dailyprogrammer
/Python/034_squareTwoLargest.py
984
4.15625
4
# https://www.reddit.com/r/dailyprogrammer/comments/rmmn8/3312012_challenge_34_easy/ # DAILY CODE MODE def square_two_largest(list): list.sort(reverse=True) return list[0] ** 2 + list[1] ** 2 print(square_two_largest([3,1,2])) # ANSWER BY Should_I_say_this def sumsq(a,b,c): l=[a,b,c] del l[l.index(mi...
cda67265b8fa8e6c0d2e8d2dc2d2ad590c23c045
dailycodemode/dailyprogrammer
/Python/027_isLeapYearAndWhichCentury.py
1,775
4.09375
4
# https://www.reddit.com/r/dailyprogrammer/comments/r0r3h/3172012_challenge_27_easy/ # MINE def whichCentury(year): return int(year[:len(year) - 2]) - 1 def isLeapYear(year): if year % 4 == 0: if year % 400 == 0: return True elif year % 100 == 0: return False el...
caa3d82c91cb2892b2f1595ede82a375dcb04e6e
dailycodemode/dailyprogrammer
/Python/099_alphabeticalWords.py
395
3.5
4
# # DAILY CODE MODE # i = open('enable1.txt', 'r') # count = 0 # for l in i.readlines(): # if l.strip() == ''.join(sorted(l.strip())): # count += 1 # word = l[::-1] # # print(count) # # # # # Answer by yentup # words, count = open('enable1.txt', 'r').readlines(), 0 # for word in words: # aword = wor...
81c2f25e56cb404b3443f6a3647d80be6ea0250a
dailycodemode/dailyprogrammer
/Python/058_base_conversion.py
2,182
3.9375
4
# # Answer by DAILY CODE MODE # import math # num = 20 # base = 2 # spaces = int(math.sqrt(num)) # subtotal = num ** (1/base) # binary = "" # for x in range(spaces, -1, -1): # if base ** x <= subtotal: # binary = binary + "1" # subtotal -= 2**x # else: # binary = binary + "0" # # # BREAK...
80eeabd9eac62ac5d3d743fd75043202c42a1696
dailycodemode/dailyprogrammer
/Python/096_controllerChains.py
1,574
3.9375
4
# # DAILY CODE MODE # def controllerChains(budget): # controller = 20 # multi = 12 # available_spaces = 2 # # dict = {"c": 0, "m": 0} # while budget >= controller and available_spaces > 0: # while available_spaces != 1: # budget -= controller # dict["c"] += 1 # ...
912322d109cd7c938b41a269a4187a554736c8b7
dailycodemode/dailyprogrammer
/Python/077_morse_combinations.py
1,756
3.75
4
# # # DAILY CODE MODE # ans = [] # # def Morse(spaces, sofar=''): # if spaces >= 2: # temp = Morse(spaces -2, sofar + '-') # if temp != None: ans.append(temp) # temp = Morse(spaces -1, sofar + '.') # if temp != None: ans.append(temp) # elif spaces == 1: # print(sofar + '....
9f349b3e2d7ec72cbd2ccfd806e0ad7d6cba12cb
dailycodemode/dailyprogrammer
/Python/#065_efficientWallet.py
1,216
3.59375
4
# DAILY CODE MODE # curr = {1: "Penny", # 5: "Nickel", # 10: "Dime" , # 25: "Quarter", # 100: "One-dollar", # 500: "Five-dollar" , # 1000 : "Ten-dollar", # 5000: "Fifty-dollar", # 10000 : "Hundred-dollar" } # # vals = list(curr.keys()) # vals.sort(reverse=True) # # money = 5250 # wallet = [] # for val in vals: # pr...
5999ebfa3a0668f8995b818019ef625883f5151b
dailycodemode/dailyprogrammer
/Python/068_Emirp.py
1,753
4
4
# DAILY CODE MODE # def emirps_below(numbers): # for n in range(numbers): # if is_prime(n) and is_prime(str(n)[::-1]): # if str(n) != str(n)[::-1]: # print(n) # # # def is_prime(n): # n = int(n) # for i in range(2, n): # if n % i == 0: # return Fal...
0763b21265ea66936b54c7109768a601ff394845
dailycodemode/dailyprogrammer
/Python/027_isLeapYear.py
832
3.9375
4
def is_leap_year(year): if year % 4 == 0: if year % 400 == 0: return "Leap year" elif year % 100 == 0: return "Regular year" else: return "Leap year" else: return "Regular year" def what_century(year): return str(int(year/100 + 1)) + " cen...
6066a8900f16f68eb125c92ef3d619fd5a856175
meastman-dev/Python-Practice
/Python Practice/functions.py
3,568
3.640625
4
def greet_user(username): print(f"Hello, {username}") greet_user('mason') def display_message(message): print(message) display_message(f"Today I will be learning about Python functions") def favorite_book(book_title): print(f"One of my favorite books is {book_title}") favorite_book("Alice in Won...
b26c4ba7d3724377b413e346fd3c0403f4693b36
victor-mertes/webscraping
/testeAPS.py
1,818
3.875
4
# Protótipo para a APS sobre Web Scraping com Python usando BeautifulSoup e requests # O site da UNIP está sendo usado como alvo do projeto from bs4 import BeautifulSoup import requests curso_desejado = input('Informe o curso desejado: ') print('Resultados que incluem "{}":'.format(curso_desejado)) def procura_curso...
4e651b33b801a58c91e21fb58cf18ca719bf8535
vanipodali/Django_Sample
/test/multi 1.py
548
3.640625
4
import threading global_lock = threading.Lock() def write_to_file(): while global_lock.locked(): continue global_lock.acquire() with open("thread_writes", "a+") as file: file.write(str(threading.get_ident())) file.write("\n") file.close() global_lock.release() # Cre...
575ce16017a9ace610e155825511410519cc0a9c
Bacbia3696/rsa-key-gen
/src/helper.py
1,937
4.21875
4
from random import randrange, getrandbits, seed def is_prime(n, k=128): """ Test if a number is a prime use Miller-Rabin algorithm Args: n int: number to test k int: number of test to do return True if n is prime """ if n == 2 or n == 3: return True if n...
eb45d733b72d6abb01b5e46a0a3dc710f7d88892
rahnerhr/csci-220-python
/hangman.py
7,394
4.15625
4
#Ariel Robinson #hangman.py #Problem: A random word is picked from the wordlist # if the player can correctly guess the word they win #hangman but if they can not they lose, they have #7 guesses #Certification of Authenticity: # I certify that this lab is my own work, but I #discussed it with Professor Stavley, and M...
bdbd2c226ad2c18abcaa9c781d7951357cd1cb0c
Vasilii-Redinskii/ps-pb-hw4
/collections.py
490
4.125
4
from collections import namedtuple # Создаем описание (т.е. некую структуру) для объекта student = namedtuple('student','first_name last_name age') # Создаем сам объект, используя описание student1 = student(first_name='Иван', last_name='Иванов', age=18) # Обращаемся к полям объекта через точку print(student1.first...
6cc3eb5dd177c54240d3e350f285dae10746e835
cos18/COM3026-Algorithm
/bruteforce/sentence_component/main.py
793
3.875
4
import categorize import os choice = '' while not (choice == '1' or choice == '2'): choice = input("입력 형태를 선택하세요 (1-콘솔창에서 직접 입력 / 2-가져올 파일 경로 입력): ") if choice == '1': sentence = input("문장 입력 ->") elif choice == '2': directory = input("경로를 입력해주세요 : ") if os.path.isfile(directory): ...
e3fba26217faed32846c399e0e3703ab59b19f3e
cos18/COM3026-Algorithm
/basic/algorithm_thinking.py
475
3.546875
4
while True: k = input("x, y, z의 중복 여부를 입력해주세요. (yes/no) : ") if k=="yes" or k=="no": k = 1 if k=="yes" else 2 break print("잘못 입력하셨습니다. 다시 입력하세요.") cnt = 0 for x in range(1, 100-k): for y in range(1, 100-x): z=100-x-y if((k==2) and (x==y or y==z or z==x)): cont...
2737b90656bf1a6ea42f2dab93441d661e829066
rnekadi/CSEE5590_PYTHON_DEEPLEARNING_FALL2018
/ICP8/housing.py
1,021
3.640625
4
from keras.models import Sequential from keras.layers.core import Dense, Activation import matplotlib.pyplot as plt # load dataset from sklearn.model_selection import train_test_split import pandas as pd dataset = pd.read_csv("housing.csv", header=None).values # print(dataset) import numpy as np X_train, X_test, Y_tra...
107948909ac33e71ddc6f660096fb7a5739d6ff6
rnekadi/CSEE5590_PYTHON_DEEPLEARNING_FALL2018
/Lab1/problem3.py
835
4.09375
4
# Consider the following scenario. You have a list of students who are attending class "Python" # and another list of students who are attending class "Web Application".Find the list of students # who are attending list of student who are attending Python class but not Web Application # Authror Raju Nekadi # Defining...
4a977849536b8afc9d7cce8f715d1359009d14da
rnekadi/CSEE5590_PYTHON_DEEPLEARNING_FALL2018
/ICP3/Source/codon.py
522
4.21875
4
# Program to read DNA Codon Sequence and Split into individual Codon # Fixed Codon Sequence codonseq = 'AAAGGGTTTAAA' # Define List to hold individual Codon codon = [] # Defining function to to fill Codon list def codonlist(seq): if len(seq) % 3 == 0: for i in range(0, len(seq), 3): codo...
2d7a2d740143a19d38e290c3dc81e00cafcdeaff
smailmedjadi/jenkins_blueocean
/src/new_functions.py
570
4.1875
4
def bubbleSort(list): for passnum in range(len(list)-1,0,-1): for i in range(passnum): if list[i]>list[i+1]: temp = list[i] list[i] = list[i+1] list[i+1] = temp def insertionSort(list): for index in range(1,len(list)): currentv...
784f620b6908f1c21a6dc8e1cd390dce9b77150b
emmaellis/alpha-beta-tic-tac-toe
/tictactoe.py
7,109
4.03125
4
from graphics import * import copy """ A move is a tuple which correspond to both coordinates on the board and the elements of the two dimensional list called spots.""" #NOTE: Need to check for tie def ticTacToe(): #intializing the board to empty #initializing the two players to our default settings spots = [[Non...
8d2e6e5444ee2780d0c706c44fd1e8ae5bf5b35b
amandasmoreira/sistDistribuidos
/Anel Circular/anel.py
1,510
3.71875
4
import threading import time atualTh = 0 nThreads = 30 class multThread (threading.Thread): def __init__(self, id, name): threading.Thread.__init__(self) self.id = id self.name = name def testUpper(self): global texto #verifica caracter minusculo na frase capturada ...
808dc5038d076c4e3a844dbb13822e98edf81b49
iamksm/mdundoscraper
/scraper/scraper.py
1,829
3.828125
4
import urllib.parse import requests from bs4 import BeautifulSoup def find_songs(name): """Function to get Artist Songs Based on the name""" # Get Name input from user the parse it and add it to the URL name = urllib.parse.quote_plus(name) url = f"https://mdundo.com/search?q={name}" # Check for ...
d3b02d43ff82c9f29a953f59f64556ca8106d9f6
stuppa/ParadigmasDeProgramacion
/Programacion funcional/Calculadora.py
1,264
4
4
def Obtener_numeros(*args): numeros = [*args] return numeros numeros = Obtener_numeros(1,2,3,4,5,6,7) def suma(): suma = 0 for num in numeros: suma += num return suma def resta(numero): resta = numero for num in numeros: resta -= num return resta ...
6aa2d7b021bf45a6d8383fd7cb925e4ee1476457
acufarah/TicTacToe
/tictactoe.py
3,469
3.75
4
class Board: spaces = [] def __init__(self): for i in range(0,10): self.spaces.append(' ') def place_board(self, space, player): self.spaces[space] = player def print_board(self): print(self.spaces[0]+'|'+self.spaces[1]+'|'+ self.spaces[2]) print('-----') print(self.spaces[3]+'|'+self.spaces[4]+'|'...
ff6141ab2caa858322da0bbfed25a9b3ad2d6f38
whitegreyblack/PyCurses
/old/old_winmanager.py
1,746
3.578125
4
import windows as wins class WinManager: def __init__(self, parent): """ Creates new windows based on number of titles passed to manager Args: parent: reference to parent object """ self.wins = [] self.parent = parent self.y, self.x = self.parent...
1d9c35afa6d66edd2f04c26e05ab62403dac84d4
n3uralc/rpi-morse
/morse.py
2,317
3.609375
4
import RPi.GPIO as GPIO from time import * from sys import * GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) led_pin = 8 GPIO.setup(led_pin, GPIO.OUT) # Setup the text we are going to translate to morse code # and add an SK at the end signaling End of Transmission text=argv[1].upper() + " SK" # Define all of our lett...
963fbd17035b80f3e17f803d3393cbcdc9e92020
EhODavi/curso-python
/exercicios-secao04/exercicio03.py
242
3.984375
4
numero1 = int(input('Informe o primeiro número: ')) numero2 = int(input('Informe o segundo número: ')) numero3 = int(input('Informe o terceiro número: ')) soma = numero1 + numero2 + numero3 print(f'A soma de todos os número é {soma}')
3f89cc9bfa8d254e18deba90534e654a811c4590
EhODavi/curso-python
/exercicios-secao08/exercicio53.py
275
3.65625
4
from typing import List def eh_identidade(matriz: List[List[int]]) -> bool: for i in range(len(matriz)): for j in range(len(matriz)): if (i == j and matriz[i][j] != 1) or (i != j and matriz[i][j] != 0): return False return True
bce9c0b41a3e751a6302c86518ac8e2cfcea9b49
EhODavi/curso-python
/exercicios-secao04/exercicio29.py
303
3.640625
4
nota1 = float(input('Informe a primeira nota: ')) nota2 = float(input('Informe a segunda nota: ')) nota3 = float(input('Informe a terceira nota: ')) nota4 = float(input('Informe a quarta nota: ')) media_aritmetica = (nota1 + nota2 + nota3 + nota4) / 4 print(f'Média Aritmética: {media_aritmetica}')
c07794c77a6de109383fc95303666481db1fc923
EhODavi/curso-python
/exercicios-secao13/exercicio06.py
626
3.984375
4
nome_arquivo = input('Informe o nome do arquivo: ') ocorrencias = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}...
c9c0ac3f7b507c15f40170980db8b16ed03f2601
EhODavi/curso-python
/exercicios-secao06/exercicio08.py
362
4.25
4
numero = float(input('Informe um número: ')) maior_numero = numero menor_numero = numero for i in range(9): numero = float(input('Informe um número: ')) if numero < menor_numero: menor_numero = numero if numero > maior_numero: maior_numero = numero print(f'Maior número: {maior_numero}') p...
d0b57d22291f86e6b514db7b5495e6c0aed561f0
EhODavi/curso-python
/exercicios-secao05/exercicio38.py
1,221
3.671875
4
dia = int(input('Informe o dia: ')) mes = int(input('Informe o mês: ')) ano = int(input('Informe o ano: ')) data_valida = False ano_bissesto = True if not (ano % 400 == 0 or (ano % 4 == 0 and ano % 100 != 0)): ano_bissesto = False if ano <= 2008: if 1 <= dia <= 31 and mes == 1: data_valida = True ...
62f2a857a852f782e5e8df401c201effef8fd156
EhODavi/curso-python
/exercicios-secao05/exercicio11.py
276
4.0625
4
numero = input('Insira um número inteiro maior do que zero: ') if int(numero) > 0: soma = 0 for elemento in numero: soma = int(elemento) + soma print(f'A soma de todos os algarismos do número {numero} é {soma}!') else: print('NÚMERO INVÁLIDO!')
edf6d6e36bdf199eaa9b92e5153a2e3c2a7d8a83
EhODavi/curso-python
/exercicios-secao05/exercicio06.py
344
4.03125
4
numero1 = int(input('Informe o primeiro número: ')) numero2 = int(input('Informe o segundo número: ')) if numero1 >= numero2: print(f'O maior número é o primeiro ({numero1})! A diferença entre eles é {numero1 - numero2}!') else: print(f'O maior número é o segundo ({numero2})! A diferença entre eles é {numero2 ...
8ae04a132b4e3f8fb4b2f09c8ddd9a8f3eec96c0
EhODavi/curso-python
/exercicios-secao04/exercicio16.py
173
3.828125
4
polegadas = float(input('Informe o comprimento em polegadas: ')) centimetros = polegadas * 2.54 print(f'{polegadas} polegadas correspondem à {centimetros} centímetros')
3c8f29a6f099c524585beda305526668cbd234f1
EhODavi/curso-python
/exercicios-secao05/exercicio33.py
462
3.78125
4
preco_antigo = float(input('Informe o preço antigo do produto: ')) preco_novo = preco_antigo if preco_novo <= 50: preco_novo = preco_novo * 1.05 elif 50 < preco_novo <= 100: preco_novo = preco_novo * 1.10 else: preco_novo = preco_novo * 1.15 print(f'Preço novo: {preco_novo}') if preco_novo <= 80: pri...
bc275150a939c99c3baeb8a6263b634fa0c1c240
EhODavi/curso-python
/exercicios-secao07-parte2/exercicio15.py
720
3.734375
4
respostas = [] for i in range(5): respostas.append([]) if i == 0: print(f'Lendo as respostas do aluno {i + 1}:\n') else: print(f'\nLendo as respostas do aluno {i + 1}:\n') for j in range(10): resposta = input() respostas[i].append(resposta) gabarito = [] print('\nLen...
926276604ff778d85b0ef490eb4155277d8660b0
EhODavi/curso-python
/exercicios-secao06/exercicio45.py
447
4.125
4
while True: print('1 - Converter de km/h para m/s') print('2 - Converter de m/s para km/s') print('3 - Finalizar') opcao = int(input('\nInforme a opção: ')) if opcao == 3: break velocidade = float(input('\nInforme a velocidade: ')) if opcao == 1: print(f'\n{velocidade} km/...
be3a873ac2f3b61bcf788fe3b3b9b54a64929814
EhODavi/curso-python
/exercicios-secao08/exercicio69.py
1,387
3.875
4
def ler(): p = input('Informe a fração p: ') q = input('Informe a fração q: ') p = p.split('/') q = q.split('/') p = [int(p[0]), int(p[1])] q = [int(q[0]), int(q[1])] p = simplifica(p) q = simplifica(q) operacoes(p, q) def simplifica(fracao): menor = min(fracao[0], fracao[1...
68136aed8d34515779d994136a18ab5ab1e4f2a2
EhODavi/curso-python
/exercicios-secao06/exercicio39.py
237
3.875
4
base = float(input('Informe a base do triângulo: ')) altura = float(input('Informe a altura do triângulo: ')) if base > 0 and altura > 0: print(f'Área do triângulo: {(base * altura) / 2}') else: print('Valores inválidos!')
342ccb2d13e9696e9b54ad7adb8e42c1a4270b95
EhODavi/curso-python
/exercicios-secao05/exercicio32.py
1,031
3.96875
4
codigo_produto = int(input('Informe o código do produto: ')) quantidade = int(input('Informe a quantidade: ')) if codigo_produto == 100: print('Cachorro Quente - 100') print(f'Total à pagar: {quantidade} x 1.20 = {quantidade * 1.20}') elif codigo_produto == 101: print('Bauru Simples - 101') print(f'Tot...
8a34055258598f8a77f4ad4e879c90ce876d81cb
EhODavi/curso-python
/exercicios-secao05/exercicio10.py
241
3.75
4
altura = float(input('Informe a altura da pessoa: ')) sexo = input('Informe o sexo da pessoa (M ou F): ') if sexo == 'M': print(f'Peso ideal: {(72.7 * altura) - 58}') elif sexo == 'F': print(f'Peso ideal: {(62.1 * altura) - 44.7}')
5174062f55ca5f07232673696c026ed8b074e7b2
EhODavi/curso-python
/exercicios-secao13/exercicio04.py
485
3.90625
4
nome_arquivo = input('Informe o nome do arquivo: ') with open(nome_arquivo) as arquivo: conteudo = arquivo.read() quantidade_vogal = 0 quantidade_consoante = 0 for letra in conteudo: if letra.lower() in ['a', 'e', 'i', 'o', 'u']: quantidade_vogal += 1 elif letra.isalpha():...
296643a210cba029c568aedbd99b2c8858015817
EhODavi/curso-python
/exercicios-secao06/exercicio53.py
258
3.96875
4
n = int(input('Informe um número inteiro positivo n: ')) numero = 1 qtd_por_linha = 1 for i in range(n): for j in range(qtd_por_linha): print(f'{numero} ', end="") numero = numero + 1 print() qtd_por_linha = qtd_por_linha + 1
cfe1ee136723b751f7261cb30d83b1678d2afc55
EhODavi/curso-python
/exercicios-secao07-parte1/exercicio31.py
452
3.578125
4
A = [] B = [] print('Preenchendo o vetor x:\n') for i in range(10): numero = int(input('Informe um número: ')) A.append(numero) print('\nPreenchendo o vetor y:\n') for i in range(10): numero = int(input('Informe um número: ')) B.append(numero) C = [] for i in range(10): if C.count(A[i]) == 0: ...
9174817ed450dab5f9f87a3f9b7656f06c45ed69
EhODavi/curso-python
/exercicios-secao08/exercicio17.py
215
3.71875
4
def soma_intervalo(a: int, b: int) -> int: soma: int = 0 if a < b: for i in range(a + 1, b): soma += i else: for i in range(b + 1, a): soma += i return soma
833cfc49c7227bb527cb5b19f32f4a6de0205157
EhODavi/curso-python
/exercicios-secao04/exercicio08.py
224
3.796875
4
temperatura_kelvin = float(input('Informe a temperatura em graus Kelvin: ')) temperatura_celsius = temperatura_kelvin - 273.15 print(f'{temperatura_kelvin} graus Kelvin corresponde à {temperatura_celsius} graus Celsius')
65ff41823badb27c48ae7bb5fefd7e25c267f320
EhODavi/curso-python
/exercicios-secao08/exercicio20.py
128
3.65625
4
def fatorial(n: int) -> int: resultado: int = 1 for i in range(1, n + 1): resultado *= i return resultado
168f9f99888e7ada20da7b4b8f634d24c4861ca6
EhODavi/curso-python
/exercicios-secao05/exercicio36.py
611
3.84375
4
valor_venda = float(input('Informe o valor da venda: ')) if valor_venda >= 100000.00: print(f'Comissão: {700.00 + 0.16 * valor_venda}') elif 80000.00 <= valor_venda < 100000.00: print(f'Comissão: {650.00 + 0.14 * valor_venda}') elif 60000.00 <= valor_venda < 80000.00: print(f'Comissão: {600.00 + 0.14 * val...
3f28b0768fa50df7d2f5b825cc64abc9fdfdcbbb
EhODavi/curso-python
/exercicios-secao07-parte1/exercicio35.py
879
3.65625
4
a = input('Informe o número a: ') b = input('Informe o número b: ') vetor_a = list(a[::-1]) vetor_b = list(b[::-1]) vetor_c = [] if len(vetor_a) <= len(vetor_b): for i in range(len(vetor_b)): vetor_c.append(vetor_b[i]) for i in range(len(vetor_a)): vetor_c[i] = str(int(vetor_a[i]) + int(veto...
a052d71f004805ab847f22fa630d8d7e2d497b00
EhODavi/curso-python
/exercicios-secao07-parte2/exercicio07.py
410
3.75
4
matriz = [] for i in range(10): matriz.append([]) for j in range(10): if i < j: matriz[i].append(2 * i + 7 * j - 2) elif i == j: matriz[i].append(3 * (i ** 2) - 1) else: matriz[i].append(4 * (i ** 3) - 5 * (j ** 2) + 1) print('Matriz:\n') for i in ...
cc3642c885b421ed667c563c2725b6d1ec46f3f1
EhODavi/curso-python
/exercicios-secao05/exercicio04.py
180
4.0625
4
numero = float(input('Informe um número: ')) if numero >= 0: print(f'O quadrado de {numero} é {numero ** 2}!') print(f'A raiz quadrada de {numero} é {numero ** 0.5}!')
c96d2f0e936cc93c14813d1d9f6209c598238897
EhODavi/curso-python
/exercicios-secao05/exercicio22.py
284
3.953125
4
idade = int(input('Informe a idade do trabalhador: ')) tempo_servico = int(input('Informe o tempo de serviço do trabalhador: ')) if idade >= 65 or tempo_servico >= 30 or (idade >= 60 and tempo_servico >= 25): print('APOSENTADO!') else: print('AINDA NÃO ESTÁ APOSENTADO!')
1d343ecfb3acfd02ae59d89a514adf58699d0d94
EhODavi/curso-python
/exercicios-secao05/exercicio24.py
517
3.953125
4
valor_produto = float(input('Informe o valor do produto: ')) estado_destino = input('Informe o estado de destino: ') if estado_destino == 'MG': print(f'Preço final do produto: {valor_produto * 1.07}') elif estado_destino == 'SP': print(f'Preço final do produto: {valor_produto * 1.12}') elif estado_destino == '...
196872a662c59c5bfe034620056198bc5a2521e3
EhODavi/curso-python
/exercicios-secao05/exercicio20.py
439
4.03125
4
A = float(input('Informe o lado A do triângulo: ')) B = float(input('Informe o lado B do triângulo: ')) C = float(input('Informe o lado C do triângulo: ')) if A < (B + C) and B < (A + C) and C < (A + B): if A == B and A == C: print('TRIÂNGULO EQUILÁTERO!') elif A == B or A == C or B == C: print...
b3168ad865a2259bafc13fb2c83fc3506fc6e895
daanbobeldijk/leerjaar1
/afvinkopdrachten3/Number Analyzer.py
351
4.09375
4
proceed = input("Please input an integer: ") while len(proceed) == 0 or (not proceed.isdigit()): proceed = input("Please input an integer: ") proceed = int(proceed) if proceed > 0: print("Positive.") elif proceed < 0: print("Negative.") elif proceed == 0: print("Zero.") if proceed % 2 == 0: print("...
d365d5e6b98cdae011c5b4fe92a380402fc07fe8
elsud/homework-repository
/tests/test_homework9/test_merge_files.py
688
3.609375
4
from homework9.merge_files import iter_from_file, merge_sorted_files def test_iter_from_file_returns_iterator_through_file(tmp_path): path_to_file = tmp_path / "file.txt" with open(path_to_file, "w") as fi: fi.write("1\n4\n9\n") assert list(iter_from_file(path_to_file)) == [1, 4, 9] def test_mer...
b680c298f6445f8fdf66de334d88edde16c7a7d4
elsud/homework-repository
/tests/test_homework1/test_task04.py
360
3.65625
4
from homework1.task04 import check_sum_of_four def test_empty_lists(): """Testing that empty lists give zero.""" check_sum_of_four([], [], [], []) == 0 def test_zero_lists(): """Testing that lists consisting of zeroes give len of decart product of all elements.""" arr = [0, 0, 0] check_sum_of_fo...
1a34811f7079f66a50978a927310731ea127f583
elsud/homework-repository
/homework7/board.py
1,185
4.03125
4
""" Given a Tic-Tac-Toe 3x3 board (can be unfinished). Tic_tac_toe_checker checks if there are some winners. If there is "x" winner, function returns "x wins!" If there is "o" winner, function returns "o wins!" If there is a draw, function returns "draw!" If board is unfinished, function returns "unfinished!" """ from ...
4349b6d9fe45c2c39ac6ea2dcc4a74b127700cdf
elsud/homework-repository
/homework11/discount.py
1,776
3.71875
4
from typing import Callable, Union def morning_discount(order: "Order") -> None: """Sets to the given instance attribute 'discount' with the percent of morning discount (50%). :param order: instance of Order that should use morning discount programm when it calculates final price :type order: inst...
665f191b2a66dd354bb272157e2b5d7857203c2b
elsud/homework-repository
/tests/test_homework7/test_backspace.py
433
3.765625
4
from homework7.backspace import backspace_compare def test_backspacing_one_different_letter_gives_true(): assert backspace_compare("ab#c", "ad#c") def test_backspacing_all_besides_last_equal_letter_gives_true(): assert backspace_compare("a##c", "##a#c") def test_empty_strings_gives_true(): assert back...
113ce9c297285bae2ff4b7f63edeb25704402dda
elsud/homework-repository
/homework6/oop2.py
3,771
3.90625
4
"""Module with classes of Homework, HomeworkResult, Student and Teacher. Homework has such attributes as text, deadline in days and datetime object when it was created. Also it has method showing is task active or it's too late. Student and Teacher inherit from Person attributes of first_name and last_name. Student c...
42d3ea31467ec54a936725c1333e607548419219
Offstavo/python_helloworld
/methods.py
542
3.90625
4
# def name(n): # print(n) # name("John") # def name(n): # return n # print(name("John")) # def square(s): # return s * s # print(square(4)) # def your_name(fname): # return fname # print("Input your First Name") # fname = input("First Name:") # print(f"Your firstname is:{your_name(fname)}") from sq...
ab5416683903ad236a86810f4132c7b5dc968366
tomprice719/hexAI
/hexAI/board_utils.py
7,270
3.53125
4
"""Utilities for representing the state of a hex game.""" from enum import Enum import itertools from colorama import Fore, Back, Style from string import ascii_uppercase neighbour_difference = [(-1, 0), (-1, 1), (0, 1), (1, 0), (1, -1), (0, -1)] class Player(Enum): RED = 0 BLUE = 1 def all_points(board_s...
8becd7b806fb380a7654c97059384082cd7cff96
Jakiem/-ranspose-matrices
/main.py
270
3.515625
4
# BEGIN (write your solution here) def transposed(matrix): result = [] zip_m = map(list, zip(*matrix)) for i in zip_m: result.extend([i]) return result # END transposed([ [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], ])
5a2510e2723ce021635792145b4ca926c46ef5c3
Nikita9456/if_else
/atm.py
1,211
3.671875
4
print("welcome to SBI") card=input("insert the card") print("insert the card") if atmcard=="debit": print("incurrect pin") else: ("please deside your langueuage") print("card inserted") language=input("enter the languege") if language=="hindi" or language=="english": print("it is your language") pin=int...
d592159043ae83479c91b1fab1b4cf70c5bb84f5
MarthaAlva/Unidad-III-Patrones-de-dise-o
/ChainOfResponsability.py
1,012
3.640625
4
''' Created on 25 nov. 2019 @author: martha ''' class Handler: def __init__(self): self.successor=None def HandleRequest(self, solicitud): pass def Sucesor(self, handlerObj): self.successor=handlerObj class Administrador(Handler): def HandleRequest(self, solicitud): pr...
9ca8c3105b2b1f392cdcb31e2b60d456f43ae49d
L200180158/Praktikum_Algopro
/P8. Kegiatan 1.py
1,303
3.90625
4
D = {'NIM':'L200180158','nama':'Sevtika Ichitia','alamat':'jln.Garuda Mas','prodi':'Informatika','fakultas':'FKI','hobi':'membaca','nampang':'ichi'} print "pilihan yang tersedia:" print "N menampilkan nama" print "n menampilkan NIM" print "l menampilkan alamat" print "p menampilkan nampang" print "t menampilkan p...
ca36010d33b15cbd45682f7d1e6b8ccb0ebdb8b5
lindameh/cpy5p4
/q2_sum_series2.py
208
4.03125
4
def sum_series2(n): if n == 1: return 1/3 else: return sum_series2(n-1) + n / (2 * n + 1) n = int(input("Enter a positive integer: ")) print("m({0}) = {1}".format(n, sum_series2(n)))
27d4c41b7b2ef199aa7de98cf6c41976af27b02f
hifish78/mypython
/dfs/subset_lint17_m.py
1,724
3.9375
4
class Solution: """ 要点: 1) 先排序,避免重复 (如果题目已经告诉你没有重复的数字,这个不是必要的步骤) 2) DFS: a) 加入第一个满足条件的结果, 注意是deep copy results.append(list(subset)) b) for i in range(index, len(nums)) 遍历每个数字,加入到subset里面, # [1] -> [1, 2] C) 从下个数字开始寻找所有以[1,2]开头的集合,并扔到results self...
b642df6c6eb8d402781477c428cf90a7420be2ba
hifish78/mypython
/dfs/permutation_ii_lint47.py
912
3.578125
4
class Solution: """ 要点: 如何去除重复 if i - 1 >= 0 and nums[i - 1] == nums[i] and not visited[i - 1]: continue """ def permuteUnique(self, nums: List[int]) -> List[List[int]]: if nums is None: return nums res = [] nums.sort() visited = [False fo...
fd8a812f48364a1831788d3f2dee6f0818eaea54
hifish78/mypython
/two_poniters/2sum_lint56.py
2,813
3.53125
4
class Solution(object): """ dict方法使用一个dictionary结构来记录对应的数字是否出现,以及其下标。 时间复杂度为O(n)。空间上需要开辟dictionary来存储, 空间复杂度是O(n)。 key:value --> nums[i]: i get all of items from dict: dict.items() , it is a list of tuple as element get all of keys from dict: dict.keys() get all of values from dict: dict.va...
8dc236b9af00e0008ed49b0d4ff4ab900a8bbbdf
DAZHAdazha/Numpy-learning-path
/分割.py
372
3.671875
4
import numpy as np A = np.arange(12).reshape((3,4)) print(A) # split方法可以将4列分为1,2块,但是无法3块 print(np.split(A,2,axis=1)) # 将其分成两列 print(np.split(A,3,axis=0)) # 将其分成三行 print(np.array_split(A,3,axis=1)) # 进行不等分割,4列分为3块 print(np.vsplit(A,3)) # vertical split print(np.hsplit(A,2)) # horizontal split
1318b7b45a0017f83f770073dc1706ae8fd7d56f
DS-PATIL-2019/Hashing-1
/Isomorphic.py
763
3.9375
4
""" The approach here is to store each letter in s as key and it's corresponding letter at t as value. we iterate through each letters in both the strings. if a particular key-> value mapping is not found we insert in the dict. while inserting we also check if the key already exsists for a different value or if the val...
55d0933225917746cf734f4ae38b7ab9b9362828
ravi4all/PythonOnlineJan_2021
/backup/code_3.py
485
4.15625
4
''' for(int i = 0; i <= 10; i++) { Logic... } ''' ''' start = 0 stop = 10 - 1 = 9 step = +1 ''' for i in range(10): print(i, end=',') print("Inside Loop") print("Bye") ''' start = 2 stop = 10 - 1 = 9 step = +1 ''' for i in range(2,10): print(i, end=',') print("Inside Loop") ...