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
47fc49136a2f7e015478b969642c8b00bb32d47f
danilocecci/CEV-Python3
/ex099.py
418
4.0625
4
def getMaxNum(* num): maxNum = 0 counter = 0 while True: num = int(input('(Para sair, digite a senha "9156")\nInsira um número: ')) if num == 9156: break elif num > maxNum: maxNum = num counter += 1 else: counter += 1 prin...
dfadc7f4442ef17c352ff299241b11fd3f42115e
danilocecci/CEV-Python3
/ex098.py
1,247
3.984375
4
from time import sleep def counter(start, end, step): if step == 0: step = 1 if start < end: print(f'Contando de {start} até {end} de {step} em {step}.') sleep(2) while start <= end: print(start, end='-> ', flush=True) sleep(0.3) start += step...
bd190ca5316386bcf29c58b08f94a933fa0439d0
danilocecci/CEV-Python3
/ex052.py
570
3.75
4
import colorama colorama.init() print('-='*9+'-') print('\033[1;31m NÚMEROS PRIMOS\033[m') print('-='*9+'-') print('Vamos descobrir se um número é primo ou não :D') number = int(input('Digite um número: ')) result = [1] end = int(number/2+1) for c in range(1,end): if number%c == 0: result.append(c) r...
e2ebf0d4d7877b1b984c7ef1d415f6fc7b83f4e0
danilocecci/CEV-Python3
/uteis/numeros/__init__.py
200
3.59375
4
# Arquivo referente à aula 22 def fatorial(n): f = 1 for c in range (1, n+1): f *= c return f def dobro(n): d = n * 2 return d def triplo(n): t = n * 3 return t
2868ec899db72dec653feb1d722e1d95472878ba
danilocecci/CEV-Python3
/ex013.py
510
4.0625
4
print('') print('Olá. Vamos calcular aumento salarial!') name = input('Para qual funcionário você quer aplicar o aumento salarial? ') salary = float(input('Qual é o salário desse funcionário? R$')) tax_salary_increase = float(input('Qual é a taxa de aumento (em %) que você deseja aplicar? ')) print('') print('Vamos lá:...
ada887337c47aad6460de82ffae6207467132e11
danilocecci/CEV-Python3
/ex090.py
327
3.828125
4
student = dict() student['Nome'] = str(input('Nome do aluno: ')) student['Média'] = float(input(f'Média de {student["Nome"]}: ')) if student['Média'] <= 6: student['Situação'] = 'Reprovado' else: student['Situação'] = 'Aprovado' print('-='*20+'-') for k, v in student.items(): print(f'{k} é igual a {v}!')
a9822753db7238bd9a953f9fd21834a76fe8383b
danilocecci/CEV-Python3
/ex082.py
764
3.8125
4
keep = 's' num = list() odd_num = list() eve_num = list() #First Option # while keep == 's': # num_handle = int(input('Digite um número: ')) # keep = input('Deseja continuar? [S/N] ').lower() # num.append(num_handle) # if num_handle % 2 == 0: # eve_num.append(num_handle) # else: # o...
c5df0292b25944df9c73d8c81b7e7953407512ff
danilocecci/CEV-Python3
/ex067.py
285
3.734375
4
while True: number_of_choice = int(input('\nQuer ver a tabuada de qual valor? ')) if number_of_choice < 0: break for c in range(1, 11): print(f'{number_of_choice} X {c} = {number_of_choice*c}') print('PROGRAMA TABUADA ENCERRADO. Volte Sempre! Obrigado :D')
673016b873f308d8db91360841c7fce62b88f6d0
danilocecci/CEV-Python3
/ex037.py
530
3.6875
4
import colorama colorama.init() print('-='*10+'-') print('\033[1;31mCONVERSOR NUMÉRICO\033[m') print('-='*10+'-') number = int(input('Digite um número inteiro: ')) choice = int(input('Agora digite o número de alguma das opções a seguir:\n1 - Converter para binário\n2 - Converter para octal\n3 - Converter para hexadec...
3405341edccfe48485dd2306e6bb808f62ba2088
danilocecci/CEV-Python3
/ex075.py
616
4.09375
4
numbers = (int(input('Digite um número inteiro: ')), int(input('Digite o segundo número inteiro: ')), int(input('Digite o terceiro número inteiro: ')), int(input('Digite o quarto e último número inteiro: '))) nine_counter = 0 even = [] if 9 in numbers: nine_counter += 1 print(f'O número 9 apareceu {nine_counte...
0ff5d9ba153ea7e0cf4b5e246199f6ee4a825a76
danilocecci/CEV-Python3
/ex063.py
226
4.125
4
sequence = int(input('Digite a quantidade de números fibonacci que deseja: ')) numbers = [0, 1] counter = 2 while counter < sequence: numbers.append(numbers[counter-1]+numbers[counter-2]) counter += 1 print(numbers)
63af36128dff39515a0ae170f713e96b44d26e9a
danilocecci/CEV-Python3
/ex005.py
258
4.21875
4
print('Vamos verificar o antecessor e o sucessor de um número!') numero = int(input('Para isso, preciso que digite um número: ')) print('O antecessor de "{}" é {}!'.format(numero, (numero-1))) print('O sucessor de "{}" é {}!'.format(numero, (numero+1)))
7e55baa246a0d94df7255b4e9ca6c4bf93ba70a1
danilocecci/CEV-Python3
/ex093.py
720
3.578125
4
player = dict() handle_score = list() player['name'] = str(input('Nome do jogador: ')) player['games'] = int(input(f"Quantas partidas {player['name']} jogou? ")) for c in range(0,player['games']): handle_score.append(int(input(f"Quantos gols {player['name']} fez na {c+1}ª partida? "))) player['score'] = handle_sco...
0e5457a432bef5b20212ab5cdd803645587b1b27
danilocecci/CEV-Python3
/ex029.py
400
3.78125
4
from time import sleep velocity = float(input('Sabendo que a velocidade máxima permitida é de 80km/h, a que velocidade (KM/h) você deseja andar nessa via? ')) print('Ok! Boa viagem. :D') sleep(1) if velocity > 80.0: print('O oh... Uma multa foi registrada em seu nome. O valor foi de R${:.2f}'.format((velocity-80)*...
0e553fc21b17d1a1a702f5f7df210f97f6ecbf49
alainlou/leetcode
/p1268.py
1,579
3.796875
4
class TrieNode: def __init__(self): self.end = False self.count = 0 self.children = [None] * 26 class Trie: def __init__(self): self.root = TrieNode() def insert(self, str): node = self.root for c in str: index = ord(c)-ord('a') i...
d444e0564190a1f6dbb25e3ad28a7c408f7c3a92
alainlou/leetcode
/p845.py
718
3.640625
4
from functools import lru_cache class Solution: def longestMountain(self, A: List[int]) -> int: n = len(A) @lru_cache(None) def len_increasing(idx): if idx == n-1: return 0 return (1 + len_increasing(idx+1)) if A[idx+1] < A[idx] else 0 @lru...
dd3f67efed34d9538db58bed5f5e894a35545ee2
alainlou/leetcode
/p342.py
211
3.5
4
class Solution: def isPowerOfFour(self, num: int) -> bool: if num <= 0: return False if num == 1: return True return num%4 == 0 and self.isPowerOfFour(num//4)
528e2248d1ea95a484a136e36bb45ac4737e885e
alainlou/leetcode
/p98.py
422
3.5625
4
from DS.TreeNode import TreeNode class Solution: def isValidBST(self, root: TreeNode) -> bool: def validate(root, lo=float('-inf'), hi=float('inf')): if root is None: return True if root.val <= lo or root.val >= hi: return False return va...
03b9d84b6d7cc0188634541ab40901be576b5f6c
alainlou/leetcode
/p231.py
198
3.546875
4
class Solution: def isPowerOfTwo(self, n: int) -> bool: if n < 1: return False if n == 1: return True return n%2 == 0 and self.isPowerOfTwo(n//2)
d22bd7fd1ea7b34edf00ae959c62d385ac5028f9
alainlou/leetcode
/p1671.py
932
3.53125
4
from functools import lru_cache class Solution: def minimumMountainRemovals(self, nums: List[int]) -> int: n = len(nums) @lru_cache(None) def make_decreasing(idx): if idx == 0: return 0 ans = idx for i in range(1, idx+1): ...
6654ea4e12a5689443ee6a0b754cd606d25365f1
alainlou/leetcode
/p328.py
1,034
3.890625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def oddEvenList(self, head: ListNode) -> ListNode: if head is None or head.next is None: return head odd_head = head ...
7f9aee8e0df32f45c4a4189bad469240c9c5a45d
alainlou/leetcode
/p1496.py
511
3.59375
4
class Solution: def isPathCrossing(self, path: str) -> bool: seen = set() curr = [0, 0] seen.add((0, 0)) for p in path: if p == 'N': curr[1] -= 1 elif p == 'S': curr[1] += 1 elif p == 'E': curr[0] += ...
907a8caf9cf508c01d87175dee1d0c50a6a87f2c
Petermuturi/pythonBasics
/whileLoop.py
204
3.875
4
magicNumber = 14 luckyNumber = 0 while luckyNumber != magicNumber: print(luckyNumber, 'not the lucky number') luckyNumber += 1 print(luckyNumber, "is the luck number:D \n we'll stop at that:)")
df9e4f51c3219d44ea1b9bb9543ec09f4cb4fe1e
Astthorarnorsson/TileTraveller-demo
/quiz8.py
579
4.03125
4
def squares(a,b): if x == a and y ==b: print(reitur{a}_{b}) direction = input("Direction: ") direction = "" x = 1 y = 1 reitur1_1 = "N" reitur1_2 = "N or E or S" reitur1_3 = "E or S" reitur2_1 = "N" reitur2_2 = "S or W" reitur2_3 = "E or W" reitur3_1 = "N" reitur3_2 = "N or S" # if x == 1 and y =...
f146b5c127bc38ac35d52a74ef051b7135560cb1
jepp5220/distributed-system-project-1
/bully_election.py
1,830
3.625
4
# Bully Algorithm # - Each node has an unique ID # - Each node communicates with each other and broadcasts their ID # - The node which has the highest ID becomes the leader. # If P receives a Coordinator message, it treats the sender as the coordinator # When any process notices that the coordinator is no longer resp...
15c4e58dde84c795844e6dd7989d114a5812fff2
pedro-iatzky/dba
/dbal/controllers/BaseController.py
3,999
3.609375
4
import json import uuid as _uuid from abc import ABCMeta, abstractmethod def serialize(_value, _type): """ Serialize an object to a postgres data type, according to the specified type :param _value: the value to cast :param _type: the final object cast type :return: """ if _val...
6a9dd2a3c9ad12d23bb75dc573794bbffc9ede21
moses-palmer/dotfiles
/home/.local/bin/jx
1,672
3.6875
4
#!/usr/bin/env python3 import json import sys from typing import Any, Mapping, Sequence def transform( record: Mapping[str, Any], mapping: Mapping[str, Sequence[str]]): """Transforms a ``dict``. The result will have a value for each key in ``mapping`` with a value extracted from ``recor...
a4111dcdfb1a4471351c795980e4b8a398192a10
simon-loeschke/Portfolio
/Python/input.py
165
3.796875
4
#!/bin/python name = input("Sind Sie ein Mann? \n") if name==str("ja"): print(" Sie sind männlich ") else: print("\n Sie sind weiblich oder divers! \n")
296eb70fe9e31ff7a31208c286320dcaf86b3b36
spectro30/guessTheNumber
/GuessTheNumberGame.py
594
3.890625
4
import random secretNumber = random.randint(1,100) print('I have choosen a number between 1 and 100.') print('Can you guess the number within 7 guesses?') for guessTaken in range(1,8) : print('Make a guess') x = int(input()) if x > secretNumber : print('Your guess is too high') elif x < secretN...
460156072e775f1bf05be035efc194f3214ae8db
youssefshaban/python1
/problems.py
1,704
3.984375
4
import math print("==================== problem 1 ======================") def get_distance(x1, y1, x2, y2): if isinstance(x1, int) & isinstance(x2, int) & isinstance(y1, int) & isinstance(y2, int): h_distance = float((x2 - x1) * 2) print(h_distance) y_distance = float((y2 - y1) * 2) ...
06035e30f7fabcc3d8191154e70291715a7c9b4a
emurph1/ENGR-102-Labs
/Lab03/Activity1f.py
540
3.71875
4
# By submitting this assignment, all team members agree to the following: # “Aggies do not lie, cheat, or steal, or tolerate those who do” # “I have not given or received any unauthorized aid on this assignment” # Emily Murphy # Mason Fields # Kelsey Wright # Ryan Oakes # Lab 03 Activity 1f # ENGR 102-522 ...
50c346bdbdbd12de77a6f3c92e0928e027440cf9
emurph1/ENGR-102-Labs
/CFUs/CFU3.py
1,304
4.125
4
# By submitting this assignment, I agree to the following: # “Aggies do not lie, cheat, or steal, or tolerate those who do” # “I have not given or received any unauthorized aid on this assignment” # Emily Murphy # ENGR 102-552 # CFU 3 # 10/03/2018 homework = int(input('Enter homework grade: ')) # user input...
99cfa230ec4dfee14e96ddd0f1c85b0266a5b0c2
emurph1/ENGR-102-Labs
/Lab12/Activity1.py
3,815
3.796875
4
# By submitting this assignment, I agree to the following: # “Aggies do not lie, cheat, or steal, or tolerate those who do” # “I have not given or received any unauthorized aid on this assignment” # # Name: Emily Murphy # Kelsey Wright # Ryan Oakes # Mason Fields # ...
7933d6c625613251adead9540abbb608cfffccec
emurph1/ENGR-102-Labs
/Lab9/DataCollecting.py
1,707
3.859375
4
# By submitting this assignment, I agree to the following: # “Aggies do not lie, cheat, or steal, or tolerate those who do” # “I have not given or received any unauthorized aid on this assignment” # # Name: Emily Murphy # Kelsey Wright # Ryan Oakes # Mason Fields # ...
d766b76be8b22864657310d055578e8ea512295d
mirrorQAQ/mirror_dnn
/examples/models.py
2,040
3.5625
4
import layers from activate import ReLU from activate import SoftMax from activate import Sigmoid from pooling import MaxPooling class DNN(layers.Module): def __init__(self, in_size, n_classes): self.h1 = layers.Linear(in_size, 128) self.h2 = layers.Linear(128, n_classes) self.relu = ReL...
d6bedb291557132fab8eb96da4725fe7797e51fe
wwwilma/tda548-RpnCalculator
/Calculator/Calculator_me.py
4,718
4.21875
4
# package calculator from math import nan from enum import Enum # A calculator for rather simple arithmetic expressions. # Your task is to implement the missing functions so the # expressions evaluate correctly. Your program should be # able to correctly handle precedence (including parentheses) # and associ...
56a8a110feaa40903857280b7100dc55c05ddb70
EduardoJ123/TC4002_2021
/directoryManager.py
3,671
3.515625
4
import unittest class recordManager: def __init__(self): self.records_file = "directory.txt" def addRecord(self, name, email, age, country): f = open(self.records_file, "a") f.write(str(name) + "\n" + str(email) + "\n" + str(age) + "\n" + str(country) + "\n") f.close...
4295e8e4649605f4ff2016498a893fdafbff31da
akshaypalkritwar/python-GUI-programming
/table.py
2,249
3.71875
4
from tkinter import * from tkinter import turtle root.title("Supermarket System : HomePage") root.overrideredirect(True) root.geometry("{0}x{0}+0+0".format(root.winfo_screenwidth(), root.winfo_screenheight())) root.resizable(False, False) root.configure(background="black") def showTable(): table = entry.get() ...
c405cb37b42c395ffa364b8942cee0680d17cab3
nmejia10/mlandpp-uniandes
/paquetes/entregas/jfcujabante49/jfcujabante49/unsupervised.py
3,219
3.578125
4
#Algoritmo Kmeans #REFERENCIAS #El siguiente algoritmo esta basado en los siguientes url y en el apoyo de Simón Ramirez #https://mubaris.com/2017/10/01/kmeans-clustering-in-python/ #http://jonchar.net/notebooks/k-means/ ##############PASO 0 CARGAR BASE################### ####Genero datos método Simón import numpy as ...
f48e846c61ab11fa3e514b8b787d6a14a449ab82
MihaiColbasevici/Instructiunea_IF
/Problema_2_IF.py
360
3.59375
4
a, b, c = input("Dati 3 numere \t").split() a = int(a) b = int(b) c = int(c) if (a < 32000) and (b < 32000) and (c < 32000) and (a > 0) and (b > 0) and (c > 0): if ((a + b) >= c) and ((a + c) >= b) and ((b + c) >= a): print("Da") elif (a + b < c) or (a + c < b) or (b + c < a): print("Nu"...
c62cf98687f71673528a0bf39d2e8a69871fa163
MihaiColbasevici/Instructiunea_IF
/Problema_11_IF.py
332
3.65625
4
a, b, c = input("Dati 3 numere: ").split() a = int(a) b = int(b) c = int(c) if (a % 2 == 0): print(a, "par.") elif (a % 2 != 0): print(a, "impar.") if (b % 2 == 0): print(b, "par.") elif (b % 2 != 0): print(b, "impar.") if (c % 2 == 0): print(c, "par.") elif (c % 2 != 0): print(c,...
65699bd59c477e72c32d3b57072b08750c07724b
RyanRosvall/program-arcade-games
/Lab 01 - Calculator/lab_01_part_a.py
238
4.1875
4
#!/usr/bin/env python3 #Fahrenheit to Celsius conversion #Ryan Rosvall #11/1/17 temperature = int(input("Enter temperature in Fahrenheit: ")) conversion = ((temperature - int(32)) * 5/9) print('The temperature in Celsius: ' + str(conversion))
2ff9d8b9a5994c399fdad2a737a6668d9ba59d18
greenfox-zerda-lasers/hvaradi
/week-03/day-3/trial.py
758
3.984375
4
# rectangle1 = {"a": 40, "b": 50} # rectangle2 = {"a": 20, "b": 30} # # def get_circumference(rect): # return rect["a"] * 2 + rect["b"] * 2 # # print(get_circumference(rectangle1)) # print(get_circumference(rectangle2)) # class Rectangle(): # a = 0 # b = 0 # # def __init__(self, a, b): # self.a = a # ...
bc2cebe6671e920cb68096f6222ff5a24846a32e
greenfox-zerda-lasers/hvaradi
/week-04/day-4/trial.py
380
4.25
4
# def factorial(number): # product=1 # for i in range(number): # product=product * (i+1) # return product # # print(factorial(3)) def factorial(number): if number <= 1: return 1 else: return number * factorial(number-1) print(factorial(3)) # product = 1 # for i in range (...
ac0a079c76ebc604f618f118a4f4372ee700bffc
greenfox-zerda-lasers/hvaradi
/week-03/day-1/37.py
113
3.84375
4
# print the even numbers till 20 a=0 while (a <= 20): if (a % 2 == 0) and a > 0: print(a) a += 1
956fd47ed4d366895bc780e4fe3b93f41f227f11
greenfox-zerda-lasers/hvaradi
/week-04/day-4/11.py
375
3.765625
4
from tkinter import * from random import randint, choice root = Tk() canvas = Canvas(root, width=600, height=600, bg="yellow") canvas.pack() x=600 y=0 canvas.create_rectangle(y, y, x, x) canvas.create_line(x/3, y, x/3, x) canvas.create_line(x*2/3, y, x*2/3, x) canvas.create_line(y, x/3, x, x/3) canvas.create_line(y, ...
76459e26f6290338ca907294bc7d5daf660e2491
greenfox-zerda-lasers/hvaradi
/week-05/day-1/helga_work.py
834
4.1875
4
#Write a function, that takes two strings and returns a boolean value based on #if the two strings are Anagramms or not. from collections import Counter word1="hu la" word2="hoop" def anagramm(word1, word2): letters1=[] letters2=[] for i in range(len(word1)): letters1.append(word1.lower()[i]) ...
97794b34ebeda7c7dcca5bdf0e513967d8d44e7e
greenfox-zerda-lasers/hvaradi
/week-04/day-3/10.py
494
3.84375
4
# create a 300x300 canvas. # create a square drawing function that takes 1 parameter: # the square size # and draws a square of that size to the center of the canvas. # create a loop that draws 20 squares with that function. from tkinter import * root = Tk() canvas = Canvas(root, width=300, height=300) canvas.pack() ...
19e59384dc5e93fe24c6be1d883c441b6de1a7e7
greenfox-zerda-lasers/hvaradi
/week-03/day-3/circle_area_circumference.py
618
4.3125
4
# Create a `Circle` class that takes it's radius as cinstructor parameter # It should have a `get_circumference` method that returns it's circumference # It should have a `get_area` method that returns it's area class Circle(): radius = 0 def __init__(self, radius, pi): self.radius = radius self.pi = 3.14...
ceca1be15aded0a842c5f2c6183e4f54aba4fd24
greenfox-zerda-lasers/hvaradi
/week-03/day-1/22.py
161
3.515625
4
v = 426 # print 'Yeah!' if dividable by 4 but print 'End of program' after regardless if (v%4) == 0: print ("Yeah!") else: print ("End of the program")
292e2239265d13677d14d3fdc6f0170852af3fcd
roblivesinottawa/Python_Object_Oriented
/Part 2/Publication.py
1,237
3.953125
4
class Publication: def __init__(self, title, price): self.title = title self.price = price class Periodical(Publication): def __init__(self, title, price, publisher, period): super().__init__(title, price) self.period = period self.publisher = publisher class Book(Publi...
b881fe869bdf97f6da563415c2b3a7bd7da23434
Amar-Ag/PythonAssignment
/Functions3.py
1,623
4.8125
5
""" 11) Python program to create a lambda function that adds 15 to a given number passed in as an argument, also create a lambda function that multiplies argument x with argument y and print the result. """ fifteen = lambda num: num + 15 multiplyTwo = lambda num1, num2: num1 * num2 print(fifteen(15)) print(multiplyTwo...
a8c02193f549ecd73063dcc15607d5dd1cab7a44
alexyanw/algo
/stackqueue/queue.py
1,565
3.703125
4
from unittest import TestCase class Node: def __init__(self, v): self.value = v self.next = None self.end = self def append(self, v): self.end.next = Node(v) self.end = self.end.next return self.end def __iter__(self): self.it = self return ...
c9a7f2a63afeb3b83847e23a15261de033d79256
alexyanw/algo
/array/anagram.py
613
3.734375
4
def is_anagram(s1, s2): if len(s1) != len(s2): return False m1, m2 = {}, {} for i in range(len(s1)): c1, c2 = s1[i], s2[i] m1[c1] = m1.get(c1, 0) + 1 m2[c2] = m2.get(c2, 0) + 1 return m1 == m2 if __name__ == '__main__': yes = [ ['ab', 'ba'], ['aba', '...
e6c6ef4bc7e6fb9a0feeaadcf5955dbcfc239873
Vitoze/Secure-Messaging-Repository-System
/primeGenerator.py
1,233
3.765625
4
import random import fractions #calculates all primes until n def primes(n): if n==2: return [2] elif n<2: return [] s=range(3,n+1,2) mroot = n ** 0.5 half=(n+1)/2-1 i=0 m=3 while m <= mroot: if s[i]: j=(m*m-3)/2 s[j]=0 while j<half: s[j]=0 j+=m i=i+1 m=2*i+3 ret...
7dd4d62a6ec56c3a933fe29d4b0ee856f963583a
WilliamDorey/Final-Project
/Progress Report 1/Pi Zero Files/motion_camera.py
1,195
3.765625
4
# Python script to passively monitor a motiona sensor that # will take a picture using the Pi Camera and label the image # with the date and time for organisation # Importing the required library elements from time import sleep from gpiozero import MotionSensor from picamera import PiCamera from signal import pa...
28851e6a49601dce47645f9d9fa0ccea5fcb48fa
HoYaStudy/Python_Study
/playground/argparse/playground_argparse.py
1,417
3.984375
4
""" Playground of argparse module Tested: * v3.8.0-amd64 """ import argparse # Step 1. Create parser # # prog - The name of the program # usage - The string describing the program usage # description - Text to display before the argument help # epilog - Text to display after the argument help parser = argparse.Argum...
d145ed878d81536f92940e039c0394179d84c22d
HoYaStudy/Python_Study
/playground/Collections.py
3,102
3.671875
4
############################################################################### # @brief Python3 - Collections. # @version v1.0 # @author llChameleoNll <hoya128@gmail.com> # @note # 2017.08.10 - Created. ############################################################################### ''' ''' from collections i...
c1c57774c47113e39d38d942341708aff20135af
TomMarquez/Evolutionary-Programming
/Final_Project/Main.py
1,391
4.125
4
from Population import Population from Window import Window import tkinter as tk from tkinter import * import random import time import random import matplotlib.pyplot as plt def main(): pop_size = 100 iteration = 10000 max_fit = 0 top_fit = 0 average_fit = 0 pop = Population(pop_size, 10, 10)...
490b325247e485c5f28db97b58f4b255be2c04b2
RomanKV-1/lesson1
/hard1.py
370
4.125
4
#Пользователь вводит число определите, является ли данное число простым. Делится только на себя и на единицу n = int(input('Введите число')) d = 2 while n % d != 0: d += 1 if d == n: print('Число простое') else: print('Число составное')
f15086d8e41223760acc5830fe0051e5b6edaa75
chay360/learning-python
/ex3.py
519
4.3125
4
#.............Numbers and Math..........# print("I will count my chickens:") print("Hens", 25 + 30/6) print("Roosters",100 -25 * 3 % 4) print("Now i will count eggs:") print(3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6) print("Is it true that 2 + 3 < 5 - 7?") print(2 + 3 < 5 - 7) print("What is 3 + 2?", 3 + 2) print("What i...
dbf2ad366c7b4cdb31587c9f352a24b1f9e41252
MLGNateDog/untitledPycharmProject
/Comparison Operators.py
222
4.34375
4
# Here are the different types of Comparison Operators # > Greater than # >= Greater than or equal to # < Less than # <= Less than or equal to # == equal to # != not equal to # Example of use x = 3 != 2 print(x)
8f01e54c576d79846737a311f5d060d5f8d1aa93
KnowledgeMavens/Science-Tech
/LeetCode/How Many Numbers are Smaller Than The Current Number.py
421
3.578125
4
class Solution(object): def smallerNumbersThanCurrent(self, nums): """ :type nums: List[int] :rtype: List[int] """ sortedNums = sorted(nums) dic = {} result = [] for i in range(len(sortedNums)): if sortedNums[i] not in dic: dic[sortedNums[i]] ...
ec74620aef0452872c4bdfb3d9c4185a54b379ae
KnowledgeMavens/Science-Tech
/NLTK/03_stemming.py
479
4
4
from nltk.stem import PorterStemmer from nltk.tokenize import word_tokenize #Stemming - Removes suffixes or prefixes to its root word ps = PorterStemmer() example_words = ["python", "pythoner","pythoning","pythoned","pythonly"] for w in example_words: print(ps.stem(w)) new_text = "It is very important to be pytho...
b9f5a15e8e0af0c669f2b4f1623b0927fa2a1375
KnowledgeMavens/Science-Tech
/Pandas9-30-17/DataFrames2.py
629
4.1875
4
'''https://pythonprogramming.net/basics-data-analysis-python-pandas-tutorial/ ''' import pandas as pd import matplotlib.pyplot as plt from matplotlib import style style.use('ggplot') style.use('fivethirtyeight') web_stats = {'Day':[1,2,3,4,5,6], 'Visitors':[43,34,65,56,29,76], 'Bounce Rate':[...
22f61385dc359d84b093cecf5470ff30f6deb30d
wrackspurt/codingame-solutions
/easy/python/the_descent.py
237
3.8125
4
""" THE DESCENT Difficulty: Easy Link: https://www.codingame.com/training/easy/the-descent """ while True: h = [] for i in range(8): mountain_h = int(input()) h.append(mountain_h) print(str(h.index(max(h))))
3213cd6617de1d1b2b6d798b3443e477310ff71b
4nurag/samplecode
/find large no.py
374
4.0625
4
a = int(input("enter first number=")) b = int(input("enter second number=")) c = int(input("enter third number=")) if a<b:#b max if b<c:#c max print(c,"is large no.") else: print(b,"is large no.") else: #print(a,"is large no.") if a<c:#c max print(c,"is large no.") ...
1f2a525543983b83a41d64c22b57ff3c2286541b
Momolunar/mypackage
/recsort/recursion.py
1,537
4.5
4
def sum_array(array): ''' Return sum of all items in array Args: array (array): list or array-like object containing numerical values. Returns: int: sum of items. Examples: >>> sum_array([1,2,3,4,5]) 15 ''' if len(array)==1: #if one item in list, return...
f2490401bf0f1e596887f5a608b14b69e824b69c
andrewnester/python-problem-solutions
/problems/arrays/sum_of_four.py
1,913
3.671875
4
""" Find all four sum numbers Given an array A of size N, find all combination of four elements in the array whose sum is equal to a given value K. For example, if the given array is {10, 2, 3, 4, 5, 9, 7, 8} and K = 23, one of the quadruple is "3 5 7 8" (3 + 5 + 7 + 8 = 23). Input: The first line of input contains a...
a282416f9b63daa88e5a6e6849d804e008699468
kylepw/ctci
/ch1/q19.py
923
4.09375
4
""" q19.py ~~~~~~ String Rotation: Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one call to isSubstring (e.g., "waterbottle" is a rotation of "erbottlewat"). H...
f253e30008e1d81a93324f8dbcaeeab6468476b8
kylepw/ctci
/ch1/q11.py
908
3.765625
4
""" q11.py ~~~~~~ Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures? """ import unittest def is_unique(s): if not isinstance(s, str): return False if len(s) <= 1: return True exists = {} for c ...
dc0a7d734b5715f74906bf2db2aa1595537492fe
kylepw/ctci
/ch1/q13.py
1,687
3.984375
4
""" q13.py ~~~~~~ Write a method to replace all spaces in a string with '%20'. You may assume that the string has sufficient space at the end to hold the additional characters, and that you are given the "true" length of the string. EXAMPLE Input: "Mr John Smith ", 13 Output: "M...
cb1d0c79331de9a64c5973e7db253ac42f783265
omogbolahan94/Budget-App
/main.py
2,024
4.3125
4
class Budget: """ Create a Budget class that can instantiate objects based on different budget categories(class instances) like food, clothing, and entertainment. These objects should allow for: 1. Depositing funds to each of the categories 2. Withdrawing funds from each category 3. Comp...
2440ddb0f0e2bc3873f11d0fe7bee65d50b55365
zhianwang/Python
/Regression/A02Module_G33419803.py
2,852
4.125
4
# -*- coding: utf-8 -*- """ Created on Sat Sep 24 16:53:56 2016 @author: Zhian Wang GWID: G33419803 This program is define 3 function to to compute the regression coefficients for the data in an input csv file and plot the regression. """ import pandas as pd import matplotlib.pyplot as plt import numpy as np from...
e15d49e24f1cf862207f9597d92cadc9083b5bfd
shikto1/Learn-Python-Programming
/collections.py
1,269
3.984375
4
""" Python Collections (Arrays) There are four collection data types in the Python programming language: // Duplicate members allowed: List, Tuple # List is a collection which is ordered and changeable. Allows duplicate members. # Tuple is a collection which is ordered and unchangeable. Allows duplicate members. // N...
1592950901ea4c30d70ff26e38241c11452e85fb
gabrielaiji/Projet-ISN
/objet.py
3,413
3.671875
4
from tkinter import * from PIL import Image from PIL import ImageTk from math import pi from math import sqrt class Objet: """Classe définissant un objet caractérisé par : - ses coordonnées : x et y - sa vitesse - son accélération - sa masse - son image - angle de rotation de l'image (EN RADIAN)...
33d8105de6289ac6e1cda09b22f437b7118df8d6
albertusdev/competitive-programming
/CF/987A.py
1,435
3.890625
4
""" Python for Competitive Programming: In short: - Write your solution inside a function. Lookup variables in the global scope is more expensive, than using variables in the local scope. - Avoid for loops like the plague. Favor Python builtins. Always use map, filter, concatenate strings with join, etc. - Writing outp...
0ff2439b7a7ced2ab34e6f91b0eb9fbe8f2122ce
Aqua5lad/CDs-Sample-Python-Code
/ListForRange.py
1,315
4.53125
5
# Colm Doherty 2018-02-21 # These are chunks of code I've written to test the List, For & Range functions # they are tested & proven to work! # here are some Lists, showing indexing & len(gth) (ie. number of items) Beatles = ['John', 'Paul', 'George', 'Ringo'] print ("the third Beatle was", Beatles[-2]) print ("the ...
8d4cf6c2d0cb4873cb230c01719af7b0ff1f2bb4
woghd123/1
/week4.py
2,082
3.875
4
print(True) print(False) print(1 < 2) print(2 < 1) print(1 <= 2) print(2 <= 1) print(1 == 1) print(1 != 1) print("You're win! True or False?") win = bool(input("if you're lose, Just press enterKey")) if win: print("게임에서 승리하였습니다") else: print("게임에서 패배하였습니다") a = int(input('A팀 스코어: ')) b = int(input('B팀 스코...
5fd61ef485355c2813bb0dd53b852f49e64204c7
sreekripa/core
/code 5.py
443
4
4
# try: # def division(a,b): # c=a/b # print(c) # x=int(input("enter the first number")) # y=int(input("enter the second number")) # division(x,y) # except: # print("sorry,you enter zero") def division(a,b): try: c = a / b print(c) except: print("sorry...
b9a8e7b1992df51a2a4ab4dc487e880b09167ec8
navyasree-583/NAVYA
/twst.py
184
4.125
4
len= int(input("Enter arr length")) arr1=[] for i in range(len): ele=int(input("Enter number")) print(f"Element number {i+1} is :",ele) arr1.append(ele) print(arr1)
fb53684b27ea6f49aa33432f1a64f33ac57e9876
navyasree-583/NAVYA
/FOLDER-A/apple.py
382
3.78125
4
# num={'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8,'i':9,'j':10,'k':11,'l':12,'m':13,'n':14,'o':15,'p':16,'q':17,'r':18,'s':19,'t':20,'u':21,'v':22,'w':23,'x':24,'y':25,'z':26} # ch = input("Enter the word") input = input('Write Text: ') input = input.upper() output = [] for character in input: number =...
7da7d8729e8ea23a346bf429311de184a2068fb1
navyasree-583/NAVYA
/year_month_days.py
508
3.8125
4
year = input("Enter the year : ") month = int(input("Enter the month : ")) l=len(year) x=[4,6,9,11] y=[1,3,5,7,8,10,12] if(l==4 and (month>=1 and month<=12)): if month in x: print(f"There are 30 days") elif month in y: print(f"There are 31 days") else: if(int(year)%4==0 an...
77cb4525998e0475a321bd8f7a79eee013dd652b
navyasree-583/NAVYA
/missing_ele.py
255
3.953125
4
len = int(input("Enter the len val")) summ=0 while(len>0): summ+=len len=len-1 arr1=[1,2,3,4,5,7,8,9,10] summ2=0 arrlen=len(arr1) print(arrlen) for i in range (0,arrlen): summ2+=arr1[i] print('missing element is ', summ - summ2)
f08f828ba60f30898477c1ff37cb0fe071077a39
dabslee/Science-Projects
/Luria-Delbruck/main.py
739
3.625
4
""" MAIN.PY Brandon Lee 2019 Allows the user to run the simulation from a console. """ import grapher userinput = input("\nMutation hypothesis (M) or acquired immunity hypothesis (A)? ") muthyp = True if userinput.upper()=='M' else False userinput = input("Default parameters (D) or custom (C)? ") if (userinput.upper...
95d0052fc4d412b14b474f709f5214488db7b0db
7777777xx/FTP_file_server
/ftp_server.py
3,111
3.53125
4
""" FTP文件服务器 服务端 多线程 tcp 并发 """ import os from socket import * from threading import Thread from time import sleep # 全局变量定义地址 HOST = "0.0.0.0" PORT = 7777 ADDR = (HOST, PORT) # 文件库位置 FTP = "D:\\MyProjects\\FTP_File_Server\\FTP\\" # 具体处理客户端请求 class FtpServer(Thread): def __init__(self, connfd): self.co...
852c089e789383369c2b5f7a58efeacd1142aab6
mwenz27/python_onsite_2019
/week_01/05_lists/Exercise_01.py
568
4.15625
4
''' Take in 10 numbers from the user. Place the numbers in a list. Using the loop of your choice, calculate the sum of all of the numbers in the list as well as the average. Print the results. ''' num = []# create a list of numbers count = 0 try: print('Input numbers 10 times \n') for i in range(10): ...
437962b8b376a8148dd7848d5aeebc836f08a188
mwenz27/python_onsite_2019
/week_03/02_exception_handling/04_validate.py
562
4.59375
5
''' Create a script that asks a user to input an integer, checks for the validity of the input type, and displays a message depending on whether the input was an integer or not. The script should keep prompting the user until they enter an integer. ''' flag = True while flag: try: user_input = input('En...
db90495b71b6cccc66dac110f6c3f22544429f24
mwenz27/python_onsite_2019
/week_03/01_files/04_rename_doc.py
1,344
4.03125
4
''' Write a function called sed that takes as arguments a pattern string, a replacement string, and two filenames; it should read the first file and write the contents into the second file (creating it if necessary). If the pattern string appears anywhere in the file, it should be replaced with the replacement string. ...
2a741fdad210ff2889e2d36528942a4e865b6028
mwenz27/python_onsite_2019
/week_03/02_exception_handling/05_file_errs.py
857
3.796875
4
''' Read in the first number from 'integers.txt' and perform a calculation with it. Make sure to catch at least two possible Exceptions (IOError and ValueError) with specific except statements, and continue to do the calculation only if neither of them applies. ''' file = 'integers.txt' try: with open(file, 'r')...
51bde09cc8367bfb88a0a9b7169030a84bf257e1
mwenz27/python_onsite_2019
/week_02/07_conditionals_loops/Exercise_08.py
183
4.03125
4
''' Demonstrate the use of the "break" statement to exit a loop. ''' for i in range(100): print(i, end=' ') if i == 80: break print(f'\n the loop broke at 80 {i}')
b9437fa9350490b813249abe6e23d7b1108333a1
mwenz27/python_onsite_2019
/week_04/intro_apis/03_catch_em_all.py
1,616
3.6875
4
''' Using the PokéAPI https://pokeapi.co/docs/v2.html#pokemon fetch the name and height of all 151 Pokémon of the main series. Create a text document that describes each Pokémon using the information available in the JSON response. NOTE: only using 'height' is enough, but if you want more, go crazy. BONUS: Using your...
d2ba4e9f40f018006ef974c6a2a1624120ff5aff
mwenz27/python_onsite_2019
/week_01/04_strings/01_str_methods.py
938
4.40625
4
''' There are many string methods available to perform all sorts of tasks. Experiment with some of them to make sure you understand how they work. strip and replace are particularly useful. Python documentation uses a syntax that might be confusing. For example, in find(sub[, start[, end]]), the brackets indicate opt...
5b9ca8cd066392ae59f20e6e311ccefb363bebc0
mwenz27/python_onsite_2019
/week_01/04_strings/05_mixcase.py
840
4.40625
4
''' Write a script that takes a user inputted string and prints it out in the following three formats. - All letters capitalized. - All letters lower case. - All vowels lower case and all consonants upper case. ''' sentence = "If real is what you can feel, smell, taste and see, then real is simply electri...
1eeaf888fcb40efb3cce79e2143649c269314c97
JaredFlomen/LearningPython
/conditionals.py
732
4.25
4
a = -1 if a > 0: print('A is a positive number') elif a < 0: print('A is a negative number') else: print('A is zero') b = -1 print('B is positive') if b > 0 else print('B is negative') a = 3 if a > 0 and a % 2 == 0: print('A is an even and positive integer') elif a > 0 and a % 2 != 0: print('A is a positive...
bbdc1473be9c2149397d0a2ad6de67169d4fbfcd
JaredFlomen/LearningPython
/advanced_python/copying.py
450
4.09375
4
import copy class Person: def __init__(self, name, age): self.name = name self.age = age class Company: def __init__(self, boss, employee): self.boss = boss self.employee = employee p1 = Person("Jared", 26) p2 = Person('Adam', 20) # p2.age = 28 # print(p2.age) # print(p1.age) company = Company...
8d38faa596757b5785460ca4320de30ee2e3f5dd
standrewscollege2018/2021-year-11-classwork-RyanBanks1827
/Raffle.py
1,762
4.03125
4
# Imports import random import time timer = 6 winningthing = "A new car" # Setting the delay variable for how fast the program will run/ DELAY = 0.1 # Defining the raffle list to be accessed and appended to later raffle = [] # defining the test function- this function makes sure the string doesn't contain integers d...
2e6f49c33c863d56f3270f10ffb4d2467b8074cd
standrewscollege2018/2021-year-11-classwork-RyanBanks1827
/List playground.py
569
4.28125
4
# For lists we use square brackets # Items must be split by comma # Items = ["Item1", "Item2"] # print(Items[0]) # To add something to the end of a list, use append() # Items.append("Dr Evil") # To add something directly into a list, use the Items.insert() or list.insert() # Items.insert(1, "Dr good") # Lists are ...
3a28417b5dcb1e8df7878579963ce9a6a725fe81
standrewscollege2018/2021-year-11-classwork-RyanBanks1827
/Team Program.py
3,892
3.765625
4
import time versionnumber = 0.2 BTD = 0.3 # Registers the List variable of the program. Teamnames = [] TeamPeople = [] teammembers=[] def command_add(teamtoregister): print("Registered the team :" + str(teamtoregister)) registerteam = str(teamtoregister) list.append(Teamnames, []) def command_remove(team...
752bd5f33a9beb8664da897ab60ad99d5727e7be
oscartap/sudoku_project
/src/store_setting.py
1,446
3.65625
4
# StoreSetting Class , retrieve file name and settings for configuration file # Author: Ana Salinas # Automation Class (Sudoku project) - 2013 from readconfiguration import FileReader from configuration import Configuration class StorerSetting: def __init__(self, config_file, settings): self.c...