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 |
|---|---|---|---|---|---|---|
d346746005b6b2a5c0b25a92e63f92c0bbadfa89 | Aryamanz29/DSA-CP | /random/word_count.py | 1,116 | 4.125 | 4 | # You are given some words. Some of them may repeat. For each word, output its number of occurrences. The output order should correspond with the input order of appearance of the word. See the sample input/output for clarification.
# Note:
# All the words are composed of lowercase English letters only.
# Input Format... |
9dc6c1eb7c8e8ebfd09968165a0bffbd5859c1bd | serhey-svintsitskiy/python-learning | /stepik/2/2.5.3.py | 157 | 3.53125 | 4 | l = sorted([int(i) for i in input().split()])
r = []
for el in l:
if l.count(el) > 1 and el not in r:
r.append(el)
print(' '.join(map(str, r)))
|
7404487d424c3ef62a01a69e63d4a417fb12731c | nhl4000/project-euler | /python2/1-10/006.py | 253 | 3.828125 | 4 | def sum_of_squares(n):
sum = 0
for i in range(1,n+1):
sum += i * i
return sum
def square_of_sum(n):
sum = 0
for i in range (1,n+1):
sum += i
return sum * sum
print(square_of_sum(100) - sum_of_squares(100))
|
cb11b8f30fbd8ef801d70e36d04fe791ac7bf72c | Vishakha-Lingadahally/All-codes | /CLT_2.py | 968 | 3.703125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 28 19:06:59 2021
@author: vishakha
"""
import numpy
import matplotlib.pyplot as plt
# Number of samples
N = [1, 10, 50, 100]
# List of sample means
means = []
# Generating 1, 10, 30, 100 random numbers from -40 to 40 and taking their mean ... |
dbf47e8169e5abf74f37a52532920b78de7ff037 | utkarsh-yadav1231/Mini-Projects | /Snake Game/snake.py | 3,709 | 3.578125 | 4 | import random
class Snake(object):
def __init__(self, init_body, init_direction):
self.body = init_body
self.direction = init_direction
def head(self):
return self.body[-1]
def take_step(self, position):
self.body = self.body[1:1] + [position]
def extend_body(self, p... |
755c5c4300d0a86838bfc847420db88c1dbe2f2a | akky93/arm_using_str | /arm_str.py | 381 | 3.5 | 4 | print('num is armstrong number')
lower=100
upper=2000
for Num in range(lower,upper+1):
num=str(Num)
order=len(num)
a_num='-'.join(num)
b_num=a_num.split('-')
b_num=[int(i) for i in b_num ]
#print(b_num)
sum=0
for n in b_num:
sum=sum+n**order
if sum==i... |
1651ed726bb94722de75170e3f06d52f413f6c1f | fengye110/employ | /src/workitem.py | 523 | 3.578125 | 4 | #!/usr/bin/env python
#coding=utf-8
import sqlite3
class WorkItem(object):
def __init__(self, name):
self.name = name
self.price = 0
def look(cls, name):
if(sql_con == None):
try:
sql_con = sqlite3.connect(dbfile)
cur = sql_con.cursor()
... |
6758bb2b1d31a56d10360a078407fef12269ccc9 | rctcwyvrn/factorpy | /standard_lib.py | 405 | 3.59375 | 4 | def min(in_list):
smallest = in_list[0]
for i in in_list:
if i<smallest:
smallest = i
return smallest
def sort(in_list):
return sorted(in_list)
def append_front(in_list,elt):
return [elt] + in_list
def append(in_list,elt):
return in_list.append(elt)
def concat(l,n):
return l + n
def extract(in_list,elt... |
7d5fc4e58802b5a730845973dee9687209768951 | NateSkiles/Python | /Student Tracker App/studentTracker_func.py | 1,786 | 3.625 | 4 | import os
from tkinter import messagebox
from tkinter import *
import sqlite3
def chkQuit(self):
if messagebox.askokcancel('Quit Program', 'Would you really like to quit the application?'):
# Close app
self.master.destroy()
os._exit(0)
def centerWindow(self, w, h):
# Get user's scre... |
19b3ef33742dc50ce62b2fadafb09158e9930a4a | NateSkiles/Python | /Misc Files/argsAndKwargs.py | 227 | 3.609375 | 4 | def myFun(*args):
for arg in args:
print(arg)
myFun('This is an example of args', 'string', 'and then an integer', 5)
def myFun2(**kwargs):
print("kwargs", kwargs)
myFun2(first="1", second="2", third="3")
|
96266e56ec70ccf0728e9aa4d4f00f89059f6b44 | NateSkiles/Python | /Misc Files/moreFunctions.py | 225 | 3.859375 | 4 | def getSum(num1, num2):
answer = num1 + num2
print('The answer is {}.'.format(answer))
myAdd = getSum # Store a function in a variable
truth1 = True
truth2 = False
print("The truth is always {}.."format(truth2))
|
a936002484082db828182928fb14d66180601de9 | weruuu/Program | /Python/LambdaFunction.py | 60 | 3.53125 | 4 | print((lambda x,y:x if x>y else y)(input('x='),input('y='))) |
4429ad534c32a11c3beff52ca8302385644cc97f | weruuu/Program | /Python/test.py | 768 | 3.75 | 4 | class Project(object):
def __init__(self, pro_name, pro_begin, pro_end):
self.pro_name = pro_name
self.pro_begin = pro_begin
self.pro_end = pro_end
def a(self,pro_name, pro_begin, pro_end):
self.pro_name = pro_name
self.pro_begin = pro_begin
self.pro_end = pro_... |
c31120953791eab728c11c612046c812f9be01d8 | n1e2h4a/AllBasicProgram | /BasicPython/Username.py | 352 | 4.09375 | 4 | class Name:
def username(self, Firstname, Lastname):
Fullname = Firstname + " " + Lastname
print("My Fullname is", Fullname)
return print(f'My Reverse name is {Lastname} {Firstname}')
Firstname = input("Enter the Firstname:--")
Lastname = input("Enter the lastname:--")
Myname = Name()
Mynam... |
eba979bd967c81ba4ad6d2435ffb09b3e4f5059f | n1e2h4a/AllBasicProgram | /BasicPython/leadingzero.py | 264 | 4.21875 | 4 | mystring="python"
#print original string
print("the original string :--- "+ str(mystring))
#no of zeros want
zero=5
#using rjust()for for adding leading zero
final=mystring.rjust(zero + len(mystring), '0')
print("string after adding leading zeros : " + str(final)) |
5b34bcee34e688a92461007c6f2e5d06825faeda | n1e2h4a/AllBasicProgram | /DictionaryPrograms.py/countnumberofitemsindictionary.py | 307 | 3.640625 | 4 | def main():
grade= {'A': [1, 2, 3, 4, 5, 6, 7, 8, 9,8,4,7],
'B': 34,
'C': 12,
'D': [7, 8, 9, 6, 4]}
count=0
for x in grade:
if isinstance(grade[x], list):
count+=len(grade[x])
print(count)
#calling main
if __name__ == "__main__":
main() |
435fd488d1a513ebebcfc35354be57debca54442 | n1e2h4a/AllBasicProgram | /ListPrograms.py/MinimumInList.py | 213 | 4.125 | 4 | table = []
number = int(input("Enter number of digit you want to print:---"))
for x in range(number):
Element = int((input(' > ')))
table.append(Element)
table.sort()
print("Smallest in List:", *table[:1]) |
414d871652dc629c4703031fb423444f2375a422 | n1e2h4a/AllBasicProgram | /Junittestingprogram/MonthlyPaymentt.py | 392 | 4.09375 | 4 | import math
class payment:
def monthly(self,principle,Year,Rate):
n = 12 * Year
r = Rate/(12*100)
Payment = principle * Rate/1-(pow(1+r, -n))
print(Payment)
principle = int(input("Enter the principle:--"))
Year = int(input("Enter the number of years:--"))
Rate = int(input("Enter the... |
6238a4c630a14ab0fada0e3942dfe605c1f4b0e7 | n1e2h4a/AllBasicProgram | /StringPrograms.py/longestlength.py | 231 | 3.734375 | 4 | def longstring(listofwords):
stringholder=[]
for n in listofwords:
stringholder.append((len(n),n))
stringholder.sort()
return stringholder[-1][1]
print(longstring(["blackberry","nokia","Reliance","oppo"]))
|
1d77288d884dff231412bb510661f95c2ef912dd | n1e2h4a/AllBasicProgram | /Matplotlibprograms/MatplotlibBasics/TwoLinesDashedOrDotted.py | 525 | 3.65625 | 4 | import matplotlib.pyplot as plt
x1=[10,20,30]
y1=[20,40,10]
plt.plot(x1,y1, label = "this is line first" )
x2=[10,20,30]
y2=[40,10,30]
plt.plot(x2,y2, label = "this is line second")
plt.xlabel("I am x axis")
plt.ylabel("I am y axis")
plt.title("Two or more lines on same plot with good legend")
plt.plot(x1,y1, color ='g... |
ffdfaf003f7ac83fb95a58b9e954e360ad0f8ec9 | n1e2h4a/AllBasicProgram | /BasicPython/stringconcate.py | 512 | 3.796875 | 4 | class concate:
def stringadd(self, number, newlist):
result = " "
if number > 0:
for x in range(number):
Element = input(' > ')
newlist.append(Element)
print(newlist)
for strings in newlist:
result += str(strings)
... |
0b5a11a958be03a0a86b7ceece2d4c69e9ee2073 | tmat84/TKinter_BP | /Tkinker/BP_xml/file_management.py | 3,312 | 3.546875 | 4 | import csv
import os
from tkinter import filedialog
from tkinter import messagebox
def open_file_dialog_box():
file_path = filedialog.askopenfilename(initialdir="/",
title="Select file",
filetypes=(
... |
18b9d6e60429bcfc31d56ece3f3d1c1c79bb30d6 | abdul1380/UC6 | /learn/decorater_timer.py | 1,792 | 4.4375 | 4 | """
The following @debug decorator will print the arguments a function is
called with as well as its return value every time the function is called:
"""
import functools
import math
def debug(func):
"""Print the function signature and return value"""
@functools.wraps(func)
def wrapper_debug(*args, **kwarg... |
ed99a1daa906509145de45d36ddc3241345d15b9 | Miguel-Duke/introToPythonNotes | /week4.py | 3,868 | 4.0625 | 4 | # Week 4 of class! The topic is making decisions in python!
# Indentation is how python recognizes common blocks. Standard indent is 4 spaces.
# Troubleshooting tip: if an error highlights the very start of a line, look
# to the line above it!
# If then statements!
# != means 'not equal to'
# == means 'is equal... |
9eee53eac8cff77e6415d6c4f264e04c1bb0492a | Nekroze/partpy | /partpy/fpattern.py | 930 | 4.09375 | 4 | """Predefined function patterns for use in Matcher.match_function methods.
Defines the following:
- alphal = lower case alphabet
- alphau = upper case alphabet
- alpha = lower and upper case alphabet
- number = digits
- alnum = digits or lower and upper case alphabet
- identifier = first(alpha)... |
241db2de37e21baa66e689aff5cd369ccfac84d3 | louisamand/instant_quoting_freight_websites_australia | /Input/import_data_scraper.py | 4,329 | 3.53125 | 4 | #! /usr/local/bin/python3.7
# This first line is important to be able to use this file from another file.
from datetime import datetime, timedelta
import csv
def import_routes():
name = '../Input/routes.csv' # relative path to the routes file
with open(name, mode = 'r') as f: # open as 'read'
routes... |
0b58ea35d31e287582d24264460601a1f9d28b1a | ocket8888/pyren | /ren/decoder.py | 3,051 | 3.78125 | 4 | def scanstring(s, end, strict=True, _b=BACKSLASH, _m=STRINGCHUNK.match):
"""Scan the string s for a JSON string. End is the index of the
character in s after the quote that started the JSON string.
Unescapes all valid JSON string escape sequences and raises ValueError
on attempt to decode an invalid string. If stri... |
4e976da0e5e664d124456f816b5e9110ec2c5735 | mimota1994/qlearning_fog | /run_this.py | 2,346 | 4 | 4 | #_*_encoding:utf-8_*_#
"""
Reinforcement learning maze example.
Red rectangle: explorer.
Black rectangles: hells [reward = -1].
Yellow bin circle: paradise [reward = +1].
All other states: ground [reward = 0].
This script is the main part which controls the update method o... |
f6801dab7171c0442d2cde75febf7c331fa78e15 | s6070094/how-smoking-affects-your-life | /project1.py | 1,054 | 3.765625 | 4 | # -*- coding: utf-8 -*-
from Tkinter import *
root = Tk() #หน้าจอหลักโปรแกรม
root.geometry('780x580+280+70')
root.title("How Smoking Affects Your Life")
root.configure(bg='light green')
label1 = Label(root, text="ยินดีต้อนรับเข้าสู่แอพ",fg='blue',bg = 'light blue')
label1.grid(row=0,column=0)
def start(): #หน้าที่2 -->... |
36ed859392c6243ab2f4a1ee26a5b5b97a71de24 | nitvishn/crypto | /brutus.py | 341 | 4.03125 | 4 | ciphertext = input("Ciphertext: ")
for k in range(26):
plaintext = ""
for char in ciphertext:
if not char.isalpha():
plaintext += char
continue
outchar = ord(char.lower()) - 97
outchar += k
outchar %= 26
plaintext += chr(outchar + 97)
print(... |
059c1bc5b74260b86185399babb7608c6b8195f4 | LongXieZju/leetcode | /array/17_practice.py | 759 | 3.5 | 4 | from collections import deque
class Solution(object):
def letterCombinations(self, digits):
"""
:type digits: str
:rtype: List[str]
"""
queue = deque([])
dic = {'2':'abc', '3':'def', '4':'ghi', '5':'jkl', '6':'mno', '7':'pqrs', '8':'tuv', '9':'wxyz'}
for i in... |
b00a279f932aaa6c0a1b418ce5ab08cb4fd2de6b | patrickqrim/CSUF-Optimized-C4.5 | /attribute_selection_methods.py | 3,267 | 3.5 | 4 | import csv
import math
import continuous_attribute_split as cas
from pprint import pprint
'''
Module that imports data and contains attribute selection methods.
Variables
-------
class_attribute : string
attribute used for ultimate classification of the data
data : list of dictionaries
data imported from file ... |
4e13d9256de4d0058b4eb268b602faae99087d67 | leomauro/langscape | /trail/nfamaps.py | 5,912 | 3.59375 | 4 | __all__ = ["create_nfa_skeleton", "create_sk_map", "nfa_comp"]
def create_nfa_skeleton(nfa):
'''
An nfa-skeleton abstracts away concrete state information but preserves the
relations between states ( follow sets ). Each state will be reduced to an integer
number normalized to the range [-1, 0, ..... |
8cdddf76b82e2a24c8e8540220b56ed8a59486d0 | antoniocaruso/corso_python | /ilprofessore/orbita2.py | 1,933 | 3.671875 | 4 | import sys
import numpy as np
import matplotlib.pyplot as plt
def main(dt: float):
"""
Risolve il calcolo dell'orbita di un pianeta sotto l'influenza di una forza centrale
gravitazione. (Sole - Pianeta). Si usa solo Python standard.
Il modello molto semplice:
$a = -1/|r|^2 * r/|r|$. nota che (-r... |
b09065b7cc902b2ee88848f3246540048a8977de | pvshreesh/Information-retrieval | /ir2/minimumHashing.py | 2,158 | 3.71875 | 4 | from nltk.tokenize import word_tokenize
from nltk import PorterStemmer
import string
import re
import random
import numpy as np
import time
# shuffle is used to generate a random shuffling of
# an array of elements 0 to size-1.
# input : int size which is the number of shingles
# return : a numpy array in of ... |
3b863f80f987ee3407a0f63085c6b1fcef802f37 | diakovidis/crypto-pms | /09/09.py | 1,296 | 3.734375 | 4 | #!/usr/bin/env python
# coding: utf-8
# -*- coding: utf-8 -*-
def fast_pow(C, d):
text = []
for i in C:
result = 1
dd = d
while dd > 0:
result = (result * i) % N
dd -= 1
text.append(result % N)
return ''.join(map(chr, text))
def find_factors(N):
... |
347158d8ad3bb62caa938b9b5b0e831d6d65fd89 | loristron/PythonExercisesLearnPython | /4 - Listas/5.py | 591 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 30 13:43:55 2020
@author: loris
Faça um Programa que leia 20 números inteiros e armazene-os num vetor.
Armazene os números pares no vetor PAR e os números IMPARES no vetor impar.
Imprima os três vetores.
"""
valores = []
pares = []
impares = []
for n in range(0,10)... |
199df6e816da405a379838095853015e532e2a28 | loristron/PythonExercisesLearnPython | /4 - Listas/8.py | 580 | 3.796875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 30 15:55:07 2020
@author: loris
Faça um Programa que peça a idade e a altura de 5 pessoas, armazene cada informação no seu respectivo vetor.
Imprima a idade e a altura na ordem inversa a ordem lida.
"""
idades = []
alturas = []
print("Idade e altura")
for n in range(... |
85aa96390e7b487225314f9d1de21ef7a9ba6b74 | loristron/PythonExercisesLearnPython | /4 - Listas/12.py | 718 | 3.71875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 30 16:49:48 2020
@author: loris
Foram anotadas as idades e alturas de 30 alunos.
Faça um Programa que determine quantos alunos com mais de 13 anos possuem altura
inferior à média de altura desses alunos.
"""
import random
import statistics as stc
alturasRand = rand... |
1c4d0aaef734a7b4e2aed901ea86608b281b02c0 | loristron/PythonExercisesLearnPython | /3 - Estrutura de Repetição/19.py | 673 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jun 25 15:23:17 2020
@author: loris
Altere o programa anterior para que ele aceite apenas números entre 0 e 1000.
"""
listando = True
lista = []
while listando == True:
entrada = input("Insira um conjunto de numeros. Digite c para calcular: ")
if entrada == 'c' o... |
91eb1dafdda0914b43af203200bc89483f581850 | loristron/PythonExercisesLearnPython | /3 - Estrutura de Repetição/12nv.py | 533 | 3.953125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jun 25 13:18:41 2020
@author: loris
Desenvolva um gerador de tabuada, capaz de gerar a tabuada de qualquer número inteiro entre 1 a 10.
O usuário deve informar de qual numero ele deseja ver a tabuada.
A saída deve ser conforme o exemplo abaixo:
Tabuada de 5:
5 X 1 = 5
5 X... |
308edceb55924c90001feaa2fc12ce8714121793 | loristron/PythonExercisesLearnPython | /4 - Listas/11.py | 422 | 3.875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 30 16:48:37 2020
@author: loris
Altere o programa anterior, intercalando 3 vetores de 10 elementos cada.
"""
a = [1,1,1,1,1,1,1,1,1,1]
b = [0,0,0,0,0,0,0,0,0,0]
c = ['a', 'a', 'a', 'a', 'a','a','a','a','a','a']
mescla = []
for n in range(0, 10):
mescla.append(a... |
46f78b55f3ab11bf893e32606c3a567141ec1821 | loristron/PythonExercisesLearnPython | /4 - Listas/15.py | 1,970 | 3.90625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 30 18:52:40 2020
@author: loris
Faça um programa que leia um número indeterminado de valores, correspondentes a notas, encerrando a entrada
de dados quando for informado um valor igual a -1 (que não deve ser armazenado).
Após esta entrada de dados, faça:
a) Mostre... |
f6847dc2b7c3b36f9515918868e77070813dc491 | loristron/PythonExercisesLearnPython | /3 - Estrutura de Repetição/17.py | 394 | 3.875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jun 25 15:10:10 2020
@author: loris
Faça um programa que calcule o fatorial de um número inteiro fornecido pelo usuário.
Ex.: 5!=5.4.3.2.1=120
"""
print("Cálculo de Fatorial")
entrada = int(input("Insira o numero a ser calculado: "))
fatorial = 1
for n in range(1, entrada... |
81b311d82029da8a91463681020a9434c47e5565 | loristron/PythonExercisesLearnPython | /3 - Estrutura de Repetição/6.py | 425 | 3.9375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Jun 24 23:19:35 2020
@author: loris
Faça um programa que imprima na tela os números de 1 a 20, um abaixo do outro.
Depois modifique o programa para que ele mostre os números um ao lado do outro.
"""
print("Um abaixo do outro: ")
for n in range(0,11):
print(n)
... |
03130ffb7302f2d2f3c97ba40cc6875bd6e5acc9 | loristron/PythonExercisesLearnPython | /1 - Estrutura Sequencial/14.py | 1,184 | 4 | 4 | #Faça um Programa que pergunte quanto você ganha por hora e o número de horas trabalhadas no mês.
#Calcule e mostre o total do seu salário no referido mês, sabendo-se que são descontados
#11% para o Imposto de Renda,
#8% para o INSS e
#5% para o sindicato
#Faça um programa que nos dê:
##salário bruto.
##quanto pa... |
d033f3316ac1b4de1b35c906d3f2a70918301767 | loristron/PythonExercisesLearnPython | /2 - Estrutura de Decisão/23.py | 661 | 4.0625 | 4 | #Faça um Programa que leia 2 números e em seguida pergunte ao usuário qual operação ele deseja realizar.
#O resultado da operação deve ser acompanhado de uma frase que diga se o número é:
#par ou ímpar;
#positivo ou negativo;
#inteiro ou decimal.
print("CALCULO SIMPLES")
valor = input("Insira a operação desejada, sepa... |
3aad1301ef5871aa1466ee073c6d9ae77a5edb34 | loristron/PythonExercisesLearnPython | /3 - Estrutura de Repetição/30.py | 1,712 | 3.84375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jun 25 17:48:22 2020
@author: loris
O Sr. Manoel Joaquim expandiu seus negócios para além dos negócios de 1,99 e agora possui uma
loja de conveniências. Faça um programa que implemente uma caixa registradora rudimentar.
O programa deverá receber um número desconhecido de v... |
acc1cc23773190ff08d3d2fcac874bb67b2ac0b9 | AO-StreetArt/AOWorkflowDeveloper | /Application/src/dbadmin/Translator.py | 9,166 | 3.515625 | 4 | from openpyxl import Workbook
from openpyxl import load_workbook
import csv
import sqlite3 as lite
from DataBuffer import DataBuffer
#Translator classes accept an external file as an output and
#creates data buffers to be processed in batches & writes the
#buffers to queues on the data stream
class Translator():
... |
6632b7a3ced8e9850550af6b2c133ce628848bde | rakkar16/WISB256 | /Opdracht4/bisection.py | 890 | 3.71875 | 4 | def findRoot(f,a,b,epsilon):
m = (a + b)/2
if abs(b - a) <= epsilon or f(m) == 0:
return m
elif f(a) == 0:
return a
elif f(b) == 0:
return b
elif f(b) > 0:
if f(m) > 0:
return findRoot(f,a,m,epsilon)
else:
return findRoot(f,m,b,epsilon)... |
6bf08ab887f1c472289aeb282ec76f3d0762f98b | GovindSuresh/AoC-2020 | /day_5/day_5.py | 2,074 | 3.65625 | 4 |
with open('day_5_data.txt') as f:
row_list = []
col_list = []
# Read in row
for line in f:
line = line.rstrip()
row = 127
low = 0
high = 127
# First 6 values specify the columns
for i in range(0,7):
# When hitting an F, we re... |
0e4c81e47aca9dd6a10f55708e2eb6bdd829525b | jessicalkavanagh/python-practice | /ex5.py | 119 | 3.65625 | 4 | print ('Type Hayley is awesome')
y = input()
if y =='Hayley is awesome':
print ('true')
else:
print ('false') |
1c8e490941bc9d7fea8d1ac9ab14c5bb5883f493 | elenarangelova/Phyton-course-in-Softuni | /Turtle-hw/turtle_5.py | 176 | 3.671875 | 4 | import turtle
g = 134
l = 120
range_number = int(input('Input number of iterations '))
for i in range (1,range_number):
turtle.left(g)
turtle.forward(l)
turtle.done()
|
19013dfc0eb0d7bb4364d22bc47c1fd72c95fc08 | djzwns/single-bungle-hwagok-imageprocessing | /practice code/Quiz01-06.py | 2,314 | 3.5625 | 4 | # 2차원 배열 처리
# 랜덤하게 x, y 크기의 배열 준비 (3~9) 사이
# 랜덤하게 값을 채움 0~255
# 이미지를 반전 처리
# 이미지가 너무 밝아서 100 어둡게
# grayscale 이미지를 흑백 영상으로 바꾸자
# 127 기준으로 흑, 백 구분하기
# 평균 값을 기준 흑, 백 구분
# 이미지 상하 반전 좌우 반전
import random
import copy
# function
def print_image(string: str, array: []):
print(string)
global y
for i in range(y):
... |
db12caf51b3dd0c9b35788c3eda224101cfe8dca | djzwns/single-bungle-hwagok-imageprocessing | /practice code/Code01-03 함수.py | 488 | 3.78125 | 4 | # function
def add_number(n1: int, n2: int) -> int:
retValue1 = 0
retValue2 = 1
retValue1 = n1 + n2
retValue2 = n1 * n2
return retValue1, retValue2 # (retValue1, retValue2)
def mul_number(n1: int, n2: int) -> int:
return n1 * n2
def func1():
# num = 1 # local var
global num
num ... |
35fc73fe97937e9bce0d2654438eb7ba98c442e2 | djzwns/single-bungle-hwagok-imageprocessing | /practice code/Quiz01-02.py | 335 | 4 | 4 | # 변수 선언
score, grade = 0, ''
# 메인
if __name__ == "__main__":
score = int(input("성적 입력: "))
if score >= 90:
grade = "A"
elif score >= 80:
grade = "B"
elif score >= 70:
grade = "C"
elif score >= 60:
grade = "D"
else:
grade = "F"
print(grade)
|
bdd839d088ae82861bed31b7ede748e276d73784 | MartinPoupa/ZakladyAlgoritmizace | /lekce14/kruhy_nad_sebou.py | 1,692 | 3.5625 | 4 | from PIL import Image, ImageDraw
import random
IMAGE_DIMENSIONS = 1000
MIN_RADIUS = 50
MAX_RADIUS = 200
CIRCUIT_COLOR_1 = "red"
CIRCUIT_COLOR_2 = "blue"
radius1 = random.randint(MIN_RADIUS, MAX_RADIUS)
radius2 = random.randint(MIN_RADIUS, MAX_RADIUS)
print(radius1)
print(radius2)
img = Image.new('RGB', (IMAGE_... |
25b6ef5d48110228a43c44e28322a973b6ef29d8 | duytinvo/comp4111 | /lecture4/patient_info.py | 570 | 3.625 | 4 | class PatientInfo:
course = "CDS@LU"
def __init__(self, **patient):
self.name = patient.pop("name", None)
self.age = patient.pop("age", None)
self.country = patient.pop("country", None)
self.gender = patient.pop("gender", None)
def print_info(self):
print("-" * 40)
... |
d4cbd946ea754ed8bddb1f487f6a4250c4e3a96b | dengxinjuan/springboard | /python-syntax/words.py | 319 | 4.15625 | 4 | def print_upper_words(words,must_start_with):
for word in words:
for any in must_start_with:
if word.startswith(any):
result = word.upper()
print(result)
print_upper_words(["hello", "hey", "goodbye", "yo", "yes"],
must_start_with={"h", "y"}) |
7e704878f33eb669e31c6a93a8368478cced3a8c | winarcooo/my-hackerrank | /algorithm/repeated_string/solution.py | 338 | 3.953125 | 4 | #!/bin/python3
import math
def isRepeated(string, num):
string_length = len(string)
counter = int((string_length * math.ceil(num/string_length))/string_length)
repeated_string = string * counter
return repeated_string[:n].count('a')
if __name__ == '__main__':
s = 'aba'
n = 10
result = isRepeated(s, ... |
8f7b45bea55fb2a16836346817579151d7d36c94 | jtallar/sokoban-solver | /mapTraverse.py | 9,550 | 3.53125 | 4 | import enum
import objects as obj
import heapq as hq
# Possible elements in space
# Eg: for el in (Element):
# print(el.name + ' ' + el.value)
class Element(enum.Enum):
Box = "\U0001F5C2 "
BoxInGoal = "\U0001F5C3 "
Goal = "\U0001F3C1"
Wall = "\U0001F9F1"
Player = "\U0001F920"
Player... |
4256395463831658a3f55bb55409e5d61bea869f | deepbuzin/explore | /beard_classifier/median.py | 957 | 3.640625 | 4 | def minimumDays(rows, columns, grid):
import queue
q = queue.Queue()
days = [[-1 for _ in range(columns)] for _ in range(rows)]
for i in range(rows):
for j in range(columns):
if grid[i][j] == 1:
days[i][j] = 0
q.put((i, j, 0))
while not q.empty():
... |
cf48baa04464fdf26d7f3ba948d7abdb7c06b32d | Ranveer-eng/HackerRankSolutions | /Breaking_Records.py | 482 | 3.515625 | 4 |
n = int(input())
scores = [int(x) for x in input().split(" ",n)]
highest = []
lowest = []
def breakingRecords(scores):
highest.append(scores[0])
lowest.append(scores[0])
for x in scores:
if (x not in highest) and (x > highest[-1]):
highest.append(x)
if (x not in l... |
5e26fa7180ec61b226b2824f4c3d4120df770254 | ptsiampas/Exercises_Learning_Python3 | /18_Recursion/Exercise_18.7.2a.py | 1,089 | 4.375 | 4 | import turtle
from math import cos, sin
def cesaro_fractal(turtle, order, size):
"""
(a) Draw a Casaro torn line fractal, of the order given by the user.
We show four different lines of order 0, 1, 2, 3. In this example, the angle of the
tear is 10 degrees.
:return:
"""
if order == 0: # T... |
712a129202333470151c53d20af112057b41d9f6 | ptsiampas/Exercises_Learning_Python3 | /15._Classes and Objects_Basics/Exercise_15.12.4.py | 1,970 | 4.375 | 4 | # 4. The equation of a straight line is “y = ax + b”, (or perhaps “y = mx + c”). The coefficients
# a and b completely describe the line. Write a method in the Point class so that if a point
# instance is given another point, it will compute the equation of the straight line joining
# the two points. It must return the... |
b10e4275bac85b19fbd094a6e205386b6f73f169 | ptsiampas/Exercises_Learning_Python3 | /07_Iteration/Exercise_7.26.16.py | 1,062 | 4.125 | 4 | # Write a function sum_of_squares(xs) that computes the sum of the squares of the numbers in the list xs.
# For example, sum_of_squares([2, 3, 4]) should return 4+9+16 which is 29:
#
# test(sum_of_squares([2, 3, 4]), 29)
# test(sum_of_squares([ ]), 0)
# test(sum_of_squares([2, -3, 4]), 29)
import sys
def test(actual,... |
ad104e36e782364406c66006947e838a5ec2ab4d | ptsiampas/Exercises_Learning_Python3 | /05_Conditionals/Exercise_5.14.11.py | 710 | 4.25 | 4 | #
# Write a function is_rightangled which, given the length of three sides of a triangle, will determine whether the
# triangle is right-angled. Assume that the third argument to the function is always the longest side. It will return
# True if the triangle is right-angled, or False otherwise.
#
__author__ = 'petert'
... |
21805be45126167dcb2657357179aa4192d53ec5 | ptsiampas/Exercises_Learning_Python3 | /04_Functions/exercise_4.9.5b.py | 521 | 3.984375 | 4 | import turtle
def draw_line(t, w):
"""
:param t: turtle object to move
:param w: width of line
"""
for i in range(2):
t.forward(w)
t.left(90)
turtle.setup(600,400) # Set the size of the window to 600x400
wn = turtle.Screen() # Set up the window and its attributes
wn... |
087cad1c17766f45940c7e98e789862465ba2934 | ptsiampas/Exercises_Learning_Python3 | /18_Recursion/Exercise_18.7.3.py | 1,236 | 4.4375 | 4 | from turtle import *
def Triangle(t, length):
for angle in [120, 120, 120]:
t.forward(length)
t.left(angle)
def sierpinski_triangle(turtle, order, length):
"""
3. A Sierpinski triangle of order 0 is an equilateral triangle. An order 1 triangle can be drawn by drawing 3
smaller triang... |
10db27f782bbe16040e2c41a187bcea9ec72a485 | ptsiampas/Exercises_Learning_Python3 | /06_Fruitful_functions/Exercises_6.9.13.py | 2,976 | 3.75 | 4 | # Write a function slope(x1, y1, x2, y2) that returns the slope of the line through the points (x1, y1) and (x2, y2).
# Be sure your implementation of slope can pass the following tests:
#
# test(slope(5, 3, 4, 2), 1.0)
# test(slope(1, 2, 3, 2), 0.0)
# test(slope(1, 2, 3, 3), 0.5)
# test(slope(2, 4, 1, 2), 2.0)
#
# The... |
4316d20578612a8c709ffd6becd19e60cbd5140c | ptsiampas/Exercises_Learning_Python3 | /14_List Algorithms/Exercise_14.11.1e.py | 1,463 | 4.09375 | 4 | # e. Return items from the first list that are not eliminated by a matching element in the second list. In this case,
# an item in the second list “knocks out” just one matching item in the first list. This operation is sometimes
# called bagdiff. For example bagdiff([5,7,11,11,11,12,13], [7,8,11]) would return [... |
a83f997f0440c05059a73922cbbcc78e66ee8740 | ptsiampas/Exercises_Learning_Python3 | /05_Conditionals/Exercise_5.14.12.py | 1,105 | 3.828125 | 4 | #
# Extend the above program from Ex. 5.14.11 so that the sides can be given to the function in any order.
#
__author__ = 'petert'
def find_hypot(c1,c2):
hpot=((c1**2)+(c2**2))**0.5
return hpot
def is_rightangled(side_1, side_2, side_3):
if side_1 > side_2: # FixMe I couldn't work this out mysel... |
fa87af0a96105b9589fad9a32955db349089d5cd | ptsiampas/Exercises_Learning_Python3 | /18_Recursion/Exercise_18.7.10.py | 1,506 | 4.21875 | 4 | # Write a program that walks a directory structure (as in the last section of this chapter), but instead of printing
# filenames, it returns a list of all the full paths of files in the directory or the subdirectories.
# (Don’t include directories in this list — just files.) For example, the output list might have elem... |
3de631c83b785cac3822aaaf26d06e85a32ce736 | ptsiampas/Exercises_Learning_Python3 | /21_Even_more_OOP/Examples_Point21.py | 2,367 | 4.5625 | 5 | class Point:
""" Point class represents and manipulates x,y coords. """
def __init__(self, x=0, y=0):
""" Create a new point at the origin """
self.x = x
self.y = y
def __str__(self): # All we have done is renamed the method
return "({0}, {1})".format(self.x, self.y)
... |
bd0710946326a0e297b20c165927891630d05dc9 | ptsiampas/Exercises_Learning_Python3 | /14_List Algorithms/list_functions.py | 2,415 | 3.765625 | 4 | def search_linear(xs, target):
""" Find and return the index of target in sequence xs - Linear Search Algorithm"""
for (i, v) in enumerate(xs):
if v == target: # Is referred to as a probe.
return i
return -1
def find_unknown_words(vocab, wds):
""" Return a list of words in ... |
13d86401e3d6e2e4bb454f872282d1cdb7904ca4 | ptsiampas/Exercises_Learning_Python3 | /20_Dictionaries/alice_words.py | 1,391 | 4.09375 | 4 | import string
def remove_punct(s):
s_without_punct = ""
s = s.replace("--", " ")
s = s.replace("-", " ")
for letter in s:
if letter not in string.punctuation:
s_without_punct += letter
return s_without_punct
def print_result(word_count):
final_word_count = list(word_count... |
dbdf7c1059cffe23b0d8c47348e25e0c9347ed7e | ptsiampas/Exercises_Learning_Python3 | /01_03_Introduction/play_scr.py | 615 | 4.15625 | 4 | import turtle # Allows us to use turtles
wn = turtle.Screen() # Creates a playground for turtles
wn.bgcolor("lightgreen") # Sets window background colour
wn.title("Hey its me") # Sets title
alex = turtle.Turtle() # Create a turtle, assign to alex
alex.color("blue") # pen colour blue
ale... |
68837a85328c5d41650ba21a3c14592ad418d426 | ptsiampas/Exercises_Learning_Python3 | /10_Event_Driven_Programming/Exercise_10.6.1.py | 3,369 | 4.1875 | 4 | # 1. Add some new key bindings to the first sample program:
#
# - Pressing keys R, G or B should change tess’ color to Red, Green or Blue.
# - Pressing keys + or - should increase or decrease the width of tess’ pen. Ensure that the pen size stays
# between 1 and 20 (inclusive).
# - Handle some other keys to chang... |
6c151bbd8c7b00728fc6288bce8cec511d839050 | ptsiampas/Exercises_Learning_Python3 | /06_Fruitful_functions/Exercises_6.9.14-15.py | 1,449 | 4.53125 | 5 | # 14. Write a function called is_even(n) that takes an integer as an argument and returns True if the argument is
# an even number and False if it is odd.
import sys
def test(actual, expected):
""" Compare the actual to the expected value,
and print a suitable message.
"""
linenum = sys._getframe(1... |
ccb17aee74b2d157f599ab9f5865438ae24f4edb | ptsiampas/Exercises_Learning_Python3 | /11_Lists/Exercise_11.22.10.py | 1,070 | 3.5625 | 4 | import sys
def test(actual, expected):
""" Compare the actual to the expected value,
and print a suitable message.
"""
linenum = sys._getframe(1).f_lineno # Get the caller's line number.
if (expected == actual):
msg = "Test on line {0} passed.".format(linenum)
else:
msg = ... |
23ba56631c68d5b1a079e534efa3c95a6bd74f48 | ptsiampas/Exercises_Learning_Python3 | /11_Lists/11.16_double_example.py | 619 | 4.0625 | 4 | import math
def is_factor(f, n):
if (n % f) == 0:
return True
return False
def is_prime(nu):
# we only need to check up to the square root of the number,
# since after that we are just checking the same in reverse
max_check = math.ceil(math.sqrt(nu))
for num in range(2, max_check):
... |
728104e06034ab692ced9e769d2c67459ad43bd0 | misterjaaay/python_school-work | /e_zarechenskiy_kz1_4.py | 258 | 3.59375 | 4 | #!/usr/bin/python
# coding: utf-8
var_string = 'wowhatamanwowowowpalehche'
index = 1
count = 0
template = 'wow'
while index != -1:
index = var_string.find(template)
if index >= 0:
count += 1
var_string = var_string[index+1:]
print count
|
14b5b48ba23cb1dc70bfea3cf44f2d894d0bcde8 | someone7140/python | /finance_api/finance_analytics/domain/market.py | 670 | 3.65625 | 4 | class Market:
__market_dict = {'prime': 'プライム', 'standard': 'スタンダード', 'growth': 'グロース'}
def __init__(self, market_code, market_name):
self.code = market_code
self.name = market_name
@classmethod
def make_market_from_name(cls, market_name):
market_code = cls.__get_code_from_name... |
8527f77cf733feb93fd84876c8fbcd1d5220cf9a | yesjonbrown/Kaggle_titanic | /Titanic analysis.py | 1,887 | 3.796875 | 4 |
# coding: utf-8
# In[39]:
import pandas as pd
import numpy as np
import matplotlib as plt
#read in our Titanic data set using pandas
df = pd.read_csv("Desktop/My Kaggle Folder/Titanic/train.csv")
#df.head(15) #prints out first 10 rows
#df.describe() #prints out stats from numerical fields
#df["Age"].median(... |
a3c6ca440bc4b0be216159b71b92693b4e213273 | dineshkumar111/Python | /try&except&finally.py | 371 | 3.859375 | 4 |
a = 5
b = p
K=int(input('Enter the number'))
print(K)
try:
print('Resource open')
print(a/b)
except ZeroDivisionError as w:
print("hey we can't divide the number by 0")
except ValueError as e:
print('Invalid Input')
except Exception:
print('Something else')
finally... |
3001cb54213d954fa80e482fd84e51f8ffea3f26 | dineshkumar111/Python | /select sort.py | 288 | 3.8125 | 4 |
def sort(nums):
n=len(nums)
for i in range(n-1):
minpos=i
for j in range(i,n):
if nums[j]<nums[minpos]:
minpos=j
nums[i],nums[minpos] = nums[minpos],nums[i]
nums = [5,3,6,8,4,2,1]
sort(nums)
print(nums) |
b03e11e9d846394bdfad31f0e08fdeb7bcecfbaa | dineshkumar111/Python | /binary search.py | 441 | 3.5625 | 4 |
pos=-1
def search(nums,n):
l=0
u=len(nums)-1
while l<=u:
mid =(l+u) // 2
if nums[mid]==n:
globals()['pos']=mid
return True
else:
if nums[mid]<n:
l=mid
else:
u=mid
... |
6f91a02f62ac5acf729fd91ebde16c8e3f253308 | dineshkumar111/Python | /prime.py | 140 | 3.8125 | 4 |
num = 10
for i in range(2,num):
if i % num == 0 :
print('prime')
break
else :
print('not prime')
|
856bd4ab8a8978121b23c37ea50f8c707e174df8 | Deepthi13Ballu/IP-Address-Validation | /code.py | 422 | 3.609375 | 4 | import re n=int(input())
for i in range(n):
string=input()
regex_string1="^(25[0-5].|2[0-4][0-9].|[01]?[0-9]?[0-9].){1,3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])$"
regex_string2="^(?:[a-f0-9]{1,4}:){7}[a-f0-9]{1,4}$"
res1=bool(re.search(regex_string1,string))
res2=bool(re.search(regex_string2,string))
if... |
b80c8d81c20c73a8091347d2334869294f3090bc | KeskiDev/what-other-words | /window.py | 1,053 | 3.953125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import tkinter as tk
from tkinter import Label, Place, messagebox
window = tk.Tk()
window.title('My Window')
window.geometry('500x500')
fetch_type = tk.StringVar()
# l = tk.Label(window, bg='white', width=20, text='empty')
# l.pack()
# def print_selection():
# l.co... |
9eb58d3e6f11e818870d69fca173aeb7654317a2 | sobinrajan1999/258213_dailyCommit | /Unsolved_question_solutions/nested_dict.py | 127 | 3.75 | 4 | list_1 = [1,2,3,4,5,6,7,8,9,0]
dict_1 = current = {}
for i in list_1:
current[i]={}
current = current[i]
print(dict_1) |
2217a5fe8973d2d5a8d900f1c5ddc9b2b07f5689 | sobinrajan1999/258213_dailyCommit | /print.py | 518 | 4.28125 | 4 | print("hello world")
print(1+2+3)
print(1+3-4)
# Python also carries out multiplication and division,
# using an asterisk * to indicate multiplication and
# a forward slash / to indicate division.
print(2+(3*4))
# This will give you float value
print(10/4)
print(2*0.75)
print(3.4*5)
# if you do not want float value the... |
1070c5bdee1b2de5c9aa9bcc32dd5a8bc4b9a7cb | sobinrajan1999/258213_dailyCommit | /Unsolved_question_solutions/max_min.py | 571 | 3.921875 | 4 | print("1. Using inbuild function: ")
set_1 = {23,456,567,234,45,679,234,3456,78,234,346,457,12,43456,124,2353,46,234,234}
print("maximum value is: {}\nminimum value is : {}".format(max(set_1),min(set_1)))
print("\n2. Using sort function: ")
result = sorted(set_1)
print("maximum value is: {}\nminimum value is : {}".for... |
4b21a140adcc8a804ad8c53783220541102a5a7d | ajilraju/python-practical-zone | /archives/Basic-Part-1/source-code/qn_18.py | 309 | 3.796875 | 4 | """"
Question is here
Write a Python program to count the number 4 in a given list.
""""
def count_num_4(list):
count = 0
for ele in list:
if ele == 4:
count = count + 1
return count
print(count_num_4([3, 4, 54, 6, 1, 5, 5,]))
print(count_num_4([3, 4, 54, 6, 4, 5, 4,]))
|
88134e9e4b4e3651eefd65c07a6c375e43f96031 | ajilraju/python-practical-zone | /archives/Basic-Part-1/source-code/qn_4.py | 137 | 4.3125 | 4 | #!/usr/bin/env python3
from math import pi as PI
radius = float(input("radius : "))
area = PI * radius * radius
print("Area = ", area)
|
264ec96c9a316950f2433a5391ffbde476cc5772 | Christopher-Wang/NSERCUSRA2018 | /Inital_Scripts/Keras_LSTM_Tutorial.py | 1,690 | 3.828125 | 4 | #Tutorial taken from https://machinelearningmastery.com/sequence-classification-lstm-recurrent-neural-networks-python-keras/
#Import necessary files
import numpy as np
from keras.datasets import imdb
from keras.models import Sequential
from keras.layers import Dense, LSTM, Dropout, Convolution1D, MaxPooling1D
#Embeddin... |
4555ccee8898150f719ab5e69fafd47238647796 | Ilso/hash_tables | /HashTable.py | 2,013 | 3.84375 | 4 | class Hash:
def __init__(self, tamanho):
self.tabela = {}
self.tamanho_maximo = tamanho
#Função Hash
def funcao_hash(self, chave):
v = int(chave)
return v%self.tamanho_maximo
#Função para verificar se tabela está cheia
def tabela_cheia(self):
ret... |
dee8bc405b8b98b181be5d1ec3dbee272d749ee1 | El-fish/Sirius_python | /4 Условия/FourthStar.py | 161 | 3.609375 | 4 | N = int(input())
M = int(input())
x = int(input())
y = int(input())
if M > N:
print(min(x, y, N - x, M - y))
elif N > M:
print(min(x, y, N - y, M - x))
|
be3b124b41e362ff4e6bf558b41a5ae0eaca66b9 | El-fish/Sirius_python | /5 Циклы/Цикл for/2.py | 152 | 3.765625 | 4 | A = int(input())
B = int(input())
if A > B:
for V in range (A, B - 1, -1):
print(V)
else:
for G in range (A, B + 1, 1):
print(G) |
09fc2262af96e7bd4367401eef75ec62e00f55e5 | Guiliang/sport-analytic-variational-embedding | /support/config_tools.py | 305 | 3.75 | 4 | class InitWithDict(object):
"""
Base class which can be initialized by reading properties from dict
"""
def __init__(self, init=None):
"""
:param init:
"""
if init:
for key, value in init.iteritems():
setattr(self, key, value) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.