blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
b5fbd542a20458bb7108bc90b87bbbe7f7a44298 | nanahyunpark/python_study | /2857.py | 687 | 3.5 | 4 | # 1. 5줄 모두 입력 받고 배열에 집어 넣기
# 2.
# 3. 세로로 5글자씩 어딘가에 저장해서 차례대로 출력해야함
#input
# ABCDE
# abcde
# 01234
# FGHIJ
# fghij
nums = []
# n1 = ""
# n2 = ["", "", "", "", ""]
n3 = []
for i in range(0,5):
nums.append(input())
# for i in range(0,5):
# print(nums[i])
for i in range(0,15):
n3.append("")
for ... |
455301ad530be8383ada6040522f1cede5a80792 | nanahyunpark/python_study | /579.py | 341 | 3.96875 | 4 |
def sort_nums(nums):
nums.sort()
nums.reverse()
return nums
def main():
n = input()
nums = input().split()
for index, value in enumerate(sort_nums(nums)):
nums[index] = int(nums[index])
for index, value in enumerate(sort_nums(nums)):
print(value, end=" ")
if(__name__ == '_... |
86a2a0e1fa38f140ea37cc553e85dbc93c980338 | victor-robles-du-edu/PythonRepo | /Stocks.py | 841 | 3.875 | 4 | """
**********************************************************************
Description: Stocks Class for stocks prices movements
Author: Victor Robles
Project: Assigment 10
Revision: 08/09/2020
**********************************************************************
"""
class Stocks():
def __init__(self, symbol... |
80d04c2f830331fa16916e68aacbdb947f301dc0 | AbeTavarez/100_Days_of_Python | /Day_2/sandbox.py | 386 | 4.125 | 4 | ##### SINGLE NUMBER ADDER ###################
two_digit_number = input('Please enter a two digit number: ') # user input
first_digit = int(two_digit_number[0]) # grabs the first char and convert it to an int
second_digit = int(two_digit_number[1]) # grabs the second char and convert it to an int
sum = first_digi... |
98d19f5f3e1b833781c622952a6c21de19dbb246 | sajjass/basic_programs | /bitdegree/inheritance.py | 1,081 | 3.875 | 4 | # Classes and Objects
# Properties
# Behaviours
# initializers and instances
# inheritance
class super_inheritance():
#initialize properties
var1 = 0
var2 = 0
var3 = ""
input = 2
input_1 = 0
def __init__(self, var1, var2, var3):
self.var1 = var1
self.var2 = var2
sel... |
10327b969a84c4a8997214f78ff39e6a66d020ff | sajjass/basic_programs | /comprehension.py | 270 | 3.734375 | 4 | from __future__ import print_function
x=[[10,20,30],[40,50,60],[70,80,90]]
print(x)
print("Elements Row wise:")
for r in x:
print(r)
print("Elements in Matrix style:")
for i in range(len(x)):
for j in range(len(x[i])):
print(x[i][j],end=' ')
print() |
568f7bc612a9acac9420032fd0284fa978ce7f17 | floryken/Ch.12_Animation | /12.0_Jedi_Training.py | 866 | 4.28125 | 4 | '''
Sign your name:Kenny Flory
All questions are about the final code in Chapter 12:
1.) Where is the ball's original location?
320,240
2.) What are the variables dx and dy?
speed it moves in a direction
3.) How many pixels/sec does the ball move in the x-direction?
180
4.) How many pixels/sec does the ball move in ... |
12bae42cb7af3eb624245352c60635bd69ac5973 | RatnamChanakya/Beginner_s-Den | /Q1-Multiplication.py | 77 | 3.78125 | 4 | x = range(1,11)
y = int(input('Enter a number:'))
for n in x:
print(y*n)
|
66c7f8ce6bd61615449f2c76132da27e40ab3183 | ZapyRay/Algors1 | /week2_algorithmic_warmup/4_least_common_multiple/lcm.py | 242 | 3.625 | 4 | # Uses python3
import sys
def lcm_naive(a, b):
for l in range(max(a,b),a*b + 1,min(a,b)):
if l % a == 0 and l % b == 0:
return l
return a*b
x = input().split()
a = int(x[0])
b = int(x[1])
print(lcm_naive(a, b))
|
5bec0ce1a5472ec0afb474ddb782ecec8dea3bfc | Partha-debug/Books_info | /oop_methord/front_end.py | 3,481 | 3.609375 | 4 | from tkinter import *
from back_end import Database
database = Database()
def get_selected_row(event):
global selected_row
index =list_box.curselection()[0]
selected_row = list_box.get(index)
title_entry.delete(0,END)
title_entry.insert(END,selected_row[1])
author_entry.delete(0,END... |
03fc364e1bde70af0063cf7e2c0abe241bf1bfdd | andriarna98/TileTraveller | /Timetraveller1.py | 436 | 3.859375 | 4 | # 9 if statements sem kanna hvar leikmadur er staddur a x/y
# True/False fyrir directions sem eru i bodi
# Ef direction er true tha er haegt ad fara i tha att
# alltaf kannad fyrst ef x er 3 og y er 1, ef thad er satt tha kemur victory
x = 1
y = 1
North = True
West = False
South = False
East = False
if x = 1 and y = ... |
b5e364a2c49c9b853fd38d714533294932617e14 | decchu14/Python-Image-Processing | /2_ImageProcessing.py | 1,016 | 3.796875 | 4 | # this simple code is to filter or convert the image
from PIL import Image, ImageFilter
img = Image.open('pokedex/pikachu.jpg')
# will filter the image to blur or smooth or sharpen and store it in variable named filtered_img
filtered_image = img.filter(ImageFilter.BLUR) # SMOOTH, SHARPEN
# will save the filtered_img... |
f351eabfd7b4350b8c9a6d99ccebadc1a680b98d | NatanielOtero18/pythonAdvanceExamples | /enumExample.py | 298 | 4.21875 | 4 | from enum import Enum
class FoodWithoutEnum:
SANDWITCH = 1
SALAD = 2
MEAT = 3
FISH = 4
# enum
class Food (Enum):
SANDWITCH = 1
SALAD= 2
MEAT=3
FISH=4
print(FoodWithoutEnum.FISH)
print(Food.SALAD)
if Food.FISH is Food.FISH:
print("Aqui tiene su pescado sr") |
7b2f155c7b9fd5e1f5962ed750d3006ba4ec38ba | fraperr/python | /ZCasino.py | 1,759 | 3.90625 | 4 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
import random
import math
import monPremierPackage.nombre
sommeDeDepart = monPremierPackage.nombre.saisirEntier("Quelle somme de départ: ")
mise = 5
while sommeDeDepart > 0:
mise = monPremierPackage.nombre.saisirEntier("Combien voulez-vous miser: ")
# Choisir un nom... |
01b55438798a61ab9463788cbeebd28bd3f92ca6 | safnuk/itemset-mining | /dataset.py | 1,826 | 3.921875 | 4 | import random
def construct(num_transactions,
max_basket_size,
total_items,
likely_items,
likely_draw):
"""Generate a list of transactions.
Used to analyze apriori and FP-growth algorithms. Implemented as
a list of sets of non-negative integers.
... |
14f2a71ee83ced03ac234f5323ccebbcb0de7d46 | i5uhail/celery_notes_and_codes | /Multithreading_Module/5_conditional_statements-consumer-producer-problem.py | 2,344 | 4.0625 | 4 | import threading
import time
import random
queue = []
MAX_ITEMS = 10
# A factory function that returns a new condition variable object.
# A condition variable allows one or more threads to wait until
# they are notified by another thread.
condition = threading.Condition()
# class should be inherited from the th... |
87f6b4c9ad3b83ee5c0ad76584aebde25877527c | i5uhail/celery_notes_and_codes | /C2_Exception_handling_basics/test.py | 433 | 3.9375 | 4 |
class SalaryError(Exception):
pass
# also an example for the use of finally in try and except block.
while True:
try:
salary = input("Please enter your salary: ")
if not salary.isdigit():
raise SalaryError()
print(salary)
break
except SalaryError:
print(... |
d7da3f465fe4c5a0972c37e414710df52435c9d9 | Rohithcoder/numbersgame | /NumbersGame.py | 537 | 4.21875 | 4 | import math
num = (int(input("Enter a Number: ")))
if num%2 != 0:
print(f"{num} is an odd number")
else:
print(f"{num} is an even number")
root = math.sqrt(num)
if int(root + 0.5) ** 2 == num:
print(f"{num} is a perfect square")
else:
print(f"{num} is not a perfect square")
multiple = (input("Would you ... |
ebb6918f54504751a5a517166896cff0600f8478 | begoon/stuff | /languages/python/date_delta/date_delta.py | 926 | 3.765625 | 4 | from datetime import datetime, timedelta
# Get current date
now = datetime.today()
print "Current date:", now
# This function returns the day of the week:
# 0 - Mon, 1 - Tue, 2 - Wed, 3 - Thu, 4 - Fri, 5 - Sat, 6 - Sun
day_of_week = now.weekday()
# Offsets in days we need.
# Mon: +1, Tue: +1, Wed: +1, Thu: +1, Fri:... |
e7fab90055edab4ca5c5b46cce0630b5b2876fba | vineetmidha/Online-Challenges | /Displacement.py | 484 | 3.671875 | 4 | https://www.hackerrank.com/contests/all-india-contest-by-mission-helix-a-11th-july/challenges/easy-2-cc/problem
def get_answer(t, x):
return t * 60 * x // 2
tests = int(input())
for _ in range(tests):
t, x = map(int, input().split())
print(get_answer(t, x))
'''
Explanation:
Tot... |
4e77b163debff62b80053952467c8dab0ad40391 | suraj0803/MachineLearning | /MACHINE LEARNING/2.Linear Regression/LinearRegression1.py | 3,389 | 4.125 | 4 | # Import Modules/Packages
import pandas as pd
import numpy as np
import sklearn
from sklearn import linear_model
from sklearn.utils import shuffle
# Loading in our data
data = pd.read_csv("C:\\Users\\User\\Desktop\\MACHINE LEARNING\\student-mat.csv", sep=";")
#since our data is seperated by semicolon we nee... |
089e6b9cc207fc3d975db50ef008381fecd28f40 | kaat0/OpenLinTim | /src/tools/visum-transformer/common/src/common/model/net.py | 3,135 | 3.5625 | 4 | import logging
from typing import Dict, List
class NetSection:
"""
Class representing a section of a net file
"""
def __init__(self, name: str, header: [str]):
"""
Create a new section with the given name and header
:param name: the name of the section
:param header: th... |
d6239065f962ffbb0cc2683a5de5e98aa741fa12 | samgeen/hackandslash | /src/CmdVars.py | 589 | 3.625 | 4 | '''
Created on 2 Mar 2014
@author: samgeen
'''
import Animals
class Player(object):
def __init__(self):
self._name = "punk"
def Name(self, newname=None):
'''
If newname is not None, set the Player's name to newname
Return: player's name
'''
if not newna... |
19144e803a0332d443059af2303ec3f8424f785b | sreshtha10/10_Days_of_Statistics_Hackerrank | /Day 2/Basic Probability.py | 394 | 3.75 | 4 | dice1 = [1,2,3,4,5,6]
dice2 = [1,2,3,4,5,6]
total = len(dice1)*len(dice2)
total_possibilities = 0
sample_space = []
for i in dice1:
for j in dice2:
sample_space.append([i,j])
for i in range(len(dice1)):
for j in range(len(dice2)):
if (dice1[i]+dice2[j]) <= 9:
total_possib... |
137eec6aef4cae34c6c34caa03e9837a536b232e | wesreisz/intro_python | /PythonApplication1/05_HowLongToComplete/HowLongToComplete.py | 632 | 3.953125 | 4 | import datetime
TITLE = 'How Long do ya Got?'
print("-"*40)
print("{:^40}\n".format(TITLE))
print("-"*40)
deadlineInput = input("Input project deadline (yyyy/mm/dd): ")
deadlineDate = datetime.datetime.strptime(deadlineInput, "%Y/%m/%d")
currentDate = datetime.datetime.today()
print("You have:")
delta = deadlineDat... |
91b61e2850205764a4accf14e1504b5ff61a8dd2 | NoahWhite1115/9tactoe-backend | /src/GameMeta.py | 1,575 | 3.703125 | 4 | from abc import ABC, abstractmethod
from datetime import datetime
class GameMeta(ABC):
def __init__(self):
self.gameState = self.makeGameState()
self.players = {}
self.spectators = []
self.gameWon = False
self.timestamp = datetime.now()
def getStateDict(self):
r... |
4285b8346196ae3fb390f22d6c20a9708faa89aa | Dawn0709/MaySoftwareTest | /ITPyCode/hw02_register_def.py | 953 | 4.125 | 4 |
# 虚拟数据
db = [{"username":"liuyun","password":"test","age":18}]
"""
方法:注册方法
参数:username,password
返回值:true:成功/false:失败
"""
def reg(username,password):
# 判断用户名和密码
if username == "" or password == "":
print("用户名或密码不能为空")
return False
# 判断用户名是否已经存在
for user in db:
if user.get(... |
9b6073d2a60025019c074a3d7ddbbd481f581a0d | CodeRaker/learningMatplotlib | /main-3.py | 285 | 3.53125 | 4 | import matplotlib.pyplot as plt
# random values
stock_price = [5,22,33,21,24,22,45,43,54,21,22,33,44,55,66,43,21,44,54]
# bins are used for sorting values into what they represent
bins = [0,10,20,30,40,50,60,70,80]
plt.hist(stock_price, bins, histtype='bar', rwidth=0.8)
plt.show() |
12d6f9e6046aadf9bc3d6340657f198ff3221e04 | cvk77/project-euler | /Python/problem5.py | 225 | 3.703125 | 4 | def is_divisable_by_all(n, upto):
for d in range(upto+1, upto / 2, -1):
if n % d != 0:
return False
return True
prims = 2*3*5*7*11*13*17*19
p = prims
while not is_divisable_by_all(p, upto=20):
p = p + prims
print p |
01c7931b4ac0e076f8c1aa22c294efe5489340a5 | cvk77/project-euler | /Python/problem4.py | 314 | 3.625 | 4 | def is_palindrome(x):
x = str(x)
for i in range(0, len(x) / 2):
if x[i] != x[-i-1]:
return False
return True
l = []
for x in range(900, 1000):
for y in range(900, 1000):
if is_palindrome(x*y) and not x*y in l:
l.append(x * y)
l.sort()
print l |
9d6ea823c7744e1303bd1778f95fe84ea7f4fc3f | franciscorafart/minimum-divisor-python | /euler5.py | 752 | 4.125 | 4 | #function that finds minimum divisor
def divisor(n):
#start with the value as it is true
isFactor = True
smallest = 10
while(isFactor):
for x in range(1,n):
#if smallest isn't divisible by x, then isFactor is false and we break the for loop
if(smallest%x != 0):
... |
4b9989ed0963745f22ce1206386b69f2de053169 | repaocha/procedure | /0002/mysql.py | 994 | 3.546875 | 4 | #-*- coding:utf-8 -*-
#将0001题生成的200个激活码保存到MySQL关系型数据库中.
import uuid
import sqlite3
def generate(num, length):
result = []
while True:
uuid_id = uuid.uuid1() #使用主机ID, 序列号, 和当前时间来生成UUID.
temp = str(uuid_id).replace('-', '')[:length] #删去字符串中的'-',取出前length 个字符
... |
e6368a31abe9aa3ce2ff194e81f13f244d88046d | MateoPereyra88/DesarrolloDeSistemas6to1raCPOK | /Primera guía (python)/2.f.py | 1,204 | 3.953125 | 4 | def main():
valorProducto = float(input("Ingrese el valor del producto: "))
variacion = cuotas = 0
print("Planes disponibles: ")
print("1.Totalmente contado con descuento del 15%.")
print("2.Mitad contado y 2 cuotas iguales del resto. El precio incremento 18%.")
print("3.La tercera parte co... |
c21fd3a9633769e86105627b7d73d3c5da972626 | jerry-mkpong/DataCamp | /Introduction_to_Python_for_Finance/2.Lists/Using list methods to add data.py | 693 | 4.5625 | 5 | '''
You can use the .append() and .extend() methods to add elements to a list.
The .append() method increases the length of the list by one, so if you want to add only one element to the list, you can use this method.
x = [1, 2, 3]
x.append(4)
x
[1, 2, 3, 4]
The .extend() method increases the length of the list by t... |
c4418609b8a794aad9cc52e7ab45f07b5264abd2 | jerry-mkpong/DataCamp | /Introduction_to_Python/3.Functions/Import_package.py | 721 | 4.375 | 4 | '''
As a data scientist, some notions of geometry never hurt. Let's refresh some of the basics.
For a fancy clustering algorithm, you want to find the circumference, C, and area, A, of a circle. When the radius of the circle is r, you can calculate C and A as:
C = 2πr
A = πr2
To use the constant pi, you'll need the m... |
82d746d865712b4466be1b1039a4b654a30ab2df | jerry-mkpong/DataCamp | /Deep_Learning_with_Keras_in_Python/4.Advanced_Model_Architectures/De-noising like an autoencoder.py | 925 | 3.875 | 4 | '''
Okay, you have just built an autoencoder model. Let's see how it handles a more challenging task.
First, you will build a model that encodes images, and you will check how different digits are represented with show_encodings(). You can change the number parameter of this function to check other digits in the conso... |
fc2505d11f9da169c09def8677575133d30b849e | jerry-mkpong/DataCamp | /Introduction_to_Python_for_Finance/1.Welcome_to_Python/Determining types.py | 316 | 3.828125 | 4 | '''
Python has a built-in command type() that can determine the type of a variable or literal value. Let's determine the data types of the variables you created in the last exercise.
'''
# Type of company_1
print(type(company_1))
# Type of year_1
print(type(year_1))
# Type of revenue_1
print(type(revenue_1))
|
ff9f9814bca954e8e338ffde5e64534736bc7cc2 | jerry-mkpong/DataCamp | /Intermediate_Python_for_Data_Science/4.Loops/Loop over DataFrame (2).py | 469 | 3.796875 | 4 | '''
The row data that's generated by iterrows() on every run is a Pandas Series. This format is not very convenient to print out. Luckily, you can easily select variables from the Pandas Series using square brackets:
for lab, row in brics.iterrows() :
print(row['country'])
'''
# Import cars data
import pandas a... |
073583acfac0fa00b56e42c8c4bc17ee3c456fc5 | jerry-mkpong/DataCamp | /Deep_Learning_with_Keras_in_Python/3.Improving_Your_Model_Performance/Comparing activation functions.py | 1,092 | 3.796875 | 4 | '''
Comparing activation functions involves a bit of coding, but nothing you can't do!
You will try out different activation functions on the multi-label model you built for your irrigation machine in chapter 2. The function get_model() returns a copy of this model and applies the activation function, passed on as a p... |
3688309ab142fd92c8bce645848728c56faa9acf | jerry-mkpong/DataCamp | /Intermediate_Python_for_Data_Science/5.Case_Study:Hacker_Statistics/Roll the dice.py | 642 | 4.34375 | 4 | '''
In the previous exercise, you used rand(), that generates a random float between 0 and 1.
As Filip explained in the video you can just as well use randint(), also a function of the random package, to generate integers randomly. The following call generates the integer 4, 5, 6 or 7 randomly. 8 is not included.
imp... |
fc014fed4fd603dd562bdf7f9150c6641fae62f6 | jerry-mkpong/DataCamp | /Intermediate_Python_for_Data_Science/3.Logic_Control_Flow_and_Filtering/if.py | 412 | 4 | 4 | '''
It's time to take a closer look around in your house.
Two variables are defined in the sample code: room, a string that tells you which room of the house we're looking at, and area, the area of that room.
'''
# Define variables
room = "kit"
area = 14.0
# if statement for room
if room == "kit" :
print("look... |
d720fc627c76f526570cbe669143f1eec5541054 | jerry-mkpong/DataCamp | /Introduction_to_Python_for_Finance/2.Lists/Subset a nested list.py | 737 | 4.65625 | 5 | '''
You can also extract an element from the list you extracted. To do this, you use two indices. The first index is the position of the list, and the second index is the position of the element within the list.
For example, if you want to extract 7 from x, you can use the following command:
x = [[1, 2, 3], [4, 5, 6]... |
99d4ac392cdfecfa613d88cdcf256de285903eac | jerry-mkpong/DataCamp | /Introduction_to_Python_for_Finance/1.Welcome_to_Python/Finding the average revenue.py | 439 | 3.890625 | 4 | '''
Variables can be used to store information and efficiently recover and manipulate stored values.
The revenue of three companies have been stored in three variables: revenue_1, revenue_2, and revenue_3.
Let's calculate the total revenue and the average revenue of these companies.
'''
# Print the total revenue
to... |
d1edc10fd3c6c59188b44b7376d75cbe3635a486 | jerry-mkpong/DataCamp | /Convolutional_Neural_Networks_for_Image_Processing/4.Understanding_and_Improving_Deep_Convolutional_Networks/Shape of the weights.py | 405 | 3.609375 | 4 | '''
A Keras neural network stores its layers in a list called model.layers. For the convolutional layers, you can get the weights using the .get_weights() method. This returns a list, and the first item in this list is an array representing the weights of the convolutional kernels. If the shape of this array is (2, 2, ... |
68b5004ef60a2887755b52c0ddc1683e02794ee8 | jeffreire/machine-learning-study | /Rascunho/MediasPonderada.py | 724 | 3.609375 | 4 | import random
dias = 0
media_acumulativa = 0
condicao = True
while condicao:
dias += 1
print('dias:{}'.format(dias))
vendas = random.randint(1,5)
print("Vendas: {}".format(vendas))
valor_vendas = 0
for i in range(vendas):
print('Informe Valor da venda {}º'.format(i + 1))
valor... |
0f17d91fe12a7e87169eefef68b45cba1271c28f | jeffreire/machine-learning-study | /Rascunho/Binomial_distribution.py | 915 | 3.65625 | 4 | def factor(n):
if n > 1:
return factor(n - 1) * n
else:
return n
def binomial_x(x,p,n):
n_factor = factor(n)
x_factor = factor(x)
n_subtrai_x_factor = factor(n-x)
nx = n_factor/(x_factor*n_subtrai_x_factor)
print('nx=', nx)
q = 1 - p
f = nx*(p**x)*(q**(n-x))
retu... |
ba6d4d284788877286b807ca7a86e41a41da0693 | myhaa/leetcode | /leetcodeTemp/leetcode/editor/cn/[22]括号生成.py | 1,278 | 3.515625 | 4 | # date: 2021-03-17 23:08:09
# 数字 n 代表生成括号的对数,请你设计一个函数,用于能够生成所有可能的并且 有效的 括号组合。
#
#
#
# 示例 1:
#
#
# 输入:n = 3
# 输出:["((()))","(()())","(())()","()(())","()()()"]
#
#
# 示例 2:
#
#
# 输入:n = 1
# 输出:["()"]
#
#
#
#
# 提示:
#
#
# 1 <= n <= 8
#
# Related Topics 字符串 回溯算法
# 👍 1639 👎 0
# leetcode submit region begin(Prohibi... |
57f16d047e29f040e162a998b6f1cdebeeb792f6 | myhaa/leetcode | /leetcodeTemp/leetcode/editor/cn/[5]最长回文子串.py | 2,192 | 3.671875 | 4 | # date: 2021-03-10 23:23:41
# 给你一个字符串 s,找到 s 中最长的回文子串。
#
#
#
# 示例 1:
#
#
# 输入:s = "babad"
# 输出:"bab"
# 解释:"aba" 同样是符合题意的答案。
#
#
# 示例 2:
#
#
# 输入:s = "cbbd"
# 输出:"bb"
#
#
# 示例 3:
#
#
# 输入:s = "a"
# 输出:"a"
#
#
# 示例 4:
#
#
# 输入:s = "ac"
# 输出:"a"
#
#
#
#
# 提示:
#
#
# 1 <= s.length <= 1000
# s 仅由数字和英文字母(大写和/或小写)组成
#
... |
5e8f4bf2f3499da0fb631bdd0706a09f3c343520 | myhaa/leetcode | /leetcodeTemp/leetcode/editor/cn/[19]删除链表的倒数第 N 个结点.py | 1,394 | 3.703125 | 4 | # date: 2021-03-16 22:40:21
# 给你一个链表,删除链表的倒数第 n 个结点,并且返回链表的头结点。
#
# 进阶:你能尝试使用一趟扫描实现吗?
#
#
#
# 示例 1:
#
#
# 输入:head = [1,2,3,4,5], n = 2
# 输出:[1,2,3,5]
#
#
# 示例 2:
#
#
# 输入:head = [1], n = 1
# 输出:[]
#
#
# 示例 3:
#
#
# 输入:head = [1,2], n = 1
# 输出:[1]
#
#
#
#
# 提示:
#
#
# 链表中结点的数目为 sz
# 1 <= sz <= 30
# 0 <= Node.val... |
983f07e54431ded90bce83af0abb7a84055f6391 | myhaa/leetcode | /leetcodeTemp/leetcode/editor/cn/[102]二叉树的层序遍历.py | 1,253 | 3.703125 | 4 | # 给你一个二叉树,请你返回其按 层序遍历 得到的节点值。 (即逐层地,从左到右访问所有节点)。
#
#
#
# 示例:
# 二叉树:[3,9,20,null,null,15,7],
#
#
# 3
# / \
# 9 20
# / \
# 15 7
#
#
# 返回其层序遍历结果:
#
#
# [
# [3],
# [9,20],
# [15,7]
# ]
#
# Related Topics 树 广度优先搜索
# 👍 842 👎 0
# leetcode submit region begin(Prohibit modification and deletion... |
efe4f566f12b7d5d9e6c1e72d0761a2d6b2b8b20 | WalkerPM/CODATTT | /work-3/homework-6.py | 160 | 3.921875 | 4 | #!/usr/bin/python3
percent = 1.03 # 3%
s = int(input("Summ of your cash? "))
n = int(input("Years for store? "))
for i in range(n):
s = s * percent
print(s)
|
38a9cd536a164b58e4598b848c62daec52816500 | dan19-meet/meet2017y1lab5 | /factorial.py | 223 | 3.59375 | 4 | def factorial_dan(n):
c = 1
for i in range(1, n + 1):
c = c * i
return c
'''
if n == 0:
return 1
else:
return n * factorial(n-1)
'''
print(factorial_dan(4))
|
c3686f57cb389753572208d9fc8b3a3e423d1ba1 | Louuucas99/CS61A_FALL2020 | /Discussion/disc03.py | 1,630 | 4.15625 | 4 | #1.1
def multiply(m, n):
"""
>>> multiply(5, 3)
15
"""
if n == 1:
return m
else:
return m + multiply(m,n-1)
#1.3
def hailstone(n):
"""Print out the hailstone sequence starting at n, and return the
number of elements in the sequence
>>> a = hai... |
7acbe71928df70d3c32bff4d4f1bdaa6b652e09e | Jabeena95/lib | /squareroot.py | 391 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue May 26 14:56:04 2020
@author: Lenovo
"""
#write a program to find power of any number?
x = float(input("enter base number:"))
y = float(input("enter power:"))
z = x**y
print(z)
#write a program to enter any number and calcute its square root?
x= float(input("e... |
edbc68fe267d06409b24f2b4bd7dd7f74dd47aef | Jabeena95/lib | /1000_3001evn.py | 393 | 4.0625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Aug 17 12:42:06 2020
@author:jabeena
"""
#Write a program, which will find all such numbers between 1000 and 3000 (both included)
#such that each digit of the number is an even number. The numbers obtained should be
#printed in a comma-separated sequence on a singl... |
7c891d212e05cc130ccefe689c299b95cebe0964 | Jabeena95/lib | /cel-fah.py | 409 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue May 26 14:41:21 2020
@author:jabeena
"""
#write a program to enter temperature in celcius and convert into fahrenheit?
c = float(input("enter temperature in celcius:"))
f = (c*1.8)+ 32
print(f)
#write a program to enter temperature in fahrenheit and convert into... |
8ce99cc1e3254c1498ec0f6e6b495b1b0bd73fdf | vadym/examples | /python/tictactoe-voc.orig/tests/test_game.py | 1,026 | 3.6875 | 4 | from tictactoe import tictactoe
import unittest
class GameTest(unittest.TestCase):
def setUp(self):
# called before every test
self.game = tictactoe.Game()
def test_create_game(self):
self.assertIsNotNone(self.game)
def test_play(self):
self.game.play(0,0)
# self.as... |
431433391787ef9391344eda3fd5ba51b571e61a | empirep/euler | /002/e002.py | 575 | 3.765625 | 4 | def fibr(n):
if n==0 or n==1:
return n
else:
return fib(n-1) + fib(n-2)
def fibi(n):
if n==0 or n==1:
return n
grandparent = 0
parent = 1
for i in range(2, n+1):
current = grandparent + parent
grandparent = parent
parent = current
return curre... |
72e86bc2b4f366399d4db7642073cc07f5fc71f5 | smallBRADLEY/controlled-assessment-design- | /task2.py | 895 | 4.15625 | 4 | answer = raw_input("Are You Creating An Entry [Press 1] \nOr Are You Searching An Entry [Press 2] ")
# IF we are creating
if answer == "1" :
# collect information
lastname = raw_input("What is the persons last name? ")
firstname = raw_input("What is the persons first name? ")
phone = raw_input("What... |
c9be81128418335aa837e57ec9f99a5eaa6d9083 | yiruigao98/Emoji-Prediction-Reddit | /inspection.py | 2,703 | 3.5 | 4 | import pandas as pd
import numpy as np
from collections import Counter
# Write a function to allow feature inspection:
def feature_inspect(df):
print("The shape of the dataframe is: ")
print(df.shape)
print("Display the top 5 rows: ")
print(df.head(5))
# Check null value:
print(df.isnull().sum(... |
c08e7bcf3bda752ec0368ba3a2bd90d5ea81b0c1 | paulzay/dsalgos | /10-days-of-js/hurdle-race.py | 155 | 3.53125 | 4 | # Complete the hurdleRace function below.
def hurdleRace(k, height):
maximm = max(height)
if (maximm > k):
return maximm - k
return 0
|
45aacb517b2f79660c507740b3bc1ba99753a7e0 | R-Sg/Learn-Python | /p37.py | 470 | 4.03125 | 4 | """
Question 37:
Define a function which can generate and print a list where the values are square of numbers
between 1 and 20 (both included).
"""
input_num = input("Write number:")
lis1=[]
def lis(n1,n2):
"""
Generate and print list where the values are square of numbers.
param:n1,n2
"""
if n1 and n2 <= 20:
f... |
ca926756683ca0cff99fd5c83c99c8e3b78a4e37 | R-Sg/Learn-Python | /p27.py | 374 | 4.34375 | 4 | """
Question 27:
Define a function that can convert a integer into a string and print it in console.
"""
#To get a integer from console input.
input_value = int(input("Write a number: "))
def converter(integer):
"""
Convert integer into string.
param:integer
return:string of given numbers.
"""
print(str(integer... |
a6e239e84eecca0fb2db798a40869d16b2f1f72d | R-Sg/Learn-Python | /p35.py | 569 | 4.15625 | 4 | """
Question 35:
Define a function which can generate a dictionary where the keys are numbers between 1 and 20
(both included) and the values are square of keys. The function should just print the values only.
"""
input_num = input("Write number:")
dict1=dict()
def dic(n1,n2):
"""
function to generate and print valu... |
65cf85cbd074fc3b19f92c05cc758c8d81e7ccdb | R-Sg/Learn-Python | /p42.py | 366 | 3.921875 | 4 | """
Question 42:
With a given tuple (1,2,3,4,5,6,7,8,9,10), write a program to print the first half values in one line
and the last half values in one line.
"""
tup1 = (1,2,3,4,5,6,7,8,9,10)
tup_lis1 = []
tup_lis2 = []
i=0
for x in tup1:
if i <= (len(tup1)/2)-1:
tup_lis1.append(x)
i+=1
else:
tup_lis2.append(x)
... |
d224ad28dac754e6ab6d14878258cf86a3f7328d | R-Sg/Learn-Python | /p9.py | 292 | 4.125 | 4 | """
Question 9: Write a program that accepts sequence of lines as input and prints the lines after
making all characters in the sentence capitalized.
"""
end_with = ''
# Taking multiline input from consol/user.
input_string = '\n'.join(iter(raw_input, end_with))
print(input_string.upper())
|
9b34369bdb236779dee2ea29eb4cfa521d5976c8 | R-Sg/Learn-Python | /p6.py | 586 | 4.0625 | 4 | import math
"""
Question 6: Write a program that calculates and prints the value according to the given formula:
Q = Square root of [(2 * C * D)/H]
Following are the fixed values of C and H: C is 50. H is 30.
"""
# For taking input from console/user.
seq = input("Write sequence of numbers:")
lis = []
def formula(D):
... |
ff00d019bc26fcf48c2f9df938e9f4e4515799e9 | R-Sg/Learn-Python | /p19.py | 681 | 4.21875 | 4 | """
Question 19: You are required to write a program to sort the (name, age, height) tuples by
ascending order where name is string, age and height are numbers.
"""
#Sort with Operator Module Functions(itemgetter)
from operator import itemgetter
persons = []
while True:
line = raw_input("> ")
if not line:
break
... |
bfa44d5d4382f55eee7c0e137b13e9116a871685 | CelioTI/AV2.-IOT | /UDP-CLIENT.py | 685 | 3.515625 | 4 | import socket
# comunicações na camada de transpote chama-se socket
HOST = 'localhost'
#variavel local
PORT = 5000
# variavel post porta udp pra pra aceita comunicação externa
udp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# variavel UDP vai abrir uma porta protocolo IPV4 e um data grama
destino = (... |
e44c94a75f4295ee9d6e4b7ad055e168f40d6b40 | xtopherbrandt/UD-953 | /vector_test.py | 5,623 | 3.546875 | 4 | import unittest
from vector import Vector
class VectorTests(unittest.TestCase):
def test_AddingPositiveFloats(self):
V1 = Vector([1.1,2,3])
V2 = Vector([2,3,4.4])
self.assertEqual( V1 + V2, Vector([3.1,5,7.4]))
def test_AddingPositiveAndNegativeFloats(self):
V1 = Vector([1.1,2... |
a605b2ccc4c3912ce87816323b112893841c1de9 | nsiicm0/project_euler | /3/impl2.py | 538 | 3.890625 | 4 | '''
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
'''
import math
def max_prime_factor(n:int) -> int:
max_p = 0
while n % 2 == 0:
max_p = 2
n = n / 2
# now we are no longer even
for i in range(3, int(math.sqrt(n)) + 1, 2):... |
be955239c876a72360a9e463a8a006a86bb1665a | nsiicm0/project_euler | /14/impl.py | 1,189 | 3.765625 | 4 | from math import floor
def colatz_verbose(start: int) -> str:
if start == 1:
return '{}'.format(start)
else:
if start % 2 == 0:
return '{} > {}'.format(start, colatz_verbose(start // 2))
else:
return '{} > {}'.format(start, colatz_verbose(3 * start + 1))
def col... |
1e1baae28adcd475674fc7ba487182c9a1136c21 | nsiicm0/project_euler | /14/impl2.py | 1,418 | 3.96875 | 4 | '''
The following iterative sequence is defined for the set of positive integers:
n → n/2 (n is even)
n → 3n + 1 (n is odd)
Using the rule above and starting with 13, we generate the following sequence:
13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
It can be seen that this sequence (starting at 13 and finishing at 1) c... |
4062ab5f953fe9aa41cddc263edd414d6e030779 | TeemuStenhammar/waterberry | /check_timed.py | 1,273 | 3.515625 | 4 | import config
import datetime
import pumps
import os
def pump_is_dripping(pump: int):
return pump in config.get_drip_waterings()
def time_is_due(time):
now = datetime.datetime.now().time()
return now > time
def already_watered(pump, time):
last_watered_str = config.get_last_watered(pump)
# Speci... |
49c1243b71c40d7f746db041431783e91bfadb39 | himanshkukreja/DAA | /Graphs/hamilton_cycle_dp.py | 4,290 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu May 19 13:50:43 2021
Identify the Hamiltonian Cycle using Dyanimic Programming
@author: Himanshu kukreja
"""
from collections import defaultdict
import copy
class Graph:
def __init__(self, vertices):
self.V = vertices
self.graph = defaultdict(list)
... |
ed3e5f8668555a50dde12def83b58500d1a28e5c | NamanJain14101999/DSA_USING_PYTHON | /DATATYPE_IN_PYTHON/PYTHON_LIST.py | 738 | 4 | 4 | """
shoppingList=['milk','chess','butter']
#print(shoppingList[0])
l=[1,2,3,4,5,6,7]
print(l)
l.insert(0,11)
print(l)
l.append(55)
print(l)
l.extend([0,0,0])
print(l)
"""
"""
l=['a','b','c','d','e','f']
#print(l[0:2])
#l.pop(1)
#del l[0:2]
l.remove('e')
print(l)
"""
"""
l=[10,20,30,40,50,60,70,80,90]
#if 20 in l:
# ... |
075ed7ce8945386f5b2c735bdf1c816ec0908702 | NamanJain14101999/DSA_USING_PYTHON | /DATATYPE_IN_PYTHON/ROTATE_BY_90_MATRIX.py | 506 | 3.703125 | 4 | import numpy as np
myarray = np.array([[1,2,3],[4,5,6],[7,8,9]])
print(myarray)
def roratematrix(matrix):
n=len(matrix)
for layer in range(n//2):
first = layer
last = n-layer-1
for i in range(first,last):
top=matrix[layer][i]
matrix[layer][i]=matrix[-i-1][layer]
... |
2c791a03073d8b438ac84afad7373d6199f9459e | NamanJain14101999/DSA_USING_PYTHON | /SEARCHING_IN_PYTHON/BINARY_SEARCH.py | 523 | 3.84375 | 4 | def binary_search(a,v):
l=0
h=len(a)
if h>=l:
f=-1
while l<=h:
mid=l+(h-l)//2
#mid=(l+h)//2 # use here mid=l+(h-l)//2 which will work very efficiently for large test
if a[mid]==v:
f=1
break
elif v>a[mid]:
... |
8306ab6dbe7196995161f22913b76777245b113b | leeacer/C4T39-L.H.Phap | /day_3/test2.py | 120 | 4.21875 | 4 | r = float(input("What is the radius of the circle: "))
S = r**2 * 3.14159
print(S)
print("The area of the circle is:",S) |
3adfc23976e48d20eb915e3df6a26c556ecb3437 | leeacer/C4T39-L.H.Phap | /list/test15.py | 303 | 3.921875 | 4 | import random
item = ["Genji", "Lucio", "Ana", "Zenyatta", "Baptiste"]
rd = random.choice(item)
shuffle = random.sample(rd,len(rd))
print(*shuffle)
answer = input("What is this word: ")
if answer == rd.lower():
print(rd)
print("That's correct")
else:
print(rd)
print("That's in correct") |
326c4da46f7f0b94c2755e8d4645ccc40796d726 | leeacer/C4T39-L.H.Phap | /list/test2.py | 106 | 3.953125 | 4 | items = ["pee", "pee", "poo"]
print(items)
new = input("What comes next: ")
items.append(new)
print(items) |
89eed6e49b09eb3822c5ab9da7c7d5c3202748e9 | leeacer/C4T39-L.H.Phap | /dictionary/drill/test1.py | 272 | 3.875 | 4 | dick = {
"name" : "lucio",
"animal" : "frog",
"color" : "green",
}
def checkKey(dick, key):
if key in dick:
print("Name exists in the dicc")
else:
print("W doesn't exists in the dicc")
key = 'name'
checkKey(dick, key)
key = 'w'
checkKey(dick, key)
|
83b94cca03e3992575612c04d2e5408a9fac1986 | leeacer/C4T39-L.H.Phap | /dictionary/drill/test9.py | 1,487 | 3.828125 | 4 | quiz1 = {
"1" : "sans",
"2" : "minecraft steve",
"3" : "shrek",
"4" : "rachet"
}
quiz2 = {
"1" : "charizard",
"2" : "lugia",
"3" : "rayquaza",
"4" : "gyrados"
}
quiz3 = {
"1" : "nintendo",
"2" : "bandai",
"3" : "sega",
"4" : "atlus"
}
quiz4 = {
"1" : "arsene",
... |
40a211fe0f06099e9c7dd960dd669b948316d478 | leeacer/C4T39-L.H.Phap | /minihack1/part4/test12-3.py | 684 | 3.96875 | 4 | import re
name = input("Enter your username: ")
while True:
email = input("Enter an email: ")
PW = input("Enter a password: ")
Pw = input("Re-enter your password: ")
alphabets = digits = 0
for i in range(len(PW)):
if(PW[i].isalpha()):
alphabets = alphabets +1
elif(PW[i].... |
9ff96074eacd357a8382717810f37a1405c61b54 | leeacer/C4T39-L.H.Phap | /minihack1/part1/test4.py | 116 | 3.734375 | 4 | radious = int(input("Enter a radious: "))
from turtle import *
shape("turtle")
speed(0)
circle(radious)
mainloop() |
6b745807b23fee4d96e5f385c6219c643a9ef956 | leeacer/C4T39-L.H.Phap | /minihack2/part2/test4.py | 201 | 3.90625 | 4 | lists = ["red", "blue", "green", "yellow"]
position = int(input("Which one would you like to see: "))
if position > len(lists) - 1:
print("That's not possible")
else:
print(lists[position - 1]) |
5d96ed7dbf84098b0d752bdc6d24caa701c3e301 | leeacer/C4T39-L.H.Phap | /minihack2/part4/test10.py | 139 | 3.78125 | 4 | a = [int(x) for x in input("Enter a list element separated by space ").split()]
for num in a:
if num % 2 == 0:
print(num, end=" ") |
b0dc50adf271058fbf9168e7047773e551a36e6f | leeacer/C4T39-L.H.Phap | /day_3/intermediate/test3.py | 160 | 3.9375 | 4 | from turtle import *
shape("turtle")
speed(0)
forward(5)
for i in range(6):
for i in range(120):
left(3)
forward(5)
left(60)
mainloop() |
94132d7b6dcb8c85b5451eafbe741a566ec71448 | billcookie0929/Personal_Practice | /Python/Hackerrand/Loops.py | 172 | 3.578125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2020/2/11 17:57
# @Author : Yupeng Cui
# @File : Loops.py
N = int(input())
for i in range(0,N):
print(i**2) |
274d0b0e216a5b59a39e52287800434a1a2c456e | JosephLee19/ToolBox-WordFrequency | /frequency.py | 2,168 | 4.53125 | 5 | """ Analyzes the word frequencies in a book downloaded from
Project Gutenberg """
def get_word_list(file_name):
""" Reads the specified project Gutenberg book. Header comments,
punctuation, and whitespace are stripped away. The function
returns a list of the words used in the book as a list.
All words are co... |
2aea114e39bbf0124f567334c496329e8034d03b | Pearltsai/lesson9HW | /lesson9HW_2.py | 597 | 3.765625 | 4 | di={'A001':'小熊軟糖 20元','A002':'冰棒 25元','A004':'王子麵 10元','A006':'汽水 30元'}
i=0
while i<1:
print('請輸入數字:1 或 2')
print('1_貨號查詢')
print('2_離開')
n=int(input('請輸入數字:'))
if n==1:
k=str(input('請輸入貨號:'))
if k in di:
print(di[k])
else:
print(... |
b935787c2467b342cf92a2cf1c0e6fae0dd875f4 | yhshin0/python_ruby | /16. OOP_Variable/python1.py | 305 | 3.9375 | 4 | ### 클래스명 옆의 object는 있을 수도 있고 없을 수도 있음. 상속과 관련된 부분.
class C(object):
def __init__(self, v):
self.value = v
c1 = C(10)
print(c1.value) # 10
### python은 인스턴스 변수에 직접 접근이 가능함.
c1.value = 20
print(c1.value) # 20
|
4d80ccfeac6a15f2b718d2a44db984c45c87d7c6 | yhshin0/python_ruby | /19. Override/python1.py | 612 | 3.515625 | 4 | class C1:
def m(self):
return 'parent'
class C2(C1):
### pass : 아무 내용없는 명령어.
### class에 아무 것도 쓰지 않으면 에러가 나는데 이를 방지하기 위해 pass를 사용
#pass
### override(부모 클래스의 메서드를 구현하지 않은 경우)
# def m(self):
# return 'child'
### override(부모 클래스의 메서드를 구현하면서 내용을 추가한 경우)
def m(self):
... |
ef64044a5809d0161d56062a9b88758e3f67f4db | yhshin0/python_ruby | /09. Container/python2.py | 497 | 3.90625 | 4 | # https://docs.python.org/3/library/index.html 참조
names = ['A', 'B', 'C']
print('A' in names) # True
print('D' in names) # False
print("a" in "bsda")
print(len(names)) # 3
nums = [1, 0, 523]
print(min(nums)) # 0
print(max(nums)) # 523
nums.append(32)
print(nums) # [1, 0, 523, 32]
nums.reverse()
print(... |
1f57bd04a5848944dad08f7c8441f8fde916780f | ysak-y/binary_matrix_generator | /binary_matrix_generator.py | 299 | 3.515625 | 4 | # -*- coding: utf-8 -*-
import numpy as np
import random
def binary_matrix_generator(r, c):
a = np.random.random_integers(0, 1, (r, c))
print "%d %d" % (c, r)
for r in a:
print " ".join(map(str, r.tolist()))
return a
if __name__ == "__main__":
print binary_matrix_generator(4, 5)
|
c002d26a08ad0b323dda31a2f17cf481c017713d | jnmugerwa/data-structures-and-algorithms | /src/main/python/data_structures/UnionFind.py | 2,366 | 3.6875 | 4 | class UnionFind:
"""
A union-find (also called "disjoint-set") data structure. Very useful for tracking high-level structure within
a graph like connected components.
author: Joshua Nathan Mugerwa
version: 5/23/20
"""
def __init__(self, iterable): # This is more fungible... dealing with in... |
57d87fe51c0e801e0d47e743827e4e37645c6069 | premgane/toys-and-misc | /lunch_picker.py | 572 | 3.671875 | 4 | #!/usr/bin/env python3
import random
from collections import defaultdict
lunch_options = ["num pang", "sweet green", "dig inn"]
option1_chosen = defaultdict(int)
option2_chosen = defaultdict(int)
same_count = defaultdict(int)
for i in range(999):
choice1 = lunch_options[random.randint(0,2)]
print(choice1)
... |
37f4e045bd21b2f3bf410bd7d28e615338de20f8 | Love-yadav/The-Perfect-Guess-Game | /Project_02_The_Perfect_guess.py | 1,005 | 3.953125 | 4 | import random
print("Computer choosed a number:from (1 to 100)")
randomnumber=random.randint(1,100)
print("\n")
print("now it is your turn:")
userguess=None
guesses=0
while randomnumber != userguess:
userguess=int(input("enter the number from 1 to 100:"))
guesses+=1
if ... |
1d9be8c933c34d4d810e1cb07bd13bada7230002 | ZhouZhouBY/quickweb-work | /fib.py | 209 | 3.796875 | 4 | class fibonacci(object):
def of(n):
dp = [1]*n
for i in range(2,n):
dp[i] = dp[i-1] + dp[i-2]
return dp[n-1]
for i in range(1,201):
print(fibonacci.of(i))
|
d9ecaaa16e422bb5b6f67998e450cb6ec3360dd9 | romeorizzi/problemsCMS_for_LaboProg | /conta_multipli/sol/soluzione_semplice_ciclo.py | 465 | 3.53125 | 4 | # -*- coding: utf-8 -*-
# Soluzione di conta_multipli, written by Alessandro Righi 2018.12.05
from __future__ import print_function
import sys
if sys.version_info < (3, 0):
input = raw_input # in python2, l'equivalente di input è raw_input
def conta_multipli(a, b, c):
count = 0
for n in range(c+1):
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.