blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
062aa61a1d0b6d0a1c5f2e967fef550f55d45825 | Jeromeschmidt/CS-1.2-Intro-Data-Structures | /Code/autocomplete.py | 369 | 3.734375 | 4 | import sys
def begins_with(text, beginning):
autocomplete_list = list()
for word in text:
if word.startswith(beginning):
autocomplete_list.append(word)
return autocomplete_list
if __name__ == '__main__':
with open("/usr/share/dict/words",'r') as file:
text = file.read().sp... |
33ed35b3f1ea9678f7cb2ac55a90c28f82f3a7e1 | Ganeshahere/python-project-lvl1 | /brain_games/games/gcd.py | 526 | 3.546875 | 4 | from random import randint
DESCRIBER = 'Find the greatest common divisor of given numbers.'
def gcd(number1, number2):
while number1 != 0 and number2 != 0:
if number1 > number2:
number1 = number1 % number2
else:
number2 = number2 % number1
return number1 + number2
de... |
b8a6b95fdc0d2cdeb5a83356c4e22b1b94da4f8f | frsojib/python | /Anisur/outer loop.py | 121 | 3.8125 | 4 | list = ["apple","grapes","orange"]
list2 = ["book","khata","matha"]
for i in list:
for j in list2:
print(i,j) |
d8786c25336a18bc1c41086ed223d479920a2918 | jessicabreedlove/project_7 | /main.py | 3,373 | 3.96875 | 4 | """
Jessica Reece
CS 1400-601
Final Project
April 5, 2021
"""
def main():
presidents = open("presidents.txt", 'r')
jobs = open("BLS_private.csv", 'r')
presidents.readline()
jobs.readline()
dem = "Dem"
rep = "Rep"
# dictionary to store differences in jobs count
... |
1a315a0ad2bdeb9da51849526b1d2f9804e28ba3 | Upasana360/All-My-Python-Programs | /centermtd.py | 107 | 3.890625 | 4 | name="maggie"
print(name.center(8,"*"))
name1=input("enter ur name:")
print(name1.center(len(name1)+3,"*")) |
b344cb2d95b4a39a6766380e3389c22375cafe40 | dnootana/Python | /concepts/trees/MinHeap.py | 2,093 | 3.765625 | 4 | #!/usr/bin/env python3.8
class MinHeap:
def __init__(self):
self.HeapList = [0]
self.currentSize = 0
def percUp(self, i):
while i // 2 > 0:
if self.HeapList[i // 2] > self.HeapList[i]:
self.HeapList[i // 2], self.HeapList[i] = self.HeapList[i], self.HeapList[i // 2]
else:
#once the parent is les... |
3886edb451f7f48796fd888031ab31a044528be4 | harvinder-power/Sea-Eagle | /mover.py | 932 | 3.921875 | 4 | import csv
import sys
#input number you want to search
number = input('Search\n')
dataEntryFileLocation = "****"
#read csv, and split on "," the line
csv_file = csv.reader(open('****'), delimiter=",")
def moveFiles(filename, folder):
#if file exists, then continue
root = "****"
filepath = root + filena... |
a5906754a3073624171163460d47f42efba0e5e6 | Svegge/GB_2021_06_py_foundations | /02_homeworks/01/task_02.py | 515 | 4.3125 | 4 | '''
2. Пользователь вводит время в секундах.
Переведите время в часы, минуты и секунды и
выведите в формате чч:мм:сс.
Используйте форматирование строк.
'''
total_secs = int(input('Please enter seconds:\n>>> '))
hh_var = str(total_secs // 360).zfill(2)
mm_var = str(int((total_secs % 360) / 60)).zfill(2)
ss_var = str(i... |
8df002e06743edcb57a114e3f5bf60cd018e2a60 | nikrhem/simmm | /numcnt.py | 107 | 3.890625 | 4 | string =input()
count = 0
for c in string:
if c.isnumeric()!=False:
count = count+1
print(count) |
7c77d7f8e0c5318f259462d228e336854e43addb | Rockfish/PythonCourse | /02_DiggingDeeper/movie_facts.py | 1,190 | 3.78125 | 4 | """
This module has a couple of functions
"""
def GetTheMovieData():
"""Reads the MontyPythonData.csv and returns
a list of dictionaries with the movie data"""
# Read the file
content = open("MontyPythonData.csv").read()
# Split the file into a list of lines
lines = content.splitlines()
... |
971a76ddab0e31aeba749b47656e0dbb6d429f1f | wxxcn/Algorithms | /rbtree.py | 7,540 | 3.859375 | 4 | # -*- coding; utf-8 -*-
class Node:
def __init__(self, key, color):
self.parent = None
self.key = key
self.color = color
self.left = None
self.right = None
class RBTree:
def __init__(self):
self.nil = Node(-1, 'black')
self.root = self.n... |
fcb33d13bca6d6f613f8351187222c250f26e1ef | Mehmetjan/Python | /pythonProject/venv/Scripts/string.py | 170 | 3.6875 | 4 | String = ' i \n am here'
print(String)
String2 =" i'm a \"man\" "
print(String2)
# formatting
String3 = "{1} {0} {2}".format ('gril','boy','others')
print(String3) |
9c9a53cc45d61f1040d5ef5c82643b078abfd25f | rksam24/MCA | /Sem 1/oops/Class and obj/Import/Computer.py | 3,127 | 4.0625 | 4 | '''Define all getter and setter methods + __str__()
LAPTOP
Attributes:
Brand
Processor
RAM
Color'''
class computer:
#contructor
def __init__(self,color,brand,processor,ram):
self.color=color
self.brand=brand
self.processor=processor
self.ram=ram
#getter function
def ge... |
6b68e5902226efd9dd017c1ff2016322fa44f775 | johannalbino/course_python_geek_university | /S16 - Orientacao a Objetos em Python/S16E114 - Classes.py | 1,605 | 4.03125 | 4 | """"
Classes
Em POO, classes nada mais são do que modelos dos objetos do mundo real sendo representados computacionamente.
Imagine que você queira fazer um sistema para automatizar o controle das lâmpadas da sua casa.
Classes podem ter:
- Atributos -> Representam as caracteristicas do objeto, ou seja, pelos atributo... |
72abf338814371ecfca736ee0249ff018d589fed | ShivonQ/Simple_RPG | /character/Hero.py | 3,055 | 3.609375 | 4 | from character.Character import Character
from character import data
class Hero(Character):
def __init__(self, name):
super().__init__(name)
# in the future a additional Class class will grant further inheritence
# Which will make many of these happen there, not here.
self.state = ... |
9727504a543a18dbc72032f0b8a333505c184ea7 | prinned/prog | /mult35.py | 130 | 3.796875 | 4 | ul = 1000
mult = 0
for i in range(0,ul):
if i % 3 == 0 or i %5 == 0:
mult += i
print(mult)
x=input('enter to cont')
|
dbde143b17491a965c609d9b8e574ce89b830d2c | aaronykchen/Genetic-Algorithm-to-Optimize-Decision-Variable | /Genetic algorithm_AaronYuKu_.py | 6,089 | 3.515625 | 4 | """
Problem 6
@Aaron YuKu Chen
"""
import numpy as np
from matplotlib import pyplot as plt
import pandas as pd
import math as m
import random
population = 100 # set the amount of the chromosomes in each population
chs_length, x_length, y_length = 23, 11, 12 # by precision 10^-3 ;chromosomes total length f... |
2389d7d6a9e09cc60ff85d4b50caaba3590c9a8c | anonymousraft/Python | /Day3/profilecreator.py | 225 | 3.828125 | 4 | #profile creator
name = input('Hello user pls enter you name\n')
age = input('How old are you\n')
city = input('Which city you are living in\n')
print('I\'M ' + name + ' I\'M ' + age + ' Years old and I live in ' + city)
|
156f20e20ac535276ff1bc3d73dbfb2678795a32 | burtgulash/fav2011-pro | /median/median.py | 1,010 | 3.578125 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
import sys, random
def rozdelit(ar, levy, pravy, p):
pivot = ar[p]
i, j = levy, levy
ar[pravy], ar[p] = ar[p], ar[pravy]
while i <= pravy:
if ar[i] < pivot:
ar[i], ar[j] = ar[j], ar[i]
j += 1
i += 1
ar[pravy], ar[j] = ar[j], ar[pravy]
return j
def quickselec... |
7258ac17d1a5346945421109503f9ea6f173580c | wpbindt/leetcode | /python_solutions/buy_sell_stock_1.py | 616 | 3.703125 | 4 | from typing import List
def max_profit(prices: List[int]) -> int:
"""
Initial way of finding this: keep left
and right pointer, right pointer iterating
through prices, and moving left pointer to
right as soon as right is absolutely smaller
than left.
Apparently very similar to max sub arr... |
8518563d5d26f9af261232c1808a528af85b037f | WDB40/CIS189 | /Module10/test/test_customer.py | 788 | 3.578125 | 4 | """
Program: test_customer.py (customer.py)
Author: Wes Brown
Last date modified: 10/28/19
Purpose: Test for the class for customer
"""
from Module10.src.customer import Customer
if __name__ == '__main__':
customer1 = Customer("123", "Jones", "Mary", "444-444-4444", "222 2nd Street, Des Moines, IA")
print(cu... |
0c34d84826102f2b6bc62653cb87588be74e972e | mayi-juu/self_study-programmer | /body/hangman.py | 1,623 | 3.96875 | 4 | # ハングマンゲームの実装
def hangman(word):
wrong=0
stages=["",
"_____ ",
"|",
"| | ",
"| 0 ",
"| /|\ ",
"| / \ ",
"| ",
]
# リストは改行しても動作する!
rletters=list(word)
# list()関数=()のなかのオブジェクトを1つずつリストの要素に格納する!
board=["_"]*l... |
c51578e09902e158d48c2a3f0a7fce4c14e3f4c6 | XMK233/Leetcode-Journey | /wasted/py-jianzhi-round3 - backup/JianzhiOffer21.py | 1,365 | 3.5 | 4 | '''
[剑指 Offer 21. 调整数组顺序使奇数位于偶数前面 - 力扣(LeetCode)](https://leetcode-cn.com/problems/diao-zheng-shu-zu-shun-xu-shi-qi-shu-wei-yu-ou-shu-qian-mian-lcof)
输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有奇数位于数组的前半部分,所有偶数位于数组的后半部分。
示例:
输入:nums = [1,2,3,4]
输出:[1,3,2,4]
注:[3,1,2,4] 也是正确的答案之一。
提示:
1 <= nums.length <= 50000
1 <= n... |
47c2340e6d5277c8492eaa4e31e008802c22b8c8 | 6desislava6/Python-FMI | /challenges/03/solution.py | 2,463 | 3.515625 | 4 | from itertools import permutations, groupby, combinations
# If the grid width is odd, then the number of inversions in a solvable
# situation is even.
# If the grid width is even, and the blank is on an even row counting from
# the bottom (second-last, fourth-last etc), then the number of inversions in
# a solvable ... |
a8189ea9f6482f48474730715b767c98560d2ea2 | shank54/Leetcode | /Shortest Word Distance.py | 548 | 3.5625 | 4 | class Solution(object):
def shortestDistance(self, words, word1, word2):
"""
:type words: List[str]
:type word1: str
:type word2: str
:rtype: int
"""
d = dict()
indx = 0
for i in words:
d.setdefault(i,[indx])
d[i].append... |
dd58d72c63a513492f9c89147c5f37b41143acfb | fmckenna/SimCenterBootcamp2020 | /code/jupyter/HomeworkExercises/Individual.py | 2,552 | 3.53125 | 4 | # **************************************************************************
#
# class: Individual
#
# author: Peter Mackenzie-Helnwein
# created: pmh - 10/28/2020
# modified:
#
# **************************************************************************
from Human import *
class Individual(Human):
"""
... |
68fc967b7bdcf1843059ded09c037285f86d530d | tony-andreev94/Python-Fundamentals | /01. Functions/03. Repeat String.py | 386 | 4.09375 | 4 | # Write a function that receives a string and a repeat count n.
# The function should return a new string (the old one repeated n times).
#
# Input Output
# abc abcabcabc
# 3
def string_repeater(string, multiplier):
result = string * multiplier
return result
input_str = input()
multiplica... |
7b7f8d7cf7262ef4a3240492489799c07fd90490 | Grey2k/yandex.praktikum-alghoritms | /tasks/sprint-8/C - Border Control/border_control.py | 1,247 | 3.703125 | 4 | RESULT_OK = 'OK'
RESULT_FAIL = 'FAIL'
def main():
try:
first = input().strip()
except EOFError:
first = ''
try:
second = input().strip()
except EOFError:
second = ''
print(RESULT_OK if control(first, second) else RESULT_FAIL)
def control(first: str, second: str)... |
1618ffe96ff041a3ea86828de0dfa8682177f6b8 | Davenport70/naan-factory | /Test_naan_factory.py | 987 | 3.5 | 4 | # Import naan factory functions
# Define and run tests
from naan_factory_functions import *
#1
# As a user, I can use the make_dough with water and flour to make dough.
print('make_dough with water and flour, expect dough as a result')
print(make_dough('water', 'flour') == 'dough')
print('got:', make_dough('water', '... |
5d9767deb41bd44bbf51a3e4a36d630f705277a0 | UNI-FIIS-BIC01/solucion-cuarto-taller | /factura.py | 1,449 | 3.984375 | 4 | class Factura(object):
def __init__(self, codigo_producto, descripcion_producto, cantidad, precio_unitario):
if cantidad < 0:
raise ValueError("La cantidad debe ser un entero positivo")
if precio_unitario < 0:
raise ValueError("El precio unitario debe ser un decimal positi... |
1d4b57e3d6263d72d63cc03c5d61e808146024f2 | henryfw/algo | /mcdowell/python/ch2-02.py | 762 | 3.875 | 4 | from ch2_linked_list import LinkedList
def findKthFromEndNode(l, k):
if l.first is None or k == 0:
return None
p1 = l.first
p2 = l.first
# move p2 forward k-1 steps
for i in range(0, k - 1):
if p2 is None:
return None
p2 = p2.next
if p2 is None:
r... |
8ef99b5c9141fcc0ee3cdc2cc739921e67832095 | mickahell/mastermind | /mastermind.py | 2,456 | 3.5 | 4 | # MASTERMIND
# Règles : 12 chances, 5 billes, 8 couleurs
# JOueur VS machine --> DONE
# TODO --> Player is machine
import random
# y = yellow ; b = blue ; g = green ; r = red ; w = white ; p = purple ; i = invisible ; o = orange
couleurs = ['y', 'b', 'g', 'r', 'w', 'p', 'i', 'o']
tour = 12
humain = True
partie = Tru... |
c79f38199de6f253c629ef2c7307f7451cf80a6d | lixit/python | /bisectionSearch.py | 339 | 3.78125 | 4 | x=25
epsilon=0.01
numGuesses=0
low=0.0
high=max(1.0,x)
ans=(high+low)/2.0
while abs(ans**2-x) >= epsilon:
print('low=',low,'high=',high,'ans=',ans)
numGuesses += 1
if ans**2 < x:
low =ans
else:
high = ans
ans = (high + low)/2.0
print('numGuesses =',numGuesses)
print(ans,'is close to ... |
7f71d6c7eb5e81f6c15cd745210ed70b038b9f27 | recollects/intelligent | /src/com/alipay/study/demo2.py | 1,812 | 4.1875 | 4 | counter = 100 # 整型变量
miles = 1000.0 # 浮点型变量
name = "runoob" # 字符串
print(counter)
print(miles)
print(name)
a = b = c = 1
print(a,b,c)
a, b, c = 1, 2, "runoob"
print(a,b,c)
'''
Python3 中有六个标准的数据类型:
Number(数字)
String(字符串)
List(列表)
Tuple(元组)
Set(集合)
Dictionary(字典)
'''
var1 = 1
var2 = 10
del var1
print(var2)
print... |
e9dbc68b1857693318958d0018af0b08f150950f | LuisDomiciano/uri | /Iniciante/1037.py | 389 | 3.828125 | 4 | # -*- coding: utf-8 -*-
num = float (input())
msg=''
if ( num < 0 or num > 100):
msg = 'Fora de intervalo'
elif (num >= 0 and num <= 25.00):
msg = 'Intervalo [0,25]'
elif (num > 25.00 and num <= 50.00):
msg = 'Intervalo (25,50]'
elif (num > 50.00 and num <= 75.00):
msg = 'Intervalo (50,75]'
elif (num >... |
ddf44ded4aa3d09c3a8c5767c2bd60c4e4334112 | dstada/HackerRank.com | /Strange Counter - Algorythms.py | 908 | 3.796875 | 4 |
def strangeCounter(t):
val = 3
while t > val:
print("val: {}, t: {}".format(val, t))
t = t-val
val *= 2
print("val: {}, t: {}".format(val, t))
print("val: {}, t: {}".format(val, t))
return val-t+1
# Solution which gives some time-outs:
# def strangeCounter(t):
# va... |
2856174bfc73bdd5dbbc59fe064b09be39a8633b | annanda/objetos_pythonicos | /arvore.py | 799 | 3.765625 | 4 | class No:
def __init__(self, valor, esquerdo=None, direito=None):
self.valor = valor
self.direito = direito
self.esquerdo = esquerdo
class Arvore:
def __init__(self, raiz=None):
self.raiz = raiz
def __iter__(self):
no = self.raiz
if no:
yield no... |
12f0b22c98c70487e3d0a38e0d0bffd7833fd3bd | Michael-Wisniewski/algorithms-unlocked | /chapter 5/7_Bellman_Ford_shortest_path.py | 1,147 | 3.859375 | 4 | def shortest_path(G, s):
"""Time complexity O(n*m), where n - number of vertices, m - number of edges.
>>> dag = {
... 0: [{'v': 1, 'w': 6}, {'v': 3, 'w': 7}],
... 1: [{'v': 3, 'w': 8}, {'v': 2, 'w': 5}, {'v': 4, 'w': -4}],
... 2: [{'v': 1, 'w': -2}],
... 3: [{'v': 2, 'w': -3}, {'v': 4, 'w'... |
e97325970af5da519501ff8b7b1354dcc1b055ed | HappyAnony/studynotes-of-python | /Modules/random_t.py | 1,192 | 3.796875 | 4 | #!/usr/bin/env python
# -*-coding :uft-8 -*-
# Author:Anony
'''
import random
print(random.random()) # 返回[0,1)之间的随机浮点数
print(random.uniform(1,3)) # 返回[1,3)之间的随机浮点数
print(random.randint(1,4)) # 返回[1,4]之间的随机整数
print(random.randrange(1,4)) # 返回[1,4)之间的随机整数
print(random.choice([4,6,6,1,3])) # 返回指定序列(字串,元组,列表,字典等)中的随机元素
pr... |
4161e8d80ca77a29e0b0565333c7369beb05cf00 | NathanYee/TextMining | /getLinks.py | 678 | 3.640625 | 4 | #This script will scrape links that lead to 2pac lyrics
#base link http://www.metrolyrics.com/2pac-lyrics.html
from urllib import urlopen
from bs4 import BeautifulSoup
import re
import pickle
links = []# list of links that we will save as links.pickle
baseurl = "http://www.metrolyrics.com/2pac-lyrics.html"
html = u... |
c1399228e2eef73f6d23110014a8c60ddbece202 | ahollyer/python-exercises | /multiplication_table.py | 282 | 4.28125 | 4 | # multiplication_table.py
# By Aspen
# Uses a loop to print the multiplication table for numbers 1-10.
print("\n9. Multiplication Table:")
for i in range(1, 11):
print("Multiples of", str(i))
for j in range(1, 11):
print(str(i) + " * " + str(j) + " = " + str(i*j))
|
62e3f42d5025e07f6f31f7da67bd0ba53c1234d3 | warnec/Inclass-6-3 | /test_calculator.py | 465 | 3.984375 | 4 | """
Unit testing the calculator app
"""
import calculator
class TestCalculator:
def test_add(self):
assert 5 == calculator.addition(1, 4)
def test_subtract(self):
assert 2 == calculator.subtraction(5, 3)
def test_multiply(self):
assert 2 == calculator.multiply(1, 2)
def te... |
322b8552880948c1dfb0263739c726351d020784 | alonsoibanez/test | /Test.py | 107 | 3.953125 | 4 | hungry=input("Are you hungy?")
if hungry=="yes":
print("Eat something")
else:
print("Do your work") |
95a5a45052f7736a45689ac428e73a5a98d981c4 | weiting1608/Leetcode | /412. Fizz Buzz.py | 950 | 3.78125 | 4 | # Approach 1: naive approach
# Time Complexity: O(N)
# Space Complexity: O(1)
class Solution:
def fizzBuzz(self, n: int) -> List[str]:
res = []
for i in range(1, n+1):
if i % 3 == 0 and i % 5 == 0:
res.append("FizzBuzz")
elif i % 3 == 0:
res.a... |
70bc4fa5980e8fb94774ae55502f432df716a5aa | macabeus/creditas-challenge | /backend-solution/tests/test_shipping_label.py | 1,562 | 3.75 | 4 | from unittest import TestCase, main
from tests.helpers.products \
import physic_product, digital_product, book_product
from shipping_label import ShippingLabel
class TestShippingLabel(TestCase):
def test_should_can_create_a_shipping_label(self):
shipping_label = ShippingLabel(
product=phys... |
834c85053f17eddb32fbc586f5284cdc9aaa3f34 | obedullah/Python | /factorial.py | 154 | 4.28125 | 4 | #!/usr/bin/python
num=raw_input("enter the number : ")
num=int(num)
result=1
for i in range(1,num+1):
result =result * i
print "the result is : ",result
|
24fdb872444ab457ee4b21e4de5b60ee6fadc3dc | xiaomengxiangjia/Python | /practice_6_9.py | 314 | 3.546875 | 4 | favorite_places = {
'xiaofu': ['paris','america','china'],
'xiaobin': ['beijing','europe'],
'xiaoli': ['chengdu', 'luzhou', 'europe'],
}
for name,places in favorite_places.items():
print("\n" + name.title() + "'s favorite places are: ")
for place in places:
print("\t" + place.title())
|
4c1b1111919f6fb44c3aaf9c507fcf0f698fe74a | raulm017/python-challenge | /PyBank/main.py | 2,168 | 3.78125 | 4 | import os
import csv
row_count=0
total_sum=0
total_change=0
largest_increase=[" ", 0]
largest_decrease=[" ", 999999999]
budget_data = os.path.join( 'Resources', 'budget_data.csv')
#print(budget_data) # prints path
with open(budget_data, newline="") as csvfile:
csv_reader = csv.reader(csvfile, delimiter=",")
... |
081bba5ab5e4bb03a77f3a76082251cb823d84f8 | dohvis/kmu-sw-proj | /week4/assignment4_20171584.py | 470 | 3.765625 | 4 | def fac(num):
if num==1 or num==0:
return 1
elif num < 0:
return -1
else:
return num * fac(num-1)
def combination(n, r):
#res1 = fac(n) / (fac(r) * fac(n-r))
if r==n or r==0:
return 1
if n<r:
return -1
else:
return combination(n-1, r-1) + combi... |
3d496f1675cb625a114c8224dd0ac27cb07023c2 | Jkatzeff/Interview-Prep | /Data Structures and Algorithms/traversals.py | 1,862 | 3.671875 | 4 | from collections import defaultdict
from queue import Queue
class TreeNode:
def __init__(self, val):
self.left = None
self.right = None
self.val = val
class GraphNode:
def __init__(self, val):
self.val = val
self.children = []
def set_children(self,arr):
self.children = arr
def iterative_traversal(root... |
f57fb865edf401ef73e215dfe322872df552cd65 | piyushPathak309/100-Days-of-Python-Coding | /Challenge Triangular Letter Pattern.py | 601 | 4.28125 | 4 | # Write a Python program that prints a triangular pattern made with letters (as shown below).
#
# The first row should have one letter A (in uppercase). The second row should have two letters B. The third row should have three letters C and so on.
#
# The number of rows is determined by the value of n, which is ent... |
dc8979cbe6a9d1d9892c71850e59166df22b3010 | pankajgupta119/Python | /loop1.py | 188 | 4.15625 | 4 | #This is example of for loop statement
i=0
limit=int(input("Enter the Number"))
for i in range(1,11):
# print(i,"X",limit,"=",(i*limit))
print("{}x{}={}".format(i,limit,i*limit)) |
3412f7e9019bb23d4fe9560b5307ecf561c65847 | gerov12/set_de_juegosPYTHON | /ahorcadoConFunciones.py | 3,639 | 3.828125 | 4 | import random
def seleccionar_palabra (palabras):
#Pido que el jugador elija un tema
tema = int(input('Elegí un tema:\n 1: animales\n 2: colores\n 3: comidas\n '))
while (tema>len(palabras)) or (tema < 1):
print('Ingresá un numero de tema correcto')
tema = int(input('Elegí un tema:\n 1: animales\n 2: color... |
de646928a1966a8badfa3bdd643172c4ba853503 | deepbsd/OST_Python | /ostPython4/mmap_timer.py | 5,054 | 4 | 4 | #!/usr/bin/env python3
#
#
# mmaptimer.py
#
# Lesson 15: Memory Mapped
# Files
#
# by David S. Jackson
# 8/21/2015
#
# OST Python4: Advanced Python
# for Pat Barton, Instructor
#
'''
Project:
Write a program that creates a ten-megabyte data file in two different ways,
and t... |
0f9f270ca8dc96ef4d275386e70bd89a5c843f0e | dongyang2/hello-world | /interview_q/leet_code/不同路径 II.py | 891 | 3.65625 | 4 | # https://leetcode-cn.com/problems/unique-paths-ii/
# coding:utf-8
# Python 3
# 从左下角走到右下角的路径条数,中间可能有障碍物
def diff_path(grid):
n = len(grid)
m = len(grid[0])
li = [[0 for __ in range(m + 1)] for _ in range(n + 1)]
li[1][1] = 1
for i in range(1, n + 1):
for j in range(1, m + 1):
... |
f45ed52f5cc41c98daccfbd7c986d26ddceb3239 | yuenliou/leetcode | /82-remove-duplicates-from-sorted-list-ii.py | 2,057 | 3.5625 | 4 | #!/usr/local/bin/python3.7
# -*- coding: utf-8 -*-
from datatype.list_node import ListNode, MyListNode
def deleteDuplicates(head: ListNode) -> ListNode:
"""解法:重点已排序"""
dummy = ListNode(0)
dummy.next = head
pre, ptr = dummy, head
while ptr and ptr.next:
dup = False
# 找到重复值子链表的最后一个节点
... |
67a7cc3cee952b3a6375132c7ca4f722e76440fc | Bukacha88/softuni_python_fundamentals | /list_advanced_exercise/02_big_numbers_lover.py | 110 | 3.921875 | 4 | numbers = input().split(' ')
numbers.sort()
numbers.reverse()
for num in numbers:
print(num, end="")
|
2142371893ba6e055f2573ba6cbe1295464138a1 | Osakeee/fogstream_vl | /блок 5_1/блок 5_1/блок_5_1.py | 991 | 3.859375 | 4 | """Дан файл с расписанием занятий на неделю. Помимо названия предмета в нем также указано лекция это, или практическое
занятие, или лабораторная работа. В одной строке может быть указаны только один предмет с информацией о нем. Посчитать,
сколько за неделю проходит практических занятий, лекций и лабораторных работ.""... |
2f7951ffcd65d541b2a19e4d4b2a6fd59004877f | hm-thg/World-Football-Leagues-Dashboard | /app.py | 13,085 | 3.546875 | 4 | import streamlit as st
import requests
import json
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from wordcloud import WordCloud, STOPWORDS
import numpy as np
import modules as md
githublink = '[GitHub Repo](https://github.com/himanshu004/World-Football-Leagues-Dashboard)'
st.sidebar.write(... |
5ed05e7fb52b7c25221252a88701c602f19db6fd | 0xE0L/TextObfs | /text_obfs.py | 15,797 | 3.75 | 4 | #!/bin/python3
import argparse
import random
### Support functions
def bitwise_not(numBin):
numBinNegated = ""
for i in numBin:
if i=='1':
numBinNegated += "0"
else:
numBinNegated += "1"
return numBinNegated
def wrap_custom(string, n):
retur... |
b2f3e6e31883e2ceb5b05293cebe227f6b90ba74 | k-irwin/pdsnd_github | /bikeshare_2.py | 17,560 | 3.953125 | 4 |
# Bikeshare Data Project
import time
import pandas as pd
import numpy as np
CITY_DATA = { 'chicago': 'chicago.csv',
'new york city': 'new_york_city.csv',
'washington': 'washington.csv' }
# Introductory Information *************************************************************************... |
9e5314ed10715619c00590f5f2a938c74f4b71a8 | Sockke/MyData | /Python/fundation/string.py | 1,169 | 4.15625 | 4 | """
有关字符串的相关操作
字符串是常量
"""
s = 'sock is a good man and he is running'
# 字符串查询
index = s.find('good')
if index != -1:
print('index = ', index)
else:
print('没有找到')
# 字符串分割
strs = s.split(' ')
for e in strs:
print(e, end=' ')
print()
# 子串的数量
str_count = s.count('is')
print('str_cou... |
4ac37dba87700c7231ef25cc539d666a117f68a3 | average-bot/fundemental_programming | /lab1_1/Lab1_1a.py | 2,260 | 4.375 | 4 |
# Assigning values to the variables that will have a constant value
budget = 500
economy = 750
vip = 2000
bag_cost = 200
meal_cost = 150
# Assigning values to the variables that will be changed later on,
# depending on the input
ticket_cost = 0
bag = 0
meal = 0
option = 0
# Printing out the ticket names... |
eb9e498c1c27cda73e055a781a562a061a361905 | ivoschwalbe/coding | /ex20.py | 1,415 | 3.59375 | 4 | from sys import argv
# Kommandozeilenargumente parsen
script, input_file = argv
# Funktion: Gesamte Datei anzeigen
# Argument: Dateiobjekt
def print_all(f):
print(f.read())
# Funktion "Zurückspulen"
# Argument: Dateihandle
# seek(0): zurück zu Zeile 0
def rewind(f):
f.seek(0)
# Funktion eine Zeile anzeigen
# Ar... |
cd55474c93febae528b620c2b61a44969cfd9a2e | edu-athensoft/stem1401python_student | /py210110d_python3a/day14_210411/homework/stem1403a_project_0404_KevinLiu.py | 1,764 | 3.8125 | 4 | """
[Challenge] Project. Volume Controller
c04_button/button_03_b.py
Description
Max value and Min value
1. User can press '+' button to increase the number by one per click
2. User can press '-' button to decrease the number by one per click
3. The number shows in a Label
constraints:
the MAX value = 10,
the MIN valu... |
c820f25ca24eb264c5e4628876fb33ca2a881064 | fhsi1/PythonStudy | /simple/addition.py | 78 | 3.796875 | 4 | num1 = 3
num2 = 10
result = num1 + num2
print(num1, "+", num2, "=", result)
|
87da1aa88822958aa299090ad4ec72ca1863457a | kelpasa/Code_Wars_Python | /6 кю/Triangle type.py | 911 | 4.53125 | 5 | '''
In this kata, you should calculate type of triangle with three given sides a, b and c (given in any order).
If all angles are less than 90°, this triangle is acute and function should return 1.
If one angle is strictly 90°, this triangle is right and function should return 2.
If one angle more than 90°, this tri... |
77f5dae8f9c69bf86a7ed63320be4ea1146d1c41 | Artyom14173/git_exercise | /klas1.py | 935 | 3.75 | 4 | import random
n = int(input('колво игр: '))
побед = 0
поражений = 0
ничьих = 0
for i in range (n):
a = int(input('чем сыграть: '))
b = (random.randint(1, 3))
if a == b:
print('ничья')
ничьих += 1
elif a ==1 and b == 2:
print('победа')
побед += 1
elif a =... |
44cf68a71c7d63502af74324b2e21b2cf9abe4a7 | oforiwaasam/bookshelf | /login_manager.py | 1,105 | 3.65625 | 4 | # login_manager.py
#
# Will hold functions that are in charge of handling the user
# login and registration system, so the users information is
# stored correctly
#
# Saves the value of the logged in user.
# Uses the User class as inputs to log people in
class Login_Manager():
def __init__(self):
... |
7bde26845ebf2f964f74a866f3836f000ec74932 | pravsara/OneBillPython | /Assignment2/qno8.py | 137 | 4.34375 | 4 | s = input("Enter the string : ")
print("Substring is present " if s.find(input("Enter substring : ")) != -1 else "Substring not present") |
eb6ddde7b05df6aa91cbfc5d467e00a1899de3b0 | MatthewTe/lazy_prices_algorithm | /src/pdf_ingestion_engine/financial_report_ingestion.py | 5,639 | 3.609375 | 4 | # Importing PyPDF2 PDF management package:
import PyPDF2 as p2
# Importing data management packages:
from collections import Counter
# Creating class that is meant to represent the Financial Report PDF:
class financial_report(p2.PdfFileReader):
"""
financial_report() object contains all the methods necessary t... |
c37096a7e010113471be77643b574a37f7856879 | maarkeez/machine-learning-snippets | /src/main/custom_library/base_models.py | 1,016 | 3.78125 | 4 | from random import randrange
# The prediction output it's a random value from the train values
def random_algorithm(train, test):
output_values = [row[-1] for row in train]
possible_predictions = list(set(output_values))
predicted = list()
for _ in test:
index = randrange(len(possible_predict... |
1acda121452f28f3205681fb4ee3ec361f1a9a85 | bingheimr/edX-Projects | /edX Midterm - Problem 6.py | 465 | 4.03125 | 4 | """
Create Function to implement following docstring details.
"""
def max_val(t):
"""
t, tuple or list
Each element of t is either an int, a tuple, or a list
No tuple or list is empty
Returns the maximum int in t or (recursively) in an element of t
"""
maxNum = []
for i in... |
da0a3a25519cda77e6b56ef414fb87b97fc64100 | 633-1-ALGO/introduction-python-CorentinClerc | /11.1- Exercice - Boucle/boucle1.py | 322 | 3.53125 | 4 | # Problème : Etant donné un tableau A de "n" nombres réels, on demande la moyenne des nombres du tableau
# Données : un tableau A de n nombre réels
# Résultat attendu : Moyenne des nombres réels du tableau A
A = [1, 5, 15, 25, 10, 55, 50, 35]
moyenne = 0
for x in A:
moyenne += x
print(str(moyenne / len(A)))
|
acc1b752bd3960b1bf41f357c3b7b9c0b08a6b25 | YoganandaMN/Coursework | /Python/Programs Python/FetchingTheStringInSpan.py | 364 | 3.5 | 4 | import requests
import urllib2
from bs4 import BeautifulSoup
def main():
url="http://www.flipkart.com/"
request=urllib2.Request(url)
print "urlopened"
handle=urllib2.urlopen(request)
soup=BeautifulSoup(handle)
for link in soup.findAll('span'):
print (link.stri... |
a9ff4f573cd0b1321f1441ed9089c6105aa5cb2c | amblakemore/UCI_Homework_Blakemore | /Python_Challenge/PyPoll/main.py | 2,209 | 3.671875 | 4 | import os
import csv
# Set the variables
candidates = []
number_votes = 0
vote_counts = []
election_data = ['1', '2']
# Create a path to our csv file in the same folder
election_dataCSV = os.path.join("election_data.csv")
# Read through the file
with open(election_dataCSV) as csv_file:
csvreader = csv.reader... |
a5fd1f0d35f8ede7e7589d14ec4eccca33f6656e | zuqqhi2/my-leetcode-answers | /733-Flood-Fill.py | 1,043 | 3.53125 | 4 | class Solution:
def floodFill(self, image: List[List[int]], sr: int, sc: int,
newColor: int) -> List[List[int]]:
visited = set()
opened = [(sr, sc)]
directions = [(-1, 0), (0, 1), (1, 0), (0, -1)]
oldColor = image[sr][sc]
while len(opened) > 0:
c... |
49a147361968b4e327a39bf2bae227669ada5fa6 | RahulChowdaryN/Cracking-The-Coding-Interivew-Solutions | /Arrays_Strings/Is_Unique_1.1.py | 527 | 3.84375 | 4 | def IsUnique(str1):
for i in range(len(str1)):
if str1[i] in str1[i+1:]:
return False
return True
def IsUnique1(str1):
while str1:
if str1[0] in str1[1:]:
return False
str1 = "".join(str1.split(str1[0]))
return True
def IsUnique2(str1):
temp_str = s... |
4e9c6deeb8db4d531fa1af9677bd0b4e0d5cd68a | danielotaviano/ufrn-pc-project | /src/NewException.py | 434 | 3.53125 | 4 | class NewException:
def __init__(self,argv):
self.argv = argv.get()
def throw(self):
if (not self.argv):
raise Exception("Para executar o programa, passe os argumentos. ex: -i NomeDoArquivoDeOrigem.txt -o NomeDoArquivoDeSaida.txt")
if ('-i' not in self.argv):
raise Exception("Para execução... |
07517c426b50f4ba1875a16cc7f17b0297361ee3 | LJLee37/HackerRankPractice | /Algorithms/Strings/Gemstones.py | 664 | 3.71875 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the gemstones function below.
def gemstones(arr):
arr = list(map(set,arr))
retval = 0
for i in arr[0]:
contain = True
for j in arr:
if i not in j:
contain = False
... |
64642c30c22196ff9f580a4ec15b5f10610c3d67 | bendhouseart/InClass | /week02/obj.py | 2,067 | 4.53125 | 5 | # camel case in python is first letter of everyword is capitalize
'''
class Person: #this is a class at its most elemental
pass
'''
# classes inherit from a parent object instructor, more on that latter.
# the take away from that is that we don't need to supply an argument
# in a class constructor.
''' Now let's... |
3387c9e57b9d1b811fd5eb08b25377da9ca8304a | amardeep18/Introduction-to-Python | /contact_list.py | 679 | 3.515625 | 4 | class Contact:
def __init__(self, first, last):
self.first_name = first
self.last_name = last
self.full_info = first+" "+last
def print_info(self):
print(self.full_info)
def send_message(self):
pass
class EmailContact(Contact):
def __init__(self, first, last, email):
super().__init__(first,last)
... |
3ed4a15c2e7e9e879af5c2ba9b89533725a67745 | WilliamVJacob/Python-Code | /01.posneg.py | 151 | 4.1875 | 4 | #program to check if the number is positive or negatiove
v12= int(input("Enter your no:"));
if(v12 > 0):
print("positive");
else:
print("negative");
|
2eefec6b629bbde8717da0df4eb77e11504ff407 | Prakort/competitive_programming | /letter-combinations-of-a-phone-number.py | 743 | 4.03125 | 4 | def solution(digits):
phone = {
'2': ['a','b','c'],
'3': ['d','e','f'],
'4': ['g','h','i'],
'5': ['j','k','l'],
'6': ['m','n','o'],
'7': ['p','q','r','s'],
'8': ['t', 'u', 'v'],
'9': ['w','x','y','z']
}
result = []
backtrack(digits, '', result, phone)
return result
def backtr... |
e5bdef22294033b261a83ead02dada40c09fc04d | sasha-n17/python_homeworks | /homework_7/task_3.py | 1,155 | 3.859375 | 4 | class Cell:
def __init__(self, num_of_cells):
self.num_of_cells = num_of_cells
def __str__(self):
return str(self.num_of_cells)
def __add__(self, other):
return Cell(self.num_of_cells + other.num_of_cells)
def __sub__(self, other):
diff = self.num_of_cells - other.num_... |
ec9f15a046ac25e39479129580468c28577496f1 | kapishyadav/skynet | /skynet/loss.py | 678 | 3.875 | 4 | '''
loss function is used to measure the accuracy of the model.
Here I'll be implementing the mean squared error loss function.
'''
import numpy as np
from skynet.tensor import Tensor
class Loss:
def loss(self, predicted: Tensor, actual: Tensor) -> float:
raise NotImplementedError
def grad(self, predi... |
5ebc54ff4a62faa078e0b996379d6405ce5529d6 | itisaby/CodePro | /LeetCode/A.Theatre Square.py | 517 | 3.578125 | 4 | import math
class Solution:
def theatreSquare(self,n,m,a):
if n==0 or m==0 or a==0:
return 0
else:
if n%a==0 and m%a==0:
return (n*m)//(a*a)
else:
n=math.ceil(n/a)*a
m=math.ceil(m/a)*a
return (n*m)//(... |
c1f64fb46c2b5487f8d5e89dd103656a557e3999 | cuppar/course | /Python/lab/lab-8/4/gamerules/rules.py | 1,021 | 3.734375 | 4 | def bomb(num):
if num > 21:
return True
elif num >= 0 and num <= 21:
return False
else:
raise Exception('扑克牌的和值应该为非负整数。')
def sum_pokers(pokers_list):
sum = 0
for poker in pokers_list:
poker_num = poker.get_number()
if poker_num > 10:
poker_num =... |
b769a4ef03e2d2135117029a08844a78979367d5 | kalemsalie/areaofacircle | /hello.py | 284 | 4.0625 | 4 | """
print("Hello guys ! How are you?")
print("I live in Cape Town")
print(5+9)
firstname=input("What is your name")
print("My name is ", firstname)
"""
#==============AREA OF A CIRLCE=======================
rad = float(input("Enter Radius: \n"))
pi = 3.1415
print(rad * rad * pi)
|
f812bcd86c582695ccb55f93091a76deb199b313 | boates/practice | /insight/FizzBuzz.py | 368 | 3.765625 | 4 | #!/usr/bin/env python
import sys
def FizzBuzz(n=100):
for i in range(1, n):
s = ''
if i % 3 == 0: s += 'Fizz'
if i % 5 == 0: s += 'Buzz'
if i % 3 == 0 or i % 5 == 0: print s
else: print i
def main():
try: n = int(sys.argv[1])
except IndexError: n = 100
Fizz... |
3d0a0d133a273fc12bd0b7404e4267a33cc1ec4f | ms-shakil/Data-Structure | /example/stack.py | 3,627 | 3.953125 | 4 | class Node:
def __init__(self,value=None):
self.data = value
self.next = None
self.previous = None
class Doubly_LinkedList:
def __init__(self):
self.head = None
self.tail = None
self.size = 0
def Add(self,value):
new_node = Node(... |
62ce11cf6374849bf27f707ecae9a85a1f3b4beb | Jessicavivi/python | /assignment/3/Ziwei Li Assignment 3a.py | 206 | 3.75 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
# Ziwei Li Assignment 3a
number = int(input('How many waves would you like to see?'))
waves = 'v'
for num in range(number):
print(waves,end = '')
|
4b9b845300e2a74c80b3c312f7bacb449b1e6a3f | teenabp/dotpy | /series_q17.py | 84 | 3.609375 | 4 | n = int(input("Enter the limit:"))
res=0
for i in range(n):
res+=n/(n+1)
print(res) |
50f570e2a85a93f8667fc46dde3d1db1d6bd1b25 | BrettMcGregor/udemy-colt-steele | /only_ints.py | 531 | 3.78125 | 4 | '''
@only_ints
def add(x, y):
return x + y
add(1, 2) # 3
add("1", "2") # "Please only invoke with integers."
'''
from functools import wraps
def only_ints(fn):
@wraps(fn)
def wrapper(*args, **kwargs):
if all(isinstance(arg, int) for arg in args):
return fn(*args, **kwargs)
e... |
68e287d494830b4fb444a59bec7ba2d1aaa6dc09 | W1nnx/Exercicios-Python | /aula 89 Boletim com listas compostas.py | 856 | 3.609375 | 4 | from time import sleep
list = []
cont = 0
while True:
list.append([])
list[cont].append(str(input('Nome: ')))
list[cont].append(float(input('Primeira nota: ')))
list[cont].append(float(input('Segunda nota: ')))
media = (list[cont][1] + list[cont][2]) / 2
list[cont].append(media)
continu... |
8de34181e069889b7ab68e2db7e4d00855db055e | SaltHunter/CP1404_Practicals_2021 | /Prac-05/word_occurences.py | 422 | 4.28125 | 4 | wordscount = {}
text = input("Text: ")
# text = "this is a collection of words of nice words this is a fun thing it is"
words = text.split()
for word in words:
frequency = wordscount.get(word, 0)
wordscount[word] = frequency + 1
words = list(wordscount.keys())
words.sort()
maxlength = max(len(word) for... |
29a65be89c046858019273bd95bcb2ab9d9f52ae | Purvil026/Rock-Paper-Scissors-Game-in-Python | /rps.py | 5,014 | 4.28125 | 4 | import random
print("Let the game begin! First one to score 5 points wins! All the best!")
actions = ["rock", "paper", "scissor"]
user_score = 0
computer_score = 0
while(True):
user = int(input("Enter 1 for rock, 2 for paper, 3 for scissor: "))
computer = random.choice(actions)
if user == 1 and computer ... |
aeab157814ce4db7b2b1927f28b18327b7218222 | chris-barrow/Easy2D-Python | /SHAPE.py | 1,107 | 3.5625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This function is used to get the shape functions.
Created on Thu Nov 22 10:50:09 2018
@author: Simon Schmitt
"""
# Import necessary Python Packages
import numpy as np
def shape(XI, KINDI):
PSI = np.zeros(KINDI+1)
DPSI = np.zeros(KINDI+1)
# Linear Elemen... |
0fc8948832bdeda180f6661e7fa91faa9fedb3fb | JMNuno/Snake | /snake.py | 4,831 | 3.890625 | 4 | #! Python3
# Mockup of Snake - Made by JN ~1/30/2017
import pygame, random, sys
import pygame.locals
# Todo list
# Add ability to grow snake
# Add collision check with self;
# Make it so food won't appear on snake body or head
class Game():
HORIZONTAL_SIZE, VERTICAL_SIZE = 300, 300 #Size of screen
... |
da57fe681f5302da3ef3fe9070ee0be382464f2b | julianespinel/blog-code | /python-profiling/brute_force.py | 1,880 | 4.03125 | 4 | '''
https://www.hackerrank.com/challenges/climbing-the-leaderboard
# Climbing the leaderboard
The function that solves the problem is:
```python
get_positions_per_score(ranks, scores)
```
The complexity of this solution is:
- Time: O(scores) * O(ranks log ranks)
- Space: O(ranks) + O(scores) = O(max(ranks,scores))
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.