blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
706288997df87249c95c8fb41e9d351f6c2860fa | AcxelMorales/Learn-Python | /classes/rectangulo.py | 444 | 3.765625 | 4 | class Rectangulo:
def __init__(self, base, altura):
self.base = base
self.altura = altura
def area(self):
return self.base * self.altura
def perimetro(self):
return (self.base + self.altura) * 2
base = float(input("Base: "))
altura = float(input("Altura: "))
rectangulo =... |
085cf8d2df1a49c87e46a3787266eb0e1806e8ee | SabinaZolnowska/JezykPython | /zestawyZadan/zestaw4/zd4.4.py | 398 | 3.953125 | 4 | #-*- coding: utf-8 -*-
#Napisać iteracyjną wersję funkcji fibonacci(n) obliczającej n-ty wyraz ciągu Fibonacciego.
def fibonacci(n):
if n==0:
wynik=0
return 0
elif n==1:
wynik=1
return 1
elif n>1:
f1=0
f2=1
for i in range(n-1):
temp=f1+f2
f1=f2
f2=temp
return f2
else:
print "Wprowadzono... |
c7595bc7ebe34963fd2fd5fc881faf9c0050f6e4 | rafaelperazzo/programacao-web | /moodledata/vpl_data/313/usersdata/303/75391/submittedfiles/imc.py | 320 | 3.859375 | 4 | # -*- coding: utf-8 -*-
PESO= float(input('Digite o peso (kg):'))
ALTURA= float(input('Digite a altura (m):'))
IMC= (PESO/(ALTURA**2))
if IMC<20:
print('ABAIXO')
if 20<=IMC<=25:
print('NORMAL')
if 25<IMC<=30:
print('SOBREPESO')
if 30<IMC<=40:
print('OBESIDADE')
if IMC>40:
print('OBESIDADE GRAVE')
|
be828487ad8092023d6f51fba3f5fb9e81516854 | elsuavila/Python3 | /Ejercicios Elsy Avila/Ejer14.py | 390 | 3.84375 | 4 | #Leer tres numeros entereos de un digito y almacenarlos en una sola variable
#Que contenga a esos tres digitos por ejemplo si A=5 y B=6 y C=2 entomces X=562
print("Bienvedido al Programa".center(50,"-"))
a = ""
b = ""
c = ""
x = ""
a = input("Ingrese primer numero: ")
b = input("Ingrese segundo numero: ")
c = input... |
4edb73c146d1becdfea673b8a4e94dc76d5f43d6 | julionieto48/situaciones_jend | /sumatoriaTriangularEuler/sumaEuler.py | 656 | 3.734375 | 4 | arregloImpar = [1,2,3,4,5] ; arreglopar = [1,2,3,4,5,6]
total = 0
for i in range(len(arregloImpar)):
suma = arregloImpar[i] + arregloImpar[-1]
print suma
arregloImpar.pop(i) ; arregloImpar.pop(i +len(arregloImpar) - 1)
total = total + suma
#print total
print arregloImpar
# https://stackove... |
780106ed06f06a52b08cdf61e94df6ea7bce195e | mishrakeshav/Competitive-Programming | /binarysearch.io/merging_k_sorted_lists.py | 1,213 | 3.734375 | 4 | class Solution:
def solve(self, lists):
# Write your code here
new_list = []
def merge(l1,l2,new_list):
n = len(l1)
m = len(l2)
i = 0
j = 0
while i < n and j < m:
if l1[i] < l2[j] :
n... |
979213b3fd840286a1ea31c978470c7a59ce61ad | praveengadiyaram369/leetcode_submissions | /leetcode_189.py | 696 | 3.6875 | 4 | # _189. Rotate Array
class Solution:
def rotate(self, nums: List[int], k: int) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
n = len(nums)
k = k%len(nums)
# _solution 1
# nums_updated = nums[(n-k):n]
# nums_updated.extend(num... |
a0761e61e636b12c2ac832860608ff5c3c45b4bc | moontree/leetcode | /version1/1020_Number_of_Enclaves.py | 2,889 | 3.796875 | 4 | """
Given a 2D array A, each cell is 0 (representing sea) or 1 (representing land)
A move consists of walking from one land square 4-directionally to another land square,
or off the boundary of the grid.
Return the number of land squares in the grid for which
we cannot walk off the boundary of the grid in any number ... |
87c0a4373ba2f270cc25e577d707bc26779b1aea | czfyy/Think-Python-2ed | /ThinkPython_Exercise12.1.py | 595 | 3.671875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Apr 24 15:00:19 2019
@author: czfyy
"""
def frequent(s):
h = histogram(s)
t = []
for x, freq in h.items():
t.append((freq, x))
t.sort(reverse = True)
res = []
for freq, x in t:
res.append(x)
... |
7b778efb517aa9c7f3403b5eaef6b530f14bd74e | aakashsbhatia2/Support-Vector-Machine | /svm.py | 6,181 | 3.796875 | 4 | """
Imported Libraries
"""
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import make_blobs
import random
import math
def create_data():
"""
Function to create data.
- Here, X0 and y hold the initial points created by make_blobs
- A np.array is created using X0 and y which... |
98bafe96c28c3fbaff44665364863e54597b20a4 | prateek1192/leetcode | /invest.py | 1,525 | 3.546875 | 4 | import sys
from collections import OrderedDict
range = input().split(", ")
starting_date = range[0]
ending_date = range[1]
line = input()
dates = OrderedDict()
while True:
try:
line = input()
data = line.split(",")
datemon = data[0]
if datemon > starting_date and datemon < ending_dat... |
62a1bdba720411b34e56927b63b51c9e5236e35c | GabrielaVargas/Tarea-02 | /auto.py | 691 | 4.03125 | 4 | #encoding: UTF-8
# Autor: Gabriela Mariel Vargas Franco, A01745775
# Descripcion: Preguntar al usario la velocidad a la que viaja un auto (km/h) y que imprima: la distancia en km que recorre en 6 hrs, la distancia en km que recorre en 10hrs y el tienpo que requiere para recorrer 500 km.
# A partir de aquí escr... |
0650f0c431ed095b03dc2cd1917cd1d20124216f | python-programming-1/homework-2b-mfreyer12 | /RockPaperScissors.py | 2,390 | 4.03125 | 4 | import random
player_score = 0
computer_score = 0
passed_name = False
while True:
if not passed_name:
print('make a move! (r/p/s)')
player_roll = input()
if player_roll.lower() not in ('r','s','p'):
continue
passed_name = True
if passed_name:
random_roll = ''
... |
ae5c9b55ac128233fd5cdff91059777d5e9e8b60 | as030pc/MisionTIC | /Fundamentos de Programacion - Python/Semana 6/Archivos/basic ej1.py | 441 | 3.796875 | 4 | import json
"""CREAR Y LEER JSON"""
"""crear diccionario"""
dicc={"nombre":"paola", "edad":20}
"""escribir archivo json"""
with open("test.json", "w") as fl: #w: escribirlo, fl es un alias
json.dump(dicc, fl,indent=4) #indent: da una estructura de identacion
"""leer un json"""
with open("test.json", "r")... |
18d1518d344503233321d3bef473fccbfaa1c24f | slahmar/advent-of-code-2018 | /23-01.py | 776 | 3.59375 | 4 | from dataclasses import dataclass
@dataclass
class Nanobot:
position: tuple
radius: int
def distance(self, other):
return sum([abs(a-b) for (a,b) in zip(self.position, other.position)])
def in_range(self, other):
return self.distance(other) <= self.radius
with open('23.txt', 'r... |
94dfc08b7f340472cf0387273b6b206498540bbb | boknowswiki/mytraning | /lintcode/python/0585_maximum_number_in_mountain_sequence.py | 2,150 | 3.90625 | 4 | #!/usr/bin/python3 -t
# binary search
# time O(logn)
# space O(1)
from typing import (
List,
)
class Solution:
"""
@param nums: a mountain sequence which increase firstly and then decrease
@return: then mountain top
"""
def mountain_sequence(self, nums: List[int]) -> int:
# write your... |
2dbbdef34ef23cfeeea3e3c7dba30aad1f31a055 | zlc18/LocalJudge | /tests/python/SecondMinimumNodeInABinaryTree/findSecondMinimumValue.py | 705 | 4.03125 | 4 | """
because of the special porperty of the tree, the question basically is asking to find
the smallest element in the subtree of root. So, we can recursively find left and right
value that is not equal to the root's value, and then return the smaller one of them
"""
def findSecondMinimumValue(self, root):
if not ro... |
8a5261e614bb9beb6ca5366055595f39f83ef566 | devendraingale2/PythonPrograms | /soln3.py | 257 | 3.828125 | 4 |
dict1 = dict(input("Enter key and value : ").split() for i in range(int(input("Enter range : "))))
print(dict1)
str1 = ""
for a in dict1:
for b in dict1:
if(a == dict1[b]):
str1 = a
break
dict1.pop(str1)
print(dict1)
|
2521ae4bc34ea0ffa306ddcfe0b1c594aa74aee5 | Shu-HowTing/Code-exercises | /E13.py | 1,996 | 3.75 | 4 | # -*- coding: utf-8 -*-
# Author: 小狼狗
'''
请设计一个函数,用来判断在一个矩阵中是否存在一条包含某字符串所有字符的路径。路径可以从矩阵中的任意一个格子开始,
每一步可以在矩阵中向左,向右,向上,向下移动一个格子。如果一条路径经过了矩阵中的某一个格子,则该路径不能再进入该格子。
例如: a b c e s f c s a d e e 矩阵中包含一条字符串"bcced"的路径,但是矩阵中不包含"abcb"路径,
因为字符串的第一个字符b占据了矩阵中的第一行第二个格子之后,路径不能再次进入该格子。
'''
'''
问题所在:如果此路不通,matrix[i*cols+j]='0',如... |
eed71f7fd0c53ef13cf4259fff04bf489600d298 | qwedsafgt/hha | /alien_invasion.py | 1,271 | 3.5625 | 4 | import pygame#导入pygame
from pygame.sprite import Group#导入group类
from settings import Settings#导入settings类
from ship import Ship#导入ship类
import game_functions as gf#导入game_functions类作为gf
def run_game():#运行程序的主要函数
# Initialize pygame, settings, and screen object.
pygame.init()#使pygame初始化
ai_settings = Setti... |
4322742f04cd515a17f3840965fc7e6bf0d09b62 | mamaluigie/Code-Wars | /python/Convert-A-Hex-String-To-RGB.py | 445 | 3.671875 | 4 | import string
def hex_string_to_RGB(hex_string):
# your code here
string_list = []
dictionary = {'r': 0, 'g': 0, 'b': 0}
for begin, end in zip(range(1, len(hex_string), 2), range(3, len(hex_string) + 1, 2)):
string_list.append(hex_string[begin:end].lower())
for x, entry in zip(string_l... |
ccfb1bf83219ad7d4bdc2d348492b1f32ff7ba90 | yaswanthkumartheegala/py | /factorial.py | 126 | 4.15625 | 4 | n=int(input('enter the number:'))
result=1
for i in range(n,0,-1):
result=result*i
print('factorial of',n,'is',result) |
7a4794b1b1987f6c816a27f4fb548211e06559dd | achrefbs/holbertonschool-interview | /0x19-making_change/0-making_change.py | 578 | 3.9375 | 4 | #!/usr/bin/python3
"""
Given a pile of coins of different values, determine the fewest
number of coins needed to meet a given amount total.
"""
def makeChange(coins, total):
"""
Given a pile of coins of different values, determine the fewest
number of coins needed to meet a given amount total.
"""
... |
658380398f1482a0afa3e31bcb780a63338354f1 | Alex-Beng/ojs | /FuckLeetcode/199.二叉树的右视图.py | 838 | 3.59375 | 4 | #
# @lc app=leetcode.cn id=199 lang=python3
#
# [199] 二叉树的右视图
#
# @lc code=start
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def rightSideView(self, ro... |
420b7fe2d8f259a3f7312669bebd4d395f94d3d7 | dorotamierzwa/PyLove-workshops | /Week 10 - repetition/10.8-figures.py | 1,931 | 3.875 | 4 | # Stwórz - z wykorzystaniem klas i dziedziczenia - kalkulator objętości brył:
# sześcianu, prostopadłościanu, stożka i walca.
# Powinien on wczytać od użytkownika opcję (0, 1, 2 lub 3) i w zależności od tego przyjąć
# 3 argumenty, 2 lub 1 i obliczyć objętość. Na wszelki wypadek wzory na objętość podane poniżej.
# Sześc... |
a63514a385ec52bb3a563ea67b52bee89d241e68 | telavivmakers/at-tami | /gerber/gerbmerge/bin/placement.py | 3,291 | 4 | 4 | #!/usr/bin/env python
"""A placement is a final arrangement of jobs at given (X,Y) positions.
This class is intended to "un-pack" an arragement of jobs constructed
manually through Layout/Panel/JobLayout/etc. (i.e., a layout.def file)
or automatically through a Tiling. From either source, the result is
simply a list of... |
3653061fd40826b990eb4a4430003e706165631b | YuduDu/cracking-the-coding-interview | /1.4.py | 298 | 3.75 | 4 | #!/usr/bin/python
from pprint import pprint
def replace(s,len):
tmp = s[:len].split(" ")
result = ""
for item in tmp:
if item != "":
result = result+item+"%20"
return result[:-3]
print replace("asd fasd fadsf a sdf at ees d fs df sdf sdf dasfhuadsf asdfad asdfaesdfs ",80) |
519112166b8d4821e6f51810e9955a254be9a358 | mehulchopradev/ava-python-core | /author.py | 860 | 3.5 | 4 | from address import Address
class Author:
def __init__(self, name, gender, ratings, address=None):
self.name = name
self.gender = gender
self.ratings = ratings
if isinstance(address, Address):
# composition association
# where the Address obj exists in the system only till the Author obj... |
b38659e37e8f59d72f2f84337dae92859f9d9cea | SarveshSiddha/Demo-repo | /assignment3/F.py | 191 | 4.125 | 4 | #print F using *
for i in range(0,6):
for j in range(0,5):
if i==0 or i==2 or j==0:
print("*",end='');
else:
print(" ",end='')
print("");
|
dd08866556ea8bbe992410b09e1f45fa4b4243c9 | jasongan234/CP1401p | /sales_bonus.py | 472 | 3.875 | 4 | def main():
""" Program to calculate and display a user's bonus based on sales.
If sales are under $1,000, the user gets a 10% bonus.
If sales are $1,000 or over, the bonus is 15%."""
sales = float(input("Enter sales: $"))
while sales >=0:
if sales<1000:
bonus= sales* 10//100
... |
11d1c1c5e09650dd5627ebf221a74dcf00d9ad48 | NickWilsonDev/python-DigitalCrafts | /python105/blastoff4.py | 195 | 3.765625 | 4 | # blastoff4.py
num = 22
while num > 20:
num = int(raw_input("Number to count down from? "))
i = num
while i > -1:
if i == 0:
print "Boom!"
else:
print i
i -= 1
|
5ca2922226b5715a2e94c49da5706e4931c2633b | Darkseidddddd/project | /leetcode/Search_in_Rotated_Sorted_Array.py | 1,665 | 3.859375 | 4 | def search(nums, target):
if not nums:
return -1
n = len(nums)
left, right = 0, n-1
if target == nums[0]:
return 0;
if target == nums[n-1]:
return n-1;
if target >= nums[0]:
while left <= right:
mid = (left+right) // 2
if nums[mid] == targe... |
242d015ab13dab743a6291419862235b67a8f362 | jmmunoza/ST0245-008 | /Parcial_2/7.py | 1,223 | 3.65625 | 4 | class Pila:
def __init__(self):
self.items = []
def __str__(self):
return str(self.items)
def no_vacia(self):
return len(self.items) == 0
def promedio(self):
sum = self.items[0]
for i in range(len(self.items)-1):
sum = sum+self.items[i+... |
8b436d72a70152991de14e636cc7cb9862c13510 | zhangquanliang/python | /学习/day8_笔试题/列表.py | 351 | 4.0625 | 4 | # -*- coding:utf-8 -*-
"""
author = zhangql
"""
# def f(x, l=[]):
# for i in range(x):
# l.append(i*i)
# print(l)
#
#
# f(2)
# f(3, [3,2,1])
# f(3)
#
# A0 = dict(zip(('a','b','c','d','e'),(1,2,3,4,5)))
# print(AO) {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}
# 生成器
def func():
yield '1'
a = func()... |
889f22752128d186670e9673ec28240fcea41af0 | wiamsuri/intro-to-programming | /0-data-type-and-operators/2-comparison.py | 438 | 3.59375 | 4 | bangkok_population = 8281000
chiang_mai_population = 131091
phuket_population = 386605
buriram_population = 1579000
# Print True or False from the statement
# Bangkok population is smaller than Chiang Mai
print()
# Chiang Mai population is smaller than Phuket
print()
# Buriram population is larger than Bangko... |
fc60d27952496a64b5af1fd035642f9a9416b7ae | krstoilo/SoftUni-Fundamentals | /Python-Fundamentals/Exams/world_tour.py | 1,061 | 3.640625 | 4 | initial_stops = input()
command = input()
while command != "Travel":
if "Add" in command:
command = command.replace("Add ","")
token = command.split(":")
index = int(token[1])
stop_string = token[2]
if index < len(initial_stops):
initial_stops = initial_stops[:in... |
0cf23cf79002ab1fa4f90d011b964270fd6bda80 | stulsani/Academic-Related-Projects | /Python-Library-Project/main.py | 2,280 | 3.9375 | 4 | #Sumeet Tulsani
from searchengine import Searchengine
from media import Media
def main():
choice = 'y'
matches = list()
while(choice == 'Y' or choice == 'y'):
print ("What type of search would you like to do::");
print (" 1. Search by Title\n 2. Search by Call Number\n 3. Search by Subject\... |
057262fe0482596a06bb5db10026b729f1d54951 | coder4378/test-your-GK | /gk-quiz.py | 945 | 3.765625 | 4 | print("Hello, welcome to the GK quiz!")
ready=input("are you ready to play(yes/no): ")
score=0
total_q = 4
if ready.lower() == "yes":
ans1 = input("is silver fish an insect (True/False)?")
if ans1.lower() == "False":
score+=1
print("correct")
else : print("incorrect it is an insect")
ans2 = input(... |
bbd68d8c47e0d5dcc67c8d6d33f16904a1d266fb | Omkarj21/DataAnalysis_Sales_Data | /QA_script05.py | 3,367 | 3.515625 | 4 | # import all the needed modules
import pandas as pd
import os
import matplotlib.pyplot as plt
#-------------------------------------------------------------------------------
""" Which products sold most and why """
#-------------------------------------------------------------------------------
### Start : Collect ... |
90aa44365d05b0bf884fa4599dc26836f7639f97 | jym197228/guessnumpractice | /r.py | 520 | 3.640625 | 4 | import random
start = input('請輸入隨機整數範圍開始值: ')
end = input('請輸入隨機整數範圍結束值: ')
start = int(start)
end = int(end)
r = random.randint(start, end)
count = 0
while True:
count += 1 # count = count + 1
num = input('請猜猜數字: ')
num = int(num)
if num == r:
print('您猜中了!')
print('您總共猜了', count, '次')
break
elif num > r:
... |
067e23c1476b6791d3ae889edcca17719342b1b2 | jnobre/python-classes | /sheet5/ex5-Folha5.py | 395 | 3.78125 | 4 |
def printFuncao():
global c #global
b=5 #local
c=6
teste = 1
print("a dentro da funcao: ", a)
print("b dentro da funcao: ", b)
print("c dentro da funcao: ", c)
a=1
b=2
c=3
print("a fora da funcao: ", a)
print("b fora da funcao: ", b)
print("c fora da funcao: ", c)
printFuncao()
print2()
print("a fora da f... |
73342b3b4f8d44e5a75b98b1d21ef21612a324b9 | JavierCuesta12/Algoritmia | /Entegas/Entrega3/Ejercicio4.py | 587 | 3.6875 | 4 | Tapones=[1,3,4,2]
Botellas=[3,2,4,1]
def Entaponar(tapones, botellas, inicio):
if inicio < len(tapones) and inicio < len(botellas):
if(tapones[inicio] != botellas[inicio]):
for i in range(inicio + 1, len(botellas)):
if (tapones[inicio] == botellas[i]):
baux=b... |
9d63be07ce5d2539d084b115983a2ea8b44b2a57 | okapetanios/practice | /leetcode/twosum.py | 400 | 3.75 | 4 | def twosum(nums, target):
index_map = {}
for i in range(len(nums)):
num = nums[i]
print("NUM:", num)
twin = target - num
print("TWIN:"+ str(twin))
if twin in index_map:
print([i,index_map.get(twin)])
print(index_map)
return
ind... |
4a8d36809efe7a342f20429c263dd6b771df741c | wanghan79/2019_Python | /2017010886_WangYuTing/ConnectMongodb.py | 947 | 4.125 | 4 | '''
姓名:王宇婷
学号:2017010886
内容:连接mongodb并操作
'''
import pymongo
client = pymongo.MongoClient(host='localhost', port=27017)
db = client['RandomData']#指定数据库
collection = db['students']
student1 = {
'id': '20170101',
'name': 'Jordan',
'age': 20,
'gender': 'male'
}
student2 = {
'id': '20... |
100a9fedbaf05b5c2db1d7fc0a66c407df7d7b79 | aashish2000/Data-Structures-in-Python | /Sorting/radix-sort.py | 587 | 3.578125 | 4 | def countingSort(arr,exp):
arr=arr[::-1]
digarr=[]
bucket=[0]*10
for i in range(len(arr)):
try:
dig=int(str(arr[i])[-exp])
except:
dig=0
#print("dig: ",dig)
digarr.append(dig)
bucket[dig]+=1
for i in range(1,10):
bucket[i]+=bucket[i-1]
#print(digarr,bucket)
sortedarr=[0]*len(arr)
for i in ... |
45cfa4ee053dd31fa68453e353a67ebca88cf506 | shrikantchine/algorithm-practice | /iDeserve/is_btree_symmetric.py | 922 | 4 | 4 | class Node(object):
def __init__(self, data, left=None, right=None):
self.data = data
self.left = left
self.right = right
def is_symmetric(root):
return symmetric_helper(root.left, root.right)
def symmetric_helper(n_left, n_right):
if n_left is None and n_right is None:
ret... |
ddd0b713ea90a4230560d6534410d43e41f020bb | yiming1012/MyLeetCode | /LeetCode/贪心算法/1196. 最多可以买到的苹果数量.py | 1,434 | 3.921875 | 4 | """
1196. 最多可以买到的苹果数量
楼下水果店正在促销,你打算买些苹果,arr[i] 表示第 i 个苹果的单位重量。
你有一个购物袋,最多可以装 5000 单位重量的东西,算一算,最多可以往购物袋里装入多少苹果。
示例 1:
输入:arr = [100,200,150,1000]
输出:4
解释:所有 4 个苹果都可以装进去,因为它们的重量之和为 1450。
示例 2:
输入:arr = [900,950,800,1000,700,800]
输出:5
解释:6 个苹果的总重量超过了 5000,所以我们只能从中任选 5 个。
提示:
1 <= arr.length <= 10^3
1 <= arr[i] ... |
aa3338bb2bc16b1169c648bad0a67fee84bee64a | munzalaj/jacklyne | /prime_number.py | 143 | 3.828125 | 4 | def_prime_number(num):
for i in range(2,num)
prime = True
if ((num/i)*i)=num
return "Not Prime"
else:
print True
|
28e5bdaa5555ece59b7f41d29f04b3e1c867f0ad | RaazeshP96/Python_assignment2 | /assignment14.py | 521 | 4.125 | 4 | '''
Write a function that reads a CSV file. It should return a list of dictionaries,
using the first row as key names, and each subsequent row as values for those keys.
For the data in the previous example it would return:
[{'name': 'George', 'address': '4312 Abbey Road', 'age': 22},
{'name': 'John', 'address': '54... |
1ac59cc2dfd0edfd10860df09961e8088d78b52a | aaronmontano/InvestBot | /PROJECT_2_RF/ML_alg.py | 3,868 | 3.765625 | 4 | # Import statements
import pandas as pd
import numpy as np
# Create a Pandas DataFrame containing closing prices for stock FNTK
fntk_df = pd.DataFrame(
{"close": [30.05, 30.36, 30.22, 30.52, 30.45, 31.85, 30.47, 30.60, 30.21, 31.30]}
)
# Review the DataFrame
fntk_df
# Set the index as datetime objects starting f... |
377d7bf0d345a462858ce2d1f70d6841e4c24018 | shaweii/programming-practices | /Python/Python triangle.py | 261 | 4.03125 | 4 | print("Python triangle.")
n = int(input("Please enter a number: "))
for i in range(1,n+1):
for j in range(1,i+1):
print("*",end=" ")
print()
"""i = 1
while i <= n:
print("*"*i)
i += 1
f = open("demofile.txt", "a")
"""
|
1ebd1ace4de9a7bb569ab28016758cd64142d949 | geekcomputers/Python | /Hangman.py | 2,216 | 4.21875 | 4 | # importing the time module
import time
# importing the random module
import random
# welcoming the user
name = input("What is your name? ")
print("\nHello, " + name + "\nTime to play hangman!\n")
# wait for 1 second
time.sleep(1)
print("Start guessing...\nHint:It is a fruit")
time.sleep(0.5)
someWords = """apple... |
a223be6a31e87564568726ca4a37ea4dd0ccad59 | vieirads/MCSC1 | /extras/solutions/4_script.py | 211 | 3.953125 | 4 | #!/usr/bin/env python
import argparse
parser = argparse.ArgumentParser(description='Double a number.')
parser.add_argument("x", help="value to double",type=float)
args = parser.parse_args()
print(args.x**2) |
6042a54aa9bbcde9dbee8b42dbbda62d670befc9 | darkbodhi/homeworks_math | /pesron.py | 945 | 3.890625 | 4 | class Acquintance(object):
def __init__(self):
self.name = None
self.byear = None
self.pnumber = None
def input(self):
self.name = input("Введіть ім*я знайомого: ")
self.byear = input("Введіть рік народження знайомого: ")
self.pnumber = input("Введіть номер теле... |
4e8cf0bc97d4834f08b4c76f54bd8b55fa61eeba | kgudipati/DataScienceTools | /simpleLinearRegression.py | 1,961 | 3.75 | 4 | '''
Simple Linear Regression Classifier Module
y_i = alpha + beta*x_i + error_i
'''
import vectors as vec
import matrix as mat
import statistics as stat
import gradientDescent as gd
import random
# Predict final label
# y_i = beta*x_i + alpha + error
def predict(alpha, beta, x_i):
return beta * x_i + alpha
# Co... |
4feb387e21fcfe764d750e2bf170d98a1678a95c | pnaithani23/python | /id_2.py | 437 | 3.765625 | 4 | id=int(input("enter the product id "))
pd=str(input("enter the product "))
cp=float(input("enter the cost price of the product "))
sp=float(input("enter the selling price of the product "))
qt=int(input("enter the quantity of the product "))
print("product name :",pd,"\nproduct id :",id,"\ncost price of the product :",... |
6e38b041c8ba9a33259be3f2f74b8910a9ebde44 | DidiMilikina/DataCamp | /Machine Learning Scientist with Python/19. Image Processing with Keras in Python/04. Understanding and Improving Deep Convolutional Networks/06. Visualizing kernel responses.py | 1,344 | 4.5625 | 5 | '''
Visualizing kernel responses
One of the ways to interpret the weights of a neural network is to see how the kernels stored in these weights "see" the world. That is, what properties of an image are emphasized by this kernel. In this exercise, we will do that by convolving an image with the kernel and visualizing th... |
5def7260c3e53ce3ebd6d9f1ab75835f19ec38de | jochemste/GB_usage_calculator | /src/DateTime.py | 1,908 | 3.828125 | 4 | # -*- coding: utf-8 -*-
import datetime
from calendar import monthrange
class DateTime():
printAll: bool
def __init__(self, printAll: bool = False):
self.printAll = printAll
def __del__(self):
pass
def getDate(self):
currentDate = datetime.datetime.now().strftime("%Y-%m-%d")
... |
ad221b19245d677b4aaaf31cd9ecae1592e1b55d | avaz7791/UCSD | /Python/Day 2/Hello USer.py | 429 | 4.09375 | 4 | # Print Hello User!
print("Hello User!")
# Take in user input
User1 = input("What is your name?")
# Respond Back with User input
print("Hello "+ User1 + "!" )
# Take in the User Age
age1 = input("What is your Age?")
# Respond Back wiht a Statement
if int(age1) < 20:
print("Awww you are just a baby!")
else... |
cdc5b2082c617f30f4f63f4bb8dc36e7278e3266 | FelipeABortolini/Exercicios_Python | /Exercícios/009.py | 473 | 3.953125 | 4 | a=int(input('Digite um número inteiro qualquer para obter sua tabuada: '))
print('{} x 0 = {}'.format(a, a*0))
print('{} x 1 = {}'.format(a, a*1))
print('{} x 2 = {}'.format(a, a*2))
print('{} x 3 = {}'.format(a, a*3))
print('{} x 4 = {}'.format(a, a*4))
print('{} x 5 = {}'.format(a, a*5))
print('{} x 6 = {}'.format(a,... |
d7926a8d3a9515f3e6f088bcb15cae95647b8b24 | noliverh/CLMITS_ACITIVITIES | /jack_n_poy.py | 1,597 | 4.09375 | 4 | import random
weapons = [1, 2, 3]
comp_action = random.randint(0, 2)
player = False
while not player:
player_action = int(input("\nEnter your weapon ([1]rock, [2]paper, [3]scissors): "))
if player_action == weapons[0]:
player_action = "rock"
elif player_action == weapons[1]:
... |
310c1a3c72d478fa66d3aa0b260767bb0c5d980d | Jnayakk/Querying-Data | /Querying Data/starter/squeal.py | 5,654 | 4.21875 | 4 | from reading import *
from database import *
# The delimiter which is a comma for sql purposes.
COMMA_DELIMETER = ','
# The operator representing equal
EQUALS_OPERATOR = '='
# The operator representing greater than.
GREATER_OPERATOR = '>'
# The delimeter which is a space
SPACE_DELIMETER = ' '
# The ... |
3a3ac81a5e353b759795d5912ded44c18445e289 | yl123168/Hello_world | /06LectureP9.py | 691 | 3.75 | 4 | animals = { 'a': ['aardvark'], 'b': ['baboon'], 'c': ['coati']}
animals['d'] = ['donkey']
animals['d'].append('dog')
animals['d'].append('dingo')
def howMany(aDict):
result = 0
if aDict == {}:
return result
for i in aDict.values():
result += len(i)
return result
def bigg... |
bff71e559bf0619c0629bd7b7d8f857066012039 | wheejoo/PythonCodeStudy | /2주차 BFS,DFS/프로그래머스/타겟넘버/김휘주.py | 470 | 3.71875 | 4 | from collections import deque
def solution(numbers, target):
answer = 0
q = deque([(0,0)])
while q:
n_sum, n_idx = q.popleft()
if n_idx == len(numbers):
if n_sum == target:
answer += 1
else:
number = numbers[n_idx]
q.append((n_sum+n... |
9878574d2c1056680df73c2a81b0f96d4346cc2b | zopepy/leetcode | /longest_even_word.py | 185 | 3.875 | 4 | def longest(s):
s = s.split()
w = [len(w) for w in s]
we = max([l if l&1==0 else 0 for l in w])
for w in s:
if len(w) == we:
return w
print(longest("hello world this is new")) |
0986719af98e8d2e88323dfad6df596a390b10d8 | fengxiaolong886/leetcode | /234. 回文链表.py | 534 | 3.796875 | 4 | """
请判断一个链表是否为回文链表。
示例 1:
输入: 1->2
输出: false
示例 2:
输入: 1->2->2->1
输出: true
"""
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def isPalindrome(self, head: ListNode) -> bool:
current = ... |
0e8f893cabeae58331612126de9dd7b3da294c05 | NintendoLink/leetcode_py | /_list/getKthFromEndSolution.py | 1,611 | 3.765625 | 4 |
class ListNode:
def __init__(self,x):
self.val = x
self.next = None
"""
剑指 Offer 22. 链表中倒数第k个节点
输入一个链表,输出该链表中倒数第k个节点。为了符合大多数人的习惯,本题从1开始计数,即链表的尾节点是倒数第1个节点。例如,一个链表有6个节点,从头节点开始,它们的值依次是1、2、3、4、5、6。这个链表的倒数第3个节点是值为4的节点。
示例:
给定一个链表: 1->2->3->4->5, 和 k = 2.
返回链表 4->5.
"""
class Solution:
"""
... |
436ce1c65da388add7e566eb053657d93132b2ef | marcdloz/cosc4377-Computer-Networks | /practice4_1.py | 1,164 | 4.09375 | 4 | import math
current_score = 1000
max_score = 500
number, answer = 9, 0
if current_score > max_score:
print("A new high score!")
max_score = current_score
if number >= 0:
answer = math.sqrt(number)
print(answer)
else:
answer = -1
print(answer)
print(2 + 2 == 4)
print(4 < 3)
print(2 < 2.5)
p... |
e9ba83a71d911d4a569e3d525ef49d392974c2f7 | rhnvrm/mini-projects | /test_driven_dev/tests/test_parking_lot.py | 3,091 | 3.65625 | 4 | import unittest
from app.parking import Parking
from app.car import Car
class TestParkingLotCreation(unittest.TestCase):
def test_create_new_parking_lot(self):
park_lot = Parking(6)
result = park_lot.size
self.assertEqual(6, result)
def test_parking_raises_error_if_arg_is_not_a_nu... |
ec0623933ecbda22d27afd07a18e79ca51469a8b | avellar1975/python | /cursoemvideo/exercicio030.py | 202 | 4.1875 | 4 |
n = int(input('Digite um número inteiro: '))
r = n % 2
if (r == 0):
print('O número digitado foi {}, ele é PAR'.format(n))
else:
print('O número digitado foi {}, ele é IMPAR'.format(n))
|
68302cf67e0ec80525548ee2b6f6c771ea053e6f | sigerclx/python | /python-book01/2018/2018-05/P071-string.py | 278 | 3.828125 | 4 | name = 'Jackyzhao'
print (name[0])
print (name[-2])
print (name[0:4])
print (name[:])
print ('Jac' in name)
print ('ack' in name)
print ('Ack' in name)
for i in name :
print ('---'+i+'----')
name = 'Jacky zhao'
newName = name[0:5]+' and ' + name[6:]
print (newName)
|
8975358b0f3596e406acc5cda3053c4d08c866cb | wagolemusa/Class | /employ.py | 454 | 3.78125 | 4 | class Employee:
def __init__(self, first,last,pay):
self.first = first
self.last = last
self.pay = pay
self.email = first + '.' + last + '@company.com'
# method to dispaly fullname
def fullname(self):
return '{} {}'.format(self.first, self.last)
emp_1 = Employee('Corey', 'Schofar', 500000)
e... |
48da3ea0fb9da1a7d2a894d5761f0b96a7306ed0 | HaTrang97/How-to-think-like-a-computer-scientist | /littleTurtleClock.py | 656 | 4.21875 | 4 | % let the turtle move a shape like a clock
import turtle
screen = turtle.Screen() % view screen
screen.bgcolor('lightgreen') % set back ground color
screen.title('Hello, Trang!') % set the title
alex = turtle.Turtle() % give him a name!
alex.shape('turtle') % let alex be a turtle
alex.color('blue') % set the color fo... |
1d5e0a0a6b67ea7e5263abe748361de0bb92c033 | SergueiBaskakov/ML | /Semana01/Arreglos_Matrices_DotProduct.py | 854 | 3.8125 | 4 | # -*- coding: utf-8 -*-
"""
Editor de Spyder
Este es un archivo temporal.
"""
import numpy as np
def main():
a = (np.random.rand(1,4)*10+1)
b = (np.random.rand(1,4)*10+1)
"""print(a)
print("tamaño: ", a.size)"""
"""c= (np.random.rand(2,4))
print(c)
print("tamaño: ", c.size)
print... |
4011f06b397b24b5acfbb92269e1226b7a7b7328 | jobevers/vsh | /vsh/cli/support.py | 1,516 | 3.640625 | 4 | import sys
import textwrap
def echo(*messages, verbose=None, indent=True, end=None, flush=None, file=None):
"""Echo *message*.
indentation can be finely controlled, but by default, indentation
is related to the verbose setting set by the command-line interface
and the verbose setting passed in as a p... |
f07f7e851fe9d5554686094ba2eaf09d05861ad5 | Keerthanavikraman/Luminarpythonworks | /regular_expression/quantifier_valid5.py | 263 | 3.71875 | 4 | #starting with a upper case letter
#numbers,lowercase,symbols
#Abv5< G6 R. Tt Dhgfhjkhg6t667":';;
import re
n= input("enter ")
x="(^[A-Z]{1}[a-z0-9\W]+)"
match = re.fullmatch(x,n)
if match is not None:
print("valid")
else:
print("invalid")
|
cab14a0af916d12beaa2638b0b151e5ef80eba37 | sumanth-vs/ProjectEuler | /test.py | 8,217 | 4.21875 | 4 | MERGE SORT
'''
def mergeSort(arr):
if len(arr) >1:
mid = len(arr)//2 #Finding the mid of the array
L = arr[:mid] # Dividing the array elements
R = arr[mid:] # into 2 halves
mergeSort(L) # Sorting the first half
mergeSort(R) # Sorting the second half
i ... |
5d256c8f0d1f37c26da0fc1135a194a479f6f630 | mickiyas123/Python-100-Exercise-Challenge | /49_pass.py | 309 | 3.875 | 4 | # Question: The code is supposed to get some input from the user, but instead it produces an error. Please try to understand the error and then fix it.
# pass = input("Please enter your password: ")
# pass can't be a variable name since it is reserved keyword
pass1 = input("Please enter your password: ") |
866c45de82fd2b95e71053659b2a78b33bead90f | Python3pkg/IoTPy | /IoTPy/modules/ML/plot.py | 1,617 | 4.15625 | 4 | import numpy as np
def plot(lst, state, plot_func, num_features):
""" This function plots data using the plot_func
Parameters
----------
lst : list
Data to plot
state : object
State used for predict and plot
plot_func : function
A function that processes the data for u... |
aae3e1887d164cc2d8b92572484635f4caa7cfda | AlanStorm/Python | /practice/函数式编程-按照权重排序.py | 970 | 3.609375 | 4 | # 权重
goods = [{"name": "good1", "price": 200, "sales": 100, "stars": 5, "comments": 400},
{"name": "good2", "price": 300, "sales": 120, "stars": 4, "comments": 500},
{"name": "good3", "price": 500, "sales": 3000, "stars": 2, "comments": 199},
{"name": "good4", "price": 1288, "sales": 8, "star... |
6499a5126cf4efa70724a88df3f34c4a090aae38 | AudreyLBacon/Final-Project-Party-Planner | /finalproject.py | 13,591 | 3.703125 | 4 |
from Tkinter import *
import tkMessageBox
from partycalc import *
import tkFont
#partycalc.Class.
root = Tk()
class Application(Frame): # Create a class called 'Application' (Which inherits from the 'Frame' class)#frame is a Tkinter thing for layout that holds everything
def __init__(self, master=None): # How... |
e9c0e8acc35bcd135a288838d5a8e910e5a8637c | adityakverma/Interview_Prepration | /LC-387. First Unique Letter in String.py | 1,622 | 3.640625 | 4 |
# Tags: Hash, String, Google, AWS, MS
# Given a string, find the first non-repeating character in it and
# return it's index. If it doesn't exist, return -1.
# Examples:
# s = "leetcode"
# return 0.
#
# s = "loveleetcode",
# return 2.
class Solution():
def uniqueLetter_aditya(self,s): # ACCEPTED
... |
c92a21cc061dc2d257de3d6e2b9e0bffcfae51ca | Virinox/saw_sharpening | /Exercise_37.py | 740 | 4.71875 | 5 | # Exercise 37
# Level 1
# written by: Vince Mao
# last modified: 2019.5.7
# Description:
# Define a function which can generate and print a list where the values are
# the square of numbers between 1 and 20 (both included). Print the last 5 elements in the list.
#
# Hint:
# Use the ** operator to calculate the power of... |
f0cdf4d9fc2596e19fa72d0c5ea87f150ffe0a49 | Abdelhamid-bouzid/problem-Sovling- | /Medium/convert.py | 1,190 | 4.40625 | 4 | '''
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)
P A H N
A P L S I I G
Y I R
And then read line by line: "PAHNAPLSIIGYIR"
Write the code that will take a string and make this conve... |
60bd29af7047f6234d46cb0c53f9db39a18c636b | leihuagh/python-tutorials | /books/AutomateTheBoringStuffWithPython/Chapter03/PracticeProjects/P01_make_collatz_seq.py | 859 | 4.59375 | 5 | # This program makes a Collatz Sequence for a given number
# Write a function named collatz() that has one parameter named number.
# If number is even, then collatz() should print number // 2 and return this value.
# If number is odd, then collatz() should print and return 3 * number + 1.
# Then write a program that ... |
e3ee856ab4f0ba61b4b0d9819ca959f543cd781a | tiddler/AutoDiff | /autodiff/node.py | 2,653 | 4.15625 | 4 | class Node(object):
"""Node in a computation graph."""
def __init__(self):
"""Constructor, new node is indirectly created by Op object __call__ method.
Instance variables
------------------
self.inputs: the list of input nodes.
self.op: the associated op object,
... |
4cdc4772d79a309608cad7a32b0dcee6085637c0 | vaibhav0103/Fb_Page_Bot | /fb_bot.py | 2,708 | 3.546875 | 4 | import facebook
from keys import *
import json
# Get Graph
graph = facebook.GraphAPI(access_token=access_token_pg)
FILE_NAME = 'last_post_id.txt'
# Retrive last post id
def retrieve_last_post_id(file_name):
f_read = open(file_name, 'r')
last_post_id = str(f_read.read())
f_read.close()
return last_p... |
669ae929a267ce425fa852cd392f7808cb932583 | iamlmn/PyDS | /algos/patterns/slidingWindows/smallestWindowContainingSubstring.py | 2,255 | 4.3125 | 4 | # Smallest Window containing Substring (hard) #
# Given a string and a pattern, find the smallest substring in the given string which has all the characters of the given pattern.
# Example 1:
# Input: String="aabdec", Pattern="abc"
# Output: "abdec"
# Explanation: The smallest substring having all characters of the p... |
c42d85e296e1b71ffff909e2a7791a72ec2e99e3 | linlilin/GA | /coba.py | 1,251 | 3.859375 | 4 | """
Matplotlib Animation Example
author: Jake Vanderplas
email: vanderplas@astro.washington.edu
website: http://jakevdp.github.com
license: BSD
Please feel free to use and modify this, but keep the above information. Thanks!
"""
from matplotlib import pyplot as plt
from matplotlib import animation
# First set up the... |
cdd303c47b0449aeeb0d66f4b994e0d501c2ed07 | anaxmnenik/Mk-PT1-41-21 | /Tasks/Kuchko/test.py | 544 | 3.78125 | 4 | #Депозит:
#начальная сумма - 20000 BYN
#срок - 5 лет
#процент (годовой) - 15%
#ежемесячная капитализация
#Вычислить сумму на счету в конце указанного срока.
a = int(input("Введите начальную сумму: "))
b = int(input("Введите срок: "))
c = float(input("Введите процент: "))
# ежемесячная капитализация
summa = a * ((1 ... |
84837d2193df06037893adc401ca856d2b29e465 | Quelklef/gin-bots | /interactive.py | 5,828 | 3.75 | 4 | """
For playing a human player against a bot using a physical deck.
Sample REPL code to use this module:
>>> import sys
>>> sys.path.append('bots/simple')
>>> from simple_gin import simple_bot
>>> import interactive
>>> interactive.play(simple_bot, bot_plays_first=True)
Of course, you can replace the simple... |
18169c3cee52110cd8a4841890f5056aafbc749d | Logan-Greenwood/py4e | /saved-things/week7-8/readingfiles.py | 430 | 3.71875 | 4 | # Use the file name mbox-short.txt as the file name
fname = input("Enter file name: ")
fh = open(fname)
total = 0
count = 0
for line in fh:
if not line.startswith("X-DSPAM-Confidence:") : continue
count += 1
line = line.rstrip()
start = line.find(":")
num2add = float(line[start + 1:])
total += n... |
06e899d38de05cd8fb293cb1b1a4453ec701525c | Modrisco/OJ-questions | /Project Euler/001-100/025.py | 419 | 3.5 | 4 | # 1000-digit Fibonacci number
# def fib(n):
# a = 1
# b = 0
# while n > 1:
# a, b = a+b, a
# n-=1
# return a
# def binetFibFormula(n):
# n = decimal.Decimal(10)
# return len(str(int((((1+sqrt(5))**n - (1-sqrt(5))**n)/(2**n*sqrt(5))))))
# print(binetFibFormula(100))
flag = 0
l = [1, 1]
i = 1
while (flag ==... |
ad4eb754aa253b059faf8f59cb6ad049f05e48ce | himanshuKp/python-practice | /challenges/find_common.py | 671 | 4.15625 | 4 | # Write a function called common_letters that takes two arguments, string_one and string_two and then returns a list with all of the letters they have in common.
# The letters in the returned list should be unique. For example,
# common_letters("banana", "cream")
# should return ['a'].
def common_letters(string_one,... |
eef52efd59b653da76902f30bd58723977341a73 | Lorena-ReyF/CursoPythonOctubre2019 | /EjemploRandInt.py | 212 | 3.53125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Oct 20 10:35:21 2019
@author: yocoy
"""
#from random import randint
#
#print(randint(0,100))
def funcion():
print("Hola")
return 0
x = funcion()
print(x) |
e709968572f9d74dfcee6c849dd55787116124a3 | thushanp/CodingPuzzles | /mergesort.py | 774 | 3.75 | 4 | def msort3(x):
# initialise my results array
result = []
# case for when we get to single elements
if len(x) < 2:
return x
# find middle of the given array
mid = int(len(x) / 2)
# recursively sort lower and upper half
y = msort3(x[:mid])
z = msort3(x[mid:])
... |
50511769268366390cee3793e072ee8d16f5a5a8 | co-dh/euler_in_j | /set_partition.py | 175 | 3.5625 | 4 |
def sp(n):
"int -> [ [int] ] "
if n == 1:
yield [1]
return
else:
for a in sp(n-1):
for last in range(1, max(a)+2):
yield a+[last]
print list(sp(4))
|
6814d483932c63d8d9f184a38927b51ba412e0e8 | LeslieK/PyScheme | /modularity.py | 5,785 | 4.28125 | 4 | """
using streams to modularize a program without storing state
each stream value represents a state
successive values represents values over time
streams allow you to go back in time; i.e. roll back state!
Ex. 3.81, 3.82
"""
from pairs import integers_starting_from, integers
from iterStreams import stream_map, stream... |
acc410f13c7f70349277fae6a80cbf6413fde68a | a-utkarsh/python-programs | /Numpy/Joining.py | 1,227 | 3.609375 | 4 | # Concatenate
import numpy as np
a = np.array([[1,2],[3,4]])
print ('First array:')
print (a)
print ('\n')
b = np.array([[5,6],[7,8]])
print ('Second array:')
print (b)
print ('\n')
# both the arrays are of same dimensions
print ('Joining the two arrays along axis 0:')
print (np.concatenate((a,b)))
print ('\n')
print (... |
d0b03677ed4468d54030200f79daf408182661ab | jrecuero/pyos | /apps/pytres/collision.py | 505 | 3.5 | 4 | from point import Point
class CollisionBox:
def __init__(self):
self.box = set()
def add(self, item):
self.box.add(item.hash())
def collision_with(self, other_box):
return self.box.intersection(other_box.box)
def collision_with_upper(self, collision):
upper_box = Col... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.