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 |
|---|---|---|---|---|---|---|
c5ec72ce973a8d01a9986a383f9978aed833dd23 | uirasiqueira/Exercicios_Python | /Mundo 3/Aula23.Ex115.py | 859 | 4.21875 | 4 | '''Crie um pequeno sistema modularizado que permita cadastrar pessoas
pelo seu nome e idade em um arquivo de texto simples.
O sistema só vai ter 2 opções: cadastear uma nova pessoa e
listar todas as pessoas cadastradas.'''
from Aula23 import Ex15p1
dic = {'nome': 'uira', 'idade':23}
print('-'* 40)
print(f'{"MENU PRI... |
65c1438f9b6dabb0f04c318cd7b45308b705ff2a | uirasiqueira/Exercicios_Python | /Mundo 3/Aula20.Ex98.py | 1,341 | 4.15625 | 4 | '''Faça um programa que tenha uma função chamada contador(), que receba
três parâmetos: início, fim e passo e realize a contagem.
Seu programa tem que realizar três contagens através da função criada:
A) De 1 até 10, de 1 em 1
B) De 10 até 0, de 2 em 2
C) Uma contagem personalizada'''
from time import sleep
'''def co... |
01427273398f798472c768bd752dd685697d28e2 | uirasiqueira/Exercicios_Python | /Mundo 3/Aula16.Ex73.py | 1,072 | 4.15625 | 4 | '''Cire uma tupla preenchida com os 20 primeiros colocados da tabela do Capeonato Bresileiro de Futebol,
na ordem de colocação. Depois mostre:
A) Apenas os 5 primeiros colocados;
B) Os últimos 4 colocados;
C) Uma lista com os times em ordem alfabética;
D) Em que posição na tabela está o time da Chapecoense'''
cbf = (... |
4f18517bdd33ee8d60828b8f517de83bc6b8627d | uirasiqueira/Exercicios_Python | /Mundo 1/Aula09.Ex22.py | 506 | 4.28125 | 4 | '''Crie um programa que leia o nome completa da pessoa:
1. O nome com todas as letras maiusculas
2. O nome com todas as letras minusculas
3. Quantas letras ao todo (sem considerar espaços)
3. Quantas letras tem o primeiro nome'''
nome = input('Digite seu nome completo:')
nome1 = nome.split()
#print (nome.upper())
#pr... |
068915765b704738e7f22348df6f3f8fd9b715a2 | uirasiqueira/Exercicios_Python | /Mundo 2/Aula12.Ex45.py | 1,392 | 4.03125 | 4 | ''' Crie um programa que faça o computador jogar Jokenpô com você'''
from random import choice
print('*.'*50)
print(' JOKENPÔ: Pedra, Papel, Tesoura.')
print('*.'*50)
opcao = ['PEDRA', 'PAPEL', 'TESOURA']
computador = choice(opcao)
jog = input('Gostaria de jogar JOKENPO?').upper()
fr... |
bfe78aeedb4f2c471e2d8f1d42dc1fcb8439e4f1 | uirasiqueira/Exercicios_Python | /Mundo 2/Aula14.Ex57.py | 597 | 4.1875 | 4 | ''''Faça um programa que leia o sexo de uma pessoa, mas so aceite os valores 'M' ou 'F'.
Caso esteja errado, peça a digitalização novamente ate ter um valor correto.'''
#nome = str(input('Qual o nome da pessoa? ')).strip()
#s = str(input('Qual o sexo da pessoa? ')).strip()
#while s not in 'MmFf':
# s = str(input('... |
bd32a444828fd6006a8a9b72c724b8696054090f | uirasiqueira/Exercicios_Python | /Mundo 2/Aula15.Ex69.py | 923 | 4.25 | 4 | '''Crie um programa que leia a idade e o sexo de várias pessoas. A cada pessoa cadastrada o programa deverá
perguntar se o usuário quer ou não continuar. No final mostra:
A) Quantas pessoas tem mais de 18 anos;
B) Quantos homens foram cadastrados;
C) Quantas mulheres tem menos de 20 anos'''
midade = homens = menorid... |
f50f04ec51563c4e60fbbe457a000f8f7fa104c4 | uirasiqueira/Exercicios_Python | /Mundo 2/Aula13.Ex50.py | 323 | 3.890625 | 4 | '''Desenvolva um programa que leia 6 números inteiros
e mostre a soma apenas daqueles que forem pares. Se o valor
digitado for ímpar, desconsidere-o'''
a = 0
e = 0
for c in range (1,7):
p = int(input(f'Digite o {c}° valor:'))
if p%2==0:
a+=p
e+=1
print(f'A soma dos {e} numeros pares foi {a}!') |
cd5220cc044ceefb289663793e540cf52f1f7ca7 | uirasiqueira/Exercicios_Python | /Mundo 1/Aula08.Ex19.py | 528 | 3.765625 | 4 | import random
a1 = input('Digite o nome do primeiro aluno:')
a2 = input('Digite o nome do segundo aluno:')
a3 = input('Digite o nome do terceiro aluno:')
a4 = input('Digite o nome do terceiro aluno:')
lista= [a1, a2, a3, a4]
escolhido = random.choice(lista)
print('Parabens {}, você foi o escolhido'.format(escolhido))
... |
4e95f1749b8250eb713c709b36531b0764d6efc8 | futureesch/python | /keyencrypt.py | 1,163 | 3.78125 | 4 | #!/usr/bin/env python3
# Author: Tom Esch
# Purpose: Encrypt a single string
# Last Revised: April 12th, 2021
# Purpose: Log the encryption event.
# Last Revised: May 5th, 2021
# Import Libraries
from cryptography.fernet import Fernet
import logging
logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d... |
44e3a5f115bcfcd9bc921703c478a35669c1e73f | EcaterinaSchita/Instructiunea-IF | /problema_2_IF.py | 217 | 3.84375 | 4 | a=int(input('valoarea primui numar este'))
b=int(input('valoarea numarului doi este'))
c=int(input('valoarea numarului trei este'))
if (a<b+c) and (b<c+a) and (c<a+b):
print('Da')
else:
print('Nu')
|
5ca88f559af1d81c79be8cf1f9e0d89be5591ddb | NisAdkar/Python_progs | /Python Programs/ListsAndFunctions.py | 3,174 | 4.59375 | 5 | #Using Functions With Lists Problems:
"""
0.Setup:
a.create a list of integers and assign it to a variable
b.create a list of strings and assign it to a variable
c.create a list of floats and assign it to a variable
1.Passing A List to A Function:
a.create a function that takes and returns an input
b.print a ... |
3ceb90716b28e92a006584a59c9cf2f7568e50b5 | NisAdkar/Python_progs | /Python Programs/FlowControlsAndComparators.py | 1,398 | 3.5625 | 4 | """
Flow Control and Comparators:
1.create a variable and assign to it an expression that is true using the greater than comparator
2.create a variable and assign to it an expression that is false using the greater than comparator
3.create a variable and assign to it an expression that is true using the greater tha... |
4ffe1b31fbdc21fc2dec484ff36470b9ac842e0f | NisAdkar/Python_progs | /Python Programs/WhileLoop.py | 1,724 | 4.4375 | 4 | """
1.While Loop Basics
a.create a while loop that prints out a string 5 times (should not use a break statement)
b.create a while loop that appends 1, 2, and 3 to an empty string and prints that string
c.print the list you created in step 1.b.
2.while/else and break statements
a.create a while loop that does the... |
d8ba13fb37f8627b061fc1e907d384e5abe1862a | spygi/interview-prep | /googleCodeJam/qualificationRound2009/C.Welcome/2.py | 1,268 | 3.78125 | 4 | #!/usr/bin python
'''
Greedy search
'''
import sys
import re
# text = 'So you\'ve registered. We sent you a welcoming email, to welcome you to code jam. But it\'s possible that you still don\'t feel welcomed to code jam. That\'s why we decided to name a problem "welcome to code jam." After solving this problem, we hop... |
156099d68a170748df634f193f5fe7bf2b578596 | spygi/interview-prep | /googleCodeJam/qualificationRound2009/C.Welcome/sample.py | 1,150 | 3.703125 | 4 | #! /usr/bin python
'''
Problematic cases: wasdwasde
wewelcome should produce 3.
'''
import sys
import re
original = 'welcome to code jam'
# texts = ['elcomw elcome to', 'wweellccoommee to', 'welcometo']
text = "So you've registered. We sent you a welcoming email, to welcome you to code jam. But it's possible that you... |
d50c580f3bee65210a747a396f9ecbe489ea6b4c | andrew-shackelford/IOPTwitter | /findTextByName.py | 4,903 | 3.78125 | 4 | #!/usr/bin/env python
'''
Takes a .json file produced by twitter.py and builds a dictionary, keyed by candidate name, with value a list of either
1) the tweets that contain the candidate's name, or
2) a candidate_twt.candidate_rec object, which contains a distillation of the tweet (currently the
text, t... |
fe4fe890c472c3a43f38487cc4a2d098a0b37d10 | sonisparky/Ride-in-Python-3 | /1.9 Statement & Comment.py | 472 | 3.953125 | 4 | """#Python Indentation
for i in range(1,11):
#print(i)
if i == 5:
break
if True:
#print('Hello')
a = 5
if True: #print('Hello'); a = 5"""
#Docstring in Python
def double(num):
"""Function to double the value"""
return 2*num
print(double.__doc__)
#Python Comm... |
fabcc057a34fa2f6b99f87d400b4e2a8124fd65f | sonisparky/Ride-in-Python-3 | /4.2 Python 3_Loops_for loop_examples.py | 1,186 | 4.3125 | 4 | #1. for loop with strings
'''for letter in "banana":
print(letter)
print("done")'''
#1.1 for loop using a variable as collection:
'''fruit = "banana"
for letter in fruit:
print(letter)
print( "Done" )'''
#1.2 use if condition:
'''fruit = "banana"
for letter in fruit:
print(letter)
... |
51bf1f588e2230dbf128dba5439dfd7ff0ac4680 | sonisparky/Ride-in-Python-3 | /4.1 Decision Making.py | 1,824 | 4.4375 | 4 | #Python 3 - Decision Making
#3.1 Python If Statements
'''if test expression:
statement(s)'''
'''a = 10
if a == 10:
print("hello Python")
# If the number is positive, we print an appropriate message
num = 3
if num > 0:
print(num, "is a positive number.")
print("This is always printed.")
... |
18b8baadd241f16e1297c7f3f9c38e0224f37ea7 | patomation/tron | /modules/duplicate.py | 1,092 | 3.703125 | 4 | # Duplicates a file
from shutil import copyfile
import ntpath
def getNextNumber(oldNumber):
newInteger = int(oldNumber) + 1
newInegerString = str(newInteger)
newNumber = '000'
if ( len(newInegerString) == 1 ):
newNumber = '00' + newInegerString
elif ( len(newInegerString) == 2 ):
... |
0b701cf8b1945f9b0a29cf2398776368a2919c03 | Aravindkumar-Rajendran/Python-codebook | /Fibonacci series check.py | 1,123 | 4.25 | 4 | ```python
''' It's a python program to find a list of integers is a part of fibonacci series'''
#Function to Check the first number in Fibonacci sequence
def chkFib(n):
a=0;b=1;c=a+b
while (c<=n):
if(n==c):
return True
a=b;b=c;c=a+b
return False
#Function to check the list in ... |
287e6337f80ee308c65302e12248d621e81e6976 | karimbahgat/ToponymGeoreferencingPaper | /dependencies/generate maps/pythongis/app/tk2/_othermisc/tkplacer.py | 9,080 | 3.953125 | 4 | """
Sub-Module of tk2: Tkinter Placer
Provides additional placement features for Tkinter's .place manager.
Note: Most of the functionality in this module requires that the widget uses a
place manager (not pack or grid)
"""
#PYTHON VERSION CHECKING
import sys
PYTHON3 = int(sys.version[0]) == 3
if PYTHON3:
xrange = ... |
a42ceda00cbb1d6f30d20edb9d642409b50a1121 | karimbahgat/ToponymGeoreferencingPaper | /dependencies/generate maps/pythongis/app/tk2/_frompygis/helpers.py | 892 | 3.5625 | 4 |
import itertools
# GUI Helpers
def trackloop(iterable, queue, updateincr=1):
# make updateincr to fraction of one
updateincr = updateincr / 100.0
# setup
total = float(len(iterable))
nextthresh = updateincr
# begin
for index, item in enumerate(iterable):
prog = index
ra... |
e8c842590d1bda46b686737a2369e01d48a08740 | dwpark10/Python | /TensorFlow/Day_03_07_stochastic.py | 4,069 | 3.796875 | 4 | import numpy as np
import matplotlib.pyplot as plt
import random
def sigmoid(z):
return 1 / (1 + np.exp(-z))
def gradient_descent(x, y):
m, n = x.shape
w = np.zeros([n, 1])
lr = 0.01
for _ in range(m):
z = np.dot(x, w) # (100, 1) = (100, 3) x (3, 1)
h = sigmoi... |
0347ed05761dbb44d24fe2d0a10e4d3a9f0464cc | dwpark10/Python | /TensorFlow/Day_01_01_python.py | 1,498 | 3.9375 | 4 | # python 3.6.4 64bit 버전으로 ( 텐서플로우가 32비트 버전은 지원하지 않음
# editor : 파이참
# 실행 : ctrl + shift + f10
# alt + 1 , alt + 4
# alt + / : 주석
# 그냥 ctrl + c 누르면 해당 라인 복사
# 다중 치환
a, b = 3, 8
print(a, b)
a, b = b, a
print(a, b)
# 연산 : 산술, 관계, 논리
# 산술 연산자 : + - * / ** // %
print(a+b)
print(a-b)
print(a*b)
pri... |
ba87b0c53cef27ea76b262e9f82e07a9695f6e2b | Thexumaker/PyBaseball | /PyMLBStats/test.py | 754 | 3.640625 | 4 | speed_kps = 299792.458
kmToMiles = .621
speed_mips = speed_kps * kmToMiles
half_speed_mips = speed_mips/2
quarter_speed_mips = half_speed_mips/2
earth_speed_mph = 66600
earth_speed_kps = ((earth_speed_mph / kmToMiles) / 60) / 60
speedAsPercentage = earth_speed_kps/speed_kps
print('Speed of light (Kilometers / sec): ... |
b5330962a7baa700caa11ed84bab587835ed32b2 | DangLeUyen/DataCamp | /Statistical_Thinking_2.gyp | 12,854 | 3.53125 | 4 | # HOW OFTEN DO WE GET NO-HITTERS?
# Seed random number generator
np.random.seed(42)
# Compute mean no-hitter time: tau
tau = np.mean(nohitter_times)
# Draw out of an exponential distribution with parameter tau: inter_nohitter_time
inter_nohitter_time = np.random.exponential(tau, 100000)
# Plot the PDF and label axes... |
c68e54bdc7082fa2fb50d04e526a619d7181a87c | Philosocode/rando-kanji | /io_handler.py | 737 | 3.53125 | 4 | #!/usr/local/bin/python3
from constants import ( TOTAL_KANJI )
def get_choice():
choice = input("> ").lower()
choice = choice.strip()
if len(choice) == 0:
return " "
return choice[0]
def pause(message = ""):
input(message)
def print_intro_prompt(index, kanji, meaning):
print(f'\... |
9f119f1e3534b9476e91ef3c3faf2ba2f32f3194 | Zahidsqldba07/Programming-Problems-1 | /Array/Rearrange Array Alternately.py | 1,976 | 3.96875 | 4 | """Given a non-decreasingly sorted array of positive integers, rearrange the array alternately such that
first element is the maximum value, second is the minimum value, third is the second max value, fourth is the second min value and so on.
Input: [1, 2, 3, 4, 5, 6, 7]
Output: [7, 1, 6, 2, 5, 3, 4]"""
def reA... |
f69ce58fa5b8d2e0da7295235adc1aefc20b689b | coderbyheart/hsrm-mi-prog3 | /Python/Aufg6-6.py | 442 | 3.6875 | 4 | # -*- coding: utf-8 -*-
print [((x1**3 + x2**3), (x1,x2), (y1,y2))
for x1 in range(25)
for x2 in range(25)
# Eliminiert Duplikate
if x1 < x2
for y1 in range(25)
for y2 in range(25)
# Eliminiert Duplikate
if y1 < y2
# Summe der beiden soll gleich sein
... |
d954b461c4c3740b90e22e5ff8634c7f65c2af67 | coderbyheart/hsrm-mi-prog3 | /Python/Aufg6-2.py | 1,908 | 3.515625 | 4 | # -*- coding: utf-8 -*-
def ggTRecursive(a, b):
"Berechnet den ggT rekursiv"
if (a == b):
return a
if (a < b):
a = ggTRecursive(a, b-a)
if (b < a):
a = ggTRecursive(a-b, b)
return a
def ggTRecursiveFast(a, b):
"Berechnet den ggT rekursiv, aber schnell"
if (a == b):
... |
a08f5c3c5acce30f37cf8ebb800d6d83462f1552 | coderbyheart/hsrm-mi-prog3 | /Python/Aufg6-5.py | 856 | 3.65625 | 4 | # -*- coding: utf-8 -*-
print "Geradzahlige Kubikzahlen von 1 bis 10"
# List Comprehension
print [x**3 for x in range(1,11) if x**3 % 2 == 0]
# Funktionale Primitive
print filter(lambda x: x % 2 == 0, map(lambda x: x**3, range(1,11)));
print ""
print "Alle Teiler einer Zahl z außer 1 und z"
for z in (123, 12345, 1234... |
9107c5240f89ab0dd0be190c861b58a8a70f3207 | TCestonaro/ds-courses | /1-Introduction-to-Python/day-1/3-controlstructures/controlstructures_solutions.py | 4,963 | 4.03125 | 4 | # code for control structures slides
# %%
#6
# Define list of numbers from 1 to 10
LNumbers = [1,2,3,4,5,6,7,8,9,10]
LNumbers = list(range(1,11))
# %%
#10
iNumber = 5
if iNumber < 10:
print('Number is less than 10')
... |
66db5947c36731b58094bf48b586f8d304e6a91b | Adrriii/ia-capture-the-flag | /src/tests/PythonPhysics.py | 5,766 | 3.625 | 4 | from math import sqrt, atan2, cos, sin, degrees, radians, pi
import unittest
from service.Physics.PythonPhysics import PythonPhysics
from service.Physics.Physics import Physics
class TestPythonPhysics(unittest.TestCase):
def __init__(self, methodName):
super().__init__(methodName)
Physics.SetIns... |
7035143271de8d2aa23f4787014c16be1fbab16d | Adrriii/ia-capture-the-flag | /src/game/model/ArgBuilder/ArgBuilder.py | 1,192 | 3.515625 | 4 | from abc import (ABCMeta, abstractmethod)
class ArgBuilder(metaclass=ABCMeta):
"""
This class represent the interface to implements for building the
argument of player's polling.
"""
@abstractmethod
def beginArgument(self):
"""
Begin a new argument. All datas about old argument... |
55440c7dfaac328a4050a9ae3bbfc4c4df44fe12 | Adrriii/ia-capture-the-flag | /src/game/model/Model.py | 900 | 3.71875 | 4 |
class Model:
"""
Interface for the Game Model, which stores the current state of the game.
"""
def __init__(self, Player1, Player2):
"""
Initialize game data.
Parameters:
Player1 (Player): The player in control of the Red team.
Player2 (Player): The pl... |
8ba50e3abc4f884b876a4ddd9c7a216d33fb443e | AbelWeldaregay/CPU-Temperatures | /piecewise_linear_interpolation.py | 2,286 | 4.34375 | 4 | import sys
from typing import (List, TextIO)
def compute_slope(x1: int, y1: int, x2: int, y2: int) -> float:
"""
Computes the slope of two given points
Formula:
m = rise / run -> change in y / change in x
Args:
x1: X value of the first point
y1: Y value of the first point
x2: X value of second point
y2: ... |
38c5e133aa5300cc7816d33dcb8b91e715527e68 | andrewwong97/halo-word-count | /halo-word-count.py | 904 | 4.03125 | 4 | #!/usr/bin/env python
import string
expected = ['the', 'and', 'to', 'of', 'i', 'you', 'a', 'my', 'hamlet', 'in']
def clean_data(doc):
data = [i.strip().lower() for i in doc.split()]
for i in range(len(data)):
data[i] = strip_punctuation(data[i])
return data
def strip_punctuation(word):
for... |
64a6cb1f13a82040666ff517880e07a93a4b26ec | mosinal88/SimpleBankingSystem | /Problems/The farm/main.py | 716 | 3.875 | 4 | money = int(input())
if 23 <= money < 678:
if money // 23 > 1:
print(money // 23, "chickens")
else:
print(money // 23, "chicken")
elif 678 <= money < 1296:
if money // 678 > 1:
print(money // 678, "goats")
else:
print(money // 678, "goat")
elif 1296 <= money < 3848:
i... |
c465262fbfa71e097e2416dd7798c971d3de6493 | mosinal88/SimpleBankingSystem | /Problems/What day is it/main.py | 195 | 4.0625 | 4 | timezone = int(input())
if -12 <= timezone <= 14:
if timezone + 10.5 < 0:
print('Monday')
elif timezone + 10.5 > 24:
print('Wednesday')
else:
print('Tuesday')
|
861703a49646221bf9ff60c62d8ad16599499161 | mosinal88/SimpleBankingSystem | /Problems/Stack class/main.py | 264 | 3.609375 | 4 | class Stack():
def __init__(self):
self.el = []
def push(self, el):
self.el.append(el)
def pop(self):
return self.el.pop()
def peek(self):
return self.el[-1]
def is_empty(self):
return self.el == []
|
17177920e255a7a2fabe6d2785a1ea2aacf0e342 | mosinal88/SimpleBankingSystem | /Simple Banking System/task/banking/banking.py | 5,383 | 3.921875 | 4 | # Write your code here
import random
import sqlite3
import sys
conn = sqlite3.connect('card.s3db')
cur = conn.cursor()
cur.execute('CREATE TABLE IF NOT EXISTS '
'card(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,'
' number TEXT,'
' pin TEXT,'
' balance INTEGER DEFAULT 0... |
b7628a6d1c593e0b61e313bef353f16553863058 | akosasante/Quizbowl-Packet-Reader | /testing gui.py | 3,762 | 3.640625 | 4 | from Tkinter import *
import pymysql
import msvcrt
import time
import re
import random
# initiates variables for pymysql connection
connection = pymysql.connect(host="localhost",
user="root",
password="island",
db="quizbowl",
charset="utf8",
cursorclass=pymysql.cursors.DictCursor)
# initiates the cursor and then sele... |
6a47156bb00b3488aaa3a2505c8ccbad1a73a54a | mingbocui/Higgs-Boson-Machine-Learning-Challenge | /src/costs.py | 1,889 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""a function used to compute the loss.
sigmoid(t)
calculate_sigmoid(y, tx, w)
calculate_mse(err)
calculate_mae(err)
compute_loss(y, tx, w, loss_method='mse')
compute_gradient(y, tx, w, loss_method='mse')
"""
import numpy as np
def sigmoid(t):
"""apply sigmoid function on t."""
return ... |
e1dd2e0f656d266fb8d469943a169daa11f8bbc6 | Jtoliveira/Codewars | /Python/listFiltering.py | 557 | 4.25 | 4 | """
In this kata you will create a function that takes a list of non-negative integers and
strings and returns a new list with the strings filtered out.
"""
def filter_list(l):
result = []
#letters = "abcdefghijklmnopqrstuwvxyz"
for item in l:
if type(item) == int or type(item) == float:
... |
e2178bffb76de34c553c9df9caaeff2ea33f7334 | xxCreatorKojixx/algorithm | /selection.py | 586 | 3.8125 | 4 |
#セレクトソート
#参考URL
#https://qiita.com/muiscript/items/257e8b9b49d891137d56
def main():
data = [5,3,9,1,7,4,2,6,8]
print(selection(data))
return
def selection(data):
for i in range(len(data) -1):
#並べられていない範囲のリストの
#最小値のインデックス番号をとってくる
minindex = data[i:].index(min(dat... |
06977379b301278f06d1e2dad9676cb6d0aa2239 | gkicchi/python_training | /class.py | 217 | 3.734375 | 4 | class Dog:
name = ""
def bark(self):
m = self.name + ": Bow-wow!"
print m
pochi1 = Dog()
pochi1.name = "Pochi"
pochi1.bark()
hachi1 = Dog()
hachi1.name = "Hachi"
hachi1.bark()
pochi1.bark()
|
e766763453b92496e90d7f25fe84e22f8ce98f1f | gkicchi/python_training | /tuple.py | 179 | 3.734375 | 4 | a = [2012, 2013, 2014]
b = (2012, 2013, 2014)
print a
print b
print a[1]
print b[1]
a[1] = 2016
print a
#b[1] = 2016
#print b
a.append(2015)
print a
b.append(2015)
print b
|
e54f322e2c643f01f39ff711aa942e3b5717135e | Jacob-Eckroth-School/362-extra-credit | /targetSum.py | 296 | 3.5 | 4 |
def findSum(array,sumTarget):
numberDict = {}
for number in array:
complement = sumTarget - number
if(complement in numberDict):
return [complement,number]
else:
numberDict[number] = None
return None
print(findSum([2,7,11,15],9))
|
4e4cb9debbc983bcf3cc5f7eaaf05a72d747da45 | apisdk/python-training | /learn-python/ex24_ex25_practice_functions/splitStringFunctionRunner.py | 550 | 4.0625 | 4 | import splitStringFunction
sentence = "All good things comes to those who wait."
words = splitStringFunction.break_words(sentence)
# ['All', 'good', 'things', 'comes', 'to', 'those', 'who', 'wait.']
print(words)
sorted_words = splitStringFunction.sort_words(words)
#['All', 'comes', 'good', 'things', 'those', 'to',... |
5574b79fd35602db7a332b706a99728a6db46727 | Ranjan-Bagri/Assignments | /factorial.py | 170 | 4.09375 | 4 | def factorial(n):
f = 1
for i in range(2,n+1):
f*=i
return f
num=int(input('Enter a integer: '))
print('Factorial of %s is %s'%(num,factorial(num)))
|
e309f5807f1240ca0c35c39b5156c5b587eb4c10 | Ranjan-Bagri/Assignments | /palindrome_number.py | 226 | 4.03125 | 4 | def palin_num(num):
inp=str(num)
nums=inp[::1]
rev=nums[::-1]
if nums==rev:
return "%s is a Palindrome Number"%inp
else:
return "%s is not a Palindrome Number"%inp
i=int(input('Enter a number: '))
print(palin_num(i)) |
ab3abff58642ca70850e324aa6ebab6289aa6c6f | kadduz/JetBrains-Academy-Python-Track | /banking.py | 5,805 | 3.6875 | 4 | import random
import sqlite3
class Card:
BIN = '400000'
def __init__(self, n=None, p=None, b=0):
self.number = n
self.pin = p
self.balance = b
def __repr__(self):
return f"Your card number:\n{self.number}\nYour card PIN:\n{self.pin}"
def create(self):
account... |
c4c4731669585c52ca2ca83d1d42dea33e2f0243 | Nikiema20/Projet-traitement-final-1 | /table.py | 3,158 | 3.828125 | 4 | class Table:
''' classe qui permet de instancier les tables initiales
attributes
__________
nom_colonnes: list
liste des noms des colonnes
lignes: list[list]
liste des lignes de la table
'''
def __init__(self , nom_col , list_lignes):
self.nom_colonnes = nom_col ... |
14a908682b0807114bac8b2a0e9cf49c7209ae84 | TomEdwardBell/PycharmProjects | /ALevel/Programming Challenges/interest.py | 1,252 | 3.890625 | 4 | def debt_calculation(initial, interest, repayment):
debt = initial
total_paid = 0
interest /= 100
repayment /= 100
months = 0
while debt != 0:
months += 1
# One month has progressed
debt += debt * interest
# Add interest
if debt * repayment > 50:
... |
6c14202d7a07d5ccf950ee9af7fc563dd016e14e | mishikaraj/TkinterUI | /Test/frame.py | 1,011 | 3.828125 | 4 | import tkinter as tk
from tkinter.ttk import *
'''root = Tk()
label = Label(root, text="Hello World")
label1= Label(root,text="ABC")
button=Button(root,text="click")
root.title("Courier Complaint System")
label.pack()
label1.pack()
button.pack()
root.mainloop()'''
'''class MyApplication(tk.Tk):
def __init__... |
f2dbbabc6a8cac5070e8a12ab74f1a72f711378a | omariba/Python_Stff | /random_gen.py | 1,023 | 3.53125 | 4 | import random
import os
import time
#generate once
#name = ""
#li = []
#while name != "00":
# name = raw_input("Items: ")
# if name == "00":
# pass
# else:
# li.append(name)
#li = ['Gitonga','Mandela','Kevin','Kimani','Cetric','Robert']
#def gen():
# random.shuffle(li)
# for i in li:
# print i
#gen()
#randomise ... |
75d53f25da76d598d7f6b1c9da30b3b11f06b439 | omariba/Python_Stff | /prime.py | 311 | 3.921875 | 4 | for num in range(1,20):
if num == 1:
print "%s is Not PrimeNumber" %num
elif num%2 == 0:
if num ==2:
print "%s is A PrimeNumber" %num
else:
print "%s is Not A PrimeNumber" %num
elif num%1 == 0 and num%num == 0:
print "%s Prime" %num
|
d92355f8065ef618216326ef8da15cd5d5d171b2 | omariba/Python_Stff | /oop/gar.py | 2,875 | 4.1875 | 4 | """
THE REMOTE GARAGE DOOR
You just got a new garage door installed.
Your son (obviously when you are not home) is having a lot of fun playing with the remote clicker,
opening and closing the door, scaring your pet dog Siba and annoying the neighbors.
The clicker is a one-button remote that works like this:
If the door... |
859a8043d4491ecb6f750c4728fa36678113bf00 | omariba/Python_Stff | /catching_errors.py | 197 | 4.125 | 4 | word = raw_input("Word: ")
vowel = ['A','E','I','O','U','Y','a','e','i','o','u','y']
try:
for i in word:
if i in vowel:
print word.index(i)
elif:
except ValueError:
print "Missing value"
|
4ff6461db41f685cb515ac4dbb9927ee04e98076 | omariba/Python_Stff | /count_remove.py | 235 | 3.5 | 4 | data = [1,1,2,3]
n = 2
li = []
#def answer(data,n):
# for i in data:
# if data.count(i) == n:
# li.append(i)
# print li
def answer(data,n):
for i in data:
if data.count(i) != n:
data.remove(i)
print data
answer(data,n)
|
52b74ac11a83e12f5b8ebea8a8dc43544f7bd179 | mti7086/keras | /Keras/keras12_emsemble3.py | 5,535 | 3.59375 | 4 | # import keras # keras 가져오겠다.
# import tensorflow
#1. 데이터
import numpy as np # numpy를 가져와 np로 지정해주겠다.
x1 = np.array([range(100), range(311,411), range(100)])
x2 = np.array([range(501, 601), range(711,811), range(100)])
y1 = np.array([range(101, 201), range(311,411), range(100, 200)])
y2 = np.array([range(5... |
0a670215ea8b4f6ad97a11bff96e4a4f26884e0f | mti7086/keras | /Keras/keras13_lstm4_earlyStopping.py | 1,934 | 3.6875 | 4 | from numpy import array
from keras.models import Sequential
from keras.layers import Dense, LSTM
#1. 데이터
x = array([[1,2,3], [2,3,4], [3,4,5], [4,5,6], [5,6,7],
[6,7,8], [7,8,9], [8,9,10], [9,10,11], [10,11,12],
[20,30,40],[30,40,50], [40,50,60]])
y = array([4,5,6,7,8,9,10,11,12,13,50,6... |
a32e9f1ed7b0de2069df756e27bf264763f66f89 | Ntare-Katarebe/ICS3U-Unit4-07-Python-Loop_If_Statement | /loop_if_statement.py | 392 | 4.28125 | 4 | #!/usr/bin/env python3
# Created by: Ntare Katarebe
# Created on: May 2021
# This program prints the RGB
# with numbers inputted from the user
def main():
# This function prints the RGB
# process & output
for num in range(1001, 2000 + 2):
if num % 5 == 0:
print(num - 1)
el... |
27ed4b157770c40d04fdf0be4b2b5d8700265716 | fadelakbarputra/belajar-python | /Day02/final-project.py | 370 | 4.09375 | 4 | print("Welcome to the tips calculator!")
total = float(input("What was the total bill? $ "))
percen = float(input("What percentage tip would you like to give? 10, 12, or 15? "))
people = int(input("How many people to split the bill? "))
bill_each_people = round((total / people) + (total * (percen/100) / people), 2)
pr... |
8624e03c16fce4d1f198c35f2da9d60aa303ac22 | fadelakbarputra/belajar-python | /Day01/02-variabel.py | 123 | 3.640625 | 4 | name = "fadel"
print(name)
name = "akbar"
print(name)
name = input("What is your name?")
length = len(name)
print(length) |
6d141f06344a46d843bd2d36ee58369df0905c14 | tonyxuxuxu/tonyxuxuxu.github.io | /leetcode_practice/exist.py | 612 | 3.640625 | 4 | class Solution:
def exist(self, board, word):
row = len(board[0])
col = len(board)
def dfs(board,word, i, j):
if len(word) == 0:
return True
if i < 0 or i >= row or j <0 or j>= col or word[0] != board[j][i]:
return False
... |
c89ce2c9b31e3a22dbc076d86b59372c4f26ee0d | tonyxuxuxu/tonyxuxuxu.github.io | /leetcode_practice/two_sum_01.py | 383 | 3.640625 | 4 | class Solution:
def twoSum(self, nums, target):
if not nums:
return None
for i in range(len(nums)):
for j in range(len(nums)):
if nums[i] + nums[j] == target:
return [i,j]
return None
if __name__ == "__main__":
nums = [2, 7, 11... |
19ff66563f436ca92ba92e4c176c6180e31a6722 | tonyxuxuxu/tonyxuxuxu.github.io | /leetcode_practice/sortcolors.py | 430 | 3.828125 | 4 | class Solution:
def sortColors(self, nums):
one, two, three = 0, 0, len(nums) - 1
while two <= three:
if nums[two] == 0:
nums[one], nums[two] = nums[two], nums[one]
one += 1
two += 1
elif nums[two] == 1:
two += 1... |
91ea1f562a975a8eb57ab252c85e60589f0cabf1 | vattikondahemanth/Mastancode | /test.py | 276 | 3.625 | 4 | class Testclass:
def __init__(self):
self.a = 0
def testmethod(self, x):
x = x + 1
self.a = self.a + 1
if x <= 3:
x = self.testmethod(x)
else:
return x
print(x)
a = Testclass()
a.testmethod(1)
|
7da373d8441740ac0b1d2edebd476f9c796d5da8 | GEEKANDI/ABC_14-DAY2 | /max_min/max_min.py | 337 | 3.6875 | 4 | def find_max_min(input_list):
if all(val == input_list [0] for val in input_list) == True:
list_x = []
list_x.append(len(input_list))
return list_x
else:
max_val = max(input_list)
min_val = min(input_list)
output_list = []
output_list.append(min_val)
output_list.append(max_val)
r... |
344bf5a3c4428edc711b4d9d032de4310cfa3ed8 | liuperic/automate_the_boring_stuff_with_python_solutions | /ch_15/practice_projects/brute_force_pdf.py | 887 | 3.796875 | 4 | # #!/usr/bin/env python3
"""Tries to decrypt PDF file using every word in dictionary file as password guess"""
import os, PyPDF2
dictionary = []
file_name = input('Enter absolute path of PDF file')
# Add dictionary to a list (per book specs)
with open('dictionary.txt', 'r') as f:
lines = f.readlines()
# Ad... |
c77ced7ee51e7ebc4e119640ea0453d73dc3aa77 | liuperic/automate_the_boring_stuff_with_python_solutions | /ch_19/practice_projects/photo_folder.py | 1,179 | 3.9375 | 4 | #!/usr/bin/env python3
# photo_folder.py - Identifies folders as photo folders based on specified criteria.
# Prints absolute path of photo folders to screen.
import os
from PIL import Image
for foldername, subfolders, filenames, in os.walk('/'):
num_photo_files = 0
num_non_photo_files = 0
for filename i... |
7122f3b55f0b152d74885759431b5e0310f5081c | liuperic/automate_the_boring_stuff_with_python_solutions | /ch_5/practice_projects/fantasy_game_dragon_loot.py | 823 | 4.0625 | 4 | #!/usr/bin/env python3
# List to Dictionary function for fantasy game inventory.
# Can now add list to inventory and display updated inventory thereafter.
def display_inventory(inventory):
print('Inventory:')
total_items = 0
for k, v in inventory.items():
print(str(v), k)
total_items += v
... |
19747bdcb1307d5a96ee538530759b2093f77960 | liuperic/automate_the_boring_stuff_with_python_solutions | /ch_4/practice_projects/character_picture_grid.py | 643 | 3.5 | 4 | #!/usr/bin/env python3
def print_picture_grid(grid):
row_length = len(grid[0])
column_length = len(grid)
for row in range(row_length):
for column in range(column_length):
print(grid[column][row], end=' ')
print()
grid = [['.', '.', '.', '.', '.', '.'],
['.', 'O', 'O',... |
554bb813ca14d61773a362f8bbf5f6a350d00a67 | liuperic/automate_the_boring_stuff_with_python_solutions | /ch_12/practice_projects/image_downloader.py | 1,409 | 3.71875 | 4 | #!/usr/bin/env python3
# image_downloader - Downloads images from Imgur
import requests, os, bs4
import pyinputplus as pyip
pic_count = 0
search = input('What would you like to search for?\n')
num_pics = pyip.inputInt('How many pictures would you like downloaded?\n')
url = 'https://imgur.com/search?q=' + search # ... |
7ac0b9332e657dc1eb583c587bb5096e6f638476 | liuperic/automate_the_boring_stuff_with_python_solutions | /ch_8/practice_projects/own_multiplication_quiz.py | 1,147 | 4.03125 | 4 | #!usr/bin/env python3
# Recreate multiplication quiz from chapter projects
# without using pyinputplus
from threading import Timer
import random, time
number_of_questions = 10
correct_answers = 0
start_time = 0
for question_number in range(1, number_of_questions + 1):
# Pick two random numbers:
num1 = rando... |
1e654d92564b7565c33acd23778627aa6574c726 | gbanegas/KissECC | /ecc.py | 3,470 | 4.28125 | 4 | # Basics of Elliptic Curve Cryptography implementation on Python
import collections
from utils.inversion import Inverse
from utils.math_utils import MathUtil
class EC(object):
"""System of Elliptic Curve"""
def __init__(self, a, b, q):
"""elliptic curve as: (y**2 = x**3 + a * x + b) mod q
- a, ... |
65fb281f478e98e88314f388508e2c7489e1e809 | gowthammg/LeetCode | /AllElementsInBinaryTree/AllElementsInBinaryTree.py | 912 | 3.84375 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def traverse(root1, left, right, li):
if (root1.left != None):
Solution.traverse(le... |
2567062051f03be30833079a98a32a1f97e60b52 | yogeshmanghnani/projecteuler | /problem_007.py | 763 | 3.796875 | 4 | #File made by Yogesh Manghnani
# The below function is the AKS primality test.
def check_if_prime(n):
if n == 1:
return False
elif n == 2:
return True
elif n == 3:
return True
elif n == 5:
return True
elif n % 2 == 0:
return False
elif n % 3 == 0:
... |
d6bf4cfe1c46129f34a6673a69e374f88d0f1872 | tjovicic/python-networking-security | /Threads.py | 742 | 3.734375 | 4 | #!/usr/bin/python3
import threading
class MyThread(threading.Thread):
def __init__(self, num, val):
threading.Thread.__init__(self)
self.threadNum = num
self.loopCount = val
def run(self):
print("Starting run: ", self.threadNum)
myfunc(self.threadNum, self.loopCount)
... |
b68739dfdda14d0ebc4190272caa4c6cb40d9b6e | Scepticae/My-Coding-Projects | /My Python Coding/Intro Scientific Computing/ProgrammingAssignments/Homework 8/sleonar5.hw8.py | 4,426 | 3.609375 | 4 | #!/usr/bin/env python3
# Template for COSC 370 Hwk #8
# Approximation of derviatives using FDA, Richardson extrapolation,
# and polynomial interpolation
from numpy import round, array, polyfit, polyder, polyval
# Problem 5.1.9
#
# Fill in this comment block with a description of the approximation
# problem and ... |
323629c0849030ba62f8a7fc74a77f866beaadbe | Scepticae/My-Coding-Projects | /My Python Coding/Intro Scientific Computing/ProgrammingAssignments/Homework 7/sleonar5.hw7.py | 3,819 | 4.28125 | 4 | #!/usr/bin/env python3
# Template for Problem 27 from Problem Set 4.1
# You must complete/finish all statements with "???"
from newtonRaphson2 import *
from math import sin, pi
import numpy as np
import matplotlib.pyplot as plt
# The trajectory of a satellite orbiting the earth is given by the equation
#
# R = C/(... |
41862910541ca792ea58dab08d7805e499581097 | Scepticae/My-Coding-Projects | /My Python Coding/HW9/frequency.py | 558 | 3.671875 | 4 | #Samuel Leonard
#sleonar5
#HW 9
#frequency.py
import sys
#Read in the file
with open(sys.argv[1], 'r') as f:
read_data = f.read()
#Break the string up into individual words and get number
#of words
words = read_data.split()
x = len(words)
#create a dictionary
tel = {words[0]: 1}
for i in range(1, x):
if words[i... |
3ca1d41b36d422e81a1c8d012cae44234d350b50 | vprasad46/DataStructuresAlgorithms | /Arrays/Search/Search in Sorted Rotated Array.py | 1,215 | 4.34375 | 4 | # Search Algorithm for Sorted Rotated Array
def search(arr, start, end, len, searchElement):
middle = int((start + end) / 2)
if end > 0 and middle < len and start != end:
if arr[middle] == searchElement:
return middle
elif arr[middle] < searchElement:
return search(arr,... |
a569ad1b2af38009ff0f9912b8a9d4af14a351d3 | vprasad46/DataStructuresAlgorithms | /Arrays/Search/Search Pivot Index.py | 541 | 4.0625 | 4 | # Search Algorithm for sorted arrays: Binary Search
def search(arr, start, end):
middle = int((start + end) / 2)
if start != 0 and end != 0:
if arr[middle] < arr[middle - 1]:
return middle - 1
elif arr[middle] > arr[middle + 1]:
return middle + 1
elif arr[middle]... |
6ddaba1a37e239c325bfd313d4f20ef5f0079c9a | pranay573-dev/PythonScripting | /Python_Lists.py | 1,447 | 4.3125 | 4 | '''
#################################Python Collections (Arrays)###############################################
There are four collection data types in the Python programming language:
bytes and bytearray: bytes are immutable(Unchangable) and bytearray is mutable(changable):::::[]
List is a collection which is ordered... |
1c8ecfb22c2096041635f921d61b8189af0216cd | jherskow/intro2cs | /intro2cs/ex7/ex7.py | 5,987 | 4.46875 | 4 | """########################################################################
# FILE : ex7.py
# WRITER : Joshua Herskowitz , jherskow , 321658379
# EXERCISE : intro2cs ex7 2016-2017
# DESCRIPTION: Functions making use of recursive logic.
########################################################################"""
EMPTY_S... |
53536c3733e5a2637d25454026c95c227488d08a | jherskow/intro2cs | /intro2cs/ex10/article.py | 1,998 | 4.0625 | 4 | """########################################################################
# FILE : article.py
# WRITER : Joshua Herskowitz , jherskow , 321658379
# EXERCISE : intro2cs ex10 2016-2017
# DESCRIPTION: Implements article object and functionality.
########################################################################"""... |
3fab5cd005d57e69ae6589ce2fca3fa74dde7477 | alvaroficial/acmd | /OUILookup.py | 1,181 | 3.765625 | 4 | from getmac import get_mac_address#Librería para obtener la mac
import sys#Librerias para obtener datos al ejecutar el programa
import getopt
argv1=str(sys.argv[1].upper())
argv2=str(sys.argv[2].upper())
def eMac(x):#Funcion para buscar la mac y su correspondiente
cont=-1
b=x in texto
for i in tex... |
5485cf71b7368fcc1de6dbb739294b0cc6a8b124 | aggiewb/scc-web-dev-f19 | /ict110/peer_assignment_2.py | 380 | 3.96875 | 4 | '''
peer programming exercise 2
converts to inches to centimeters
Aggie Wheeler Bateman
10/7/18
'''
CONVERSION_INCHES_TO_CENTIMETER=2.54
def main():
print("This program converts inches to centimeters.")
inches = eval(input("Enter the number of inches: "))
centimeters = inches * CONVERSION_INCHES_TO_CENTIME... |
29b440e1130521cb7fdc12a381a215b2725c90fa | aggiewb/scc-web-dev-f19 | /ict110/3.5_coffee_shop_order.py | 578 | 4.21875 | 4 | '''
This is a program that calculates the cost of an order at a coffee shop.
Aggie Wheeler Bateman
10/10/19
'''
COFFEE_PER_POUND = 10.50 #dollars
def main():
print("Welcome to Coffee Inc. order calculation system. This system will calcute the cost of an order.")
print()
orderAmount = f... |
000fec743dd12b9254000e20af4d3b38f6d4e28c | aggiewb/scc-web-dev-f19 | /ict110/itc110_midterm_gas_mileage.py | 600 | 4.28125 | 4 | '''
This is a program to calculate the gas mileage for your car based off of the
total miles traveled and the gallons of gas used for that distance.
Aggie Wheeler Bateman
11/6/19
'''
def getMiles():
miles = int(input("Please enter the total amount of miles traveled: "))
return miles
def getGas():
gas = ... |
930cd2911cb85cb7036434b242538e75a3f6e9ac | aggiewb/scc-web-dev-f19 | /ict110/enter_read_file.py | 607 | 4.125 | 4 | '''
This is a program a program that allows a user to enter data that is
written to a text file and will read the file.
Aggie Wheeler Bateman
10/17/19
'''
from tkinter.filedialog import askopenfilename
def main():
print("Hi! I am Text, and I will allow you to enter a text file, and I will read the file.")
p... |
8f345bf4f72eacf7100153b108dd1e1862f32418 | HighMileage/advents_of_code | /aoc_2020/day_01/day_01.py | 805 | 3.78125 | 4 | import csv
import itertools
import sys
def inputs(file_path):
with open(file_path, "r") as input_file:
for value in csv.reader(input_file):
yield int(value[0])
def main(file_path):
for pair in itertools.combinations(inputs(file_path), 2):
value_1, value_2 = pair
if value_... |
5fa4ae7ca1ec64c1b82b4d56ca424ac391d808de | HighMileage/advents_of_code | /aoc_2018/day_01/day_01.py | 519 | 3.703125 | 4 | import csv
def inputs():
with open('input_01.txt', 'r') as input_file:
for value in csv.reader(input_file):
yield int(value[0])
def main():
observed_states = set()
frequency = 0
while True:
for change in inputs():
observed_states.add(frequency)
fre... |
44d93bddb7c00d2cc12e9203f52083a25cf05bb8 | ryanyb/Charlotte_CS | /gettingStarted.py | 1,952 | 4.6875 | 5 |
# This is a python file! Woo! It'll introduce printing and variable declaration.
# If you open it in a text editor like VS Code it should look nifty and like
# well, a bunch of text.
# As you can see, all of this stuff is written without the computer doing anything about it
# These are things called comme... |
3c9521ccea2534b07c2b975ac310e9db272c0782 | Sangeeth-S/Python_Training | /example.py | 539 | 3.71875 | 4 | import time
sets = 0 #5
count = 0 #15
while sets < 5:
sets += 1
print('Set {}'.format(sets))
while count < 15:
count += 1
print('Count {}'.format(count))
time.sleep(0.1)
count = 0
time.sleep(2)
import time
sets = 0 #6
count = 0 #20
while sets < ... |
f2b0c174dae016629d98396c24b9c1848afea049 | andrelaraprofile/andrelararepository | /condicionais.py | 1,964 | 4.0625 | 4 | # Faça um programa que leia a validade das informações:
# a. Idade: entre 0 e 150
# b. Salário: maior que 0
# c. Sexo: M, F ou Outro
idade= int(input('Qual a sua idade?'))
if idade > 0 and idade <= 150:
print('Informação válida')
else:
idade < 0 and idade >150
print ('Informação inválida')
s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.