blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
eecd03e4ac10c672cf239475946e062479be2cc1 | nandadao/Python_note | /note/download_note/first_month/day09/answer_exercise/exercise05.py | 1,025 | 3.984375 | 4 | """
创建函数,生成指定行数的杨辉三角。
杨辉三角:
每行端点与结尾的数为1,每个数是它左上方和右上方的数的和
输入:6
输出:
[
[1],
[1, 1],
[1, 2, 1],
[1, 3, 3, 1],
[1, 4, 6, 4, 1],
[1, 5, 10, 10, 5, 1]
]
"""
def get_yang_hui_triangle(ro... |
9530887f7114f4f51ec489ca04921bc0538f7011 | yosshor/my-repository | /python_course/substracting.py | 1,063 | 4.15625 | 4 | def substracting(first_num, second_num):
"""This function take two argument and substracting the second_num from the first_num
:param first_num : first_num value
:param second_num : second_num value
:type first_num : int or every num that you want to insert
:type second_num : in... |
24ac9f43bd4e79f31d7fb91c5a2d8b25ed8ecd4c | andrebola/Yoruba-Intonator | /transformations.py | 1,475 | 3.859375 | 4 | from char_to_unicode import readable_char_to_unicode
import string
eng_letters = string.ascii_letters
"""Creates a dictionary from english chars to all possible
readable unicode chars"""
def all_accent_transformations():
readablechars = readable_char_to_unicode.keys()
transformations = {}
for ch in eng_letters:
... |
18b615450bbc0f5fdba6e6bf51929b9deafe12ca | sarkarChanchal105/Coding | /Leetcode/python/Easy/maximum-subarray.py | 2,221 | 3.890625 | 4 | """
https://leetcode.com/problems/maximum-subarray/
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.
Follow up: If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is ... |
8dc889ba9f9a0f7631b6ebfc48e1ab90decc0b50 | Djcarrillo6/TwilioQuest-Python | /fizzbuzz.py | 258 | 3.8125 | 4 |
import sys
sys.argv.pop(0)
for arg in sys.argv:
if (int(arg) % 3 == 0) and (int(arg) % 5 == 0):
print("fizzbuzz")
elif int(arg) % 5 == 0:
print("buzz")
elif int(arg) % 3 == 0:
print("fizz")
else:
print(arg)
|
a96782245fd255d87b9aa37f726d8c4b7dfda7cb | m860/data-analysis-with-python | /practises/test-threadpool.py | 887 | 3.53125 | 4 | # from multiprocessing.dummy import Pool as ThreadPool
# def squareNumber(n):
# print(n)
# return n ** 2
#
#
# # function to be mapped over
# def calculateParallel(numbers, threads=2):
# pool = ThreadPool(threads)
# results = pool.map(squareNumber, numbers)
# pool.close()
# pool.join()
# re... |
9d268dee60f6ae83d72694b6880cde1a69a31d60 | Neocher/neupy | /neupy/algorithms/basics/lms.py | 1,282 | 3.71875 | 4 | import numpy as np
from neupy.algorithms.basics.base import SimpleTwoLayerNetwork
__all__ = ('LMS',)
class LMS(SimpleTwoLayerNetwork):
""" LMS Neural Network. Algorithm has several names, including the
Widrow-Hoff or Delta rule. Algorithm similar to :network:`Perceptron`
Neural Network, but has differe... |
02368b4653c06d7620fac3ed1722432acd955f33 | jeina7/HackerRank_Challenges | /30Days_of_Code/Day27_Testing.py | 2,221 | 3.921875 | 4 | # Hackerrank 30 Days of code Challenge
# https://www.hackerrank.com/domains/tutorials/30-days-of-code
# Day 27
def minimum_index(seq):
if len(seq) == 0:
raise ValueError("Cannot get the minimum value index from an empty sequence")
min_idx = 0
for i in range(1, len(seq)):
if seq[i] < seq[min... |
25969662f469718a3bd05b51a3ca4da384cb7b1a | dernaut/Sockets-con-hilos-Python | /Taller4/Cliente.py | 1,794 | 3.53125 | 4 | import socket
TCP_IP = '127.0.0.1'
TCP_PORT = 5000
BUFFER_SIZE = 1024
print ("-----------------------------------------------\n")
print ("PRESENTADO POR JULIAN GIRALDO CARDONA\n")
print ("LUIS ZULUAGA, JAIME MARIN, DANIEL LADINO\n")
print ("-----------------------------------------------\n")
cod=""
s = socket.... |
87020eb5dfa2c2f966359d6599da959791731e2e | HenryFroylan123/Ejercicios | /Patrones/Patrones.py | 2,212 | 3.8125 | 4 | import re #libreria de expresiones regulares
filename = "ExpresionesRegulares.txt"
try:
#lectura del archivo, pasandolo a una variable
archivo = open(filename, 'r')
except:
print ('El archivo que intentas abrir no existe')
quit()
texto = ''
#lectura de lineas del archivo para ser pasados a una ... |
eeed4b12792cafae2d7c54b0dc754d03444736a0 | gustavorb5/python-works | /discount_table.py | 233 | 3.859375 | 4 | discount = 0.60
price_list = [4.95, 9.95, 14.95, 19.95, 24.95]
for price in price_list:
total = round(price - (discount*price), 2)
print(
f'Your product costs ${price}, but with the discount now it\'s only ${total}')
|
f9f7c49a61b60b0cd64ca782e6e5a2d9aefe3aa3 | VishwanathOnGit/Python-Projects | /File_Rename/RenameMyStack.py | 671 | 3.828125 | 4 | """
Rename More than one file in a directory.
NOTE: BELOW CODE IS STILL STATIC.
"""
import os # Import OS Package
try:
os.chdir('D:/DataScience/') # Path of File
print(os.getcwd()) # Return Current Working Directory
lst_dir = os.listdir() # Lis... |
a3aee7eb35f074bc3030bb58d3864fe462f83ef6 | 634480/smoothie | /27 sep_POO/ani.py | 323 | 3.625 | 4 | class Animales:
'clase para creacion de animales'
cuenta = 0
def __init__(self, ojos, pelaje, estatura):
self.ojos = ojos
self.pelaje = pelaje
sel.estatura = estatura
Animales.cuenta += 1
def ladra (self):
print
def muerde (self):
pri... |
cce356e716f95e181bc2c47833aeb78cc1f350fe | Kurdupov/Colocvium | /col24.py | 1,214 | 3.671875 | 4 | # 24. Знайти суму елементів масиву цілих чисел, які діляться на 5 і на 8
#одночасно. Розмірність масиву - 30. Заповнення масиву здійснити випадковими
#числами від 500 до 1000.
#Курдупов Олексій 122Г
import numpy as np #імпортуємо Бібліотеку numpy .
import random #імпортуємо random
while True:
Z=np.zeros(30,dtype=in... |
c87d7b550e91b361fc811e62ab61ef33b88b1795 | Jeanpigi/Python | /basic/funcion.py | 405 | 3.625 | 4 | def add(numero1, numero2):
total = numero1 + numero2
return total
print(add(2, 2))
def nombre_completo(nombre, apellido, inverso=False):
if inverso:
return print(f'{apellido} {nombre}')
else:
return print(f'{nombre} {apellido}')
nombre_completo('Jean Pierre', 'Arenas')
nombre_compl... |
4d10dcb86334196531f7680187d5caf3b89e7199 | avigupta10/SDE-interview-questions | /Day8/N meeting in one room.py | 629 | 3.640625 | 4 | # User function Template for python3
class Solution:
# Function to find the maximum number of meetings that can
# be performed in a meeting room.
def maximumMeetings(self, n, start, end):
# code here
st, en = -1, -2
prev = -1
ans = 0
v = []
for i in range(n)... |
6c51fd9dc94fc7e80f3fb933ba658e59d192e730 | ljwhite/python | /basics/sqlite_python.py | 2,586 | 3.90625 | 4 | import sqlite3
import sys
import csv
db_conn = sqlite3.connect('test.db')
print("Database Created")
the_cursor = db_conn.cursor()
db_conn.execute("DROP TABLE employees")
def print_db():
try:
result = the_cursor.execute("SELECT id, f_name, l_name, age, address, salary, hire_date FROM employees")
... |
6e68015e117aaea9c9c8b2b6fe9f0b41729eb9b0 | PrathikT24/Python_Basics | /leap.py | 186 | 4.09375 | 4 | year=int(input("Enter a year \n "))
if year%4==0:
print("Leap year \n ")
elif year%100==0 and year%400==0:
print("Leap year \n ")
else:
print("Not a leap year \n ")
|
193db9a5da4932390431d7d3a055442da2c2e40e | LeonDuan/Leetcode-Solutions | /src/82.removeduplicatesfromsortedlistii.py | 861 | 3.6875 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def deleteDuplicates(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
toRemove = {}
cur = h... |
5764eb9d7deb86ff1788f74c944bfe77427afc5f | gfarrasb/compumath | /ER2.py | 775 | 3.671875 | 4 | import sys
import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
total = len(sys.argv)
if total <> 3:
print "Usage: python ER2 n-nodes p-probability. We will generate a random graph"
sys.exit("Error")
numnodes = int(sys.argv[1])
prob = float(sys.argv[2])
print ("# nodes: " + str(numnodes))
pr... |
a1d0529533c5a90be73ceba1a1ce0e07ad580c59 | hyde1004/CodingBat | /string-1.py | 2,869 | 3.640625 | 4 | import unittest
def hello_name(name):
return 'Hello ' + name + '!'
def make_abba(a, b):
return a + b + b + a
def make_tags(tag, word):
return '<' + tag + '>' + word + '</' + tag + '>'
def make_out_word(out, word):
return out[:2] + word + out[2:]
def extra_end(str):
# return (str[-2] + str[-1]) * 3
return str[... |
3a8100d103fdea5231aca9c4c8def72d174be064 | 5tarlight/first-python | /basic/dictonary.py | 96 | 3.65625 | 4 | a = {
'name': 'pey',
'phone': '123123',
'birth': '0817'
}
for k in a.keys():
print(k)
|
0c8ab5ca5b89f4fa212ba408ceafbc78884b8170 | wlouhichi/Customers-Activity-Simulation | /FutureEventList.py | 705 | 3.71875 | 4 |
import heapq
from Event import Event
class FutureEventList(object):
"""
Engine for discrete event simulation.
"""
def __init__(self):
self.FEL = []
def isEmpty(self):
return len(self.FEL) == 0
def schedule(self, timestamp, customer, callback):
""" pq specifies which queue to schedule in.
"""
e = Ev... |
89f27c6087b440db405b95fe741182fa8ce7a6ef | xys234/coding-problems | /algo/heap/find_kth_smallest_sum_in_sorted_array.py | 2,285 | 3.734375 | 4 | """
1439.
Hard
You are given an m * n matrix, mat, and an integer k, which has its rows sorted in non-decreasing order.
You are allowed to choose exactly 1 element from each row to form an array.
Return the Kth smallest array sum among all possible arrays.
Example 1:
Input: mat = [[1,3,11],[2,4,6]], k = 5
Out... |
3b2e33603e0ada2df8b6855e57010291e0035ffe | serashioda/code-katas | /src/count_bits.py | 181 | 3.578125 | 4 | """Implementation of the Bit Counting Kata."""
def count_bits(n):
"""Convert a number to binary and counts the number of 1 bits."""
val = bin(n)
return val.count("1")
|
f9ecf5bceb18e7e6d78d8e1b20af8115afbbdadc | jtc01/learn-arcade-work | /Scratch Work/drawing_samples.py | 2,277 | 4.0625 | 4 | """
This program will show how to draw
using arcade and python
"""
#import arcade
import arcade
#open an arcade window
#set width, height, and title
arcade.open_window(600,600, "Drawing example")
#choose backround color
arcade.set_background_color(arcade.csscolor.SKY_BLUE)
#start drawing
arcade.start_render()
#draw le... |
03dafab9176511b003c6fadd3f92ff1f98d45884 | SaraBrito-developer/sequencia_fibonacci_simples | /fibonacci_simples.py | 477 | 4.1875 | 4 | sequencia = int(input("Quantos numero Fibonacci você deseja? "))
contagem = 0
num1, num2 = 0, 1
if sequencia <= 0:
print("você precisa digitar um numero maior que 0")
elif sequencia == 1:
print("sequencia numerica fibonacci",sequencia,":")
print(num1)
else:
print("A sequencia Fibonacci requisitada foi... |
90c5a79df45dc0df67d90838b0a0b511ad33dee0 | MMSuperD/PythonStudy | /系统学习Python/网络/06.socket_tcp下载数据服务端.py | 791 | 3.5625 | 4 |
import socket
def main():
#1.创建套接字
socket_tcp_server = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
#2.绑定本地信息
add = ("",3005)
socket_tcp_server.bind(add)
#3.socket 由主动变为被动(listen)
socket_tcp_server.listen()
while True:
print("witing...")
#4.等待客户端连接 accpet
new_client_socket,client_addr... |
71bb4641c0b73f2388a886b12c4058bb73e1723c | love-adela/algorithm-ps | /acmicpc/11403/11403.py | 848 | 3.703125 | 4 | import sys
def bfs(vertex:int, distance:int):
queue = [vertex]
visited = [False] * N
flag = False
while queue:
vertex = queue.pop(0)
if not visited[vertex]:
visited[vertex] = True
for elem in adjacent[vertex]:
if elem == distance:
... |
663119cf908b2cf78260a252883609b11ff80bcc | wang264/JiuZhangLintcode | /AlgorithmAdvance/L6/optional/118_distinct-subsequences.py | 2,209 | 3.78125 | 4 | # 118. Distinct Subsequences
# 中文English
# Given two strings S and T. Count the number of distinct subsequences of S which equals T.
#
# A subsequence of a string is a new string which is formed from the original string by deleting some
# (can be none) of the characters without disturbing the relative positions of the ... |
ac520ac5e4d1b8d0530aa1680dc9b307933009ab | missbanks/pythoncodes | /17072018.py | 860 | 3.671875 | 4 | import csv
# tuples is defined as a heterogenous group of items although
# in practiise heterogenity is not actually enforced
#to create a tuple
tuple_1 = () # tuple literal
tuple_2 = tuple() # tuple method
#tuple are imutable
# print(tuple_1)
# print(tuple_2)
#
# flightsfile = oepn("fights.csv")
# reader = csv.read... |
a76f1dc31af777d4da09cbac1245c2dddcdf4127 | sandeepyadav10011995/Data-Structures | /Pattern-Slow And Fast Pointer/6. Rearrange A Linked List.py | 4,087 | 4.0625 | 4 | """
The Fast & Slow pointer approach, also known as the Hare & Tortoise algorithm, is a pointer algorithm that uses two
pointers which move through the array (or sequence/LinkedList) at different speeds. This approach is quite useful when
dealing with cyclic LinkedLists or arrays.
By moving at different speeds (say, i... |
4fbd1fbfc0263d8cb61376d2be3d1e49ddf29987 | DLeonski/bootcamp | /Day1/Zadanie10.py | 354 | 3.828125 | 4 | a = float(input("Podaj pierwszą liczbę: "))
b = float(input("Podaj drugą liczbę: "))
c = input("Podaj rodzaj operacji: ")
if c == "+":
w = a + b
elif c == "-":
w = a - b
elif c == "*":
w = a * b
elif c == "/" and b != 0:
w = a / b
if c == "/" and b == 0:
d = ("Nie można tego obliczyć.")
else:
d ... |
3403ea8ba270ed77b4ed1ed6085cde068f5f9f7c | vishalsinha21/python-basics | /module_demo.py | 238 | 3.640625 | 4 | import itertools
n = [10, 13, 16, 22, 9, 4 , 37]
even = []
odd = []
for key, grp in itertools.groupby(n, key=lambda i:i%2 == 0):
if key:
even.extend(grp)
else:
odd.extend(grp)
print(even)
print(odd)
|
7b208b6133b92f5db6a15b6a9bbf5215d3461209 | aydin-parvez/playground | /alien_invasion.py | 1,036 | 4 | 4 |
aliens = 2
password = "SNAKE"
population = 7400000000
print()
print()
print("You need to activate the global defence network.")
print("Hope you know the password, for Earth's sake...")
print()
print("--------------------------------------------------------------------------------")
print(" WELCOME... |
76bb00fc34358d4fd7d7172487bfafc6b121f3e0 | BerilBBJ/scraperwiki-scraper-vault | /Users/D/Dahl/test2_2.py | 1,344 | 3.671875 | 4 | #ERDETFREDAGSCRAPER
import scraperwiki
import urllib2
import lxml.html
print "Is it friday?"
url = 'http://erdetfredag.dk'
response = urllib2.urlopen(url)
html = response.read()
print "Lets find out!"
print html
root = lxml.html.fromstring(html) # turn our HTML into an lxml object
ERDET = root.cssselect('body') #... |
47530858c1a9f01df3f3844e5c307048d0ea4a22 | Aasthaengg/IBMdataset | /Python_codes/p02380/s853696457.py | 279 | 3.5 | 4 | from math import sin, cos, radians, sqrt
a, b, C = map(float, input().split())
C = radians(C)
S = a * b * sin(C) * 0.5
h = 2.0 * S / a
c = sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(C))
L = a + b + c
print("{:.10f}".format(S))
print("{:.10f}".format(L))
print("{:.10f}".format(h))
|
90e30f8c75e9f3f8bdaf562391c9390fc0b4b685 | skonienczwy/DataScience | /DataScienceFromScratch/Statistics/Dispersion/StandardDeviation.py | 292 | 3.96875 | 4 | import math
from typing import List
from Variance import variance
num_friends = [1,10,2,9,5,2]
def standard_deviation(xs : List[float])-> float:
'''The standard deviation is the square root of the variance'''
return math.sqrt(variance(xs))
print(standard_deviation(num_friends) ) |
7b4b1c294b01f28d9260540f325bd0b7d3580165 | kemrop/LearnCenter | /unit/car_test.py | 1,140 | 3.765625 | 4 | import unittest
from car import car
class TestCar(unittest.TestCase):
def setUp(self):
self.car_make = "Toyota"
self.car_model = "Camry"
self.car_year = "1999"
self.car_owner = "Car Owner"
self.car_mileage = 140000
unittest.TestCase.setUp(self)
self.car = ca... |
b042e81c2b6900806cd9ef6323a9a9d788f9071b | karnwatcharasupat/Algorithms-for-DNA-Sequencing | /Programming Assignments/Week 3/main.py | 975 | 3.5625 | 4 |
from utils import readGenome
from editDistance import editDistance
f = "chr1.GRCh38.excerpt.fasta"
t = readGenome(f)
def bestMatchDistance(x, y):
# Create distance matrix
D = []
for i in range(len(x)+1):
D.append([0]*(len(y)+1))
# Initialize first row and column of matrix
for i in range(l... |
b27bdc20978ca3365e8fe5b87f1f1207f7d48774 | nish235/PythonPrograms | /Oct15/ArmstrongWhile.py | 252 | 4.125 | 4 |
num = int(input("Enter a number: "))
s = 0
temp = num
while temp > 0:
dig = temp % 10
s = s + dig ** 3
temp = temp // 10
if s == num:
print(num, "is an Armstrong number")
else:
print(num, "is not an Armstrong number")
|
7520f81224fc3070c4da07b8233404948133aca2 | VanessaVallarini/uri-online-Python-3 | /1060.py | 266 | 3.5625 | 4 | l=[]
soma=0
l.append(float(input()))
l.append(float(input()))
l.append(float(input()))
l.append(float(input()))
l.append(float(input()))
l.append(float(input()))
for n in l:
if (float(n)>0):
soma= soma+1
print(soma,"valores positivos")
|
98f325a516515d4f3f3ce4061b5c62ea20d1391c | tamirfri/WorldOfGames | /_strings.py | 835 | 3.546875 | 4 | hello_name = """
Hello {} and welcome to the World of Games (WoG).
Here you can find many cool games to play
"""
game_to_play = """Please choose a game to play:
1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back
2. Guess Game - guess a number and see if you chose like the com... |
63d6cfbb12427f1d6607336ad73dd353b3ed08d4 | SR-Sunny-Raj/Hacktoberfest2021-DSA | /27. LeetCode Problems/7. Reverse_Integer.py | 1,030 | 3.921875 | 4 | """
7. Reverse Integer #969
Link:- https://leetcode.com/problems/reverse-integer/
Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0.
Assume the environment does not allow you to store 64-bit... |
83f40f07dde247a3bde555e3bf1be8cea9d7e9fc | ousikin/PythonReview | /python33-55/53 异常.py | 329 | 3.796875 | 4 | '''
try:
可能出现异常的代码
except:
如果有异常执行的代码
finally:
无论是否有异常都会执行的代码
'''
def add(a, b):
try:
return a / b
except:
print('除数不能为0')
finally:
print('你好啊')
c = add(1, 0)
print(c)
|
cb3f0359b2e42d02305e7432e14c9b7affdb016c | Ayon-Ghosh/basic_SQLlite_Flask | /sql-search.py | 689 | 3.84375 | 4 | import sqlite3
import random
with sqlite3.connect("newnum.db") as connection:
c = connection.cursor()
prompt = "Select the operation that you want to perform [1-5]: 1.Average 2.Max 3.Min 4.Sum 5.Exit"
user_int_map = {'1':"SELECT AVG(num) FROM numbers",
'2':"SELECT MAX(num) FROM numbers",
... |
c19d86bbb78bc6096d4bbe691b1f362560e59e99 | kalmahan/Python | /program.py | 464 | 3.5625 | 4 | time = int(input("Ввести время"))
if time >= 1 and time <= 6:
print("Ночь")
elif time >= 6 and time <= 9:
print("утро")
elif time >= 9 and time <= 12:
print("Полдень")
elif time >= 12 and time <= 15:
print("Обед")
elif time >= 15 and time <= 18:
print("Вечер")
elif time >= 18 and time <= 24:
pri... |
fa422b426bf96b87697a0a610496e32270197054 | lhk2013/sky-py | /study.py | 3,189 | 4 | 4 | # -*- coding: utf-8 -*-
flag = False
if flag:
print "True"
else:
days = ['Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday']
print "False"+ " "\
"False"
print days
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# 文件名:test.py
# 第一个注释
'''
这是多行注释,使用单引号。
这是多行注释,使用单引号。
这是多行注释,使用单引号。
'''
""... |
395edc00fd293e99018e1d3dd499dae3a4d5262c | NamanMathur77/programming_questions | /Object_Oriented_Programming/datastructures/queue_using_stacks.py | 1,007 | 4.21875 | 4 | # enQueue(q,x)
# while stack1 is not empty, push everything from stack1 to stack2
# push x to stack1
# push everything back to stack1.
# deQueue(q)
# if stack1 is empty then error
# pop an item from stack1 and return it
class Queue:
def __init__(self):
self.s1 = []
self.s2 = []
def enQueue(self, x):
if len(se... |
c64d59b8861a8fa75f4eedc5203b9e9fba3b0381 | drtierney/hyperskill-problems | /Python/Topics/Class instances/Students/main.py | 419 | 4.03125 | 4 | class Student:
def __init__(self, name, last_name, birth_year):
self.name = name
self.last_name = last_name
self.birth_year = birth_year
# calculate the student_id here
self.student_id = name[0] + last_name + birth_year
s_name, s_last_name, s_birth_year = [input() for n in... |
3b06a1b901b5f82e59756bf529ee0a60705d88f8 | jonnyf89/AirlineManagementSystem | /countryAtlas.py | 1,818 | 4.09375 | 4 | '''CountryAltlas class holds information on aircrafts'''
'''it takes a csv file as an input and uses this to populate a dictionary object with relevant data about each aircraft type'''
import csv
from country import Country
class CountryAtlas:
__countryDict = {} #this is the dictionary... |
feaf2681ef05d862faf4b31e8cf80ae5bcea260c | ETorres95/Hoja-de-Programacion | /Ejer 05.py | 84 | 3.640625 | 4 | n = int(input('Ingrese un digito: '))
s = (n*(n+1)/2)
print('La sumatoria es: ', s)
|
5b06bde0215df2a90f86ddcd1e7cfc9077d6cab0 | ShengBian/CS325 | /HW4/lastToStart.py | 2,822 | 4.15625 | 4 | # Author: Sheng Bian
# Date: April 28, 2017
# Description: This program read input from a file named act.txt. The
# file contains lists of activity sets with number of activities in the
# set in the first line followed by lines containing the activity number,
# start time & finish time. The program will use last-... |
31ac315070c9493f21543ad133b963966f372933 | ProperBeowulf/cp1404practicals | /prac_05/word_occurrences.py | 449 | 4.125 | 4 | word_dictionary = {}
user_string = input("please enter a string")
words_list = user_string.split()
for word in words_list:
if word in word_dictionary:
word_dictionary[word] += 1
else:
word_dictionary[word] = 1
words_list = list(word_dictionary.keys())
words_list.sort()
longest_word = max(len(... |
e56ff432a7fc54bb2cb9d3e9cff0ccd76ae67ba8 | vthaver/pythonfordatascience | /learnpython_hard/ex13_Parameters_Unpacking_Variables.py | 737 | 4.09375 | 4 | #Exercise 13 LPTHW: Parameters, Unpacking, Variables
# cover one more input method to pass variables to a script. You can use a python script with custom npouts without having to do user input one a a time for each variable.
from sys import argv #from the sys library import a feature...
# this line unpacks the argv ... |
fb25097306923ce99e4e761c974e6a8d47375827 | OmarSalah95/Lambda-Treasure-MUD-Automation | /adv.py | 13,352 | 3.53125 | 4 | import requests
import json
import random
import time
from player import Player
from api import url, key, opposite, Queue
player = Player()
def get_name(name):
"""
Using the most recent locations of treasure, the player travels to those rooms
and picks up items until inventory is full, then will automati... |
bf2e3aedb861ab96bbce7cc8d79e28b7378ef05d | pramod-cpu/python | /functional programs/triplets.py | 550 | 3.84375 | 4 | '''
author - Pramod
date - 20-1-2021
package -functional programs
Title - Sum of three Integer adds to ZERO
'''
def findTriplets(arr, n):
found = True
for i in range(0, n-2):
for j in range(i+1, n-1):
for k in range(j+1, n):
if (arr[i] + arr[j] + arr[k] == 0):
... |
d8100b16ee6d0267760db685e9664b2611e1d96e | Raidro/Programas-para-Aprender-Python- | /11_Experimentos - Estruturas de Controle.py | 280 | 3.75 | 4 | #=======================================#
# EXPERIMENTOS - EXTRUTURAS DE CONTROLE #
#=======================================#
a = 4 # variavel global
if a==2:
print ('A e igual a 2')
elif a==3:
print ('A e igual a 3')
else:
print ('A n e nem 2 nem 3') |
c2f63b97f21f1c3b825bc3f3b9e9263a9a0e84bf | DoctorLai/Codeforces | /D/Python/171D.py | 147 | 3.609375 | 4 | n = int(raw_input(""))
if (n == 1):
print 2
elif (n == 2):
print 3
elif (n == 3):
print 1
elif (n == 4):
print 2
else:
print 1 |
78ebc3fdb00d42c2f5a00afc0164993adc3169e0 | khatiakilanava/DS-Homework | /client-main.py | 14,473 | 3.546875 | 4 | """
MAIN STRUCTURE: GUI -> **Tkinter** contains __ pages -> {Client(base), Login, Joining, Waiting, Playing, Result}
User data stored in class **Userinfo**. And use this class to talk to server. (Tkinter for logic, Userinfo give function)
"""
"""
Every game login first, then create character and name. So in this game, ... |
4d877324c6ff192b353a002aecb086f648b09007 | FanboyxD/-Proyecto-1 | /proyecto 3 final/Dakar deaht.py | 5,713 | 3.5625 | 4 | #------------------------Librerias-----------------------------------#
from tkinter import *
import random
import tkinter.font
import tkinter.messagebox
import json
import game
#-------------------------Ventana del menu(tkinter)------------------#
root = Tk()
root.wm_title("Dakar Death")
root.resizable(widt... |
c6e74e75ad73427faee040d00beb82ef60604fd9 | StarlordHarsh/Python | /list.py | 413 | 3.703125 | 4 | inventory = ["sword", "armor", "shield", "healing potion"]
start = int(input("\nEnter the index number to begin a slice: "))
finish = int(input("Enter the index number to end the slice: "))
print("inventory[", start, ":", finish, "] is", end=" ")
print(inventory[start:finish])
inventory[1:6] = ["orb of future telling"]... |
90b6f4d856a76b93f716af2ddc481c57f16e8baa | nicluo/speed-runner | /speedrunner/ui/srwindow.py | 1,653 | 3.5625 | 4 | """
Tkinter-based UI
"""
import sys
import Tkinter as tk
from .redbutton import RedButton
from .numberdisplay import NumberDisplay
from .borderedframe import BorderedFrame
from .subwindow import SubWindow
APP_WIDTH = 180
APP_HEIGHT = 180
WINDOW_PADDING = 50
class SRWindow(tk.Tk):
"""Root window for Tkinter.
... |
130c8a32f5c530ef5fd12d3f6a68f8fe9baa0e27 | yitelu/LC | /Array/122_BestTimeToBuyAndSellStockII.py | 236 | 3.53125 | 4 | prices = [7, 1, 5, 3, 6, 4]
def maxProfit(prices):
profit = 0
for i in range(1, len(prices)):
if prices[i] > prices[i -1]:
profit += prices[i] - prices[i -1]
return profit
print(maxProfit(prices)) |
0969e0fed8e38e3df3cc908ede84a638bbf63995 | shardulrane/Python_Practice | /demo.py | 382 | 3.75 | 4 | from time import sleep
from threading import Thread
class Hello(Thread):
def run(self):
for i in range(10):
print("Hello")
sleep(1)
class Hii(Thread):
def run(self):
for i in range(10):
print("Hii")
sleep(1)
t1=Hello()
t2=Hii()
t1.start()
sleep(0... |
d18c5935474566da183c2c77f1d0e7c6abcbeea5 | tlima1011/Python | /media_idades.py | 323 | 3.84375 | 4 | idade: int; media: float; soma: float
n: int
soma = 0
n = 0
print('Digite as idades:')
idade = int(input())
if idade < 0:
print('IMPOSSIVEL CALCULAR')
exit()
else:
while idade >= 0:
n += 1
soma += idade
idade = int(input())
media = soma / n
print(f'MEDIA = {media:.2f... |
87f6d476252aae85552c0e94fc44a85d225a86d2 | IvanIsCoding/OlympiadSolutions | /beecrowd/1019.py | 382 | 3.5625 | 4 | # Ivan Carvalho
# Solution to https://www.beecrowd.com.br/judge/problems/view/1019
# -*- coding: utf-8 -*-
"""
Escreva a sua solução aqui
Code your solution here
Escriba su solución aquí
"""
entrada = int(input())
dicio = {3600: 0, 60: 0, 1: 0}
for i in [3600, 60, 1]:
dicio[i] = int(entrada / i)
entrada -= dic... |
12855acfaa18f026db99cdae939ab8c2452970c1 | leayl/mynotes | /数据结构与算法小练习/二叉树/bTree.py | 912 | 4 | 4 | """
二叉树相关demo
# todo 只有个大概,没弄完,递归生成树时如何退出还不清楚
"""
class Node:
def __init__(self, data):
self.data = data
self.lchild = None
self.rchild = None
class BTree:
def __init__(self):
self.root = None
@classmethod
def create_tree(self, ):
"""
生成二叉树
:p... |
6c74cc76997450022487e3e5bd00c22382b34161 | kavinsenthil21/programs | /days.py | 199 | 4.25 | 4 | #find months and days
days = int(input("enter the days"))
years = int(days/365)
days2=days%365
month = int(days2/30)
days3=days2%30
print('years={} months = {} days = {}'.format(years,month,days3))
|
b8c14fa3467bb45c7a75bac7337fb0524eaa263f | nomore-ly/Job | /算法与数据结构/LeetCode/字典树(Trie)/Again/14.最长公共前缀.py | 1,653 | 3.546875 | 4 | #
# @lc app=leetcode.cn id=14 lang=python3
#
# [14] 最长公共前缀
#
# @lc code=start
class Node:
def __init__(self,val = None,isEnd = False):
self.val = val
self.next = {}
self.is_end = isEnd
class Trie:
def __init__(self):
self.node = Node()
def insert(self,word:str)->None:
... |
85719edcb8a2dc0e7d6723006358b41d80278990 | daniel-reich/ubiquitous-fiesta | /9yk63KrKDHzNFWKBJ_20.py | 436 | 3.6875 | 4 |
def is_it_inside_rec(folders, target, parent, found):
if parent in folders:
if target in folders[parent]:
found = True
else:
for child in folders[parent]:
found = is_it_inside_rec(folders, target, child, found)
return found
def is_it_inside(folders, X... |
e91573dc1e8dadc8a1f78a063161b8b214cda383 | WangYangLau/learnpython | /Practice_14.py | 1,657 | 3.9375 | 4 | # -*- coding: utf-8 -*-
from functools import reduce
#功能:把用户输入的不规范的英文名字,变为首字母大写,其他小写的规范名字
print(u'把用户输入的不规范的英文名字,变为首字母大写,其他小写的规范名字:')
def normalize(name):
return name.capitalize()
L = ['adam', 'LISA', 'barT']
L2 = list(map(normalize,L))
print(L2)
print(u'使用了capitalize()')
print('>>>--------------------------------... |
80327c02469a3a746ca6485f0e096136982765e9 | seongjaelee/ProjectEuler | /problem050.py | 669 | 3.5 | 4 | import problem
import math
import utility
class Problem(problem.Problem):
def __init__(self):
number = 50
question = 'Which prime, below one-million, can be written as the sum of the most consecutive primes?'
problem.Problem.__init__(self, number, question)
def getAnswer(self):
def f(limit):
primes = uti... |
c1a61eb54878009cde88d98b365f0d5d95792734 | ylmzsmh/python-dersnotu | /20190118cuma/ornek_modul6.py | 176 | 3.5625 | 4 | #!/usr/bin/python
# -*- coding:UTF-8 -*-
def listeTopla(liste):
toplam = 0
for i in liste:
if type(i) == int:
toplam = toplam + i
return toplam |
3099aca015c7a7a5ed2638d83cbb703b6003ec47 | kevinjzheng/CS-UY-1114 | /Homeworks/Homework4/kjz233_hw4_qy6.py | 269 | 3.78125 | 4 | #Problem 6
#PART A
seqLeng = int(input("Please enter the length of the sequence: "))
seqSum = 1
for i in range(seqLeng):
seqNum = int(input("Please enter your sequence: "))
seqSum = seqNum * seqSum
print("The geometric mean is:", (seqSum ** (1/seqLeng)))
|
2895d4f4aec70f0dce742642b8fccf75e5080284 | thesmritisharma/Acadview | /Classes_and_modules_2.py | 1,750 | 3.9375 | 4 | '''
#Question 1
class Animal:
def animal_attribute(self):
print('Animals')
class Tiger(Animal):
def tiger_method(self):
print('Tigers')
obj = Tiger()
obj.animal_attribute()
#Question 2
A B
A B
#Question 3
class Cop:
def __init__(self, name, age, work, exp, des):
self.name = na... |
39640c39dae46a96633613c097764bc63df316b9 | RaviC19/For-and-While-Loops-Python | /while.py | 363 | 4.15625 | 4 | message = input("What's the password? ")
while message != "Everybody knows the rules":
print("Wrong!")
message = input("What's the password?")
print("Correctamundo!")
# # Printing 1-10 in a for loop
# for num in range(1, 11):
# print(num)
# # Printing 1-10 in a while loop
# number = 1
# while number <... |
85ce9c4d8a657ece8fc15d873d23060613e95ee9 | QingCheng1991/SchoolProject | /CS50_pset6/mario.py | 166 | 3.546875 | 4 | import cs50
print('height: ',end='')
s=cs50.get_int()
while(s>0 and s<24):
for i in range(s):
print(" "*(s-(i+1))+"#"*(i+2))
break
|
a6f40583609298c94cee2311c48ddb2941445fe2 | CodevEnsenada/actividades | /ejercicio-03/ejercise-3/act1.py | 614 | 3.8125 | 4 | cal = int( input("Calificacion: ") )
if cal < 4 :
print("Estas reprobado")
elif cal > 4 and cal < 8 :
print("pasate")
else:
print("eres un genio")
cal1 = int(input("Dame calificacion 1:"))
cal2 = int(input("Dame calificacion 3:"))
cal3 = int(input("Dame calificacion 3:"))
promedio = (cal1+cal2+cal3)/3
print("... |
fa99d27325d8e4a07fca2872ddf4adbaeef27cde | lynn-study/python | /format.py | 457 | 3.640625 | 4 | #!/usr/bin/python
width = input("input width: ")
price_width = 10
item_width = width - price_width
header_format = "%-*s%*s"
format = "%-*s%*.2f"
print header_format % (item_width, "Item", price_width, "Price")
print "-" * width
print format % (item_width, "apple", price_width, 4.5)
print format % (item_width, "... |
04d27a5d8773342ed693695283744b64f38e7770 | Uche-Clare/python-challenge-solutions | /Ekeopara_Praise/Phase 1/Python Basic 1/Day11Tasks/Task1.py | 142 | 3.890625 | 4 | '''1. Write a Python program to swap two variables.'''
def swap(vr1, vr2):
vr1, vr2 = vr2, vr1
return vr1, vr2
print(swap(20, 400))
|
d20e4ae9bf3e2760c8ad52134d562dce0ee96ac3 | Bogdan808/mypython | /using_list.py | 682 | 3.78125 | 4 |
shop_list = ['apple', 'mango', 'carrot', 'banana']
print('Я должен сделать', len(shop_list), 'покупки.')
print('Покупки:', end=' ')
for item in shop_list:
print(item, end=' ,')
print('\nТакже нужно купить риса.')
print('Отсортирую-ка я свой список')
shop_list.sort()
print('Отсортированный список покупок выгл... |
3a9d223b46ddf42fa5441b463b4ced1b1fad7ed2 | avi527/Array | /copyElements.py | 421 | 4.4375 | 4 | # Python program to copy all elements of one array into another array
arr1 = [1, 2, 3, 4, 5];
arr2=[None]*len(arr1)
for i in range(0,len(arr1)):
arr2[i]=arr1[i]
#Displaying elements of array arr1
print("Elements of original array: ");
for i in range(0,len(arr1)):
print(arr1[i])
#Displaying elements ... |
7f6826287896b181460935b1eb7b6c087ea3699c | 316513979/thc | /Clases/Programas/PythonFácil/Problema2S.py | 473 | 4.40625 | 4 | #!/usr/bin/python2.7
# -*- coding: utf-8 -*-
# 316513979, Diego Armando Santillán Arriaga, Taller de Herramientas Computacionales
# Este programa recibe una matriz de enteros y devuelve una tupla con 2 listas,
# una contiene la suma de los valores de cada fila y otra la suma de los valores
# de cada columna.
import Pr... |
18ed5c39448d5c9a0384042d2ee181eb6d024672 | jslx2/whatup | /parrot2.py | 653 | 4.1875 | 4 | #flag: acts as a signal of the program
"""
we can write our programs so they run while the flag is set to True and
stop running when any of several events sets the value of the flag to False.
while statement needs to check only one condition-- whether or not the flag is currently True.
"""
prompt="\nTell me somthing, ... |
dbe7236ef6f296d0ce0ce4274838bfdd4f5dcf29 | li-zeyuan/TinyUrl-Service | /convert_to_62system.py | 528 | 3.515625 | 4 | CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
def convert_to_62system(num):
"""
将数字转化成62进制
:param num: 十进制数字(int)
:return: 62进制字符串(str)
"""
if num == 0:
return CHARS[0]
res = []
while num:
num, rem = divmod(num, len(CHARS)) # num为商, rem为余数
... |
1ef45b514b9cc4526447a124950ff890d9e1e381 | rh01/gofiles | /lcode1-99/ex96/removeSubfolders copy.py | 2,636 | 3.609375 | 4 | # -*- coding:utf-8 -*-
class Solution(object):
def removeSubfolders(self, folder):
"""
:type folder: List[str]
:rtype: List[str]
"""
# 输入:folder = ["/a","/a/b","/c/d","/c/d/e","/c/f"]
# 输出:["/a","/c/d","/c/f"]
# 解释:"/a/b/" 是 "/a" 的子文件夹,而 "/c/d/e" 是 "/... |
976e42ff352fb7764be35503848976ad05569213 | pgdouyon/sudoku-python | /sudoku.py | 13,685 | 3.9375 | 4 | #! /usr/bin/env python3.3
import sys
import itertools
class MinHeap(object):
"""Priority Queue used to keep track of GridEntry
objects with lowest number of candidates"""
def __init__(self):
self.heap = [None]
self.heap_size = 0
@staticmethod
def parent(index):
""" Return... |
4e3ffc5fc14fbbacaea08fdc069b168adda0d21b | Franklyn-S/listas-FUP | /Lista 6 FUP - Recursão/Códigos Python/1.3.py | 268 | 4.09375 | 4 | def soma(n1,n2):
if n2 == 0:
return n1
elif n2 == 1:
return n1+1
else:
return soma(n1+1,n2-1)
n1 = int(input("Digite o primeiro dígito da soma: "))
n2 = int(input("Digite o segundo dígito da soma: "))
print(soma(n1,n2))
|
ca4fd0e7bc9448338ab39a3f8b0e35a598e5f6b7 | ece-mohammad/CodeForces | /Autocomplete.py | 469 | 3.765625 | 4 |
# http://codeforces.com/group/P8UZg7UOT5/contest/225111/problem/D
def Autocomplete():
s = input()
n = int( input() )
visited = [input().strip() for _ in range(n)]
visited = filter(lambda x: x.startswith(s), visited)
visited = [i for i in visited]
if visited:
... |
d894b034d10a42381b98c232287be5276845a0df | MetalSkink/Curso-Python | /Condicionales/Ejercicio3.py | 268 | 4.0625 | 4 | '''
Hacer un programa que pida un caracter e indique si es una vocal
o no
'''
char = input("Dame un caracter -> ").lower()
if char == 'a' or char == 'e' or char == 'i' or char == 'o' or char == 'u':
print("Es una vocal")
else:
print("No es una vocal :(") |
93559722aa82c8fcbb24a88be2b271fe609a8262 | voloshchukivanna/Python | /Homework4.py | 1,783 | 3.96875 | 4 | # #Task 1
#
# a = input("Enter: ")
#
# try:
# print(a[2], a[-2], a[0:5], a[:-2], a[::2], a[1::2], a[::-1], a[::-2], a[-2::-2], a[-2:0:-1], len(a), sep="\n")
# print("Верно!")
# except SyntaxError:
# print("Строка слишком коротка!")
#
#
# #Task 2
#
# a = input("Enter number 1: ")
# b = input("Enter number 2: ")... |
4f3d2d3bdd5a0cb42ddb9e0fab27163ae34600bb | hakank/hakank | /cpmpy/12_pack_problem.py | 3,445 | 3.59375 | 4 | """
12-pack problem in cpmpy.
From Mathias Brandewinder:
'The 12 pack-problem: combination of integers'
http://clear-lines.com/blog/post/The-12-pack-problem-combination-of-integers.aspx
'''
A fun problem came my way today. Imagine that you are the owner
of a renowned brewery in Bizzarostan, a country where beer is so... |
efec8737be8e3da0d6b0b6e4c33a3fa22f5c77b8 | yarivgdidi/lastSoldier | /lastSoldier.py | 5,985 | 3.578125 | 4 | CONST_DEPTH=1
class Board:
def __init__(self):
self.boards = {}
############################# This is where magic happens #############################
def solve(self, board, path):
for line in range(5):
for column in range(line + 1):
for move in ['r', 'dr... |
23cb359ab97f22ee1755505af2ecd65dfc6297ff | n303p4/pielang | /ralpha.py | 2,185 | 4.03125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# "Reverse alphabet cipher"
import sys
table0 = {"a": "z",
"b": "y",
"c": "x",
"d": "w",
"e": "v",
"f": "u",
"g": "t",
"h": "s",
"i": "r",
"j": "q",
"k": "p",
"... |
f4fe8465ddb4d9b3999f7524422e69f7d94e5a5b | tazimkhan/PythonAssignment | /Assignment-9/9.7.0..py | 357 | 3.921875 | 4 | s=set()
z=int(input("enter the number of keys"))
for e in range(0,z,1):
a=input("enter the keys values")
s.add(a)
print(s)
s1=set()
x=int(input("enter the number of keys"))
for e in range(0,x,1):
a=input("enter the keys values")
s1.add(a)
print(s1)
if(s1.issubset(s)):
print("s1 is a subset of s")
el... |
b3b81a4a02035946cf7f179d010a5d542ae8b89b | yeswhos/Code-Practice | /python/demo10_practice/demo02_tuple.py | 199 | 3.9375 | 4 | #创建元组
tup = ('jack', 'rose')
tupp = tuple(('jack', 'rose'))
tup_empty = ()
# print(tup)
# print(tupp)
t = (1, [2, 3], 4)
print(t[1])
t[1].append(5)
print(t)
for item in t:
print(item)
|
ee4d6f00b27388be97eaf6382ba8959b615952d4 | parkercoates/oiler | /euler032.py | 737 | 3.5625 | 4 | #! /usr/bin/python
def permutations( lst ) :
'''Returns sequential permutations of a list'''
if len( lst ) > 1 :
for i in xrange( len( lst ) ) :
for rest in permutations( lst[:i] + lst[i+1:] ) :
yield lst[i:i+1] + rest
else:
yield lst
solutions = set()
#for p in permutations( range( 1, 10 ) ) :
#produ... |
c55dc08b469b63fb882197ede42987a03b1a7716 | momenurmaruf2742/Python_tutorial | /tuto25,26.py | 637 | 4.0625 | 4 | # reading file in python
""""
"r" for read and its defult
"w" for write
"x" for create file if not exist
"a" append add in the last in any file
"t" text file its also default
"b" binarry mode
"+" read and write"""
f = open("maruf.txt","rt")
#content = f.read()#here is 23 charecter readable
... |
8166f8c6edd5ea84b44f7426e01451dbd54701fb | RafaelCsantos/AlgBionfo | /Semana 2/qtd_de_tinta.py | 226 | 3.875 | 4 | largura=float(input("Digite a largura da parede"))
altura=float(input("Digite a altura da parede"))
print("A área é de ", (largura*altura), "m \n", "a quantidade de tinta necessária é : ", (largura*altura)/3, "latas")
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.