blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
b68c20ee8b61d500af14fcb016d6dc27f1c41e3d | drlvitalii/codewars | /tasks/disemvowel.py | 991 | 4.25 | 4 | # Trolls are attacking your comment section!
# A common way to deal with this situation is to remove all of the vowels from the trolls' comments,
# neutralizing the threat.
# Your task is to write a function that takes a string and return a new string with all vowels removed.
# For example, the string "This website is ... |
3c8c450d8af89d0cf30977169f6621d84e0e6f53 | ggornes/Chesspyrito | /utils.py | 998 | 4.21875 | 4 | def split_string_to_chars(_string):
"""
Split string characters and store them in an List[chr: c]
:param _string: a string variable
Example" split()
:return:
"""
return [char for char in _string]
def list_of_list_board_to_str(b):
"""
Parse Board b List[List[Square]]
b is a board... |
d66e3d3964480e556658b930ee2028c72635d7b2 | skirdapa/StepikPythonEducation | /Python Basics and Application/week 3/demo code/exist counter.py | 738 | 3.90625 | 4 | """
Вашей программе на вход подаются две строки s и t, состоящие из строчных латинских букв.
Выведите одно число – количество вхождений строки t в строку s.
Пример:
s = "abababa"
t = "aba"
Вхождения строки t в строку s:
abababa
abababa
abababa
Sample Input 1:
abababa
aba
Sample Output 1:
3
Sample Input 2:
ababab... |
d0720469e4c559dd96bb98ce62c41f8948608907 | abdullahibneat/Data-Visualisation | /Plot 3 - daily visits time series.py | 1,697 | 3.59375 | 4 | import matplotlib.pyplot as plt
from data import summary_data, visitor_data
# The following thresholds were determined from the previous plot:
#
# total visitors: HIGH=150k+, MEDIUM=50k+, LOW=<50k
#
# Because the "low" graph produces too many lines,
# added a very low threshold for visitors less than 18k
categories = ... |
c92bdb7cf20e1e44274c98ba0ad29042753263b5 | reshmaj121/python_assignment | /atm.py | 3,489 | 3.890625 | 4 | database = {
'reshma121': {
'name': 'Reshma Jadhav',
'age': 32,
'email': 'reshma123@gmail.com',
'pin': '1234',
'balance': 20000,
},
'shiv456': {
'name': 'Shiv Verma',
'age': 40,
'email': 'shiv456@gmail.com',
'pin': '456... |
b151894622787604682b85fd7d96fbae34f7884e | EvgenijSulima/Prometheus1 | /2.2(old).py | 201 | 3.578125 | 4 | import sys
x=int(sys.argv[1])
y=int(sys.argv[2])
z=int(sys.argv[3])
pes='Everybody sing a song:'
if z == 1 :
zn='!'
else:
zn='.'
pes=str('Everybody sing a song:')+((' la'+'-la'*(x-1))*y)+zn
print pes |
c974f0c4206fe7c4c2956874e921e0ef3435c261 | owenbob/Yummy-Recipes | /Classes/user.py | 2,035 | 3.703125 | 4 | """
User class that should contain our functions and variables for testing
the database list belongs to the app as a databse
"""
class User(object):
#A user should contain a username,email address and a password in order to use Yummy recipes
def __init__(self,username,email,password):
#Initilia... |
25570af9f81abc0d6aa955df74a7757d8b2788ad | Sayan-Roy-729/Infosis-proble- | /Problem-1.py | 878 | 4.40625 | 4 | # Write a code to find the minimum among three given numbers.
def minThreeNumber(num1, num2, num3):
'''It is a function to find out of the minimun number amon the three numbers. It takes three numbers.
And print that number which is smallest.'''
if num1<num2 and num1<num3:
print(... |
f8a11dd4cfab0c3646129f94126d0d8b175249e9 | swamirahul/Recommendation_system | /ContentBased/practice | 493 | 3.6875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 15 14:02:30 2019
@author: vaibhavswami
"""
s="pwkew"
str_list = []
max_length = 0
for x in s:
if x in str_list:
str_list = str_list[str_list.index(x)+1:]
print("before Append string list",str_list)
str_list.append(x)
... |
8486ac1c0bcab4404b1aecf2a4fcc3665d42637e | NilsBaumgartner1994/Tricc-Security-Test | /poisonMqtt/gpsParser.py | 758 | 3.609375 | 4 |
def readRoute(filename="gps_burger_king_route.txt"):
"""
Reads gps coordinates from files, except for first and last line. Format in file, e.g.[52.286851666666664, 8.033383333333333, 501552],
:param filename: String with the filename
:return: [[lat, long], [lat, long], .... ] with lat and long as float... |
806cf881e4771ca8d629e3ae7451834ea291cc12 | nitsky/algorithms | /misc/maximum_subarray.py | 736 | 4 | 4 | # maximum_subarray.py
# Find the contiguous subarray with the largest product.
# For example, given the array [2,3,-2,4],
# the largest product is 6 for subarray [2,3].
def max_subarray(values):
if len(values) < 1:
raise Exception("input must have at least one value")
local_max = values[0]
local... |
12452e3478f7b0f19063b86a4e4eef36ee19698b | brianchiang-tw/leetcode | /No_0437_Path Sum III/path_sum_iii_by_dfs_and_helper.py | 1,555 | 4 | 4 | # The implementation in thie file is a practice code, not a good one with consideration of time complexity and space complexity.
'''
Description:
You are given a binary tree in which each node contains an integer value.
Find the number of paths that sum to a given value.
The path does not need to start or end at ... |
9966f48a84e09ad7bb6e362d079eb73c5fbbe280 | Cobrettie/intro-python-ii | /src/room.py | 1,051 | 3.796875 | 4 | # Implement a class to hold room information. This should have name and
# description attributes.
# * The room should also have `n_to`, `s_to`, `e_to`, and `w_to` attributes
# which point to the room in that respective direction.
from typing import List
from item import Item
class Room:
def __init__(self, ... |
679fd5e0d9aeab6b2f9e01b9b64f3f3694168f98 | akshatvaidya/SocketProgramming | /Server.py | 5,501 | 3.78125 | 4 | # Name - Akshat Vaidya
# Student Id - 1001550684
# importing all the necessary libraries
# socket library is used to create and handle various sockets
# Threading library is used to create threads which help in multithreading
# easygui library is used to create gui
# os library is used to get the file list at a s... |
6b54f32ee0b6a27bcff4c3a627375c7542416020 | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/bob/7668f94477dd41caa49f02e0cc375f84.py | 1,024 | 4.125 | 4 | #
# Skeleton file for the Python "Bob" exercise.
#
def hey(what):
what = what.rstrip()
if what.isupper():
return 'Whoa, chill out!'
elif what.endswith('?'):
return 'Sure.'
elif containsLetters(what) == False:
return 'Fine. Be that way!'
else:
r... |
9c473ca0ba0403cae22eef77f44a7f0936dae61b | eldojk/Workspace | /WS/G4G/Problems/dp/maximum_sum_such_that_no_two_elements_are_adjacent.py | 732 | 4.03125 | 4 | """
amzn
http://www.geeksforgeeks.org/maximum-sum-such-that-no-two-elements-are-adjacent/
M(i) = max(arr[i] + M(i-2), M(i-1))
where M(i) is the maximum sum where i is the last element of the sub sequence
"""
def maximum_sum_non_adjacent(array):
dp = [el for el in array]
dp[1] = max(array[0], array[1])
... |
744bd10c70adff3b09601d4f3cd5980e68f37cc3 | Maulikchhabra/Python | /LearningPython/builtInFunctions.py | 1,465 | 3.96875 | 4 | # abs() => return absolute value of the argument
print(abs(21-1.5))
print(abs(-1.25))
print(abs(3-4j)) #magnitude of the complex is returned
# all() => return True if all passed iterable are true and false otherwise, return True on empty iterables
print(all([1,2,3])) #all true
print(all([0,False])) #0 and False are ... |
cd87e30fccbaf8f2dfa2dabf5ee8468b5f9a7ed2 | WheelzMonster/Python-Mosh | /epsi/seance_2/seance2_fonctions.py | 1,304 | 4.15625 | 4 | # # Exercice 1**********************************************************************
# number = int(input("choisissez une base pour votre table d'opération: "))
# longueur = int(input("choisissez la longueur de la table: "))
# symbole = input(
# "choisissez une table d'addition ou multiplication, tapez additi... |
7e74e8cba49ba6948e67f87f750ce94974c04ee2 | christianbrotherson/CodeWars | /exclamation_mark_series_11.py | 278 | 4.0625 | 4 | # My Original Code
# def replace_exclamation(s):
# vowels = ('a','e','i','o','u')
# for i in s:
# if i.lower() in vowels:
# s = s.replace(i, '!')
# return s
#Best Practice
def replace_exclamation(s):
return "".join("!" if i in "aeiouAEIOU" else i for i in s)
|
fb9879643e03a6225c89bb125c4469e1a1649d2d | Ghosoun33/testProject | /Day59.py | 628 | 3.5 | 4 | Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import re
>>> str = 'The rain in spain'
>>> x = re.sub('\s', '9', str)
>>> print(x)
The9rain9in9spain
>>> x = re.sub('\s', '9', str, 2)
>>> print... |
adf81c45706cde426da9bc30637ddc3df6b20035 | oonisim/python-programs | /nlp/src/layer/sequential.py | 4,914 | 3.703125 | 4 | """A layer of sequence of layers
A sequence of layers is yet another layer which has the same signature of a layer.
The difference is each I/F is a composite of the layers in the sequence.
Hereafter, this sequential layer is called 'container' or 'container layer'.
layer function F:
F=(fn-1 o ... fi o ... o f0) wh... |
fcb8a86543ccda0cc4e2fb4b7cbba207ff964f60 | beasteers/slurmjobs | /slurmjobs/args.py | 5,716 | 3.921875 | 4 | '''Argument Formatters
'''
from . import util
from . import grid
class Argument:
'''The base-class for all argument formatters.
If you want to provide a new argument formatter,
just override this class and change either the:
* ``format_arg`` method that is used to format positional and key-value pa... |
2e6c0c72b5ac9fab1ebe0643ec49bfc2abd9208c | vneblitt/cs595-f13 | /assignment08/q02/mostratings.py | 1,316 | 3.734375 | 4 | # Valentina Neblitt-Jones
# CS 595 Introduction to Web Science
# Fall 2013
# Assignment #8 Question #2
# What 5 movies received the most ratings? Show the movies and the number of ratings sorted by number of ratings.
import codecs
g = open('mostratings.txt', 'w')
movieratings={}
countingratings={}
movieinfo={}
with... |
d4ad0239616e16982ab0948de7d36d0e009e66ab | SixingYan/algorithm | /005LongestPalindromicSubstring.py | 1,935 | 4 | 4 | """
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
Example 1:
Input: "babad"
Output: "bab"
Note: "aba" is also a valid answer.
Example 2:
Input: "cbbd"
Output: "bb"
"""
"""
Comments
dp string
"""
"""
My
"""
class Solution:
def longestPalind... |
415d7ca983b41fd4b3f3bd41404feb9b230c4d45 | sianweid/Python_101 | /10_Enumerates.py | 409 | 3.984375 | 4 | # Enumerates, einfaches Indexieren und Iterieren von Daten
smaller = [1,2,3]
names = ['jan', 'peer', 'gerd']
for i in range(len(names)):
print(i, names[i])
# Besser:
for index, val in enumerate(names):
print(index, val)
# Kombinierbar mit zip-Funktion
for number, (index_names, val) in zip(smaller, enumer... |
7bc6fcf6f8ffe335001af6daa7352f346337db72 | mruiz54/Ejercicios-Curso-de-Iniciaci-n-a-la-Programaci-n-en-Python | /Ejercicios/Funciones/Ejercicio5.py | 442 | 3.921875 | 4 | # 5. Crea una función que reciba la base y la altura de un triángulo y devuelva su área. A = ½ bh.
print("Ejercicio 5")
def Área_triángulo (base, altura):
A = 0.5*base*altura
return A
base = float (input("Introduzca la base del triángulo: "))
altura = float (input("Introduzca la altura del triángulo: "))... |
0b14106cdba26fd04bc50c5b6a268f48296f1000 | bdebelle/learnpython | /ex05.py | 669 | 3.671875 | 4 | name = 'Brian J. DeBelle'
age = 26 #not a lie
height = 70.0 # inches
weight = 190.0 #lbs
eyes = 'Brown'
teeth = 'white'
hair = 'Black'
print "Let's talk about %s." % name
print "He's %d inches tall." % height
print "He's %d punds heavy." % weight
print "Actually thats no too heavy."
print "He's got %s eyes and %s hai... |
319ec0850578a77015ea1fa195eb5b4a0bc45df2 | kimsr96/algorithm | /py_100/53.py | 230 | 3.53125 | 4 | a = list(input())
print(a)
for i in a:
for j in a:
if i == '(' and i!=j:
if j == ')':
print("YES")
break
else:
print("NO")
break
|
d0bd0598ea86bfd23fd58597e8f1555507f527d3 | malaybiswal/python | /basicAlgo/quickSort.py | 521 | 4 | 4 | def quickSort(arr,start,end):
if(start<end):
index=partition(arr,start,end)
quickSort(arr,start,index-1)
quickSort(arr,index+1,end)
return arr
def partition(arr,start,end):
pIndex=start
pivot=arr[start]
for i in range(start+1,end+1):
if(arr[i]<pivot):
... |
41e9b7afbb7283c54b769b3a4cdec659c79c65e4 | sethmh82/SethDevelopment | /Python/Easy-Questions/Find-the-numbers-with-even-digits.py | 568 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Dec 30 11:32:23 2020
@author: SethHarden
"""
#class Solution:
nums = [12,345,2,6,7896,22]
def findNumbers(self, nums):
output = 0 #set our counter to even 0
for i in nums: #loop through the array
i = str(i) #we need to convert it to a string so w... |
99b31273276097f045477d7dff0814336f54523c | mayur200/python_course_data | /otherprogram/hackerrank25.py | 490 | 3.90625 | 4 | # https://www.hackerrank.com/challenges/itertools-combinations-with-replacement/problem
# itertools.combinations_with_replacement()
from itertools import combinations_with_replacement
word, num = map(str,input().split())
lexi = list(combinations_with_replacement(word,int(num)))
sorted_lexi = []
for tup in lexi:
f... |
3e5933af326d36ca3977ddf3837a3512e571b3b5 | juxiaona/test | /bubble_sort.py | 267 | 4.15625 | 4 | def bubble_sort(lists):
len_list=len(lists)
for i in range(len_list):
for j in range(len_list-i-1):
if lists[j]>lists[j+1]:
temp=lists[j]
lists[j]=lists[j+1]
lists[j+1]=temp
print(lists)
return lists
lists1=[1,4,6,3,7,5,2]
bubble_sort(lists1)
|
e2c183bc25b7fb517de1ff1a15b42c83ce5b706b | wooowsol/start-Python | /제01일차/variable2.py | 646 | 3.765625 | 4 | # variable2.py
# 변수 다뤄 보기
# 변수 a에 값 10을 대입/할당 하여라.
# 변수 정의시 데이터의 타입을 명시하지 않아도 됩니다.
# 변수이름 = 지정할 값
a = 10
b = 20
print(a+3)
print(b)
# 소괄호 또는 콤마로 연결하면 튜플이라고 합니다.
a, b = ('가가', '나나')
print(a)
print(b)
# 대괄호가 있으면 리스트라고 합니다.
[c, d] = ('다다', '라라')
print(c)
print(d)
e = f = '홍길동'
print(e)
print(f)
# swap 기능 : 2개의 변수의 값을 서... |
31db6292da9af8161d3a87898c40abd83ebc9b52 | SidMallya/fibonacci | /fibonacci.py | 308 | 4.125 | 4 | n = int(input("How many Fibonnaci numbers do you want to print? (must be greater than 1)\n"))
while n < 2:
n = int(input("Please enter a number greater than 1.\n"))
fib = [0, 1]
print(fib[0],end=' ')
print(fib[1],end=' ')
while len(fib) < n:
fib.append(fib[-2]+fib[-1])
print(fib[-1],end=' ')
|
a33b1d1baa179e635e54634b05eb65297579b748 | Mr-alan9693/cursoemvideopython | /Radar eletrônico.py | 358 | 3.671875 | 4 | velocidade = float(input('Qual é a velocidade atua do carro? '))
if velocidade > 80:
print('\033[0;31mMULTADO\033[m, você passou o limite permitido que é de \033[31m80km/h\033[m!')
multa = (velocidade-80) * 6
print('Você deve pagar R$ {:.2f} reais de multa.'.format(multa))
else:
print('\033[32mTenha um ... |
9c09c007b6a99a96d3979a0ca5802a7bd02e6eb9 | bharti-11/assignment1 | /assignment12.py | 2,264 | 3.59375 | 4 | #Q.1- What is an access token? Generate your access token for any API.(for example Twitter,Spotify etc).
# An access token is an object that describes the security context of a process or thread.
#The information in a token includes the identity and privileges of the user account associated with the process or thread... |
5861fd1fc240a40762d5439e95b483aa5d85c4a3 | Vk-Demon/vk-code | /ckcompany28.py | 372 | 3.859375 | 4 | nnum=int(input()) # Given a number N and an array of N strings,Print yes, if all strings have atleast one vowel in them otherwise print no.
lt=[input() for i in range(0,nnum)]
tc,c=0,0
for i in lt:
c=0
for j in range(0,len(i)):
if(i[j]=='a' or i[j]=='e' or i[j]=='i' or i[j]=='o' or i[j]=='u'):
c=1
tc=tc... |
5ab6b239b8c0ad2492b9bc7c311e631d972259d2 | crebiz76/checkio | /python/HOME/SunAngle.py | 837 | 3.875 | 4 | '''
Precondition:
00:00 <= time <= 23:59
Result:
06:00 - 0 deg
12:00 - 90 deg
18:00 - 180 deg
'''
def sun_angle(time):
#replace this for solution
print('Time=', time)
degH = 15
degM = 15/60
Time = time.split(':')
#print(Time)
Hour = int(Time[0])
Minute = int(Time[1])
print(Hour, M... |
363e72cd72a4d15efb6fb0146942cdb1ce6bccaa | hbussell/pinax-tracker | /apps/pyvcal/mock/docs/demo.py | 1,831 | 3.921875 | 4 | from mock.repository import Repository
import mock.mock_constructor as mc
import unittest
# This file features a very simple example of using mock to test methods that
# relies on a repository
# get_branch is the method to be tested
def get_branch(repo_path, branch):
"""Helper to get Branch for project's repo.""... |
28d3fb0d28db58b90642bde3d51638e48bc3b421 | TheShellLand/pies | /v3/Libraries/builtin/statement/pass.py | 322 | 4.03125 | 4 | #!/usr/bin/python
for letter in 'Python':
if letter == 'h':
pass
print 'This is pass block'
print 'Current Letter :', letter
print "Good bye!"
# Current Letter : P
# Current Letter : y
# Current Letter : t
# This is pass block
# Current Letter : h
# Current Letter : o
# Current Letter : n
# Good by... |
a3d3ff0b0d4c2a9e5c29a654ea9a7eeb445d40b1 | bibek720/Hacktoberfest | /Python/stringSubsetsRecursive.py | 678 | 4.03125 | 4 | #author Matteo Messmer https://github.com/matteomessmer
#to simplify the function
def strSubsets(original):
return strSubsetsRecursive(original, '', [''])
def strSubsetsRecursive(original, accumulator, subsets):
if len(original) > 0:
currentChar = original[0]
#go to the next char and add it t... |
ae619faf6f59de9eb594e653153b9818c999b69f | meghakorade16/leetcode-solution | /july-leetcode-challenge/ugly-number-2.py | 546 | 3.53125 | 4 | def nthUglyNumber(n: int):
if n <= 0:
return 0
ugly = [1]
twoIndex, threeIndex, fiveIndex = 0, 0, 0
while len(ugly) < n:
by2 = ugly[twoIndex] * 2
by3 = ugly[threeIndex] * 3
by5 = ugly[fiveIndex] * 5
mini = min(by2, min(by3, by5))
ugly.append(mini)
... |
87839319d5d86384f648ca741b4dd39c343bc7fe | joannaluciana/python_exer05032020 | /pliki2.py | 3,380 | 3.890625 | 4 | import csv
import statistics
data= []
with open("przykladowy.csv", "r") as f:
reader = csv.DictReader(f)
for row in reader:
data.append (
{
"year": int(row["Year"]),
"score":int(row["Score"]),
"title": row["Title"]
}
)
# ... |
188304b19e2fdd57f108e4d25ddc22d4d6266c7a | Mose16/CommicBookStore | /CommicBookStore/generator.py | 5,389 | 3.5 | 4 | #File name
file = open("python.txt", "r")
#Controls:
xPass = True
xAnd = True
xQuotes = False
xFuncCheck = True
###---Functions---###
#File managers
def readFileLines(file):
lines = file.readlines()
return lines
def createFile(fileName, text):
newFile = open(fileName + ".tx... |
24aeca55e3afa0ce8c1215f6c2e8f3088f93459d | jashidsany/Learning-Python | /Codecademy Lesson 9 Files/L9.1_Iterating_Through_Lines.py | 923 | 4.625 | 5 | # When we read a file, we might want to grab the whole document in a single string, like .read() would return.
# But what if we wanted to store each line in a variable? We can use the .readlines() function to read a text file line by line instead of having the whole thing. Suppose we have a file:
# keats_sonnet.txt
... |
af9c0210b3854096220155d1724f2a4775c6a275 | slaweklink/hackerRankprograms | /Capitalize a name.py | 82 | 3.59375 | 4 | name = input()
print(" ".join(i.capitalize() for i in name.split(' ')))
|
75861ba97792730bba305d307b6e130bf67e74a1 | YoupengLi/leetcode-sorting | /Solutions/0137_singleNumber.py | 2,693 | 3.921875 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/7/21 8:20
# @Author : Youpeng Li
# @Site :
# @File : 0137_singleNumber.py
# @Software: PyCharm
'''
137. Single Number II
Given a non-empty array of integers, every element appears three times except for one, which appears exactly once. Find that single one.
... |
c5609749b527a5300d1f7d320276156312137a6d | arch1baald/dlcourse_ai | /assignments/assignment3/layers.py | 10,622 | 3.578125 | 4 | import numpy as np
def l2_regularization(W, reg_strength):
'''
Computes L2 regularization loss on weights and its gradient
Arguments:
W, np array - weights
reg_strength - float value
Returns:
loss, single value - l2 regularization loss
gradient, np.array same shape as W - gra... |
beaf5313d54a2b4e7a579d86617da5f18426946b | kilbooky/hackerrank | /30days/7_dictionarys.py | 418 | 3.8125 | 4 | ''' submission ready '''
# get number of entries, create a phonebook (dictionary) object
n = int(input())
phonebook = {}
# populate dictionary
while (n):
k, v = input().split(' ')
phonebook[k] = v
n = n-1
# lookup
for i in range(len(phonebook)):
entry = input()
if entry not in phonebook.keys()... |
b0e549b5f4b7a6b98dcf104d9606b5ae66c8c3c2 | m-01101101/udacity-datastructures-algorithms | /3. data_structures/tree/binary_tree.py | 8,066 | 4.21875 | 4 | """Defining a class for a binary tree
Constraints: a node can only ever have two children at most
Assume that duplicates are overwritten by the new node that is to be inserted.
- Other options are to keep a counter of duplicate nodes
- Or to keep a list of duplicates nodes with the same value.
"""
from confi... |
27ed2f4a787b9f37e7f5a52501ac619f8c0ddc4a | Sonnenhut/aoc2020 | /day21.py | 1,803 | 3.53125 | 4 | def part1():
raw_lines = open("inputs/day21.txt").read().splitlines()
without_allergens, _ = solve_allergens(raw_lines)
return len(without_allergens)
def part2():
lines = open("inputs/day21.txt").read().splitlines()
_, allergen_causes = solve_allergens(lines)
return ",".join(map(lambda key: ne... |
3b62d8f24963b4e594eb497374ab2e5494d019c3 | hnm6500/csci141---python | /bananarama.py | 3,879 | 3.859375 | 4 | #Hrishikesh N Moholkar
import turtle
import math #import the mathematical functions
turtle.setup(900,100) #sets the coordinate of window
turtle.setworldcoordinates(-10,-10,450,30) #SETS THE START POINT AND END POINT OF WORD
def Bletter():
turtle.forward(... |
3082567f2cf7ee14cd6c9510025440d00972b77f | Maria-Fedoseeva/homework.py | /2.py | 351 | 3.625 | 4 | user_time = int(input('Сколько секунд нужно перевести в часы и минуты? '))
hours = user_time // 3600
minutes = (user_time - hours * 3600) // 60
seconds = user_time - hours * 3600 - minutes * 60
count_time = f'{user_time} секунд - это {hours}ч:{minutes}мин:{seconds}сек'
print(count_time)
|
4098bd060a3ffcdb003cc509e16e6edaeae930e3 | JUNYOUNG31/TIL | /day3/practice3.py | 145 | 3.765625 | 4 | #섭씨에서 화씨 로 변환
C = float(input())
F = (C* 1.8) + 32
c= '{:0.2f}'.format(C)
f = '{:0.2f}'.format(F)
print(f'{c} ℃ => {f} ℉') |
b6f0ca38943ac29dad532af9a7ec4787a7fc3eb5 | NataliaNasu/cursoemvideo-python3 | /PacoteDownload/ex044.py | 1,103 | 3.734375 | 4 | preco = float(input('Informe o preço dos produtos: R$'))
pagamento = int(input('Condições de pagamento: '
'\n[1] à vista no dinheiro/cheque'
'\n[2] à vista no cartão'
'\n[3] em até 2x no cartão'
'\n[4] 3x ou mais no cartão'
... |
fd2d317ba5b7463f56c2b266edbdfb324f8cc332 | utkarsh-max/tutorial | /objoriented2.py | 503 | 3.578125 | 4 | from tkinter import *
from tkinter import messagebox
root=Tk()
def msg():
res = messagebox.askyesno("For Programmer", "Are you a programmer")
if res == True:
print("You are a programmer")
else:
print("You are not a programmer")
class objoriented2:
def __init__(self):
root... |
2c1b6d50623ea052bd440263f15e5161b833a22c | SoftwareLabMaseno/pythontest | /functions.py | 115 | 3.578125 | 4 | def printme(x,y):
return x+y
print(printme(30,40))
def getName():
name = input("Name?")
print(name)
|
7513472d24d6090efd5a3c9def621a59b41405ab | jchavez2/COEN-144-Computer-Graphics | /Jason_C_Assigment1/assignment1P2.py | 1,936 | 4.21875 | 4 | #Author: Jason Chavez
#File: assignment1P2.py
#Description: This file rasters a circle using Bresenham's algorithm.
#This is taken a step further by not only rastering the circle but also filling the circle
#The file is saved as an image and displayed using the computers perfered photo drawing software.
from PIL imp... |
2cd4ce8cbfbdbedd2b858c98ba76103dc4351c3a | logan-lach/Algos | /DP/coin_change.py | 1,665 | 3.515625 | 4 | import math
from typing import List
def coinChange(coins: List[int], amount: int) -> int:
denominations = dict()
min_amount = math.inf
def merge_amounts(A):
hold = dict()
for j in A.keys():
for i in denominations.keys():
if abs(i-j) >= 0:
if... |
132913466ab713c225b90d0787dab306ba2d5def | mbebiano/exercicios-python | /exerciciocoursera/faatorial.py | 217 | 3.890625 | 4 | # Imprimir Fatorial
Number = int(input("Digite o valor de n: "))
Count = Number - 1
if Number == 0:
print(1)
else:
while Count >= 1:
Number = Number * Count
Count= Count-1
print(Number)
|
577ba0395b072b5729d012f5eca824bdcc339b9b | IamA1536/Execrise | /com/a/example49/lambda_use.py | 268 | 3.90625 | 4 | MAX = lambda x, y: x * (x >= y) + y * (y > x)
MIN = lambda x, y: x * (x <= y) + y * (y < x)
if __name__ == "__main__":
a = int(input("Please input the first number:"))
b = int(input("Please input the second number:"))
print(MAX(a, b))
print(MIN(a, b))
|
bd9ba9e5b0cfae8131c7ddf9767490e867297a28 | dk-yoon/Algorithm | /Software Expert Academy/Difficulty (1)/6220 알파벳 대소문자.py | 136 | 3.8125 | 4 | p = str((input()))
if p == p.upper():
print("%s 는 대문자 입니다." %(p))
else:
print("%s 는 소문자 입니다." %(p))
|
4e51cfcadde1ab2c8cf3b770181e2d0825cbe5ca | elle-johnnie/code_challenges | /palindrome.py | 617 | 4.25 | 4 |
def is_palindrome(string):
"""
determine if a word is a palindrome
ignore case and spaces
convert str to lowercase array without spaces or punctuation
reverse the converted string and compare
"""
# for_str = []
# for let in str:
# if let.isalpha():
# for_str.append(... |
f032446236625ceaa28b75c60b41130cc9f3f384 | Mariyee30/mycssi2019lab | /WeLearn/M3-Python/L3-Python_Object/pet.py | 1,534 | 4.15625 | 4 | pet = {
"name": "Doggo",
"animal": "dog",
"species": "labrador",
"age": 5
}
class Pet(object):
def __init__(self, name, age, mood):
self.name = name
self.age = age
self.mood = "happy"
def move(self):
if self.mood == "happy":
print("%s is %s, he jumps... |
397beb58ddd087d18694566d2adeb034424e4777 | drpuig/Leetcode-1 | /first-unique-number/first-unique-number.py | 1,241 | 3.765625 | 4 | class FirstUnique:
def __init__(self, nums: List[int]):
self.dic = {}
self.dl = DL()
for num in nums:
self.add(num)
def showFirstUnique(self) -> int:
return self.dl.head.next.val
def add(self, val: int) -> None:
if val not in self.dic:
node ... |
6b133457c07916b7d634b4199dca44289fe8d09e | fyericlam/movie_trailer_website | /media.py | 903 | 3.796875 | 4 | import webbrowser
class Movie():
"""This class provides a way to store movie related information"""
# Class constructor
def __init__(self, movie_title, movie_storyline, movie_duration, poster_image, trailer_youtube):
"""
Attributes:
movie_title (str): Name of movie
... |
247e263b8534e86ba74e69f74491a8b72cf8e063 | PiyushChandra17/HackerRank_30_Days_Of_Code | /Day 9- Recursion 3.py | 258 | 3.875 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the factorial function below.
factorial = lambda x: 1 if x<=1 else x * factorial(x-1)
print(factorial(int(input())))
if __name__ == '__main__':
x = int(input())
|
bc7ca4e6e9250ceed31608525ea7c905254e5156 | JiriHorak/diskoseismology | /disko/functions.py | 19,579 | 3.671875 | 4 | """
Module implementing the radial functions on the disk.
"""
import numpy as np
import math
def common_range(range1, range2, eps=0):
"""
Given two ranges, this function returns the union on the overlap.
Parameters
----------
range1 : numpy.array
First range.
range2 : numpy.array
... |
ad43a8a9e7afab876d878c517ffacda487823f52 | dharmit01/competitve_coding | /regexsubstitution.py | 464 | 4.03125 | 4 | # One can solve this challenge by using the re.sub() tool along with (?<= ) which is a positive lookbehind that makes sure that the pattern is preceded by a space. Also, by using (?= ) which is a positive lookahead that makes sure that the pattern is followed by a space.
import re
for line in range(int(input())... |
3e66227cc6aa3272ed53e594ba80b28c2c8f2d71 | professor123409/Python_Basics | /Tuples/compare 2 tuple.py | 184 | 4 | 4 | t1=eval(input("Enter tuple"))
t2=eval(input("Enter tuple"))
print("comparison is in process")
if t1==t2:
print("the elemnts are same")
else:
print("the elements are diffrent")
|
099dd6bad485d4212982d773b3a35f5e21d0d0ec | Thundzz/advent-of-code-2020 | /py/day_04/solve.py | 3,260 | 3.515625 | 4 | from collections import namedtuple, Counter
from operator import add, mul
from functools import reduce
def parse_field(raw_field):
return raw_field.split(":")
def parse_input(filename):
with open(filename) as file:
lines = [l.strip() for l in file.readlines()]
passports = []
passport = {}
for line in lines:
... |
ecbf0f9005317c0983228bb59d761e12b213f143 | armallen/Codewars | /ExplosiveSum.py | 1,042 | 3.796875 | 4 | # Dictionary of already computed partitions
partitions = {}
# Define key
def hash(a, b):
return "".join([str(a), " ", str(b)])
# Recursive partition function
def partition(sum, largest_number):
# We cannot go further, no number left
if largest_number == 0:
return 0
# We managed to find a sol... |
678a62748a48000a387e3362c1d6362ffc2efe36 | yanshengjia/algorithm | /leetcode/Tree & Recursion/117. Populating Next Right Pointers in Each Node II.py | 4,362 | 3.6875 | 4 | """
Given a binary tree
struct Node {
int val;
Node *left;
Node *right;
Node *next;
}
Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL.
Initially, all next pointers are set to NULL.
Example:
Input: {"$id":"1","left":{"$id":"... |
0978d4f499a82e11a017ac3cbaf8ec2aaac06e20 | ifukazoo/LanguageExercises | /22_最大値を選ぶ/python/a.py | 751 | 4.375 | 4 | #!/usr/bin/env python
# coding: -utf8
if __name__ == '__main__':
import sys
user_input = input("Enter the first number: ")
first_number = int(user_input)
user_input = input("Enter the second number: ")
second_number = int(user_input)
user_input = input("Enter the third number: ")
third_n... |
02c0d566a9d002c6e5d1ba767b5fc3310b052b7c | Aswene/Cactus | /Standard operations (BIDMAS-postfix).py | 3,034 | 3.6875 | 4 | class Stack(list):
def pop(self, n):
if n == 0:
return []
elif n <= len(self):
res = self[-n:]
del self[-n:]
return res
else:
raise ValueError("cannot pop {} items, only {} in stack".format(n, len(self)))
def push(self... |
f19f74d238682b7a93a96865730dbe019debf5fa | codio-templates/sigcse-2020-demo | /.guides/code/code_visualizer.py | 682 | 3.953125 | 4 | plain_text = "Bring your vision of Computer Science education to life"
key = 13
mode = "encrypt"
SYMBOLS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 !?."
encrypted_text = ""
for char in plain_text:
if char in SYMBOLS:
char_index = SYMBOLS.find(char)
if mode == "encr... |
72f68980302a4d8bf442ecf4f1fef99cc195bb27 | zegged/homesystem | /server/old/server4.py | 5,091 | 3.53125 | 4 | #!/usr/bin/env python
#ref: https://www.youtube.com/watch?v=6jteAOmdsYg&list=PLhTjy8cBISErYuLZUvVOYsR1giva2payF
import socket
import sys
import threading
import time
from queue import Queue
NUMBERS_OF_THREADS = 2
JOB_NUMBER = [1, 2]
queue = Queue()
all_connections = []
all_addresses = []
# Create a socket (conne... |
f5a57ce787706c98d6d3ac17c2d47fd88fd0dc8c | Yaachaka/pyPractice1 | /bhch09/bhch09exrc05.py | 1,517 | 4.09375 | 4 | """
bhch09exrc05.py: Write a program that allows the user to enter any number of test scores. The user indicates they are done by entering in a negative number. Print how many of the scores are A’s (90 or above). Also print out the average.
"""
print('*'*80)
score = eval(input('Enter score: '))
count = 0
count2... |
f513001c852d49e6597987921b194a1b7c584352 | xUlqx/Programacion-1 | /Parcial-1/documento.py | 1,822 | 3.671875 | 4 | from paginas import Pagina
import os
class Documento():
def __init__(self):
self.paginas = []
self.nombre = ""
def crear_documento(self):
archivo = input("Ingrese el nombre del Documento: ")
self.nombre = archivo
f = open(self.nombre, 'w')
f.close() ... |
ad3451ca98774c5b83b47ad4fcf264627f8f7a57 | Rawattt/Fake-News_Detection | /lang/check_news.py | 961 | 3.578125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[14]:
import sys
from nltk import word_tokenize
from nltk.corpus import stopwords
# In[15]:
def _calLanguageRatio(text):
languages_ratios = {}
tokens = word_tokenize(text)
words = [word.lower() for word in tokens]
for language in stopwords... |
b5e6845bcde53f711858bc53006fad9dc92f7c14 | sburstein/Python_Finance | /Mean_Variance_Optimization/script1.py | 1,327 | 3.546875 | 4 | import pandas as pd
import matplotlib.pyplot as plt
from rf import return_portfolios, optimal_portfolio
#import codecademylib3_seaborn
import seaborn
import numpy as np
path='stock_data_weak.csv'
# 1. Load the stock data
stock_data = pd.read_csv(path)
print(stock_data)
# 2. Find the quarterly return for each period
... |
d4ab1353fe886129043f11055130e0755a7a399b | adibhaktaram/python-class-notes | /funcEx.py | 320 | 3.515625 | 4 | def example(myVar):
x = myVar
def numTabs(n):
print('\t')*n, end = ''
def concatTwo(string1, string2):
concat = string1+string2
numTabs(3)
print(concat)
if __name == '__main__':
import math
x = math.sqrt(2)
print(x)
def approxsqrt2(x):
approx = 1+1/(2+1/(2+x))
print(approx)
|
ea6d2acee6de75028ac80d54f2e45fbc7314086d | fanzijian/leet-code-practice | /src/code/code_1382.py | 967 | 3.953125 | 4 | #!/usr/bin/env python
#-*- coding: utf-8 -*-
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def balanceBST(self, root):
"""
:type root: TreeNode
... |
d646870e4fec7115b548b4a8faddedc050e9ff79 | icisneros/python_practice | /montyhall.py | 3,831 | 3.984375 | 4 | import random
import matplotlib.pyplot as plt
import numpy as np
def printHeader():
print "\n\n######################################################################\n\n"
print " Monty Hall Problem Simulator "
print "\n\n######################################################... |
cebada770dd1fcd20cc0ff21470303c400c8ac19 | Subhashini1207/Subhashini-B | /Mul of frst 3 nos.py | 82 | 3.875 | 4 | N=int(input())
N1=N*2
N2=N*3
print(N,end=" ")
print(N1,end=" ")
print(N2,end=" ")
|
9da28571d422c0db03c5b9a2b52c0bca0b475e6d | foob26uk/coding-questions | /ch1/ch108.py | 524 | 3.96875 | 4 | # 1.8
def anagrams(words):
hashTable = {}
for word in words:
sortedWord = "".join(sorted(word)) # can also do string.join(sorted(word), "")
if sortedWord in hashTable:
hashTable[sortedWord].append(word)
else:
hashTable[sortedWord] = [word]
li = []
for key... |
3fc5436de13d6aa79aa14812977f4280cbb191c8 | pcortes80/intropython-desafio-letras | /letras.py | 939 | 3.734375 | 4 | # Desafío - Letras
# Patricio Cortés
# G18
# 04-09-2021
# Importa librerias
import string
# definir funcion "gen"
def gen(num):
abc = string.ascii_lowercase # pasamos el abecedario a la variable "abc"
concatenador = "" # guarda las letras del abecedario
contador = 0 # c... |
67bbb0093dd1d9611209f3a722f48cebf79e8dc5 | jvdgoltz/launcher_sim | /modules/isatmos.py | 3,432 | 4.125 | 4 | #with this python module it is possible to calculate temperature, density and pressure of the earth atmosphere at a certain altitude.
#The base of these calculations is the International Standard Atmosphere.
#The functions are called "temp(altitude)", "dens(altitude)" and "press(altitude)"
#It is possible to use the... |
d5f7d05c175fe29dbba3f634d75ccc5fc9984bd5 | trvsed/100-exercicios | /ex017.py | 199 | 3.953125 | 4 | from math import trunc
real=float(input('Digite um número aleatório :'))
inteiro=trunc(real)
print('O número digita foi {} e quando transformado em inteiro se tornou {}!'.format(real, inteiro)) |
9038c1bbdc7fc4fbefd83c6213f7f87e075f385b | starrye/LeetCode | /Stack/面试题09. 用两个栈实现队列.py | 1,209 | 3.640625 | 4 | #!/usr/local/bin/python3
# -*- coding:utf-8 -*-
"""
@author:
@file: 面试题09. 用两个栈实现队列.py
@time: 2020/5/14 14:35
@desc:
"""
from typing import List
"""
用两个栈实现一个队列。队列的声明如下,请实现它的两个函数 appendTail 和 deleteHead ,分别完成在队列尾部插入整数和在队列头部删除整数的功能。(若队列中没有元素,deleteHead 操作返回 -1 )
示例 1:
输入:
["CQueue","appendTail","deleteHead","delet... |
5b6d5e5c3455945a390bce41c4a9154196b1ac92 | michalkasiarz/automate-the-boring-stuff-with-python | /excel-word-and-pdf-documents/pyPDF2Module.py | 708 | 3.53125 | 4 | import PyPDF2, os
# PyPDF2 module
# opening PDF file in read-binary mode
pdf_file = open(r"C:\Users\micha\Documents\Training\meetingminutes1.pdf", "rb")
# reading file with PyPDF2
reader = PyPDF2.PdfFileReader(pdf_file)
# printing number of PDF file
print(reader.numPages) # 19
# creating a page object
page = read... |
a205a4eed166a703c5e12df7ad2ecd378f005f40 | HEMALATHA310/python_basics | /searchPython.py | 470 | 3.828125 | 4 | #wrong program
g=[]
c=0
n =int(input("Enter count of numbers:"))
print("enter the number one by one:")
for i in range(0, n):
a=int(input())
g.append(a)
print("enter key value:")
key=(input())#should not have key without data type if it is will be assigned to string and will not consider it
for i in... |
24a94b8ae02440f653ed42c588dd39f62c1e751e | zopepy/leetcode | /sortlist.py | 3,521 | 4.0625 | 4 | # class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def mergeTwoLists(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNode
"""
if l1 is None:
return l2
if l2 is None... |
a8f9fd7faa0237a3b0a251698cbefcd8288ff5cf | zjuzpz/Algorithms | /SmallestRectangleEnclosingBlackPixels.py | 1,468 | 3.90625 | 4 | """
302. Smallest Rectangle Enclosing Black Pixels
An image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. The black pixels are connected, i.e., there is only one black region. Pixels are connected horizontally and vertically. Given the location (x, y) of one of the black pixels, retu... |
a4a3f1205c47f29c83240e6092c9e2529c84945b | kmcodes/euler | /test51.py | 742 | 3.859375 | 4 | import time
start = time.time()
###################################
def digits(num):
digits=str(num)
dig_list=[int(dig) for dig in digits]
return dig_list
def remake(digits):
num = int(''.join(map(str,digits)))
return num
def isprime(n):
flag= True
if n%2==0 and n>2:
return False
... |
49bd7b94b021c1be1ca43fbbe7c31aa67e7986be | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_81/161.py | 2,976 | 3.53125 | 4 | import os, copy
class memoized(object):
"""Decorator that caches a function's return value each time it is called.
If called later with the same arguments, the cached value is returned, and
not re-evaluated.
"""
def __init__(self, func):
self.func = func
self.cache = {}
def __call__(self,... |
6b258122ff3918c2e4629b19edff1465e85a646f | terrysf/scripts | /random_password.py | 1,217 | 3.828125 | 4 | #Generates a random password of desired length with one special character and one number :)
import random
import argparse
import os
numbers = ['0','1','2','3','4','5','6','7','8','9']
letters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
specials = [... |
045dea64c22b85341ef3c26e5f3adc8fc5bba440 | EdgarOlv/ClienteServidor-Python | /Cliente Echo TCP em Python.py | 1,236 | 3.734375 | 4 |
import socket # Biblioteca para aplicacao em rede
cliente_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # cria um socket TCP/IP (SOCK_STREAM)
end_servidor = ('localhost', 10000) # end_servidor recebe endereco e porta do serv... |
73f8607e8f809ee87c4fe8ff048285e18e510d01 | megamayoy/EGP_Realtime_ExchangeRate | /DatabaseInterface.py | 2,031 | 3.765625 | 4 | import psycopg2
import DatabaseConfig as dc
class DatabaseInterface:
"""a simple interface to execute PostgreSQL database operations especially creating tables
and inserting records"""
db_config = dc.DatabaseConfig()
db_connection = None
def __init__(self):
#establishing a da... |
fc9bae9476d06396073c77f2dc754a0f95fa470e | 0000duck/srcRep | /learn_python/try_except.py | 227 | 3.515625 | 4 | #!/usr/bin/python
# FileName: try_except.py
import sys
try:
s = raw_input ( ' Enter something-->')
except EOFError:
print '\n why did you do an EOF on me?'
except:
print '\nsome thing error happen.'
print 'Done'
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.