blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
c8e6ec74ebe6821c2723eb2d928307d25a6e4f51 | MichalMianowski/python-workouts | /Credit_card/credit_card.py | 1,272 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Mar 23 13:04:14 2019
@author: MM
Program finds the smallest monthly payment to the cent such that we can pay off
the debt (from credit card) within a year.
balance - the outstanding balance on the credit card
annualInterestRate - annual interest rate as a de... |
9e2b9eb7c954abff284c955b9e17164ac5e5aa42 | shivamkalra111/Tkinter-GUI | /Radio.py | 1,027 | 3.703125 | 4 | from tkinter import *
from PIL import ImageTk, ImageTk
root = Tk()
root.title('Learn GUI')
root.iconbitmap('C:\\Users\\ealihks\\Desktop\\My Own Work\\GUI Application\\Tkinter\\icon.ico')
#r = IntVar()
#r.set('2')
toppings = [
("Pepperoni", "Pepperoni"),
("Cheeze", "Cheeze"),
("Mushroom", "Mu... |
bfdc04cc351afa2e477ca89515390d46d4efdd2c | ayadirihem/calculator_terminal | /Calculator.py | 464 | 3.828125 | 4 | import re
def calcul():
while True:
print(" Hello human how can we help you today !!")
num = input(">> ")
fonct = re.sub('[a-z,A-Z,;#!():$§£&]', '', num)
s = eval(fonct)
print("=> Resultat:", s)
print("----Do you want to calculate another thing ? Y/N")
resp ... |
f1420207de3e14acf638ca560d2ed4c69a7506a1 | Essilia/PyTest | /Test/prctice.py | 612 | 3.6875 | 4 | # name=["一一","二二","三三"]
# socre=["99","100","98"]
# num=0
# name1=input("请输入姓名:")
# for i in range(3):
# if i == num and name1 == name[num]:
# print(name1+"的成绩是:"+socre[num])
# num=num+1
# d = {"一一":"99","二二":"100","三三":"98"}
# name2 = input("请输入姓名:")
# # if name2 in d:
# # print(d[name2])
# # else... |
4ac0d689929e0f861789903d3da67beaac2073aa | anahiquintero99/Ejercicios-de-python | /ejercicio8.py | 303 | 3.890625 | 4 | def degrees():
degreesc = int(input('Ingresa grados celsious: '))
degreesf = (degreesc * (9/5) ) + 32
degreesc = (degreesf - 32 ) * (5/9)
print(f' {degreesf} farenheit = {degreesc} celsious')
if __name__ == "__main__":
print('Convierte grados celsious a fahrenheit')
degrees()
|
36dfd1f58d19e168b957a2224e959f491629dc11 | UWPCE-PythonCert-ClassRepos/Wi2018-Online | /students/marc_charbo/lesson09/mailroom_v5_oo.py | 3,072 | 3.890625 | 4 | import donor as Donor
import donors_data as DonorData
DONOR_LIST = {'Jim':[25.00, 150.00, 2000.00, 100000.00],'Linda':[10000.25],'Bob':[5.03, 100.01, 6.00]}
def initial_donor_set():
return [Donor.Donor('Jim', [25.00, 150.00, 2000.00, 100000.00]), Donor.Donor('Linda', [10000.25]),
Donor.Donor('Bob', [5... |
571fb2b78bf6319fbb3916ce7ce33cca1747ac86 | zarkoblagojevic00/games_sales_analysis | /games_sales_analysis/src/classifiers/logistic_regression.py | 3,019 | 3.9375 | 4 | import numpy as np
import matplotlib.pyplot as plt
class LogisticRegression:
def __init__(self, learning_rate=0.1, epochs=100, threshold=0.5):
self.learning_rate = learning_rate
self.epochs = epochs
self.threshold = threshold
self.coefficients = [] # column_vector
def fit(se... |
d853c7b7db065295b7b39bd97169c9caffaf5b2a | WuLC/LeetCode | /Algorithm/Python/889. Construct Binary Tree from Preorder and Postorder Traversal.py | 912 | 3.84375 | 4 | # -*- coding: utf-8 -*-
# Created on Sun Aug 19 2018 15:55:10
# Author: WuLC
# EMail: liangchaowu5@gmail.com
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
# recursive
class Solution(object):
... |
f90a00d72d4579cbca20709142387e62cdd9b4b7 | hanzohasashi33/Competetive_programming | /HackerEarth/Array1D/Prasun_The_Detective.py | 427 | 3.6875 | 4 | # Write your code here
'''
import re
mess1 = input()
mess1 = re.sub(r"[^\w\s]", '', mess1)
mess1 = mess1.replace(" ",'')
mess2 = input().replace(" ",'')
mess2 = re.sub(r"[^\w\s]",'', mess2)
if(set(mess1).issubset(set(mess2))==True):
print ("YES")
else :
print ("NO")
'''
mess=input()
mesr=input()
mess=mess.... |
65df4ca4ec70340571c7874dbcee07c6f1e071d8 | marinecollet/Sudoku | /BackTracking.py | 2,914 | 4.1875 | 4 | from Cell import *
class BackTracking:
"""Back tracking algorithm to solve the sudoku"""
def __init__(self, puzzle):
self.puzzle = puzzle
self.box_size = 3
self.height = len(self.puzzle)
self.width = len(self.puzzle[0])
self.solved_puzzle = []
self.number_of_el... |
4ede2f897724ca773fc9f10e0d4748bf60d86f06 | steelfury/Homework | /main.py | 495 | 4.09375 | 4 | ## Program to check for Coronavirus symptoms and advise actions
is_temperature_high_string = input ("Do you have a high temperature? (Yes/No) ")
## Selection
if is_temperature_high_string == "Yes":
print("Please contact 111.nhs.uk")
else:
is_cough_continuous_string = input ("Do you have a continuous cough? (Yes/No... |
1ebd617e7474b66cdf6be544c45e45d8dd5b8a8b | JoneNash/improve_code | /LeetCode/718_Maximum_Length_of_Repeated_Subarray.py | 572 | 3.6875 | 4 | #!/usr/bin/env python
# encoding: utf-8
"""
@author: leidelong
@contact: leidl8907@gmail.com
@time: 2018/11/28 7:07 PM
@info: 最长公共子序列问题
"""
#DP方法
def findLength( A, B):
dp = [[0 for _ in range(len(B) + 1)] for _ in range(len(A) + 1)]
for i in range(1, len(A) + 1):
for j in range(1, len(B) + 1):
... |
3ce68f33956a0f04e726d60bc3d6538967ae4553 | pokalaanirudh/concrete_strength-analysis-using-Regeression | /Part D.py | 1,748 | 3.75 | 4 | import keras
from keras.models import Sequential
from keras.layers import Dense
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error
import statistics
import numpy as np
dataframes = pd.read_csv("/home/pokala/coursera/concrete_data.csv")
mean_sq_er_li... |
7b0cfb4e79e3f55eeb9250a8c5fa3ad8c8c0dc5c | pallavipsap/leetcode | /205_isomorphic_strings.py | 1,975 | 3.6875 | 4 | # May 29 2020
class Solution:
def isIsomorphic(self, s: str, t: str) -> bool:
#time complexity : O(N) where N is the length of s or t: considering we go ahead only if both are same
if len(s) != len(t): return False
'''
dict = {}
for i in range(len(s... |
120b0c8f52440cda36d2b28e8902d7b4f7a4205c | kennlebu/ShoppingListApp | /tests/user_tests.py | 1,812 | 4.21875 | 4 | import unittest
from app.user import User
class UserTests(unittest.TestCase):
""" Tests for the user class """
def test_user_creation(self):
""" Tests whether a user is created and stored successfully """
user = User('kennlebu', 'password', 'Kenneth', 'Lebu')
assert user
self... |
283df911af273088d2e358de20fcd6c4c7c50887 | jasontruong93/InCollege-Kansas | /test_main.py | 1,988 | 3.53125 | 4 | import csv
import os.path
import pytest
from csv import writer
import main as m
import student as s
# To test password verfication. In Terminal run: pytest test_main.py
class TestClass:
# Tests if requirements for a valid password are satisfied within main.checkPass()
# Validates if Less than 8... |
0bd796ae00849f6f2382a8380888c71e364a6201 | syoung/s3lib | /notes/agua/private/bin/test/python/pizza/dict1.py | 207 | 4 | 4 | mydictionary={'keyname':'somevalue'}
for key, value in mydictionary.iteritems():
print "key %s: value %s" % (key, value)
#for key in mydictionary:
#print "key %s: value %s" % (key, mydictionary[key]) |
fbc79740ac3ac6485773073ac70762adb08aa694 | codeAligned/codingChallenges | /codewars/counting_duplicates.py | 283 | 3.5625 | 4 | # https://www.codewars.com/kata/54bf1c2cd5b56cc47f0007a1/solutions/python
import collections
def duplicate_count(text):
print(text)
c = collections.Counter(text.upper())
results = []
for key in c:
if c[key] > 1: results.append(key)
return len(results) |
f3ba5ae707e45f289e684807913280976776610c | piastrepiano/Pre-AP-Computer-Science-1 | /3apcs3rd/guessingGame.py | 592 | 4.03125 | 4 | def main():
keep_going = True
import random
print('Hello! What is your name?')
my_name = input()
number = random.randint(1, 9)
print('Well, ' + my_name + ', I am thinking of a number between 1 and 9.')
while keep_going:
print('Take a guess.')
guess = input()
guess = i... |
6ecf6e2deac1964334c39f82cc797b67584eed6d | mengfa/note | /list/rob.py | 715 | 3.828125 | 4 | # -*- coding: utf-8 -*-
# File Name: rob
# Description :
# Author : LvYang
# date: 2019/3/25
# Change Activity: 2019/3/25:
class Solution(object):
def rob(self, nums):
"""
:type nums: List[int]
:rtype: int[2,1,1,2]
"""
d = 0
... |
0bd3301196b6f5a33b5332a065f28b67ae69d606 | ederst/exercism-python | /hamming/hamming.py | 193 | 3.546875 | 4 | def distance(strand_a: str, strand_b: str) -> int:
if len(strand_a) != len(strand_b):
raise ValueError("Invalid input.")
return sum(x != y for x, y in zip(strand_a, strand_b))
|
7b2e5e13efdf1733d635643a63be2177c74f72dd | lyf1006/python-exercise | /5.if语句/5.4/checkname_ten.py | 376 | 3.78125 | 4 | current_users = ['Mary','Lily','admin','Jack','Tom']
new_users = ['John','qingqian','mary','xiaoxiannv','Tom']
for user in new_users:
#列表解析,实现忽略大小写的比较
if user.lower() in [current_user.lower() for current_user in current_users]:
print("该用户名已被占用,请更换。")
else:
print("设置用户名成功。") |
ec383a9dd2ddab7f0c2e4859c06c925c20896a58 | weepwood/CodeBase | /Python/Exercise/三角形.py | 491 | 3.515625 | 4 | # 计算三角形边长及面积
import math
a = float(input("请输入三角形a边长="))
b = float(input("请输入三角形b边长="))
c = float(input("请输入三角形c边长="))
if not a <= 0 and b > 0 and 0 < c < a + b and b + c > a and a + c > b:
long = a + b + c
h = long / 2
s = math.sqrt(h * (h - a) * (h - b) * (h - c))
print('三角形边长为:', long)
print('三角形... |
bab85445a4ecd67d7660e9a92cad5ff1d22d855d | LichaDC/GitProgramming | /Código Dallas/Código Dallas Google Drive/Python 3/Excepciones.py | 741 | 3.84375 | 4 | #1)
#print(14/0)
#DEMS CDIGO
#Como salta el error, el cdigo no se sigue ejecutando
#try:
# print(14/0)
#except:
# print("Hay un error al dividir")
#try:
# print(14/0)
#except ZeroDivisionError:
# print("No se puede dividir por 0")
#try:
# tupla = (1,3,3,4,5)
# print (tupla[10])
#except ZeroDivision... |
b57816fd6ddeadad93ef2de7b2fa23a36ff688c9 | Lammatian/ADS | /structures/linkedlist.py | 3,842 | 3.984375 | 4 | class LinkedList(object):
"""Implementation of linked list with standard methods"""
_title = "Linked list"
class Node(object):
"""Single node of the linked list with a value"""
def __init__(self, val):
"""
Initialise a node
:param val: data hel... |
626c10ddd8e15f67099a3b1c19fce6489cea4a62 | rksam24/MCA | /Sem 1/oops/string.py | 2,364 | 4.46875 | 4 | def main():
#option
print("""1.Number of Words in String
2.Reverse of String
3.Reverse each word of String
4.Largest word in String""") #used multiline string to print the option
option() #calling function to select option
def option():
print() #for next line
#select choice
ch=int(input('Enter ... |
fcaf68afae031a902293ba1055aea7d80fb23e3e | chanheum/python_study | /알고리즘 기본/재귀/factorial(recursive_func).py | 226 | 3.984375 | 4 | def factorial(num):
if num == 0:
return 1
else:
return num * factorial(num - 1)
print(factorial(1))
print(factorial(2))
print(factorial(3))
print(factorial(4))
print(factorial(5))
print(factorial(6))
|
53ea516c8f362c42de78f0250d2ac3d516c44993 | hrithiksagar/Competetive-Programming | /Python/Chapter 6 Conditional expressions/Practice set 1.py | 906 | 3.890625 | 4 | """
1. WAP to find greatest of four Numbers entered by user:
2. WAp to find out weather a student is pass or fail, iof it requires total 40% and atleast 33%
in each sub, to pass. Assume 3 Sub and take marks as an input from user
3. A spam comment is defined as a text contanising following keywords:
"Make a lot of mon... |
3d20ce52ba44167d704bb7f1720450e4ed2d8d17 | libaoming/python---lottery | /lottery.py | 690 | 3.8125 | 4 | import random
# menu
def menu():
user_enter = get_user_number()
lottery_number = create_lottery_numbers()
match_numbers = user_enter.intersection(lottery_number)
print("you got {}, you won ${}!".format(len(match_numbers),100**len(match_numbers)))
# User can pick 6 numbers
def get_user_number():
number_c... |
33527cf4b2fbd20632614cc285252a4a053ab88d | marktheawesome/computer-programin-1 | /mad-lib/mad_lib.py | 4,798 | 3.890625 | 4 | import time
print("ready to playt Mad Libs?")
time.sleep(1)
print ('If you are readay press the Enter key')
input()
print(' Give me an adjective, plese ')
adjective = input()
print(' Now a noun ')
noun = input()
print(' I need a plural_noun. ')
plural_noun = input()
print(' How about a female in ... |
566798cc310b460e5a14b42bb65edfb5b2e2884c | BenjaminStanelle/Basic-Python-Operations | /num.py | 726 | 3.890625 | 4 | #Benjamin Stanelle 1001534907
def main():
my_List=[]
num_Elements= int(input("Enter the number of elements in the list: "))
for x in range(num_Elements):
value= float(input("Enter a new element for the list: "))
my_List.append(value)
print("Original List: ",my_List)
min... |
7b935097494ff1af70c6fffaa3de067d86ff0c72 | VimalMinsariya/euler-project | /math/grad_turtle.py | 454 | 3.84375 | 4 | import turtle
import sys
print(sys.version) #한글은 문제 없지요
turtle.setworldcoordinates(0,-2560,2560,0)
bob = turtle.Turtle()
bob.speed(0)
turtle.colormode(255)
bob.right(90)
for r in range(255):
bob.setposition(0,-r * 10)
for g in range(255):
bob.color(r,g,0)
bob.setx(g*10)
bob.begin_fill()
... |
5591269eefe68078c0ff327cb1ea6da3f807f133 | Trietptm-on-Coding-Algorithms/prog | /python/python_features/src/algorithms/sorting_algorithms.py | 1,219 | 3.953125 | 4 | import random
import sys
"""
Function listing
cli()
gen_list(size, range_of_numbers)
execute_sort(selection_name)
void()
usage()
"""
def bubble_sort(list_of_numbers):
index = 0
is_sorted = False
length = len(list_of_numbers)
def swap(a,b):
... |
49c8c5504bf0d1932ef3f7b3a294e7577fd1be7b | antoni-g/programming-dump | /vgg/manhattan.py | 875 | 4.25 | 4 | # The following method get the manhatten distance betwen two points (x1,y1) and (x2,y2)
def manhattan_distance(x1, y1, x2, y2):
return abs(x1 - x2) + abs(y1 - y2)
def convert(l):
try:
l[0] = float(l[0])
l[1] = float(l[1])
except ValueError:
print("An input character was not a number.")
exit()
# Enter yo... |
4e433635c064fb9dd08a39ebc491d1396eaaf543 | mzfr/Competitive-coding | /Arrays/search-in-sorted-matrix/solution1.py | 676 | 3.8125 | 4 | mat = [ [10, 20, 30, 40],
[15, 25, 35, 45],
[27, 29, 37, 48],
[32, 33, 39, 50] ]
def bin_search(arr,low, high, x):
"""recursive function for binary search
"""
if high>= low:
mid = (low+high)//2
if arr[mid] == x:
return mid
if x < arr[mid]:
... |
e83d43f4f1e3e4dc7e0a4434ee3b827c23330f87 | elobejko/fcc-arithmetic-formatter | /arithmetic_arranger.py | 1,414 | 3.84375 | 4 | def arithmetic_arranger(problems, print_res = False):
if(len(problems) > 5):
return "Error: Too many problems."
firstLine = ""
secondLine = ""
thirdLine = ""
space = " "
count = 0
resultsLine = ""
r = 0
for problem in problems:
eq = problem.split()
count +=1
#Only + and - operat... |
af6b07c5b6fa839531397e767d3e8d8694c061e4 | NichHarris/leet-code | /stringMult.py | 1,388 | 3.9375 | 4 | # https://leetcode.com/problems/multiply-strings/submissions/
class Solution(object):
def multiply(self, num1, num2):
"""
:type num1: str
:type num2: str
:rtype: str
"""
product = int(num1)*int(num2)
return str(product)
# OR
# # https://leetcode.com/problem... |
9dcc589ddaba8570a623246818ccbc5f957c086a | Larkiskek/Astro | /botton.py | 4,597 | 3.59375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Nov 14 13:55:48 2020
@author: Филипп
"""
import pygame as pg
pg.init()
class Botton():
"""Класс кнопки.
"""
def __init__(self, screen, coords, width, height, color, text):
self.screen = screen
"""Холст, на котором размещается кнопка."""
... |
9137fdc6ea3c62947f299d4a9738eb07979921a1 | sergiogbrox/guppe | /Seção 5/exercicio09.py | 175 | 3.78125 | 4 | sal = float(input("Salário: "))
emp = float(input("Empréstimo: "))
if emp > sal*20/100:
print('Empréstimo não concedido.')
else:
print('Empréstimo concedido.')
|
16408f816740635a8149f24b257fe29c401f0790 | vinay26-01/python | /search in lists.py | 300 | 3.5 | 4 | def search(n,data,s):
c=0
for i in range(n):
if data[i]==s:
c+=1
if c==2:
return i
else:
return False
n=int(input())
data=list(map(int,input().split()))
s=int(input())
search=search(n,data,s)
print(search)
|
baa226d19742480c225965a16e51e6faaaefc216 | carloxlima/curso_python | /exercicio031.py | 426 | 3.734375 | 4 | km = float(input("Digite a distancia da sua viagem em KM : "))
media= 200
preço1= 0.50
preço2= 0.45
print("O valor da sua viagem é de {} reias.".format(km * preço1) if km <= media else "O valor da sua viagem é de {:.2f} reias.".format(km * preço2))
if km <= media:
print("O valor da sua viagem é de {} reias.".form... |
ac1362c79177c1ebb9ff18a37e8614f7bf2b90e1 | aidardarmesh/leetcode | /Problems/112. Path Sum.py | 1,034 | 3.859375 | 4 | from typing import *
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def hasPathSum(self, root: TreeNode, sum: int) -> bool:
if not root:
return False
stack ... |
4ba4f4b547b3d2b3cec78ea8e693a8f15bca1340 | parasshaha/Python- | /manualfromkeys.py | 637 | 3.75 | 4 | def fromkeysss(input_dict,output_dict_values):
result_dict={}
keys_list=[]
if type(output_dict_values)==list or type(output_dict_values)==tuple:
keys_list=input_dict.keys()
values_length=len(output_dict_values)
for i in range(len(keys_list)):
if i < values_length:
result_dict[keys_list[i]]=output_dict_v... |
5d5ceb211550f6975c1cb5b168f94bf5e44dccd6 | Zerl1990/python_algorithms | /problem_solving/cracking_the_code_interview/trees_graphs/tree_node.py | 660 | 3.921875 | 4 | import os
import sys
class TreeNode(object):
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left
self.right = right
def __str__(self):
if not self.left and not self.right:
return str(self.value)
string = str(self.le... |
5d0ac8f59a7e6f4605ceb95ac30686dc3c20a398 | brookebon05/OOP_Work | /CarClass.py | 409 | 3.65625 | 4 | class Car:
def __init__(self, year1, make1):
self.__year_model = year1
self.__make = make1
self.__speed = 0
def accelerate(self):
self.__speed += 5
# return print("Speed was set to: ", self.__speed)
def brake(self):
self.__speed -= 5
# return print("... |
7487dbffe552e370c2332e48cba5ffce34b1092f | SORARAwo4649/Learning_EffectivePython | /Section1/Item4.py | 2,082 | 3.78125 | 4 | # Cスタイルフォーマット文字列とstr.formatは使わずf文字列で埋め込む
print('Cスタイルフォーマットによる記述')
# 2進数と16進数を整数文字列に変換-Cスタイルフォーマット
# ※非推奨
a = 0b10111011
b = 0xc5f
print('Binary is %d, hex is %d' % (a, b))
print('###############################')
# 組み込みのformatとstr.format
print('組み込みformatによる記述')
# 数値を3桁で区切る、小数点第2位までにする
a = 1234.5678
formatted = forma... |
c2bef44b115c0f3dabc9f4a0374f7a82d31c83bb | Heroinblackberry/Blackberry3 | /Python/2.py | 227 | 3.90625 | 4 | def StrRevers(string):
index = len(string);
output = "Output:";
output = output + str(sorted(string));
print output;
print u'These Numbers will be in ascending order.';
input_st = raw_input();
StrRevers(input_st); |
3a1180d1384b9e6cf6d65d34a835aa44f649dd36 | KodeBlog/Python-3 | /06-tuples/app.py | 1,359 | 3.609375 | 4 | attributes = ('id','name','username','email','password')
print(type(attributes))
print(attributes)
#Code commented because it raises an exception
"""attributes = ('id','name','username','email','password')
attributes[3] = 'created_at'"""
attributes = ('id','name','username','email','password')
attr = list(attribu... |
be17fbce400b8fd59f7df88a2df6d83a8b96ba07 | dongho108/CodingTestByPython | /boostcamp/ex/hash/1.py | 342 | 3.59375 | 4 | def solution(participant, completion):
answer = ''
participant.sort()
completion.sort()
# print(participant, completion)
for i in range(len(completion)):
if participant[i] != completion[i]:
return participant[i]
return participant[-1]
print(solution(["leo", "kiki", "eden... |
0b5d86b64acb7fa7f46ca6bdd2ba74c71c959126 | legoyda/pythontutorexrss | /Площа прям трикутника.py | 222 | 3.6875 | 4 | b = int(input('Ведіть довжину бічної сторони>>'))
h = int(input('Ведіть довжину висоти>>'))
s = 1/2*b*h
print('Площа прямокутного трикутника =',s) |
5c1e47e9dafcff4cc8b285436f3efc4b358213c3 | C-Begley/university_work | /first_year/Workspace/CS1PX/Unit 14/Lab Files/example3.py | 347 | 3.703125 | 4 |
import Tkinter
def display():
messageLabel.configure(text="Hello World!")
top = Tkinter.Tk()
messageLabel = Tkinter.Label(top,text="")
messageLabel.grid()
showButton = Tkinter.Button(top,text="Show",command=display)
showButton.grid()
quitButton = Tkinter.Button(top,text="Quit",command=top.destroy)
quitButton.... |
648560dcc0e207768a37fe8798041752e661d961 | dynnah/LuizaCode | /Python-Exercises/desafio04-loop.py | 239 | 4.09375 | 4 | for number in range(0,101):
if number%3 == 0 and number%5 == 0:
print("Dedezinha Querida")
elif number%3 == 0:
print("Dedezinha")
elif number%5 == 0:
print("Querida")
else:
print(f"{number}") |
4d0a317fca5f1f5a099241689734a6ad3ed3f6f0 | kmad1729/python_notes | /metaprogramming/practice_code/code_1.py | 1,995 | 3.90625 | 4 | 'very basic building blocks in code'
delim = '*' * 20
class A:
def method1(self, *args):
print("this is method1")
print("the are args ", args)
def print_foo(self):
print("foo")
def uppercase_all(*args):
print('args -->', args)
return list(map(str.upper, args))
def func_with_... |
be0bf4e5ff576bc9014c19b7aab9a858be8e5cfc | ybarros7/AgendaADS | /funcoes.py | 2,330 | 4 | 4 | import csv
# Mensagem de Bem Vindo e Opcoes ao Usuario
def bemvindo():
print('\n')
print("Bem Vindo a Agenda")
print("Selecione uma Opcao")
print("1 Adicionar um novo contato")
print("2 Listar os contatos da agenda")
print("4 Para procurar contatos na agenda")
print("5 Remover um conta... |
611c7f5b12f729cfd095784cdd044bca2fc19041 | ctc316/algorithm-python | /Lintcode/Ladder_37_BB/medium/59. 3Sum Closest.py | 888 | 3.796875 | 4 | class Solution:
"""
@param numbers: Give an array numbers of n integer
@param target: An integer
@return: return the sum of the three integers, the sum closest target.
"""
def threeSumClosest(self, numbers, target):
n = len(numbers)
if n < 3:
return
numbers.s... |
2d07a7742bb6b3a1b9eef1b40b37959e4711c480 | sbacchus91/compound-interest | /sbacchus_hw_5_15_5.py | 2,346 | 3.78125 | 4 | """
Shane Bacchus
Class: CS 521 - Fall 1
Date:10/10
Homework Problem # 5
Description of Problem (just a 1-2 line summary!):
Compound interest recursive and nonrecursive implementation
"""
def calc_compound_interest(principal_float,interest_float,years):
"""Future Value Calculated Non-Recursively"""
... |
6aa12b355a09b9d9e850f8fbf4cfa04428272b0a | 0x000613/Outsourcing | /Python/2020-06-04-문자열뒤집기/reverse.py | 96 | 4.03125 | 4 | s = str(input())
s_reverse = ''
for char in s:
s_reverse = char + s_reverse
print(s_reverse) |
9e0446fe563f92ace3773b2584917f994c495156 | Samuel2402/python-demo | /Practice/attributes_practice/class_example_2.py | 1,479 | 3.796875 | 4 | ### Actuall ###
class Student():
class_ = "student"
def __init__(self,name,age,test_1,test_2,test_3):
self.name = name
self.age = age
self.test_1 = test_1
self.test_2 = test_2
self.test_3 = test_3
def calcaverage(self):
return int((self.test_1 + self.test_2 ... |
0fead01ff50a3b933e0ded597f607a377d08960c | iheb1919/holbertonschool-higher_level_programming | /0x04-python-more_data_structures/100-weight_average.py | 272 | 3.578125 | 4 | #!/usr/bin/python3
def weight_average(my_list=[]):
if my_list and type(my_list) == list:
scores, weights = 0, 0
for score, weight in my_list:
scores += score * weight
weights += weight
return scores/weights
return 0
|
a4b55e94244227ef003bdb3c40f9ab3d6f1218b4 | RahulRao23/tic-tac-toe | /program.py | 13,177 | 3.890625 | 4 | from tkinter import *
root = Tk()
root.geometry('900x900')
# frame for the game board
frame = LabelFrame(root, borderwidth=4, bg='#EA7773')
frame.grid(row=1, column=1,padx=20, pady=20, sticky=N)
# frame for the options
frame_options = LabelFrame(root, borderwidth=4, bg='#EA7773')
frame_options.grid(row=1, column=2,p... |
21bb6650cc0049487c5b41f73dbdaf3cad2f9f28 | MariosTserpes/Azure-SparkCore-for-Data-Engineers | /joins_transforms.py | 3,366 | 3.59375 | 4 | '''
Filter & Join Transformations
'''
spark = pyspark.sql.SparkSession.builder.appName('DEng3').getOrCreate()
races_df = spark.read.parquet("races")\
.withColumnRenamed("name", "race_name")
circuits_df = spark.read.parquet("circuits")\
.filter("circuit_id < 70")\
.withColumnRenamed("name", "circuit_name")
... |
a67fdc53d88b6ec548e1ac941a62961985f409d6 | TonyJenkins/python-workout | /31-pig-latin-translation-of-a-file/pig_latin_file.py | 574 | 3.78125 | 4 | #!/usr/bin/env python3
"""
Exercise 31: Pig Latin Translation of a File
Obfuscate a file using the simple "Pig Latin" rules.
"""
def pig_latin(word):
if word[0] in 'aeiou':
return word + 'way'
else:
return word[1:] + word[0] + 'way'
def pig_latin_file(filename):
with open(fil... |
02239835f9a694af548dc728c4182752cb666f06 | D-HAC/solutions | /Fall-2016-17/week3_disemvoweler/disemvowel_lambda.py | 735 | 3.84375 | 4 | # Just does basic disemvoweling.
disemvowel = lambda s: ''.join([(lambda v: '' if v in 'aeiou' else v)(v) for v in list(s)])
# print(disemvowel('Yet another one line solution.'))
# Proper disemvoweling!
disemvowelWithVowels = lambda s: [''.join([(lambda v: '' if v in 'aeiou' else v)(v) for v in list(s)]), ''.join([(la... |
bbe52c76145eb226791df544a29c72d92d195d83 | Bedrock02/Interview-Practice | /Array_Strings/permutations.py | 649 | 3.984375 | 4 | '''
Find all possible permuations
Approach
For every character in word
build
start collection with one character
for every other character possible
a + find_permutations(given_string - a)
b +
c +
d +
a
b
c
d
'''
def find_permutations(given_string):
collection = []
def get_permutations(input, prepend=''... |
037f5896026fe6289fdf294721c312b21bfc7f86 | Jane11111/Leetcode2021 | /208.py | 1,076 | 4.03125 | 4 | # -*- coding: utf-8 -*-
# @Time : 2021-04-21 16:14
# @Author : zxl
# @FileName: 208.py
class Trie:
def __init__(self):
"""
Initialize your data structure here.
"""
self.root_dic = {}
def insert(self, word: str) -> None:
"""
Inserts a word into the trie.
... |
9e90eef62ca4da81201813f532e697d7785bc118 | Nateque123/python_tutorials | /chapter4_func/functions.py | 264 | 4 | 4 | # Function example
def add_two(a,b):
return a+b
num1 = int(input("Enter 1t number: "))
num2 = int(input("Enter 2nd number: "))
print(add_two(num1,num2))
# fname = input("Enter first name: ")
# lname = input("Enter last name: ")
# print(add_two(fname,lname)) |
c23ebaed2b0cad852a5ae734f452fe5b3e9e2d4f | KeKe115/Python_Practice | /func-let3.py | 315 | 3.734375 | 4 | # 引数に関数を要求する関数を定義
def calc_5_3(func):
return func(5, 3)
# 引数に掛け算を行う無名関数を指定する
result = calc_5_3( lambda a, b: a * b )
print(result)
# 引数に足し算を行う無名関数を指定する
result = calc_5_3( lambda a, b: a + b )
print(result)
|
cb8ef152d318d9ab1d17255895c3e26f0d8f0113 | Baljeet-Singh-Original/Practice-Questions. | /DSA Step 5/Finding Max and Min in a single Scan.py | 226 | 4.125 | 4 |
arr1 = [5,4,3,6,24,2,45,32,89]
max1 = arr1[0]
min1 = arr1[0]
for i in arr1:
if i > max1:
max1 = i
elif i < min1:
min1 = i
print("The largest element is ", max1)
print("The smallest element is ", min1)
|
640b81c47e6b3edeb00f50214407145889cce84f | juliansilvit/gpccodes | /Codigos estudiantes por lenguaje/PY/Bryann Valderrama/Strings/anagramsPattern.py | 1,092 | 3.578125 | 4 | from sys import stdout
NO_OF_CHARS = 256
def compare(arr1, arr2):
global NO_OF_CHARS
for i in range(NO_OF_CHARS):
if arr1[i] != arr2[i]:
return False
return True
def anagramsSearch(pat, txt):
global NO_OF_CHARS
M = len(pat)
N = len(txt)
countP = [0 for x in range(NO_O... |
d3053dd10523b97b8277afb78dc8f71028981bc9 | zVelto/Python-Basico | /aula3/aula3.py | 272 | 3.671875 | 4 | """
str -string
"""
print('Essa é uma "string" (str).')
print("Essa é uma 'string' (str).")
print("Esse é meu \"texto\" (str).") # Caractere de escape
print('Esse é meu \'texto\' (str).') # Caractere de escape
print(r'Esse é meu \n (str).') # Caractere de escape
|
67a5c198bbab91cf23a6be1aa91f04cb85aa83fe | bleckfox/passKeeper | /passKeeper.py | 4,379 | 3.5 | 4 | # Создание файла учетных записей
import shelve
import QuestandAnsw
########################################
''' Создаю функцию, в ней пишу код добавления новых учетных записей.
Введенные значения записываю как ключ и значение соответственно в файл.
'''
def add_account():
while True:
... |
73fba64e92d326033c213ba0cfd620068b9cab47 | SupriyoDam/DS-450-python | /Graph/check if undirected graph is cyclic using disjoint set.py | 968 | 3.875 | 4 | from collections import defaultdict
from DisjointSetData import Disjoint
class Graph:
def __init__(self, n):
self.graph = defaultdict(list)
self.n = n
def addEdge(self, starting_vertex, end_vertex):
self.graph[starting_vertex].append(end_vertex)
self.graph[end_vertex].append(s... |
70397ce356880ded90b035b78a239a2d07d3761d | yafiimo/python-practice | /main.py | 3,794 | 3.828125 | 4 | from functools import reduce
# Check if a value is classified as a boolean primitive. Return true or false.
def booWho(x):
return True if type(x) == bool else False
print('booWho:', booWho(False), booWho(25))
# Create a function that looks through an array and returns the first element
# in the array that passes a ... |
03b223972a5326d5ddecbc61fdc7a990faa6b760 | PrathushaKoouri/Binary-Search-4 | /88_H-Index2(Binary Search).py | 1,123 | 3.59375 | 4 | '''
Accepted on leetcode(275)
Time - O(logn), space O(1)
We have to give output as maximum number of papers with maximum citations which should match and rest of the papers should have less than the maximum citations mentioned above.
'''
class Solution:
def hIndex(self, citations) -> int:
# 1. ... |
df4c430b4d8697b4ae2059ed587a84f7102bcd25 | maxherre/Python38_Projects | /Exercise_4_Divisors.py | 529 | 4.3125 | 4 | '''
from www.practicepython.org
completed on 30.10.2020
Create a program that asks the user for a number and then prints out a list of all the divisors of that number.
(If you don’t know what a divisor is, it is a number that divides evenly into another number.
For example, 13 is a divisor of 26 because 26 / 13 has ... |
adfc759e97a2c9187502740b6af006b86d3bc682 | mohammad-javed/python-pcap-course | /020-035-string-methods/string_fix_answer.py | 197 | 3.921875 | 4 | txt = ",$,, chocolate banana ice-cream..."
# Add more options in the strip()
txt = txt.strip(",$ .")
# Clear any whitespaces left and print the outcome
txt = " ".join(txt.split())
print(txt)
|
9b0d6a22e95dca52295ef125408a921307506fb7 | primaayunda/Send-email | /emailscript.py | 1,165 | 3.6875 | 4 | # getpass used to make user's password invisible
# smtplib is a a library taht provided by python
import getpass
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# mimetext because you will only send a text message
sender = str(input("Please input your username: "))
pa... |
0ebd435de3950d05ab32efcc45c338d0e0c88972 | Ayush-mega-coder/Basic-Python-Projects | /employeeperfo.py | 351 | 3.640625 | 4 | work_hours=[('ayush',100),('mayank',200),('jose',400)]
def employee_check(work_hours):
current_max=0
employee_of_month=''
for employee,hours in work_hours:
if hours>current_max:
current_max=hours
employee_of_month=employee
else:
pass
return(e... |
c03a12c67d0b3b25fe0e45bb6dce5f9c1419f9db | Nithanth/Graduate-Algorithm- | /Array/056. Merge Intervals.py | 1,216 | 4.15625 | 4 | """
Given a collection of intervals, merge all overlapping intervals.
Example 1:
Input: [[1,3],[2,6],[8,10],[15,18]]
Output: [[1,6],[8,10],[15,18]]
Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6].
"""
# Definition for an interval.
class Interval(object):
def __init__(self, s=0, e=0):
... |
59326d2c6e41e4ebead938d87f6b7690dd7a11f7 | matiferna/twitterBot | /usage.py | 2,661 | 3.734375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 8 19:36:32 2019
@author: edoardottt
This file has a method called print_usage that brings as input a number (the error code).
It prints the appropriate error code and error message.
Then It quits.
This file is under MIT License.
... |
9122ad3d58de7a4f3a95a01ce38e358a7858073c | jiwon73/lecture_4_1 | /lecture_4/try_except.py | 170 | 3.515625 | 4 | try:
a,b=input('두수를 넣으세요').split()
result=(int(a)/int(b))
print(result)
except:
print('대입한 두수가 정확한지 확인하시오')
|
7f4155d2ae465c1116c48e88425b9a3cb9617d15 | HeyMam/Sparta_Algoritm | /week_3/08_queue.py | 1,574 | 4.15625 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class Queue:
def __init__(self):
self.head = None
self.tail = None
def enqueue(self, value):
new_node = Node(value)
if self.is_empty():
self.head = new_node
sel... |
e32357d3b076671de52e834f17a88a51efae1b85 | xuysang/learn_python | /书籍/你也能看懂的python算法书/二分法.py | 383 | 3.859375 | 4 | numbers = [1,3,5,6,7,8,13,14,15,17,18,24,30,43,56]
head,tail = 0, len(numbers)
search = int(input("enter a number to search:"))
while tail - head > 1:
mid = (head+tail)//2
if search < numbers[mid]:
tail = mid
elif search > numbers[mid]:
head = mid
elif search == numbers[mid]:
ans = mid
break
else:
if sear... |
4863d0e1014c11bb7736a4f6da70255cba30ad0a | Andrecdec/exercicios_variaveis_e_tipos_de_dados | /Ex_43_sec_4.py | 960 | 3.96875 | 4 | '''
Seção 4 - exercício 43
Escreva um programa de ajuda para vendedores . A partir de um valor lido, mostre:
- O total a pagar com desconto de 10%;
- O valor de cada parcela, no parcelamento de 3x sem juros;
- A comissão do vendedor, no caso da venda ser a vista(5% sobre o valor com desconto);
- A comissão do vendedo... |
08156950d028967e278b99e799b841902367044e | wei-Z/Python-Machine-Learning | /self_practice/Chapter 10 Predicting Continuous Target Variables with Regression Analysis.py | 13,027 | 3.75 | 4 | # Predicting Continuous Target Variable with Regression Analysis
# Explore the Housing Dataset
import pandas as pd
df = pd.read_csv('https://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data', header=None, sep='\s+')
df.columns = ['CRIM', 'ZN', 'INDUS', 'CHAS', 'NOX', 'RM', 'AGE', 'DIS', 'RAD'... |
ff003e28056c2b87db86631a75b7960b5e543db9 | YaelChen/BankAccount | /2 Bank account.py | 788 | 3.96875 | 4 | class BankAccount:
bank_name = "PayPy"
def __init__(self, _balance=0):
self._balance = _balance
def deposit(self, amount):
self._balance += amount
def withdraw(self, amount):
self._balance -= amount
def print_balance(self):
print(f"The current balance... |
469ce6b4daf42c8898ea6fddceeb288754962e56 | AAlpenstock/UpUp | /Personal work window/knowledge/change_str_to_list.py | 378 | 3.59375 | 4 | """
转以空格为分隔符的字符串为两层列表嵌套
"""
import re
def change_str():
with open('./str_origin.txt','r',encoding='UTF-8') as fp:
str_1 = fp.read()
str_1 = re.split('\n',str_1)
# for i in range(len(str_1)):
# str_1[i] = [str_1]
print(str_1)
return str_1
if __name__ == '__main__':... |
5b0a079a4b5554a65be2bd881021bf2508202829 | qlhai/Algorithms | /data_structure_py3/sort/bubble_sort.py | 467 | 3.90625 | 4 | def bubble_sort(data):
for i in range(len(data)):
for j in range(1, len(data)-i):
if data[j-1] > data[j]:
data[j-1], data[j] = data[j], data[j-1]
def bubble_sort_opt(data):
for i in range(len(data)):
found = False
for j in range(1, len(data)-i):
i... |
9b5f91d8280b5fdfd2751839749f1308b94b103a | Shiv2157k/leet_code | /revisited/math_and_strings/math/square_root_x.py | 1,829 | 4.0625 | 4 |
class SquareRoot:
def results(self, x: int) -> int:
"""
Approach: Pocket Calculator
Time Complexity: O(1)
Space Complexity: O(1)
:param x:
:return:
"""
from math import e, log
if x < 2:
return x
left = int(e**(0.5 * log(... |
c63c03245a5cabcb1fab67abd42ca924c6ad3ce6 | Rsj-Python/project | /py_codewars/有效扩号.py | 307 | 4.03125 | 4 | def valid_parentheses(string):
a = 0
for i in string:
if i == '(':
a += 1
if i == ')':
a -= 1
if a < 0:
return a
return a == 0
print(valid_parentheses('())((())()'))
|
338d82e2efbf6cf59850d216af33da8c8df8aeeb | jdixosnd/jsonl-to-conll | /jsonl_to_conll/io.py | 355 | 3.5 | 4 | import json
def json_to_text(jsons, output_filename):
with open(output_filename, "w") as f:
for each_json in jsons:
for line in each_json:
f.writelines(" ".join(line) + "\n")
def read_jsonl(filename):
result = []
with open(filename, "r") as f:
for line in f.readlines():
result.append... |
02dfdd8bd4982167a5b3e38ac41f3d0dee99d67b | tuxedocat/gym | /aoj/course/alds1_1_a.py | 422 | 4 | 4 | def insertion_sort(arr):
for i in range(len(arr)):
key = arr[i]
j = i - 1
while (j >= 0) and (arr[j] > key):
arr[j + 1] = arr[j]
j -= 1
arr[j + 1] = key
print(" ".join(map(str, arr)))
return arr
def main():
N = input()
arr = [int(i) for i... |
1688167f57a0c9237462c7c08400c38048821199 | pbldmngz/codewars | /kyu7/disemvowel_trolls.py | 129 | 3.640625 | 4 | def disemvowel(string):
return "".join([x for x in string if x not in ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U", ]]) |
65456f2d0fa4994f6cc924d5605e9286011e09f6 | AhsanUrRehmanSiddiqui/Classification | /Classification/k-NN.py | 2,150 | 3.53125 | 4 | import pandas as pd
import csv
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
from sklearn.datasets import load_iris
from sklearn import neighbors
from sklearn import datasets
iris_data = datasets.load_iris()
print ('Keys:', iris_data.keys())
print ('-' * 20)
p... |
4d719ef3cdb24443243637bb7ebbf88771d6922b | dev-danilosilva/lambda_py | /tests/test_math_functions.py | 3,119 | 3.765625 | 4 | import unittest
import lambda_py.math as m
class TestMathFunctions(unittest.TestCase):
def test_if_sum_2_is_commutative(self):
func = m.sum2
x = 4
y = 5
self.assertTrue(func(x)(y) == func(y)(x))
def test_if_sum_2_result_of_the_function_is_the_sum_of_two_values(self):
... |
48e2d850a9a1c43ab4f79390f3728bdc9f071673 | Ash0492/BinarySearch | /lastOccur.py | 445 | 3.53125 | 4 | def LastOccur(l,x):
low=0
high=len(l)-1
while low<=high:
mid=(low+high)//2
if l[mid] > x:
high =mid-1
elif l[mid]<x:
low=mid+1
else:
if mid==len(l)-1 or l[mid]!= l[mid+1]:
return mid
else:
low=mi... |
a8c2a8200a9a4115ce7645e3c4af1860ccc77b0c | ardaunal4/My_Python_Lessons | /Statistics/central_limit_theorem.py | 523 | 3.703125 | 4 | import numpy as np
import matplotlib.pyplot as plt
import random
x = np.random.random_integers(10,size=100000)
mean_sample = []
for i in range(10000):
sample_number = random.randrange(5, 10) # It generates a random number in an given interval (5, 10)
samples = random.sample(list(x), sample_number) # It take... |
182bbbb65732746b62369d9fefa1380ec9659024 | seattlegirl/leetcode | /maximum-product-of-three-numbers.py | 1,275 | 3.9375 | 4 | #coding=utf-8
"""
给定一个整型数组,在数组中找出由三个数组成的最大乘积,并输出这个乘积。
示例 1:
输入: [1,2,3]
输出: 6
示例 2:
输入: [1,2,3,4]
输出: 24
注意:
给定的整型数组长度范围是[3,104],数组中所有的元素范围是[-1000, 1000]。
输入的数组中任意三个数的乘积不会超出32位有符号整数的范围。
即先将数组排序,我们假设数组够长,那么可能数组最左边三个是绝对值比较大的三个负数,数组最大值肯定要求正数,
那么则有两种可能:取最右边三个或者最左边两个乘最右边一个 ,最后比较这两种情况取最大值即为所要求的值
"""
class Solution(obj... |
18271a7a7af378e9a056508cb37af4e6d5da0500 | Anisha7/CS2.1 | /code/sorting.py | 8,163 | 4.1875 | 4 | #!python
from sorting_iterative import is_sorted, bubble_sort, selection_sort, insertion_sort
from sorting_recursive import split_sort_merge, merge_sort, quick_sort
from sorting_integer import counting_sort, bucket_sort
# def is_sorted(items):
# """Return a boolean indicating whether given items are in sorted or... |
7f405cddbbf6484346ea4cbc9d35cf63ba73c219 | AruzhanSakenova/python2021 | /w7/tsis7.py | 3,462 | 3.5 | 4 | import pygame
import math
pygame.init()
width, height = (900, 660) #x,y
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption('Functions')
WHITE=(255,255,255)
BLACK=(0,0,0)
RED=(255,0,0)
BLUE=(0,0,255)
pi = math.pi
running= True
while running:
# Even loop
for event in pygame.event.get():
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.