blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
4c2f2e314fe8d2ff1500df3ac9235f436a258ec1 | ariadn3/Athena | /Medium puzzles/theLastCrusadeEp1.py | 1,799 | 3.703125 | 4 | import sys
def result(gridType, entry):
if gridType == 1:
return ((0,1), 'TOP')
elif gridType == 2 or gridType == 6:
if entry == 'LEFT':
return ((1,0), 'LEFT')
elif entry == 'RIGHT':
return ((-1,0), 'RIGHT')
elif gridType == 3:
if entry == 'TOP':
... |
a9819facf5b3f0030492eae055b31962e65e62c0 | Maheshgavhane4299/assignments-of-group-C | /15.py | 912 | 4.0625 | 4 | # Question No:15 -Python | Ways to check if element exists in list
list = ["akki","ak12#",234,0,1,9,"puja",12.89,18.19,"12ak@A",7,"akki"]
print(list)
#way 1(naive method)
# if 2342 in list:
# print("yes present")
# else:
# print("no not present")
#
# if "ak12#" in list:
# print(True)
# else:
#... |
ad5f51c21ce0ef18dd9284a18e68462bf9c6b048 | zahrasalarian/State-Machines | /NFA_to_DFA.py | 5,617 | 3.609375 | 4 | # opening the NFA with lambda transitions file
f = open("NFA_input_2.txt","r")
lines = f.readlines()
# getting alphabet
alphabet = lines[0].rstrip().split()
# getting states
nfa_states = lines[1].rstrip().split()
# getting starting state
nfa_starting_state = lines[2].rstrip()
# getting final states
nfa_final_states... |
f73ab0e14b4b77a01670208ad8a70fd9ac46846d | MAPE-15/TIC_TAC_TOE | /Tic_Tac_Toe-project - FINISHED.py | 31,713 | 4 | 4 | # TIC-TAC-TOE
# FINISHED !!!
('''
ADD SOMETHING TO A MULTIPLE LIST
a = [[], [], []]
a[0].append(1)
print(a)
''')
('''
HOW IT IS SUPPOSED TO WORK !!!
tic_tac_toe_list = [
['1'], ['2'], ['3'],
['4', 'X'], ['5'], ['6'],
['7'], ['8'], ['9', 'O']
... |
c92d3e3df4e2580756685a8347d87394782127fb | Tiagovcdbr/Logica-de-Programacao-Geek-University-Udemy | /ProgramasPython/secao08/Exercicio06.py | 365 | 3.96875 | 4 | #variaveis
vetor = []
#entrada
codigo = int(input("Informe o código: "))
#processamento
if codigo != 0:
for n in range(0, 5):
num = float(input("Informe um valor real: "))
vetor.append(num)
if codigo == 1:
for n in vetor:
print(n)
if codigo == 2:
vetor.reverse()
... |
0b7f715f6b2f6522095ec6a1d24a901d3d9d1c67 | GamersElysia/kunkkas-plunder | /kunkkasplunder/components/grid.py | 1,423 | 3.765625 | 4 | import itertools
from .position import Position
class Grid:
def __init__(self, width, height, default_value=None):
self.width = width
self.height = height
self.default_value = default_value
self.values = []
def __getitem__(self, key):
if isinstance(key, Position):
... |
5ca372dfacf2cc8bb95d8a57bae04e872573a90a | noorulameenkm/DataStructuresAlgorithms | /StackAndQueue/maxStack.py | 1,344 | 4.25 | 4 | from Stack import Stack
"""
Time Complexity:-
In the push() operation, we are setting one element in the stack, so the time complexity
will be O(1). In the pop() operation, we are removing one element, so the time complexity
will also be O(1). Additionally, the max_rating function only fetches the top... |
003942216a380a8ffc5d41a584e7871864ff9816 | yemao616/summer18 | /Top100/581. Shortest Unsorted Continuous Subarray.py | 582 | 3.5625 | 4 | """
Reference: http://bookshadow.com/weblog/2017/05/15/leetcode-shortest-unsorted-continuous-subarray/
~Hint: use two numbers to record the first and last index
"""
class Solution(object):
def findUnsortedSubarray(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
sn... |
c61b454adfae84b2a5f1397e212eb6c31721e81b | KishoreSurapathi/Python | /Fibonacci.py | 320 | 3.8125 | 4 | import time
memo = {}
def fibnacci(n):
if n <= 2:
return 1
if n in memo:
return memo[n]
temp = fibnacci(n-1) + fibnacci(n-2)
memo[n] = temp
return temp
start = time.time()
for i in range(1,100):
print(fibnacci(i))
end = time.time()
print("The time of execution:", end-start)
|
f6f73d89554fce9c649429a1bd2a4c712e2341cf | bittencourt94/4linux | /exercicios/verifica.py | 127 | 3.5625 | 4 | def verifica(num):
v = num % 2
if v==0:
print("Numero par")
else:
print ("Numero impar")
|
5e6ca635e1cb52b12f252fc7bcbbd72d6dcaf29f | amitfld/amitpro1 | /loop_targilim/loop4.5.py | 599 | 4.03125 | 4 | num1 = int(input('enter number: ')) #קולט שני מספרים חיוביים.
num2 = int(input('enter number: '))
count = 0
while num1 < num2: #מוודא שהמספר הראשון גדול מהשני
num1 = int(input('enter a bigger number: '))
while num2*count + num2 <= num1: #מחשב את מנת החלוקה של המספר הראשון בשני(ללא... |
bc26f0f368810857a7840ebd808fa20caee7f867 | Josh-Dwernychuk/booj | /booj.py | 7,393 | 3.734375 | 4 | import csv
from datetime import datetime
import requests
from xml.etree import ElementTree
def get_xml_feed(url):
''' Method to request XML data from given url
Args:
url <str>: URL endpoint to be requested
Returns:
xml_response <str>: serialized xml response returned from e... |
cc8bf8eacfa3cc5c06790ed9e89046c69dc2744e | ErickOduor/bootcamp | /Inputs and outputs/inputsandoutputs.py | 125 | 3.984375 | 4 | a = int(input("enter the value of a: "))
numbers = [6, 5, 3, 8, 4, 2, 5, 4, 11]
for x in numbers == a
print("valid")
|
94feec9dbdc06348626b79a9dbc23e59f7684cf1 | Howuhh/hse_optimization | /hw1/submission.py | 2,759 | 3.5625 | 4 | import numpy as np
def parabola_min(x1, x2, x3, fx1, fx2, fx3):
x2sx1 = x2 - x1
x2sx3 = x2 - x3
f2sf1 = fx2 - fx1
f2sf3 = fx2 - fx3
u = x2 - (x2sx1**2*f2sf3 - x2sx3**2*f2sf1) / (2*(x2sx1*f2sf3 - x2sx3*f2sf1) + 1e-8)
return u
def optimize(f, a, b, eps=1e-8, max_iter=200):
K = (3 - 5 ... |
ea4695a31c1534c17ffb7643213a17354a75e7b7 | Cycluone/StartLearn | /src/Electric_car.py | 1,322 | 4.21875 | 4 | #!/usr/bin/env python
# -*-coding:utf-8 -*-
from src.model import Dog
d = Dog("D", 14)
d.sit()
class Car(object):
"""一次模拟汽车的简单尝试"""
def __init__(self, make, model, year):
self.make = make
self.model = model
self.year = year
self.dosomething_reading = 0
def get_descriptiv... |
ab55cb348b71a2b253407f415b6cfe9ed6254068 | rashmiKumari03/Voice-Assistant---Alexa-Basic- | /main.py | 5,356 | 3.71875 | 4 | import speech_recognition as sr
import pyttsx3
import pywhatkit #access by alexa like...youtube,spotify or any application.
import datetime
import wikipedia
import sys
import pyjokes
listener = sr.Recognizer()
engine=pyttsx3.init()
voices=engine.getProperty('voices')
engine.setProperty('voice',voices[1].i... |
2bf7158351a6740a84e92615cf2465a7524acaff | cardvark/babynames-python-exercise | /babynames.py | 2,981 | 3.859375 | 4 | #!/usr/bin/python
# Copyright 2010 Google Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
# Google's Python Class
# http://code.google.com/edu/languages/google-python-class/
import sys
import re
import urllib
"""Baby Names exercise
Define the extract_names() functi... |
942463002fad3791c280a21a869eef4d070df432 | Custom2043/ten_weird_quirks_coding | /python/compare.py | 143 | 3.8125 | 4 | print "" is ""
print 0 is 0
print [] is []
print {} is {}
a= 256
b= 256
print a is b
a= 257
b= 257
print a is b
a= 257; b= 257
print a is b
|
1b520a303cb8938af478691d04b712a10609d5ee | fitzritz99/python_scripts | /function_loop_ex.py | 1,260 | 3.75 | 4 | def is_even(x):
if x % 2 == 0:
return True
else:
return False
print is_even(900)
def count(sequence, item):
count = 0
for i in sequence:
if i == item:
count += 1
return count
def purify(lst):
res = []
for ele in lst:
if ele % 2 == 0:
... |
d301a77da333fee20a0792a4aa2e21e3230913a9 | sherry-fig/CEBD1100_Work | /function2.py | 336 | 4.125 | 4 | def isnumbernegative(n):
if n<0:
return True
return False
print(isnumbernegative(4))
my_value=-2
#print number is negative OR number is positive
if isnumbernegative(my_value):
print("number is negative")
else:
print("number is positive")
def isnumbernegative(n):
return n<0
print(isnumb... |
52968d194ee2e7212186d8f073bb0060404d5673 | yasminmenchaca/python-sandbox | /lists.py | 2,217 | 4.1875 | 4 | names = ['Jenny', 'Alexus', 'Sam', 'Grace']
dogs_names = ['Elphonse', 'Dr. Doggy DDS', 'Carter', 'Ralph']
names_and_dogs_names = zip(names, dogs_names)
print(list(names_and_dogs_names))
orders = ['daisies', 'periwinkle']
orders.append('tulips')
orders.append('roses')
print(orders)
orders = ['daisy', 'buttercup', 's... |
672601b38b2ac04fdfe3512a0a55ba2fd32b9948 | vedpari/Python_4_everybody | /py4e_assignment09.4.py | 1,000 | 3.8125 | 4 | #Write a program to read through the mbox-short.txt and figure out who has the sent the greatest number of mail messages. The program looks for 'From ' lines and takes the second word of those lines as the person who sent the mail. The program creates a Python dictionary that maps the sender's mail address to a count o... |
6437a0d94847e047e46be0f8ff6714f33ac2f006 | tagler/Maryland_Python_Programming | /chapter14_databases.py | 774 | 4.125 | 4 | import sqlite3
import string
con = sqlite3.connect("database_example.sqlite3")
cursor = con.cursor()
sql_cmd_1 = "create table if not exists customers (firstname TEXT, lastname TEXT, address TEXT, city TEXT, state TEXT, zipcode TEXT)"
cursor.execute(sql_cmd_1)
with open("customers.txt","r") as data_file:
for eac... |
f19be70cdc6c6ba0ce4f96cf663ed2ca3e8d13d6 | ValiumK/first_repo | /hello_admin(if).py | 654 | 3.953125 | 4 | # 28.08.2021 Упражнение if-else со списками
users =['admin', 'john', 'maria', 'anna', 'vasya']
for user in users:
if user == 'admin':
print("Hello admin, would you like to see status report?")
else:
print(f"Hello {user.title()}, thank you for logging again!")
# Упражнение со множественными спи... |
b52efb6392e4cb06b9cbaa1f21ef17385d364e2b | pykale/pykale | /kale/loaddata/tabular_access.py | 1,655 | 3.71875 | 4 | """Authors: Lawrence Schobs, lawrenceschobs@gmail.com
Functions for accessing tabular data.
"""
from typing import List, Union
import numpy as np
import pandas as pd
def load_csv_columns(
datapath: str, split: str, fold: Union[int, List[int]], cols_to_return: Union[str, List[str]] = "All"
) -> pd.DataFrame:
... |
d0cbf8d231ff6ca3ec43729a5109b50abc4dcca3 | sm11/CodeJousts | /heap_module.py | 364 | 3.6875 | 4 | import heapq
# from heapq import heappop
def kthLargestElement(nums, k):
heapq.heapify(nums)
for i in range(len(nums) - k):
heapq.heappop(nums)
return nums[0]
if __name__ == "__main__":
nums = [7, 6, 5, 4, 3, 2, 1]
# k = 2
# print (kthLargestElement(nums, k))
largest = (heapq... |
cf77655b48270356a50e3e99c25f5780c80c5949 | leosartaj/credit | /credit/printing.py | 1,214 | 3.890625 | 4 | """
Handles printing
"""
import os
import main
KEYSEP = ' -> '
LSEP = ' '
DELIMITER = os.linesep
def printkv(key, val, sep=KEYSEP):
"""
formats key, value
prints key, value
"""
return key + KEYSEP + val
def printlist(l, sep=LSEP):
"""
Joins a list with the separator sep
"""
re... |
877e68ff456d6a41dd7a7a27b2e406ab0eca93c5 | schiob/TestingSistemas | /ago-dic-2018/Daniel Enriquez/practica.py | 634 | 3.765625 | 4 |
def contar(numbers):
pares=impares=negativos=positivos=0
for num in numbers :
if num % 2 == 0:
pares+=1
else:
impares+=1
if num< 0:
negativos +=1
elif num>0:
positivos+=1
return pares, impares, negativos,positivos
if _... |
a71a27ef8ccd66e33f9e90e5cb80575725b57060 | Rodrigs22/ExerciciosCursoEmvideo | /cod/ex032.py | 720 | 3.640625 | 4 | from datetime import date# biblioteca para informar o dia atual para a maquina
#cores
cores = {'limpa': '\033[m',
'ciano': '\033[36m',
'amarelo': '\033[33m',
'vermelho': '\033[31m',
'verde': '\033[32m'}
#programa para decobrir se o ano é bissexto
print(cores['ciano'])
ano = int(input... |
1965733806353b1184bf35164daa63721ea2fcbb | AleksDominik/kattisExercis | /Oddities.py | 175 | 3.828125 | 4 | x=int(input(""))
c=[]
for i in range(0,x):
c.append(int(input("")))
for w in c :
if w%2==0:
print(str(w)+" is even")
else:
print(str(w)+" is odd") |
ac71239434b32987fbee3bbcf13729e79c0c5b57 | Aasthaengg/IBMdataset | /Python_codes/p02392/s758008805.py | 95 | 3.5625 | 4 | a,b,c = [eval(x) for x in input().split()]
if a < b and b < c:
print("Yes")
else:
print("No") |
bd1d7e5bef490e5a95130ec23d624d3982334e30 | ZapisetskayaJulia/labs_2016 | /lab_1/ex_9.py | 93 | 3.609375 | 4 | #task 9
s = input()
for i in range (1,2*len(s),2):
s = s[:i] + '*' + s[i:]
print (s[:-1]) |
8c4bcee05651aaf0df3288933d2984df2b4dcb3c | erjan/coding_exercises | /can_i_win.py | 1,359 | 3.84375 | 4 | '''
In the "100 game" two players take turns adding, to a running total, any integer from 1 to 10. The player who first causes the running total to reach or exceed 100 wins.
What if we change the game so that players cannot re-use integers?
For example, two players might take turns drawing from a common pool of numbe... |
905da853256127fbbbecb61b0c64bad090c0c65c | d1m0ne/Assignment-5 | /Python_assignment_5.0.py | 2,182 | 4.25 | 4 | month = input()
daynum = int(input())
def month_to_num(month):
monthnum = 0
if month == "January":
monthnum = 1
if month == "February":
monthnum = 2
if month == "March":
monthnum = 3
if month == "April":
monthnum = 4
if month == "May":
mon... |
b834d416a972b44612064c750a240adb42604ac6 | adam-schul/Hangman | /hangman.py | 5,262 | 3.78125 | 4 |
# Imports
import re, sys, random, time
from string import ascii_lowercase
# Importing text file as list
words = open('heart2.txt').read()
damn = re.findall(r'\w+', words)
# Choosing a word with some parameters
def choose():
for i in range(len(damn)):
mainWord = random.choice(damn)
if len(mainWo... |
62e0e2cf123f209128cae418f22fb599314b6ff0 | DylanZSZ/StackNN | /formalisms/trees.py | 1,357 | 3.921875 | 4 | """
Helper functions for working with trees.
"""
from nltk.tree import Tree as NLTKTree
def get_root_label(tree):
"""
Finds the label of the root node of a tree.
:param tree: A tree
:return: The label of the root node of tree
"""
if type(tree) is not Tree:
return tree
else:
... |
3b490ed9385a43accdc9d0927c88c7351f6233dc | BigShow1949/Python100- | /32.py | 245 | 4.3125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 题目:按相反的顺序输出列表的值。
a = ['one', 'two', 'three']
for i in a[::-1]:
print i
print '输入列表格式为:1,2,3,4'
s=input()
print type(s)
a=list(s)
print a[::-1]
|
aba8067d33481d00bbe4e32a56f5f23451acf849 | daviguelfi/logatti | /Linguagens de programação/1277389056.loteria.py | 851 | 3.765625 | 4 | #/usr/bin/env python
#coding: utf-8
#Programa gerador de numeros para Mega Sena
#Construido por
#Lus Eduardo Boiko Ferreira
#Voc pode modificar e distribuir o cdigo desde que
#no retire o nome do autor.
import random
linha='-'*75
text0='por Luis Eduardo Boiko Ferreira'
text1='Mega-Sena Generator'
sequencia=r... |
edfc645ae048c9b233da3eb6eb42e8bf3ee4e673 | suchishree/django_assignment1 | /python/looping/assignment2/no8.py | 110 | 3.859375 | 4 | # W.A.P to print Multiplication Table
for x in range(1, 11):
print(x, " ", "*", " ", "5", "=", x*5)
|
c4764544a709384800d14029fc6f0903fbe57b95 | 6112/project-euler | /problems/019.py | 1,809 | 4.15625 | 4 | # encoding=utf-8
## SOLVED 2013/12/20
## 171
# How many Sundays fell on the first of the month during the twentieth century
# (1 Jan 1901 to 31 Dec 2000)?
def euler():
# array of lengths of months
month_lengths = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
# values to add to day-of-the-week accumulat... |
fb3cc1ddf5eaba0519632d5d54b0977c37e2bceb | antaresc/autostyle-visualizer | /data/utils.py | 5,798 | 3.859375 | 4 | """ A script filled functions that converts data into different forms.
Antares Chen
September 2, 2016
"""
from datetime import datetime
from collections import defaultdict
import argparse
import json
import csv
import ast
# -------------------------- FILE UTILITIES --------------------------
def load_csv(filename... |
08dd89a86c41f500b76953c9628f9780ff0b3dd2 | Aasthaengg/IBMdataset | /Python_codes/p02571/s360836222.py | 328 | 3.640625 | 4 | string1 = input()
string2 = input()
n, m = len(string1), len(string2)
best = float("inf")
for i in range(n - m + 1):
current = string1[i:i+m]
differences = 0
for i in range(m):
if current[i] != string2[i]:
differences += 1
best = min(differences, best)
if best == float("inf"):
print(0)
else:
pri... |
d95d204260190411bdca179e71134b2a3fa5d85f | edivaldofontes/Calculo1 | /TVI-bissecao.py | 1,970 | 4.09375 | 4 | import math
def buscaSolucao(f,a,b,N):
'''Aproxima a solução da equação f(x)=0 no intervalo [a,b] pelo método da BISSEÇÂO.
Quem fizer cálculo numérico verá esse método!
Parâmetros
----------
f : A função f(x)
a,b : Números reais representando o ínicio e o fim do intervalo [a,b].
... |
562fade7d65efb1b36f6648f1cfda578d5081b08 | beginmachinelearning/pandas | /4_dataframe_arithmetic.py | 438 | 3.640625 | 4 | import pandas as pd
import numpy as np
my_df=pd.DataFrame(np.arange(10))
#Add 1
my_df.add(1)
#Sub 1
my_df.sub(1)
#reverse sub
my_df.rsub(1)
#Divide
my_df.div(2)
#Reverse Divide
my_df.rdiv(1)
#Multiply
my_df.mul(10)
#Exponent
my_df.pow(2)
#Using NumPy Abs
np.abs(my_df.sub(10))
#Sum, defaults to axis 0, Sum one... |
4bfaa6f322110e086cc7e0c937c6e1f76ed89d9c | jsundram/euler | /058 - Primes on Square Spirals.py | 1,424 | 3.9375 | 4 | #!/usr/bin/env python
# encoding: utf-8
"""
058 - Primes on Square Spirals.py
Created by Jason Sundram on 2009-12-17.
Copyright (c) 2009. All rights reserved.
Starting with 1 and spiralling anticlockwise in the following way, a square spiral with side length 7 is formed.
37 36 35 34 33 32 31
38 17 16 15 14 13 30
39 ... |
ab6ccde708f4f30d67eb0b9fd1704717c3d9791d | pathbox/python-example | /python-small-example/counter_add.py | 510 | 3.546875 | 4 | from collections import Counter
a = ['apple', 'orange', 'computer', 'orange']
b = ['computer', 'orange']
ca = Counter(a)
cb = Counter(b)
print(ca)
print(cb)
ca + cb # Counter({'orange': 3, 'computer': 2, 'apple': 1})
def sumc(*c):
if (len(c) < 1):
return
mapc = map(Counter, c) # map 化操作
s = C... |
e12fe40c0f62b6694c26f40cc57c9a64cf2f2d0e | stefanin/Python | /16 sqllite.py | 1,479 | 3.609375 | 4 |
'''
Creare il DB con il tool sqllite che si carica dal sito :
sqlite3 film.sqlite
https://code.activestate.com/pypm/ per ricercare un oggetto / funzione
pip install iptools
film = tabelle("nometabella", db)
'''
import sqlite3
import iptools
db = sqlite3.connect('./film.sqlite')
db.execute("drop table film")
db... |
43eee04610e867de80e60ff544092f62978968bc | sharfir/Test | /Loop/testwhile.py | 226 | 4.03125 | 4 | #!/usr/bin/env python3
#while语句循环执行是while里面的所有缩进行,
#直到number大于等于5,才停止循环,并且每循环一次,number+1
number = 0
while number < 5:
print(number)
number += 1
|
343677c250f436b5095c72985eadd30da635da00 | Young-Thunder/RANDOMPYTHONCODES | /if.py | 206 | 4.1875 | 4 | #!/usr/bin/python
car = raw_input("Which car do you have")
print "You have a " + car
if car == "BMW":
print "Its is the best"
elif car =="AUDI":
print "It is a good car"
else:
print "UNKNOWN CAR "
|
8bd2ac949fe6ab36acb8cc5f52c98f10d10dcbb9 | cairoas99/Projetos | /PythonGuanabara/exers/listaEx/Mundo3/ex076.py | 257 | 3.65625 | 4 | listagem = ('Lapis', 1,
'Borracha', 1.5,
'Caneta', 2.1,
'Post IT', 3.5)
print('-'*32)
print(f'{"Listagem de preços" :^32}')
for c in range(0 , len(listagem)-1, 2):
print(f'{listagem[c]:.<25}R$:{listagem[c+1]:<6.2f}') |
b841a7a7c851f4225cf9e161fd315f67390b454c | chenqianethz/learning_python2017 | /python beginner 2016fall/exercise in script00.py | 1,027 | 3.640625 | 4 |
"""exercsie 1
a=66
b=78
while a!=b:
if a-b > 0:
a = a-b
else:
b = b-a
print ("the greatest common devisor=",a)
"""
"""exercsie 2
a=1
b=2
m=a
a=b
b=m
print (a,b)
"""
"""exercsie 3
a=float(input("pls enter the working hours"))
b=float(input("pls enter salary per hour"))
if a<=40:
m=a*b
else:
m=(a-40)*b*2+40*b... |
b6ca30f883ea9a0782706a470618b42f0aff4a26 | NicThelander/algorithms | /Python/recurse_sort_descending.py | 1,130 | 4.34375 | 4 | def recurse_sort_des(ls, active_index=0):
"""
Passed a list as an argument and then recursively
finds and swaps the biggest integer from further in
the list with the current position.
Note: The active index is used for tracking it's place
within the list, you can supply one yourself but it will... |
0f46b28dd5b87367754ef56f2773114cd9597eac | mfguerreiro/Python | /Introdução/temperatura.py | 145 | 3.8125 | 4 | tempFah = float(input("Digite uma temperatura em fahrenheit: "))
tempCel = ((tempFah - 32)*5) /9
print("A temperatura em celcius é: ", tempCel)
|
7d2989a10819d1d68b4f18891a06e5ba7578dab4 | ejolie/problem-solving | /Hackerrank/old/30-Days-of-Code/recursion3.py | 181 | 3.828125 | 4 | n = int(input())
factorial = lambda n: 1 if n <= 1 else n * factorial(n-1)
print(factorial(n))
'''
def factorial(n):
if n <= 1:
return 1
return n*factorial(n-1)
''' |
0341ee411a300ed9ca58d000db7ccb20ac9a754c | krishppuria/Python-work | /Code_challenge/reverse.py | 125 | 3.828125 | 4 | def reverse(string_fun):
return string_fun[::-1]
string_user=input()
reverse_str=reverse(string_user)
print(reverse_str) |
738aaae4d30e6d9cc07d124973af7461a85ae97c | Nicobossio42/Exercises3004 | /Ex3.py | 129 | 3.734375 | 4 | x = float(input("Introduzca el primer numero: "))
y = float(input("Introduzca el segundo numero: "))
print("La suma es: ", x + y) |
1be4aae4998f324f5917da9f2d67e979bc4bf8d5 | developer579/Practice | /Python/Python Lesson/Second/Lesson5/Sample11.py | 492 | 4.3125 | 4 | data = [1,2,3,4,5]
print("現在のデータは",data,"です。")
print("data[::-1]をfor構文で表示します。")
for d in data[::-1]:
print(d)
print("data[::-1]は",data,"です。")
print("reversed(data)をfor文で処理します。")
for d in reversed(data):
print(d)
print("reversed(data)は",reversed(data),"です。")
print("現在のデータは",data,"です。")
print("data.reverse()を処理します。"... |
75fbf5bc0ba8e3c16c6255a7efdeb742b1bda3e4 | FabioCostaR/aprendendoPYTHON | /Desafio92.py | 1,018 | 3.765625 | 4 | #Crie um programa que leia nome, ano de nascimento e carteira de trabalho e
#cadastre-os(com idade) em um dicionário se por acaso a CTPS for diferente
# de zero, o dicionário receberá também o ano de contratação e o salário. Calcule
# e acrescente, além da idade, com quantos anos vai se aposentar.
from datetime imp... |
c0e3c576a3e9799149b9fe51fd51d457f4256f91 | dsnowb/leetcode | /merge_two_sorted_lists.py | 655 | 3.59375 | 4 | class Solution:
def mergeTwoLists(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNode
"""
if not (l1 or l2):
return l1
if not l1:
return l2
if not l2:
return l1
if l1.val < l2.v... |
23d76df236d3234c1cd182bf3fc2b2825ed3b702 | KaEnfors/GyKurser2020 | /Prog2_2020/1 - Program/Gamecard.py | 4,615 | 3.5625 | 4 | import cards
import time
#Boolen values
startGame = False
cardTrueOrFalse = True
cardTrueFalseBot = True
#The type of card picked
cardPicked = []
cardPickedBot = []
# Game data
allowedInput = ["C", "D", "H", "S"]
playerData = []
botData = []
i = 0
pointsBot = 0
pointsPlayer = 0
#Rounds nad lives
rounds = 10
lives = ... |
f82d8b3f60b1c1f7e41c4ce5443315a4cc6c819f | AartiBhagtani/Algorithms | /python/itertoolsProductFunctionExample.py | 481 | 3.671875 | 4 | # Link : https://www.hackerrank.com/domains/python
# Gives combination of every element in one list with every other element in all other list
from itertools import product
if __name__ == '__main__':
k, m = [int(x) for x in input().split()]
temp = []
for _ in range(k):
temp.append([int(x) for x in ... |
53ba2ba4f832446fccebb60af393258a56a8fbf8 | cfudala82/DC-Class-Sept-17 | /projects/week1/day4_functions.py | 2,179 | 3.859375 | 4 | # import matplotlib.pyplot as plot
# import math
# print('1.Hello')
# def hello (name):
# print('Hello {}'.format(name))
# hello('Igor')
# print('2.y=x+1')
# def f(x):
# return x + 1
# xs = list(range(-3, 4))
# ys = []
# for x in xs:
# ys.append(f(x))
# plot.plot(xs, ys)
# plot.show()
# print('3.Squar... |
2d494df74c870d63d3d602b48e198d3d54a4d43a | Jenifferbio/intro-python-1_usp | /jogo_nim.py | 2,110 | 3.84375 | 4 |
def computador_escolhe_jogada(n, m):
c_remove = 1
while c_remove != m:
if (n - c_remove) % (m+1) == 0:
return c_remove
else:
c_remove += 1
return c_remove
def usuario_escolhe_jogada(n, m):
jogada_val = True
while jogada_val:
j_remove = int(input('Qu... |
8dcae89238dc90a80f87a5114798d5e86cffd756 | Iiridayn/sample | /Coderbyte/20-ArithGeo.py | 556 | 4.09375 | 4 | # Challenge: Test if sequence is Aritmetic or Geometric. It won't be both (all same number). 10 points, 13 mins
def ArithGeo(arr):
if len(arr) < 3: return -1 # not a meaningful sequence
diff = arr[1] - arr[0]
div = arr[1] / arr[0]
for x,y in zip(arr[1:], arr[2:]):
if diff and y-x != diff: diff = None
... |
316787d9cb37ce9b9bbf5f225a32a5ee31bdbb5e | acbrimer/holbertonschool-higher_level_programming | /0x01-python-if_else_loops_functions/0-positive_or_negative.py | 204 | 3.96875 | 4 | #!/usr/bin/python3
import random
number = random.randint(-10, 10)
if number == 0:
print("{} is zero".format(number))
else:
print("{0} is {1}".format(number, ("positive", "negative")[number < 0]))
|
412a69cbe50c6a88a095dea25901c49c3d51f9f5 | pbradford0/AoC_day12 | /day12.py | 1,164 | 3.71875 | 4 | #Author: Phil Bradford
#Solution for http://adventofcode.com/2015/day/12
import sys
import re
import json
def red_sum(item):
if type(item) is dict:
#loaded a dict, go deeper
if "red" in item.values():
return 0
else:
return sum(map(red_sum, item.values() ))
elif type(item) is list:
#loa... |
80970dd3c1a95aefa9d0ae4c95074e2052bdacfa | Angelongone/Python | /py/Iter.py | 191 | 4.3125 | 4 | #!/usr/bin/python3
#迭代的两个基本方法:iter()和next()
list = [1,2,3,4,5]
it = iter(list)
print(next(it))
print(next(it))
#用for语句遍历
for x in it:
print (x,end=" ")
|
c9e122d87a6c15c0efc5ec508b4911d4e35ba77b | Ziyu2020/Python | /20_05_2020.py | 679 | 3.953125 | 4 | def gcd(x,y):
"""the minimal factor"""
(x, y) = (y, x) if x > y else (x, y)
for factor in range(y, 0, -1):
if x % factor == 0 and y % factor == 0:
return factor
def lcm(x,y):
"""the least common multiple"""
common_multiple = x * y // gcd(x,y)
return common_multiple
x = int... |
30e87f8688e765353163c6e7f0c68ea0c1b645a3 | sleticalboy/Pylearn | /com/sleticalboy/python/basic/function/13_return_value.py | 649 | 4.125 | 4 | #!/usr/bin/env python
# -*- coding=utf-8 -*-
# 函数返回值
def get_formatted_name(first_name, last_name, mid_name=''):
"""返回格式化的姓名"""
full_name = first_name + " "
if mid_name:
full_name += mid_name + " "
full_name += last_name
return full_name.title()
# 调用函数
print(get_formatted_name('lee', 'b... |
91cee1ada840898e46cc89a81d3497f45eb31c7a | bitsapien/anuvaad | /public/phase-2-20160620022203/PYTHON/bookshelf.py | 344 | 3.734375 | 4 | #!/usr/bin/python
# Name : Bookshelf
# input:
# n : number of books
# m : number of books remaining in the first shelf
elements = raw_input().strip().split(' ')
n = int(elements[0])
m = int(elements[1])
# write your code here
# store your results in `number_of_methods`
# output
# Dummy Data
number_of_methods = 4
p... |
f3a185452cd98aeb260d833e0de2cb8dd70bfc38 | bargc/GabrielClasses | /HomeWork1/save_files_functions.py | 829 | 3.65625 | 4 | import csv
def write_to_file(content, filename, writetype):
savefile = open(filename, writetype)
savefile.write(content)
savefile.close()
def write_to_csv(content, filename, writetype):
resultFile = open(filename, writetype)
wr = csv.writer(resultFile, dialect='excel')
wr.writerows(content)
i... |
d6baed4262541412cfb5a7e9dd8176dcf3f63dcb | GongGecko/GitSun | /gong_master_se/running_time.py | 1,039 | 3.875 | 4 | print('............................S010101............................')
#运行时间
import time
start_timeA=time.time()
start_timeB=time.clock()
print('............................Sxxxxxx............................')
a1=set(list(range(90900))[::3]) & set(list(range(30600))[::7])#集合交集
a2=[x for x in a1]
a3=sorted(a2)
print... |
b8f116909ef44287942ff7c3a3a5e1c141b361fc | timmwuensch/signature-validation | /main/image_processing.py | 5,861 | 3.640625 | 4 | ## The following methods are used to support the single components with image processing functions
import numpy as np
import cv2
def show_image(image, title='Test'):
## Method shows an image
cv2.imshow(title, image)
cv2.waitKey(0)
cv2.destroyAllWindows()
def make_28_square_image(image):
... |
80edab6c23cfa3087bc7708db48573950555a6d1 | t3eHawk/pepperoni | /pepperoni/formatter.py | 2,002 | 3.546875 | 4 | """Output records formatter."""
class Formatter():
"""Output records formatter.
Class represents output records format.
Parameters
----------
record : str, optional
Format of the output record.
error : str, optional
Format of the error message.
traceback : str, optional
... |
e88d0868a7fd0afd36100d814bd16fb7525d211c | tmu-nlp/100knock2016 | /Hayahide/chapter01/knock02.py | 155 | 3.75 | 4 | #-*- coding: utf-8 -*-
str1 = u"パトカー"
str2 = u"タクシー"
str3 = ""
for i in range(0, 4):
str3 += str1[i]
str3 += str2[i]
print str3
|
2e6a6ef867e7c1e0fe7c899479a57b0a54e21015 | dragosbus/mit_6.00.1 | /hangman/ps3_hangman.py | 3,545 | 4.34375 | 4 | # Hangman game
import random
WORDLIST_FILENAME = "words.txt"
def loadWords():
"""
Returns a list of valid words. Words are strings of lowercase letters.
Depending on the size of the word list, this function may
take a while to finish.
"""
print("Loading word list from file...")
# inFile... |
e49387896e5b00a9d3b5bfce986e666eae463c0d | vivasvan1/beautifulProblems | /problemCode/SentenceWordInverse.py | 279 | 3.75 | 4 | x = list(input("Input String: "))
x = x [::-1]
j = 0
def reverseword(x):
i = 0
print(int)
while i !=int(len(x)/2):
temp = x[i]
x[i] = x[len(x)-1-i]
x[len(x)-1-i] = temp
i+=1
return str(x)
print(reverseword(x))
|
7dc6929ccdd46cf1aa70eb679a40d5ec59cecc37 | MaxMcGlinnPoole/scraping_and_data | /boxofficemojoscraper/scraper.py | 1,796 | 3.5625 | 4 | import bs4
import urllib.request
'''
Reads the top 100 movies of 2016 and puts the information into a csv file
'''
class Movie:
def __init__(self, rank, title, studio, gross):
self.rank = rank
self.title = title
self.studio = studio
self.gross = gross
def __str__(self):
... |
eaf8b53dddea76f7b2a5e8e3bf04ab4a60727525 | sheauyu/sapy | /src/exercise_solutions/S3_imaginary.py | 822 | 3.765625 | 4 | """ Solution to Exercise 'Modifying Text Files', Chapter 'Data Input' """
# author: Thomas Haslwanter
# date: April-2021
# Import the required packages
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import os
# Set the required parameters
data_dir = '../../data'
file_name =... |
4357dfac9100c85a55166c6f224704b9256031dc | sonir/sonilabPython | /tuple_tool.py | 423 | 3.71875 | 4 | def make(val):
return (val,)
def merge(tuple1, tuple2):
new_tuple = (tuple1 + tuple2)
return new_tuple
def sort(tuple1):
my_list = list(tuple1)
my_list.sort()
return tuple(my_list)
def split(tpl,index):
my_list = list(tpl)
list_a = my_list[:index]
list_b = my_list[index:]
retu... |
5241804cb45a326154925771c414f802654cf954 | Derakonga/Learning | /average_number.py | 410 | 3.984375 | 4 | user_numbers = []
user_num = ""
n_num = 0
finish = ""
while finish != "Yes":
while not user_num.isdigit():
user_num = input("Add a number: ")
user_numbers.append(int(user_num))
user_num = ""
print("Number added!")
n_num += 1
finish = input("END? (Yes / No): ")
addnum = sum(user_num... |
b7171d1e1678d71cf8ea4ac5b34eca8fd9c0ab6d | alex-rudolph/Simple-UDP-example | /UDP_CAR_Server.py | 5,491 | 3.578125 | 4 | ## Alexander Rudolph
## William Cervantes
## Zosimo Geluz
import socket
import sys
class Car(object):
## This is the definition for Cars
## contains info for: Manfacturer, Model, Color, Year, and Condition
def __init__(self, manufacturer, model, color, year, condition):
# initialize the paramet... |
97548bd46fcde818fc78affa77171d9fdd86218b | J-Gottschalk-NZ/FRC_Panda | /06_round_up.py | 350 | 3.828125 | 4 | import math
# rounding function
def round_up(amount, round_to):
# rounds amount UP to the specified amount (round_to)
return int(round_to * round(math.ceil(amount) / round_to))
# Main Routine starts here
to_round = [2.75, 2.25, 2]
for item in to_round:
rounded = round_up(item, 1)
print("${:.2f} --> ${:.... |
5b8787b614b566f6f936d15a29bfd0b57aea4f6f | excelsky/Leet1337Code | /111_minimum-depth-of-binary-tree.py | 776 | 3.921875 | 4 | # https://leetcode.com/problems/minimum-depth-of-binary-tree/
# 6gaksu
# 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 minDepth(self, root: TreeNode) -... |
ae1f7ae318c6bcb8f4e664e3175dab57385b2c7d | M45t3rJ4ck/Student | /Counting.py | 454 | 4.4375 | 4 | # Write a Python program called “counting.py” to count the number of characters (character frequency) in a string.
# Store each letter followed by the number of occurrences in a list and print
# it out.
# Sample String : google.com'
# Expected Result : {'o': 3, 'g': 2, '.': 1, 'e': 1, 'l': 1, 'm': 1, 'c': 1}
U_in = ... |
dd6c9e13d1fd7e2c23f23ac989c0e3cef08fb5f4 | vamsikrishna6668/python-core | /7-8(am)/corePython/control stmtss/zomatadiscount.py | 909 | 4.25 | 4 | veg =int(input('No of items of veg:'))
nonveg =int(input('No of items of Non-veg:'))
vegcost=200
nonvegcost=300
vegdiscount=(veg*vegcost)*0.10
nonvegdiscount=(nonveg*nonvegcost)*0.10
totalcostveg=(veg*vegcost)-vegdiscount
totalcostnonveg=(nonveg*nonvegcost)-nonvegdiscount
if totalcostveg>200:
print('The no of items... |
e4e5d43fdd4ad85d57a665f8d7dc6ab27da36ebf | BrindaSahoo2020/Python-Programs | /ReverseSentence.py | 309 | 4.125 | 4 | #Python program to reverse a sentence
#Sample Input
'''I am new to python programming'''
#Sample Output
'''Reversed sentence is : programming python to new am I'''
str1 = str(input("Enter a sentence:"))
word = str1.split()
output = word[-1::-1]
str2 = " ".join(output)
print ("Reversed sentence is :",str2)
|
d45050f317d4bc670fc49f99f2f6acc092ed2843 | matias18233/practicas_python | /entregable_3/TuDolarBank.py | 773 | 4 | 4 | # Nombre: Fernando Matías
# Apellido: Cruz
# Comisión: 1
# Se obtiene la cantidad de dólares a comprar
cadena = input("Ingrese la cantidad de dólares a comprar: $")
dolarComprar = float(cadena)
if dolarComprar <= 0:
print("No puede comprar una cantidad negativa de dólares")
else:
# Comienza el cálculo del val... |
84876d0a6e7083bc0db70e439ee4e853666c7ec1 | Pavan14vamsi/Algorithms | /Algorithms.py | 1,649 | 4.21875 | 4 | '''Implement the following algorithm:
Sort(A):
for j = 2 to A.length:
i = j-1
key = A[j]
while i>0 and key<A[i]:
a[i+1] = a[i]
i = i-1
A[j] = key
'''
class PavanSorting ():
'''This class has several sorting methods. All of them have the same API structu... |
f18caa5bbf3c428e3448d0ac191be3f693901076 | dharper998/CS110-Course-Work | /lab3.py | 1,414 | 4.09375 | 4 | import math
import turtle
def setUpWindow(screenObject):
'''
Changes range of x and y axis of window and changes the background color
param list: (str) Variable assigned to the window
return: (str) No return for this function
'''
screenObject.setworldcoordinates(-360, -1, 360, 1)
screenObject.bgcolor("Blue")
... |
62491f08692d64d9da28bc1033e3cbdd5377ab9d | akshayDev17/Extractive-Text-Summarizer | /scorer.py | 797 | 3.90625 | 4 | """ Module to award score to tokenized sentences """
from collections import defaultdict
from nltk.tokenize import word_tokenize
from nltk import FreqDist
def give_score(word_list, sentence_list):
""" we first calculate the frequency distribution of each word in
our data(word tokenize list), and based on th... |
d9ee8476009c9e5cfa9dbe539c2174d317370928 | abbeeda/ggbo | /jj6.py | 568 | 3.5625 | 4 | <<<<<<< HEAD
a=input("请输入年份:")
b=a[-1:]
c=int(a[:-1])
while b == "年":
break
else:
print("输入错误")
if c%4==0:
if c%100==0:
print("该年不是闰年")
else:
print("该年是闰年")
else:
print("该年不是闰年")
=======
a=input("请输入年份:")
b=a[-1:]
c=int(a[:-1])
while b == "年":
break
else:
print("输入错误")
if c%4==0:
if ... |
93f17233f96a625d8aaeb4cb8c1f1f8f4c38a8ba | dhyoon1112/python_practiceproblems | /25. Guessing Game Two.py | 1,084 | 3.953125 | 4 | import random
def guess2():
counter = 1
array = [_ for _ in range(1,101)]
guesses = [0]
numbers = []
start = 0
end = 100
while True:
guess = random.randint(start,end)
print("Is your number lower or higher than " + str(guess))
number = input("Type 'hig... |
8dc6a16b80192aeeee0b5be903e67f8062e36712 | lalchan123/Contest-Programing-Code | /URI_1070.py | 69 | 3.5625 | 4 | # x = int(input())
# for x in range(x, x+11, 2):
# print(f"{x}")
|
be56a71aa70f027f91ea05c9ae850401fee27783 | joetomjob/PythonProjects | /src/Sem1/circleflake.py | 1,170 | 4.125 | 4 | import turtle as t
def drawcircleflake(size,order):
'''
pre: turtle facing east at centre of the circleflake
post : turtle facing east at centre of the circleflake
:param size: the size of the circleflake
:param order: the level of the circleflake
'''
if order ==1:
t.speed(0)
... |
80ba9d411741a59b1cd5cfc2b0935b032fa2f27a | DevilEars/Pygame | /Boids/Boid.py | 3,670 | 3.828125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Feb 13 17:38:29 2020
@author: devilears
"""
import math
import random
class Boid:
"""
Keeps track of a Boid's position and velocity in 2 dimensions
Boids follow three rules:
1. Flock together towards the centre
2. Don't bump ag... |
5fd5a9d9f0534bf55edff5abdd48287b6af7766f | khorshidisamira/The-role-of-graphlets-in-viral-processes-on-networks | /LinearRegressor/LinearRegressor.py | 3,475 | 3.625 | 4 | # Linear Regression
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import matplotlib
from sklearn.metrics import mean_squared_error
from sklearn.cross_validation import train_test_split
from sklearn.linear_model import LinearRegression
matplotlib.style.use(... |
80d21bc2f0261f1da9eaf5fa7ae970792e0dc729 | AngelSolomos/intro_python | /combinations.py | 433 | 3.828125 | 4 | from itertools import combinations
if __name__ == "__main__":
a_list = [1, 2, 3, 4, 5]
comb_2 = combinations(a_list, 2)
for combination in comb_2:
print(combination)
print()
comb_3 = combinations(a_list, 3)
for combination in comb_3:
print(combination)
print()
... |
7d7f5a5f3f1951af41dc8c613ee74f2a439e64f9 | BiancaPal/PYTHON | /INTRODUCTION TO PYTHON/styling_functions.py | 2,211 | 3.921875 | 4 | # STYILING FUNCTIONS
# Functions should have descriptive names, and these names should use lowercase letters and
# underscores. Descriptive names help you and others understand what your code is trying to do
# Module names should use these conventions as well.
# Every function should have a comment that explains conci... |
a72c3ea06d42196473df958375ee380594ebef1b | dunitian/BaseCode | /python/1.POP/1.base/02.sum.py | 124 | 3.65625 | 4 | num1 = input("输入第一个数字")
num2 = input("输入第二个数字")
print("num1+num2=%d" % (int(num1) + int(num2))) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.