blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
18563b04d6ab9fe6175f4406a23c9c785d4b27e4 | 40309/variables | /spot check 2.py | 560 | 3.796875 | 4 | #Tony K.
#23/09/2014
#Spot check
whole_number= int(input("Please enter your integer of grams: "))
hundred = whole_number // 100
remainder1 = whole_number % 100
fifty = remainder1 // 50
remainder2 = remainder1 % 50
ten = remainder2 // 10
remainder3 = remainder2 % 10
five = remainder3 // 5
remainder4... |
13379372df1dd1a01be9881f4eaefc1666bd3fee | sungminoh/algorithms | /leetcode/solved/662_Maximum_Width_of_Binary_Tree/solution.py | 3,736 | 4.0625 | 4 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2020 sungminoh <smoh2044@gmail.com>
#
# Distributed under terms of the MIT license.
"""
Given the root of a binary tree, return the maximum width of the given tree.
The maximum width of a tree is the maximum width among all levels.
The w... |
6a1505bdc83fd6a62e8cf342309665a1728e649a | kyleecodes/Python-Advent-Calendar | /dec15.py | 321 | 3.8125 | 4 | # Write a function called where_is_2(series) that returns the position (integer) of the number 2.
import pandas as pd
def where_is_2(series):
where_is_two = series.get_loc(2)
return where_is_two
if __name__ == '__main__':
my_list = [1, 6, 4, 9, 3, 0, 2]
data = pd.Index(my_list)
where_is_2(data)... |
7cd95a2bfe2161389153693bd8b2f212cf5b4de8 | smaecrof/Python-Playground | /pyDictionaries.py | 850 | 3.828125 | 4 | # Author: Spencer Mae-Croft
# Date: 08/31/2020
dean = {
'first_name': "Dean",
'last_name': "Colvin",
'age': '69',
'hometown': "Plyouth",
'state':"Indiana",
'occupation':"Judge",
}
for key, value in dean.items():
print("\nKey: " + key + " ------> " + value)
spencer = {
... |
2f76af470e5d7110407e619952ffa1464d104b0d | FaezehAHassani/python_exercises | /syntax_list.py | 1,007 | 3.84375 | 4 | # doing things to list
ten_things = "Apples Oranges Crows Telephone Light Sugar"
print("Wait there are not 10 things in that list. Let's fix that.")
stuff = ten_things.split(' ') # if I put '' it give an error
print(stuff)
more_stuff = ["Day", "Night", "Song", "Frisbee", "Corn", "Banana", "Girl", "Boy"]
print(more_... |
6bc76baaf14c6605e16add5f1fd994459f739f5b | gup-abhi/comp_image | /compressor.py | 333 | 3.53125 | 4 | # import PIL module
import PIL
# importing image from PIL module
from PIL import Image
# opening image from the current working directory
img = Image.open("margot.jpg")
# resizing the image to specific dimensions
img = img.resize((500, 500), PIL.Image.ANTIALIAS)
# saving the resize image to the directory
img.save("m... |
22007182db9256d478d3e063bd526b0222329bf9 | DaphneKeys/Python-Projects- | /guessthenumtrynexcept.py | 1,166 | 3.96875 | 4 | import random
print('What is your name?')
name = input()
while True: #infinite loop
answer = random.randint(1,20)
tries = 5 #added tries variable to count down works properly
print('Hello! ' + name + ' We are going to play a guess game. Choose a number between 1 to 20\nTotal : 5 tries\n')
while... |
f187e276afc96d69056eee0639c583ca14a33904 | Ricardo301/CursoPython | /Desafios/Desafio036.py | 701 | 3.734375 | 4 | import colorama
colorama.init()
ValorCasa = float(input('Qual é o valor da casa R$ '))
salario = float(input('Qual é o seu salário? '))
ano = int(input('Em qunatos anos será percelada ?'))
presmensal = ValorCasa / (ano*12)
percentualSal = salario * 0.3
if presmensal > percentualSal:
print('Para pagar uma casa de ... |
94e77c1f12be2d0e6c92d6bb8cefbc74caddc49a | ChaitanyaPuritipati/CSPP1 | /CSPP1-Practice/cspp1-assignments/m10/how many_20186018/how_many.py | 786 | 4.15625 | 4 | '''
Author: Puritipati Chaitanya Prasad Reddy
Date: 9-8-2018
'''
#Exercise : how many
def how_many(a_dict1):
'''
#aDict: A dictionary, where all the values are lists.
#returns: int, how many values are in the dictionary.
'''
counter_values = 0
for i in a_dict1:
counter_values = counter_... |
26d5a199376a5d5da3b8916ee096c81d021668d1 | SafeeSaif/Personal-Code | /PE9 guessing game.py | 661 | 3.828125 | 4 | import random
ans = random.randint(1,100)
counter = 0
def GG():
global counter
guess = int(input("Guess a number between 1 and 100, including 1 and 100!"))
if (guess < 1) or (guess > 100):
print("Invalid Input. Please guess between 1 and 9!")
GG()
elif guess ... |
ecc5ae4c24b61bcc5084932639b6ca6129e3559d | dlwnstjd/python | /pythonex/0811/conprehensionex1.py | 859 | 4 | 4 | '''
Created on 2020. 8. 11.
@author: GDJ24
컴프리헨션 예제
패턴이 있는 list, dictionary, set을 간편하게 작성할 수 있는 기능
'''
numbers = []
for n in range(1,11):
numbers.append(n)
print(numbers)
#컴프리헨션 표현
print([x for x in range(1,11)])
clist = [x for x in range(1,11)]
print(clist)
#1~10까지의 짝수 리스트 생성
evenlist = []
for n in range(1,... |
ddb92903626d550e904edae91d9d3049801e1856 | JoshPennPierson/HackerRank | /Algorithms/Implementation/Birthday Chocolate.py | 520 | 3.53125 | 4 | #https://www.hackerrank.com/challenges/the-birthday-bar
#!/bin/python3
import sys
def getWays(squares, d, m):
ways_to_break = 0
n = len(squares)
for i in range(n-(m)+1):
this_sum = 0
for j in range(m):
this_sum += squares[i+j]
if this_sum == d:
ways_to_brea... |
4207dd1925f6d2779660dd54937602c4aebb095e | rybodiddly/Archaeology-Grid-Layout-Tools | /hypotenuse.py | 174 | 4 | 4 | from math import sqrt
print('Input sides A & B of triange:')
a = float(input('a: '))
b = float(input('b: '))
c = sqrt(a**2 + b**2)
print('Length of side C (hypotenuse):', c) |
75bc634d23e6e4f3a7ce7912ad7a3730843cb198 | tylerhuntington222/Rosalind | /transcribe.py | 221 | 3.59375 | 4 |
def main():
with open('data', 'r') as f:
data = f.readline()
t = ""
for i in data:
if i == "T":
t += "U"
else:
t += i
t = t.strip()
print (t)
main()
|
bcd21fe69099f75fd17b95b1c151e4b8f1a7a1dc | MedvedMichael/PrepareSession | /Convertions/venv/convertions.py | 1,797 | 3.796875 | 4 | import math
def convert16to10(num16=""):
num10 = 0
alphabet = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]
for i in range(len(arr16)):
num10 += (16 ** (len(num16) - i - 1)) * alphabet.index(num16[i])
print(num10)
return num10
def convert10to16(num10=0)... |
8db319648fd17606fa301af4964677201bcf8f29 | liorch1/learning-python | /list_overlap.py | 389 | 3.796875 | 4 | #!/usr/bin/env python36
import random
a_list = []
b_list = []
c_list = [] #list after filtering
list_element = int(input("please enter a number: "))
for i in range(list_element+1):
a_list.append(random.randrange(1,100,1))
for j in range(11):
b_list.append(random.randrange(1,100,1))
for num in a_list:
if num in... |
5539fd21c34ef951c8065a14bd15eca7a053bf22 | chris-miklas/Python | /lab04/pcalc.py | 452 | 3.84375 | 4 | #!/usr/bin/env python3
"""
Polish notation calculator.
"""
import sys
stack = []
for i in sys.argv[1:]:
if i.isnumeric():
stack.append(i)
else:
a, b = int(stack.pop()), int(stack.pop())
if i == '+':
stack.append(a + b)
elif i == '-':
stack.append(a - b... |
06db574b027c177f1468c9cf46aa9466450b1621 | AnmolKhawas/PythonAssignment | /Assignment5/8.py | 122 | 3.765625 | 4 | #Take the input from the console and create a 2D List.
m=[]
for i in range(2):
m.append(input().split(" "))
print(m)
|
e05f12b0c40cc88a422990b6af0fd1507b36d3ff | Zanzan666/2017A2CS | /Ch23/binary_tree.py | 1,847 | 3.546875 | 4 | #Jenny Zhan Opt3
np=-1
class BTNode:
def __init__(self):
self.value=''
self.lp=np
self.rp=np
class BT:
def __init__(self,length):
self.fp=0
self.records=[]
self.rootp=np
for i in range(length):
newNode=BTNode()
newNode.lp=i+1
... |
3c24e47b9739fd16748d8b6d00d262cf37e3a820 | karlalopez/hackbright | /ready-set-code/bartender-solution-with-prints.py | 1,546 | 3.84375 | 4 | import random
questions = {
"strong": "Do ye like yer drinks strong?",
"salty": "Do ye like it with a salty tang?",
"bitter": "Are ye a lubber who likes it bitter?",
"sweet": "Would ye like a bit of sweetness with yer poison?",
"fruity": "Are ye one for a fruity finish?"
}
ingredients = {
"str... |
f3b16e58273d44d8ddd5723944d9d09b9fe91932 | RRCHcc/python_base | /python_base/day05/exercise02.py | 1,160 | 4.1875 | 4 | """
练习3
在控制台中输入一个月份
返回该月份的天数
1 3 5 7 8 10 12(31天)
4 6 9 11(30天)
2 (当28天
使用元组
"""
month = int(input("请输入月份:"))
day_of_month = (31, 28, 31,30, 31, 30, 31, 31, 30, 31, 30, 31)
if month > 12 or month < 1:
print("输入错误")
else:
print(day_of_month[month-1])
month =int(input("请输入月份:"))
if month<1 or month>12... |
46a51a3dc2c738701422a9352fa9488d13e7616a | envisioncheng/python | /pyworkshop/2_intermediate_python/chapter4/exercise_part5_try_except.py | 274 | 4.1875 | 4 | try:
my_dict = {"hello": "world"}
print(my_dict["foo"])
except KeyError:
print("Oh no! That key doesn't exist")
try:
my_dict = {"hello": "world"}
print(my_dict["foo"])
except KeyError as key_error:
print(f"Oh no! The key {key_error} doesn't exist!") |
0d1e569eb57b766cdf3e1cee3d21e93e0204bbb3 | Aasthaengg/IBMdataset | /Python_codes/p03197/s189769078.py | 124 | 3.65625 | 4 | N = int(input())
ret = "second"
for _ in range(N):
a = int(input())
if a % 2 != 0:
ret = "first"
print(ret)
|
9905d616ba947f617a1159fc4a5954c91aca9d5d | danielballan/scikit-image | /doc/examples/plot_windowed_histogram.py | 5,113 | 3.546875 | 4 | from __future__ import division
"""
========================
Sliding window histogram
========================
Histogram matching can be used for object detection in images [1]_. This
example extracts a single coin from the `skimage.data.coins` image and uses
histogram matching to attempt to locate it within the origi... |
c21ca4ee01b74868728316a94fada3419eb9bdf6 | wodndb/PythonWithKoreatech | /hw03/hw03_05_01.py | 382 | 4.03125 | 4 | #!usr/local/bin/python
# coding: utf-8
def addall(L):
"Return SUM of element in List that is parameter of this function by for~in literal"
result = 0
for k in range(len(L)):
if(type(L[k]) == int):
result += L[k]
return result
print ">>> addall([1])"
print addall([1])
print
print ">>> addall([1, 2, 3, 4, 5, ... |
e24151d2dcee730e42356a25a6eb000862b8e2c3 | sk12bansal/python_prg | /cycle.py | 177 | 3.828125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Aug 9 15:34:57 2017
@author: surakum2
"""
from itertools import cycle
a=[10,20,30,40]
b=[50,60,70,80]
for v in cycle(a,b): print(v) |
007c0a11798300eae4d1b912ce409a71af3c1294 | hzfmax/path_planning | /utils/distance.py | 725 | 3.5 | 4 | import math
CHV = 1.
CD = math.sqrt(2)
def manhattanDistance(
i1: int,
j1: int,
i2: int,
j2: int
) -> float:
dx, dy = abs(i1 - i2), abs(j1 - j2)
return CHV*(dx + dy)
def diagonalDistance(
i1: int,
j1: int,
i2: int,
j2: int
) -> float:
dx, dy = abs(i1 - i2... |
e7f9020bd287389c07b1e332a937c963fd862186 | seoseokbeom/leetcode | /142LInkLIstCycle2.py | 410 | 3.5 | 4 | # Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def detectCycle(self, head):
slow= head
fast= head
while slow.next!=None and fast.next!=None and fast.next.next!=None:
s... |
59e2b59557d9c919da8c6e209788f4cac2524846 | henrikhellstrom/chess | /piece/pawn.py | 3,111 | 3.5 | 4 | from piece import Piece
import pygame
import constants
class Pawn(Piece):
#white is a boolean
#pos is a list [x, y], holding square index
def __init__(self, white, pos):
self.white = white
if white == True:
self.image = pygame.image.load(constants.image_dir + "/white_pawn.png")
... |
9b3b3fe46d3f9bfa165d1d54c1c45c11ad9a00dd | Sonatrix/Sample-python-programs | /fibonacci_series.py | 138 | 3.75 | 4 | num = int(input())
def fibo(n):
a,b = 0,1
for i in range(n):
yield a
a,b = b,a+b
for i in fibo(num):
print(i)
|
7e748bef5e0b8ccfc8e667a18a2d9dcf2462ea91 | hiteshishah/BDA | /HW_KNN_Hiteshi_Shah.py | 16,378 | 3.53125 | 4 | """
hw_knn_hiteshi_shah.py
author: Hiteshi Shah
date: 11/9/2017
description: To write a program to remove outliers from the training data using KNN
"""
import numpy as np
import math
class TreeNode:
"""
A tree node contains:
:slot attr: The attribute that the node belongs to
:slot val:... |
3c09cdbde93e56c0c4d3b49ba34ab548236696d8 | mradu97/python-programmes | /matrix_practice.py | 376 | 3.78125 | 4 |
i=0
while(i <= 10):
j=5
while(j>(i/2)):
print(" ",end="")
j=j-1
j=0
while(j<i+1):
print("*",end="")
j=j+1
print("")
i=i+2
i=12
while(i >= 0):
j=6
while(j> (i/2)):
print(" ",end="")
j=j-1
j=0
while(j<i-1):
print("*"... |
20c68827ab499f77cfacd859d56b8c0815603728 | stacyzhao/Monty-Hall-Dilemma | /monty-hall.py | 2,540 | 3.78125 | 4 | import random
def player_select_door(doors):
return random.randint(0,len(doors)-1)
def setup_game(number_of_doors):
# doors = ["Car"] + ['Goat' for x in range(0, number_of_doors - 1)]
doors = ["Car"] + ['Goat' + str(x) for x in range(0, number_of_doors - 1)]
random.shuffle(doors)
return doors
def... |
3835ec856d25c12b67531ab4ed9503571821077d | kevinconway/chattools | /tests/test_mention.py | 3,169 | 3.625 | 4 | """Test suites for @mention tools."""
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
from chattools import mention
def test_mentions_are_empty_if_not_present():
"""Ensure there are no mentions generated if not ... |
edd7ba01dc19e8ca95ccd195dc2d581d0a030db3 | elzbyfar/tkh-phase-1 | /week-007-solutions/song_script.py | 917 | 3.6875 | 4 | class Song:
def __init__(self, title, artist, genre):
self.title = title
self.artist = artist
self.genre = genre
self.price = 0.99
self.purchases = 0
self.total_sales = 0.00
def display_info(self):
return f"{self.title} by {self.artist}"
... |
955e9e3012e65c505411c40a6944e4859b3c276f | jpragasa/Learn_Python | /Basics/19e_Dictionaries_Challenge.py | 1,332 | 4.0625 | 4 | locations = {0: "You are sitting in front of a computer learning Python",
1: "You are standing at the end of a road before a small brick building",
2: "Random text 1",
3: "Random text 2, aaa",
4: "Random text 3",
5: "Random text 5"}
exits = {0: {"... |
018127f1a505764b72523f1c9028f1c47e352d2a | Hallldor/school_projects | /hlutaprof1/q4test2.py | 220 | 4.0625 | 4 | string1 = ""
for number in range(1, 11):
print("{:5}{:5}{:5}{:5}{:5}{:5}{:5}{:5}{:5}{:5}".format(number * 1, number * 2, number * 3, number * 4, number* 5, number * 6, number * 7, number * 8, number * 9, number* 10)) |
0d40b810e38ce707fd470d6339ef5281a10bf415 | mmatvienko/aes | /main.py | 2,070 | 3.875 | 4 | from aes import *
import argparse
parser = argparse.ArgumentParser(description='Use AES with ECB.')
parser.add_argument('--keysize', type=int, default=128,
help="""Define key size. Pick between
128-bit or 256-bit.""")
parser.add_argument('--keyfile', type=str,
... |
70223e604759aedf6744a49058c2ec6a23852501 | friedlich/python | /19年8月/8.09/np.argmax.py | 428 | 3.890625 | 4 | # np.argmax:返回沿轴最大值的索引值
import numpy as np
# 一维数组
A = np.arange(6).reshape(2,3)
print(A)
# 返回一维数组中最大值的索引值:
B = np.argmax(A)
print(B)
C = np.argmax(A, 1)
print(C)
B = np.argmax(A, 0)
print(B)
# 二维数组
# 要索引的数组:
E = np.array([[4,2,3],[2,3,4],[3,2,2]])
print(E)
print(E.shape)
F = np.argmax(E, axis=0)
print(F)
G = np.arg... |
56e6a2a3207025573241af5c717f44f46c9a4b8d | yuuee-www/Python-Learning | /Pygame/Heads or Tails Game/check.py | 889 | 3.828125 | 4 | from pythonds.basic.queue import Queue
def check(): # Code for checking the results
ans_check = input('Do you want to print the result in dorder they were played or sorted? \n \
[Enter "o" for in order and "s" for sorted]\n')
if ans_check == 'o':
f = open('result.txt','r') # ... |
3e2cbeb8177a4d636310543237df358405faaf78 | njaneto/dev-python | /scripts_py/Cap_5/exec_1.py | 397 | 3.875 | 4 | def main():
dia, mes, ano = eval(input("Digite o dia, mes e ano"))
data = "{0}/{1}/{2}".format(dia,mes, ano)
meses = ["Janeiro", "Fevereiro", "Marco", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro","Dezembro"]
mesStr = meses[mes - 1]
data2 = "{0} {1}, {2}".format(me... |
c2d5b9cdea7719e3ff7bac82f760b8a1311f6efd | Luciano-A-Vilete/Python_Codes | /BYU_codes/Vilete_004.py | 948 | 3.890625 | 4 | #Python Code 004
#Library import
import random
#Words lists
adjectives = ['attractive', 'brainy', 'brave', 'charming', 'smart']
animals = ['zebra', 'elephant', 'lion', 'dog', 'cat', 'bat']
verbs1 = ['run', 'scream', 'fly', 'walk', 'think']
exclamations = ['wow!', 'amazing!', 'great!!!', 'Wonderful!', 'Awesom... |
68bb58f6bda7d537d6f103431c8d0cc5df415660 | eencdl/leetcode | /python/countAndSay.py | 946 | 3.921875 | 4 | __author__ = 'don'
"""
The count-and-say sequence is the sequence of integers beginning as follows:
1, 11, 21, 1211, 111221, ...
1 is read off as "one 1" or 11.
11 is read off as "two 1s" or 21.
21 is read off as "one 2, then one 1" or 1211.
Given an integer n, generate the nth sequence.
Note: The sequence ... |
9439135f5c06e6dee6d7a2d0c06a7d4ff6728dc6 | romanannaev/python | /lessons stormnet/2019-10-24/dict.py | 1,323 | 3.640625 | 4 | # dictionary = {'andrey':27, 'alex':57, 'eugen':47, 'anfisa':37, 'nik':17,}
# dictionary2 = {}
# age = 20
# for i in range(16):
# dictionary2["name" + str(i)] = age + i
# # print(dictionary2)
# dictionary = dict(minsk=1000, gomel= 500, gomel= 600)
# # print(dictionary)
# a = [['minsk', 1000], ['gomel', 500]]
# f... |
dc4c3f9f928bc6dfd3ddf582f3b066cd9caf000a | saurav912/Codeforces-Problemset-Solutions | /CDFPangram.py | 124 | 3.6875 | 4 | x = int(input())
y = input()
y = y.upper()
y = list(y)
if len(set(y)) == 26:
print('YES')
else:
print('NO')
|
860a2c9d21dfa690cb15d59bb7df3b8fe8ebb380 | DrewRitos/projects | /AssignXIII("IXL").py | 7,956 | 4.1875 | 4 | import random
#I import random to generate all of the numbers within each problem
print("Welcome to IXL")
#Asks the user what they want to practice for the first time
op = input("What skill would you like to practice today?")
#Starts a loop that allows the user to take multiple tests multiple times
while True:
#The po... |
ca353ca9c936ea6dabcbb8a968ab5bb27d363228 | jhkang1517/python_basic | /python_basic_grammar/python기초_class예시.py | 273 | 4.03125 | 4 |
# Why use __init__ function?
class A(object):
def a(self, bag):
self.bag = bag
return print(bag)
class B(object):
def __init__(self, bag):
self.bag = bag
return print(bag)
CLSA = A()
CLSA.a("JH's bag")
CLSB = B("JH's bag")
|
f00fa6b718d5052a17abfb958ed57820fc2d0029 | GreatBahram/exercism-python | /space-age/space_age.py | 902 | 3.921875 | 4 | from typing import Callable, Optional
SECONDS_IN_EARTH_YEAR = 31557600
ORBITAL_PERIODS = {
'earth': 1,
'mercury': 0.2408467,
'venus': 0.61519726,
'mars': 1.8808158,
'jupiter': 11.862615,
'saturn': 29.447498,
'uranus': 84.016846,
'neptune': 164.79132,
}
def age_on_planet(seconds_alive... |
cdd7e7e9057f08c66230dca49fb5403401e36e9f | housseinihadia/HackerRank-Solutions | /Regex/06 - Assertions/03 - Positive Lookbehind.py | 800 | 3.734375 | 4 | # ========================
# Information
# ========================
# Direct Link: https://www.hackerrank.com/challenges/positive-lookbehind/problem
# Difficulty: Easy
# Max Score: 20
# Language: Python
# ========================
# Solution
# ========================
import re
regex_pattern = r'(?<=[1... |
93ba8c4d2e4433ff5f68d58660f75123a28cf0f7 | csalgar81/practice05 | /ocurrences_of_words.py | 451 | 3.921875 | 4 | """Program description"""
text = "this is a collection of words of nice words this is a fun thing it is"
dict1 ={}
words = text.split()
words_sorted = []
for element in words:
dict1[element] = 0
for element in words:
if element in dict1:
dict1[element] += 1
# print (dict1)
for key in dict1:
word... |
0b2a1af42020bc02e0f0c5e62133d5a74b0b936f | Tanner-York-Make-School/SPD-2.31-Testing-and-Architecture | /lab/refactoring/consolidate_duplicate_conditional_fragments.py | 701 | 3.703125 | 4 | """
By Kami Bigdely
Consolidate duplicate conditional fragments
"""
def add(mix, something):
mix.append(something)
return mix
def mix_ice_with_cream():
print('mixed ice with cream.')
return ['ice', 'cream']
def is_coffee(drink):
return 'coffe' in drink
def is_strawberry_milkshake(drink):
ret... |
a910e89a06e7d6771e5a7d92d2dfa82d3af12bf9 | joolink96/Python | /Quiz-표준체중.py | 943 | 3.65625 | 4 | #QUiz-표준체중
# 표준 체중을 구하는 프로그램을 작성하시오
# *표준 체중 : 각 개인의 키에 적당한 체중
# (성별에 따른 공식)
# 남자: 키(m) x키(m) x 22
# 여자: 키(m) x키(m) x 21
# 조건1 : 표준 체중은 별도의 함수 내에서 계산
# *함수명 : std_weight
# *전달값 : 키(height),성별(gender)
# 조건2 : 표준 체중은 소수점 둘째자리까지 표시
# (출력 예제)
# 키 175cm 남자의 표준 체중은 67.38kg 입니다.
def ... |
698bcbed9ba4a2fec1ab8395801405761e08322a | DowlutZuhayr/hello-world | /Homework3.py | 1,215 | 3.984375 | 4 | def main():
num1 = input("Enter a number: ")
if num1.isdigit():
print("Continue")
else:
num1 = input("Enter a valid number: ")
num2 = input("Enter another number: ")
if num2.isdigit():
print("Continue")
else:
num2 = input("Enter a valid number")
... |
ccb566e7a407e5ae523e7215d10a8f5132444ca0 | anilkumarreddyn/PythonProgramming | /Practicals/Practical1/MaxOutOf3.py | 264 | 4.25 | 4 | # 2 Write a program to get the maximum number out of three numbers
a, b, c = input("Enter Three Numbers: ").split()
a, b, c = int(a), int(b), int(c)
if a > b and a > c:
print("A is Max")
elif b > a and b > c:
print("B is Max")
else:
print("C is Max")
|
0aeab3c581a23559e4122b58d6d746cf6af7b02c | elisgitpage/ConwaysGameOfLife | /MainGame.py | 1,211 | 3.6875 | 4 | """
Matplotlib Animation Example
author: Jake Vanderplas
email: vanderplas@astro.washington.edu
website: http://jakevdp.github.com
license: BSD
"""
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import animation
# set up figure, axis, plot element
fig = plt.figure()
ax = plt.axes(xlim=(0,2),... |
ff8d7708f2311a7c4b57bcca37d7d8c6c3ca0152 | sergeymong/Python | /Python Data Science/Data Science from Scratch/linear_algebra.py | 1,777 | 3.703125 | 4 | from functools import reduce
import cProfile
from functools import partial
def vector_add(v, w):
return [v_i + w_i for v_i, w_i in zip(v, w)]
def vector_subtract(v, w):
return [v_i + w_i for v_i, w_i in zip(v, w)]
# its the same that reduce
# def vector_sum(*vectors):
# resul# t = vectors[0]
#
# f... |
4cf2ca1d92b0352f084c2ad65f96d032cae77b3f | Ayush-1211/Python | /Python Decorators/1. Higher Order Functions.py | 273 | 3.65625 | 4 | '''
A function is called Higher Order Function if it contains other functions as a parameter or
returns a function as an output
'''
def create_adder(x):
def adder(y):
return x + y
return adder
add_15 = create_adder(15)
print(add_15(10)) |
68e7b718a037df9de07e7976178042dc55083045 | tugsbayasgalan/6.857-PSET-1 | /code/2a.py | 2,001 | 3.515625 | 4 | from nltk.corpus import words
def xor(input1, input2):
assert len(input1) == len(input2)
result = ""
for index in range(len(input1)):
if input1[index] == input2[index]:
result += "0"
else:
result += "1"
return result
def convert_binary_to_word(binary_string):
... |
2ee0f61cbd96521fbd0aa71f12e54243b4b1a54e | rajatsharma98/CS677 | /HW/lyndon97_3_3_7.py | 2,670 | 3.59375 | 4 | '''7. what are the top 5 most popular items for each day of the week?
does this list stays the same from day to day?'''
import os
import pandas as pd
wd = os.getcwd()
input_dir = wd
file = os.path.join(input_dir, 'BreadBasket_DMS_output.csv')
df = pd.read_csv(file)
# out_file = os.path.join(input_dir, 'res_1.csv')
# ... |
a48d9c88b2b624cd3e014fe17cc02a464eda4977 | jon-moreno/learn-python | /ex18sd.py | 652 | 3.984375 | 4 | # this one is like your scripts with argv
def print_two(*args):
arg1, arg2 = args
print "arg1: %r, arg2: %r" % (arg1, arg2)
def print_any(*args):
x = 1
for y in args:
print "argument", x, y
x += 1
# ok, that *args is actually pointless, we can just do this
def print_two_again(arg1, arg2):
print "arg... |
68d5a6f6bccc26636eeb6dcbf68289493b776af9 | mat10tng/doctorEulerPython | /Euler37.py | 384 | 3.78125 | 4 | from doctorPrime import *
sm = 0
count = 0
number = 5
while count != 11:
prime = str(findPrime(number))
isTrucatable = True
for i in range(len(prime)):
if (not isPrime(int(prime[i::])) ) or ( not isPrime(int(prime[:len(prime)-i:])) ):
isTrucatable = False
print(prime)
number+= 1
if isTrucatab... |
b3530616126a70c407f8fb45f2ac2a1c8970d133 | MyeongJaeKim/deeplearning | /exercise/linear_regression/linear_regression_bias.py | 1,021 | 3.65625 | 4 | import tensorflow as tf
# 테스트 데이터
x = [1, 2, 3]
y = [1, 2, 3]
# 변수 선언
a = tf.Variable(tf.random_uniform([1], -10.0, 10.0))
X = tf.placeholder(tf.float32, name="X")
Y = tf.placeholder(tf.float32, name="Y")
b = tf.Variable(tf.random_uniform([1], -10.0, 10.0))
# Y = aX + b
hypothesis = tf.add(tf.multiply(a... |
0424ae97e61552837e1ca47af433f4588939bf8b | itroulli/HackerRank | /Python/Collections/002-defaultdict_tutorial.py | 363 | 3.671875 | 4 | # Name: DefaultDict Tutorial
# Problem: https://www.hackerrank.com/challenges/defaultdict-tutorial/problem
# Score: 20
from collections import defaultdict
d = defaultdict(list)
n, m = map(int, input().split())
for i in range(1, n+1):
d[input()].append(i)
for _ in range(m):
b = input()
if b in d:
... |
66293a7abf3d36dc53d384df2fa86c56bf7ca251 | sreeaurovindh/code_sprint | /recursion/fmax.py | 210 | 3.53125 | 4 | def fmax(arr,mVal,n):
if n == len(arr):
return mVal
else:
if mVal <arr[n]:
mVal = arr[n]
return fmax(arr,mVal,n+1)
a = [3,4,1,55,66,2]
print(fmax(a,a[0],0)) |
d3f3ac2c017d34a0c093ea810abe7b991fc0a596 | JingruWu10/thinkful | /linear_regression.py | 2,800 | 3.65625 | 4 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import statsmodels.api as sm
loansData = pd.read_csv('https://github.com/Thinkful-Ed/curric-data-001-data-sets/raw/master/loans/loansData.csv')
## cleaning the file
loansData['Interest.Rate'] = loansData['Interest.Rate'].str.rstrip('%').a... |
c11ec7fa0262ba1bee19b19d5454a1519799a98a | rodgers2000/Projects | /udacity/data-structures-and-algorithms/notes/basic-algorithms/knapsack.py | 483 | 3.875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 1 14:34:01 2019
@author: mrodgers
"""
def max_value(knapsack_max_weight, items):
lookup_table = [0] * (knapsack_max_weight + 1)
for item in items:
for capacity in reversed(range(knapsack_max_weight + 1)):
if item.weigh... |
404ef32c163524500dfdac707af3e8abedabc641 | shyfeel/myTestCode | /Python/python编程从入门到实践/helloworld.py | 94 | 3.625 | 4 | #-*- coding: UTF-8 -*-
char = ["a","b","c","d"]
#a = char.pop(0)
char.remove("b")
print char
|
aa243adf437344f246ff3acbba31fcaafcc727f6 | apolloLemon/CalculPython_S4 | /lambda.py | 120 | 3.578125 | 4 | def polynome(a,b,c):
return lambda x : a*x**2 + b*x + c
f = polynome(1,1,1)
g = polynome(2,0,-3)
print f(3)
print g(3) |
ca69381a8623f148bc036407276f5e076fd51e56 | AnshVaid4/Python | /Login password cracking/For Windows/exe file codes/CODE CryptHashes EXE.py | 2,200 | 3.78125 | 4 | import bcrypt
import time
print(" // // ")
print(" // // ")
print(" // // ")
print(" //======// _____ ... |
c5284dbcfbd1c74f4d00b3392e3b3e564fa9b287 | yintrigue/awesome-baby-names | /src/abn/utils/performance.py | 1,053 | 3.734375 | 4 | """The performance modules includes tools to manage algorthm performance.
"""
import time
from typing import Callable
class Timer:
"""Timer class provides tools to time code performance.
"""
def __init__(self) -> None:
__start = 0
__end = 0
def start(self) -> None:
"""Start t... |
74a8bc289eb1f48fe80a28eadff2d9816983f823 | begsener/PythonCourse | /ex5.py | 1,514 | 4.125 | 4 | <<<<<<< HEAD
#exercise 5
# " double quote means that it is a string
my_name = 'Zed A. Shaw'
my_age = 35
my_weight = 180 #lbs
my_height = 74
my_eyes = 'blue'
my_teeth = 'white'
my_hair = 'brown'
print ("Let's talk about %s." % my_name) #%s means it is a string
print ("He's %d inches tall." % my_height) #%d means it i... |
c646fb8626cdfa8ea6d4d52f178ec2845096b617 | ebookleader/Programmers | /Level1/makePrimeNumber.py | 946 | 3.625 | 4 | from math import sqrt
from itertools import combinations
def solution(nums):
sum_list = []
answer = 0
# 3중 for문 사용하는 방법
for i in range(len(nums)):
for j in range(i+1, len(nums)):
for k in range(j+1, len(nums)):
sum_list.append(nums[i]+nums[j]+nums[k])
for s in su... |
12268451d5a76026b9bff7ff8ea370daaf7dff73 | niranjan09/DataStructures_Algorithms | /DP/maxSumContiguousArray.py | 650 | 3.53125 | 4 | # Kadane's algorithm
def getMaxSumContiguousArray(arr):
start_max, end_max, max_sum= 0, 0, float('-inf')
start_current, end_current, current_sum = 0, 0, float('-inf')
for numi, num in enumerate(arr):
if(num > current_sum + num):
start_current = end_current = numi
current_sum... |
9f406f26c666cbf63fb3bf502c9a5bcdbe041bb6 | z502185331/leetcode-python | /150-Evaluate-Reverse-Polish-Notation/solution.py | 800 | 3.671875 | 4 | class Solution(object):
def evalRPN(self, tokens):
"""
:type tokens: List[str]
:rtype: int
"""
if not tokens:
return 0
stack = []
operators = ['+', '-', '*', '/']
for token in tokens:
if token not in operators:
... |
34b97f78e3a3319dc5c6019228d59ebda2e877ab | fred-yu-2013/avatar | /pyexamples/tests/test_class.py | 940 | 3.90625 | 4 | # -*- coding: utf-8 -*-
__author__ = 'Fred'
class MyClass():
def __init__(self):
self.counter = 100
obj = MyClass()
print obj.counter
# del后无法添加
# del obj.counter
# AttributeError: MyClass instance has no attribute 'counter'
# print obj.counter
obj.name = 'John'
obj.id = 5
print obj.id
# 可以通过__dict__... |
5fb64ed3ff919136f22a4637309a19d016d6ca07 | gitrookie/codesnippets | /pycode/sortingalgos.py | 230 | 3.640625 | 4 | # sortingalgos.py
def insertsort(l):
length = len(l) - 1
for i in range(length):
j = i + 1
num = l[j]
while j > 0 and l[j-1] > num:
l[j] = l[j-1]
j -= 1
l[j] = num
|
1a635ba93d596e08f2954f3a53de5ddfc7be28f2 | VinothRajasekar/practice | /graphs/knightsboard.py | 1,041 | 3.640625 | 4 | from collections import deque
DIRECTIONS = [(2,1),(2,-1),(-2,1),(-2,-1),(1,2),(1,-2),(-1,2),(-1,-2)]
def find_minimum_number_of_moves(rows, cols, start_row, start_col, end_row, end_col):
def get_neighbors(lcoation):
neighbors =[]
for i, j in DIRECTIONS:
new_r, new_c = location[0] + i ,... |
6bbcac2bbed36c4bb59e1055693bf31b120f014e | Firmino-Neto/Exercicios---Python--UFC- | /Função e vetores -py/38.py | 526 | 3.9375 | 4 | def Ordenada():
print ("Digite os elementos da lista: ")
i = 0
c = []
while i < 10:
n = int(input("Digite um numero: "))
if i == 0 or n > c[-1]:
c.append(n)
i = i + 1
else:
j = 0
while j < len(c):
if n <= c[j]:
... |
ceae6bb3ad7b07e8fbd5a40fc9d41448a47a94f3 | srangar03/InteractiveProgramming | /test.py | 6,001 | 3.75 | 4 | import pygame
# Define some colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
def draw_stick_figure(screen, x, y):
# Head
pygame.draw.ellipse(screen, BLACK, [1 + x, y, 10, 10], 0)
# Legs
pygame.draw.line(screen, BLACK, [5 + x, 17 + y], [10 + x, 27 +... |
722df7e1799052de3ba62399b04c860bad8dfede | kzbigboss/scc-csc110 | /module 3/KazzazMarkEXTR01SecHY1Ver02.py | 1,306 | 4.3125 | 4 | # Project: EXTR: 1 - Triangle (KazzazMarkEXTR01SecHYVer01.py)
# Name: Mark Kazzaz
# Date: 2017-07-12
# Description: This program will draw a triangle based on user input of height
def main():
# greet user, share input requirement
print('Welcome to the trianger printer!'
,'Pleas... |
ffaba0f0e5ebeaa43601228c908422529f0771f9 | nineninenine/space-invaders | /game_functions.py | 10,758 | 3.640625 | 4 | import sys
import pygame
import sys
from time import sleep
from bullet import Bullet
from alien import Alien
def check_keydown_events(event, ai_settings, screen, ship, bullets):
"""respond to key presses"""
#if the event.key attribute is a right arrow key(pygame.K_RIGHT), move the ship right
#by ticking moving_rig... |
4ed34673a26cef8aa90e13d95c8077d72e8aee40 | dunn0052/Personal-projects | /dice_fctns.py | 962 | 3.984375 | 4 | #dice functions
def factorial(n):
if(n < 0):
print("can't be negative")
return
elif(n%1 > 0):
print("must be whole number")
return
if(n == 0):
return 1
if (n > 1):
n = factorial(n-1) * n
return n
#recursive itera... |
032b62b1801b589d655cf84e9b69485f086c2938 | edobranchi/Hashing | /main.py | 4,107 | 3.84375 | 4 | import Linear_Hash
import Chained_Hash
import plot
def print_menu(): ## Your menu design here
print(30 * "-", "MENU", 30 * "-")
print("1. Popolazione Hash Lineare")
print("2. Popolazione Hash Concatenato")
print("3. Grafici Hash Lineare")
print("4. Grafici Hash Concatenato")
print("5. Test Ri... |
e0a2e3d78eb4588b908e2f09968bfcd033255ce8 | fabsta/url_downloader | /src/FileDownloader.py | 4,950 | 3.515625 | 4 | from urllib2 import urlopen, URLError, HTTPError
from urlparse import urlparse
import os.path
import imghdr
class FileDownloader:
'FileDownloader class that handles file downloads'
def __init__(self):
"""
constructor method for FileDownloader. Initiates an empty array of urls
Defines allowed image types
... |
cf84c7a1f5f352a5f2748511aa8ca29f2ae1aaf5 | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/sieve/e9021824770448cc9970aa356bcc1694.py | 190 | 3.515625 | 4 | def sieve(limit):
primes = range(2, limit)
for i in primes:
not_primes = [x for x in primes if x % i == 0]
primes = [x for x in primes if x not in not_primes or x == i]
return primes
|
12bbbdf87dfa78ad6d51264d706393fddc20b14c | surbbahl/sdet | /Listchecker.py | 147 | 3.609375 | 4 | numlist=[10,20,40,50,40]
firstelement=numlist[0]
lastelement=numlist[-1]
if firstelement==lastelement:
print(True)
else:
print(False) |
98d3ae2af10b2d67fc6b238421ec4f43831ee4d9 | edt-yxz-zzd/python3_src | /script/try_python/try_func_keyword.py | 566 | 3.921875 | 4 |
'''
we can not:
f(self, a, **kw)
self.f(a, self=1) # Error
'''
def f(a, **kw):
return a+kw['a']
try:
f(1, a=2)
# TypeError: f() got multiple values for argument 'a'
except TypeError:pass
else: raise
class C:
def f(a, **kw):
return a+kw['a']
def g(self, *a, **kw):
print(a)
... |
91965c127a0cc4acb36c6eaded097a3f2e204682 | FrozenLemonTee/DSAA | /algorithm/Bubble_sort.py | 1,038 | 3.765625 | 4 | from DSAA.data_structure.basic.init_structure import initializeLinkedList
from DSAA.algorithm.Nodes_changing import exchangeNode
import time
def bubbleSort(my_linked_list):
if my_linked_list.length() == 0 or my_linked_list.length() == 1:
pass
elif my_linked_list.length() == 2:
if my_linked_lis... |
4e23b285ea4e1888bc398f736f62c42efbf52e94 | jae-hun-e/python_practice_SourceCode | /뼈대코드/5/5-18.py | 286 | 3.828125 | 4 | def insert(x,ss):
def loop(ss,left):
if ss != []:
if x <= ss[0]:
pass # Write your code here.
else:
pass # Write your code here.
else:
left.append(x)
return left
return loop(ss,[]) |
47d3501563c96b471dad29117f192e60e673f144 | GezhinOleg/Py_Dev_L4 | /proba.py | 599 | 3.6875 | 4 | import json
from pprint import pprint
class CountryIterate:
def __init__(self, start, end, interval_size = 2):
self.start = start - interval_size
self.end = end
self.interval_size = interval_size
def __iter__(self):
return self
def __next__(self):
... |
e4563c71f4493db051ce2fb24e905c8be30d5aaa | zhangxinzhou/PythonLearn | /helloworld/chapter05/demo01.07.py | 268 | 4 | 4 | str1 = '@明日科技 @扎克伯格 @abc'
count = str1.count('@')
print("字符串:", str1, "包含", count, "个@符号")
print(str1.count('@'))
print(str1.find('@'))
print(str1.count('#'))
print(str1.find('#')) # index与find类似,不过找不到时会抛异常
|
0d3ee274b09f506103419a3d5e2d443c0d38b8c0 | snigdhasen/myrepo | /examples/ex11.py | 1,084 | 3.890625 | 4 | '''
various file reading techniques
'''
import json
def read_file_1(filename):
file = open(filename, 'rt')
for line in file.readlines(): print(line, end='')
file.close()
def read_file_2(filename):
file = open(filename, 'rt')
# the 'file' object itself is iterable; no need to call .readlines()
... |
0000e64b5789f5ee9ed16b73462406bec84f9e1f | mandos1995/online_judge | /BOJ/단계별로 풀어보기/ch02_if문/1300_두 수 비교하기.py | 235 | 3.8125 | 4 | """
문제
두 정수 A와 B가 주어졌을 때, A와 B를 비교하는 프로그램을 작성하시오.
"""
num1, num2 = map(int, input().split())
if num1 > num2:
print('>')
elif num1 == num2:
print('==')
else:
print('<') |
cec3bd9b6d105269e6be4613c5c078105b6a368d | shankar7791/MI-10-DevOps | /Personel/Siddhesh/Python/24Feb/Operator4.py | 164 | 4.15625 | 4 | # Logical Operators
x = int(input("First number : "))
y = int(input("Second number : "))
if x is y :
print("True")
elif x is not y :
print("False")
|
a06d251656d70de9cf2669ad98288f791db8af37 | bunshue/vcs | /_4.python/__code/Python大數據特訓班(第二版)/ch03/ch03_all.py | 10,663 | 3.796875 | 4 | # filewrite1.py
content='''Hello Python
中文字測試
Welcome'''
f=open('file1.txt', 'w' ,encoding='utf-8', newline="")
f.write(content)
f.close()
# filewrite2.py
content='''Hello Python
中文字測試
Welcome'''
with open('file1.txt', 'w' ,encoding='utf-8', newline="") as f:
f.write(content)
# fileread1.py
with open('file1.t... |
037e5af0c260d4f0ba1ab51341d8ecdcd58485be | busz/my_leetcode | /python/Pascals_Triangle.py | 1,045 | 3.890625 | 4 | '''
Created on 2014-3-22
Leetcoder : Pascal's Triangle
Problem :
Given numRows, generate the first numRows of Pascal's triangle.
For example, given numRows = 5,
Return
[
[1],
[1,1],
[1,2,1],
[1,3,3,1],
[1,4,6,4,1]
]
@author: xqk
'''
class Solution:
# @return a list of lists of integers
de... |
66f597aec9d1bad37c9688a6496bb01030718947 | vanillasky/skogkatt | /commons/util/numeral.py | 821 | 3.828125 | 4 | from typing import Any
def to_decimal(value: str) -> int or float:
"""
int 또는 float 으로 형변환
:param value: string value
:return: int or float or None if cannot convert type
"""
result = value.lstrip('0')
if result == '' or result == '00':
return 0
try:
result = int(value... |
28a274c712fb074c6b8e71fc8ec1b37721de11d3 | Diegotmi/Des_python | /Calculadora.py | 184 | 4 | 4 | primeiro_numero = int(input('Insira seu primeiro número:'))
segundo_numero = int(input( 'Insira o segundo número:') )
print('Soma dos numeros é:', primeiro_numero + segundo_numero) |
1c80635c0eb3227a9ffbc6d851fc1544739e0372 | EmperoR1127/algorithms_and_data_structures | /Stacks and Queues/ArrayStack.py | 959 | 3.84375 | 4 | class ArrayStack:
"""LIFO Stack implementation using a Python list as underlying storage."""
def __init__(self):
"""A list used to store data"""
self._data = []
def __len__(self):
return len(self._data)
def is_empty(self):
return len(self._data) == 0
def push(self,... |
81546e178116cd7f3d4a8da67d1b93e33f7e2e4f | Hoangxt/PythonK | /Tutorial/ExRandom Password Generator/Random_Password_Generator.py | 777 | 4 | 4 | '''
Project: Random Password Generator
Password: adbXYZ-69_96
'''
import string
import random
LETTERS = string.ascii_letters
NUMBER = string.digits
PUNCTUATION = string.punctuation
def password_generator(length=8):
printable = f'{LETTERS}{NUMBER}{PUNCTUATION}'
printable = list(printable)
random.shuffle(p... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.