blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
0e1fed18a9d5170586d7d6a0687b9d73919b3e68
SOURADEEP-DONNY/WORKING-WITH-PYTHON
/File Handling/filee.py
220
3.71875
4
f=open("Abhi.txt","r") s=f.readlines() print(s) longest=" " for i in s: if(len(i)>len(longest)): longest=i l=len(longest) print("Longest Line: ",longest) print("Length of longest line: ",l)
0894e717570faf276766743af228ebc40e489cf4
fogugy/gb_algorithm
/#3_16.01/task7.py
525
4
4
# В одномерном массиве целых чисел определить два наименьших элемента. # Они могут быть как равны между собой (оба являться минимальными), так и различаться. import random as rnd ls = [rnd.randint(0, 10) for x in range(10)] min1 = float('inf') min2 = float('inf') for x in ls: if x < min1: min1 = x ...
2541b850b8cb2c6c420852367e57395f3eea8d7e
madihamallick/Py-games
/Hangman/main.py
5,955
3.796875
4
import pygame, math, random #setup display pygame.init() #initializing pygame module WIDTH, HEIGHT= 800,500 #width and height in pixels background (where we want our game to be played) win = pygame.display.set_mode((WIDTH,HEIGHT)) #creating dimensions for pygame, accepts tuple only pygame.display.set_caption("Hangman ...
1bdbb75314505cfd33dc3517d3dfc662836382cd
Swarajsj/Python-Programes-
/Function5.py
622
4.09375
4
# %% # Program to print the minimum value def minimum(a, b): if a < b: return a elif b < a: return b else: return "Both the numbers are equal" minimum(100, 100) # %% # Wap to find the distance between to points #((x2-x1)**2 + (y2-y1)**2)**0.5 def distance(x1,...
549e724d9d6d9540777d1e19947dc81491c6fef5
Denisov-AA/Python_courses
/HomeWork/Lection8_TestWork/Task_10.py
1,352
3.921875
4
class Money: def __init__(self, ruble: int, penny: int): self.ruble = ruble self.penny = penny self.sum = self.ruble * 100 + self.penny def __add__(self, other): return f"{(self.sum + other.sum) // 100}, {(self.sum + other.sum) % 100}" def __sub__(self, other): retu...
95433e3119a998bcb19e39a514d0d341d6e162b5
Jeta1me1PLUS/learnleetcode
/459/459repeatedSubstring.py
666
3.734375
4
# Basic idea: # First char of input string is first char of repeated substring # Last char of input string is last char of repeated substring # Let S1 = S + S (where S in input string) # Remove 1 and last char of S1. Let this be S2 # If S exists in S2 then return true else false # Let i be index in S2 where S starts t...
4037474e2f6b89a585a9d553e5200d4d92a49e75
rhty/atcoder
/python/graph/union_find.py
1,165
3.75
4
from typing import Dict class UnionFind: par: Dict[int, int] siz: Dict[int, int] def __init__(self, N: int) -> None: self.par = {i: -1 for i in range(N)} self.siz = {i: 1 for i in range(N)} def root(self, x: int) -> int: if self.par[x] == -1: return x else...
fbe9229cc84b8fbbc9f601bdd10ecabec5a7ed3c
kambehmw/algorithm_python
/atcoder/NS20200420/A2.py
171
3.8125
4
s = input() sr = s[::-1] for c1, c2 in zip(s, sr): if c1 == c2 or (c1 == "*" or c2 == "*"): continue else: print("NO") exit() print("YES")
14cfdd5f4038be57303e78f3b14ea1559fba913d
zhouhaosame/leetcode_zh
/1-60/23_merge_k_Sorted_lists.py
4,514
3.828125
4
def merge_k_sorted_linked_lists(lists): from functools import reduce def merge_two_sorted_linked_list(l1, l2): if l1 and l2: if l1.val < l2.val: head = pre = l1 l1 = l1.next else: head = pre = l2 l2 = l2.next ...
0ac5161b91ac886b4c1a5b89651b3ca938a67104
DanLEE278/Python_practice
/15.3. 다중상속.py
1,962
3.71875
4
# 다중 상속은 하나의 클래스가 두개 이상의 다른 클래스들을 받을때 사용 # 2개의 클라스가 a, b가 있다고 가정할때 a 클라스를 b 클라스에 상속시킬 수 있다 class unit: def __init__(self, name, hp): # 여기서 __init__은 생성자이다 self.name = name self.hp = hp print("{0} 유닛이 생성되엇습니다.".format(self.name)) print("체력 {0}, 체력 {1}".format(self.hp, self.h...
cfcfcfab84b2a3a1ad91254cf48ef2a1f7ac6b37
gokul1998/Python
/while.py
54
3.75
4
a = "madam" b = a[::-1] if a==b: print("yelllllo")
198d365b56e298180b8eb47c68782045c86095c3
Artem-Markula/Python-Shool-s-Programs-
/3 Глава/Персональный привет.py
666
3.609375
4
quote ="Думаю. на мировом рынке можно будет продать штук пять компьютеров." print("Исходная цитата : ") print(quote) print("\nOнa же в верхнем регистре:") print(quote.upper()) print("\nB нижнем регистре:") print(quote.lower()) print("\nKaк заголовок:") print(quote.title()) print("\nC ма-а-аленькой заменой:") ...
cb54ea0ba8c3bd3f0a83fec201df7d13d30a7f8f
Greek-and-Roman-God/Athena
/codingtest/week05/sangsu.py
221
3.578125
4
#상근이 동생 상수 def reverse_num(num): reverse=list(str(num)) reverse.reverse() reverse=("".join(reverse)) return reverse a, b=map(int, input().split()) a=reverse_num(a) b=reverse_num(b) print(max(a,b))
213c365782ea4fa4aae03388c92f7070171ec5bb
tizhad/python-tutorials
/printfor/printfor.py
119
3.71875
4
# number = int(input()) # for i in range (1,number): # print (str(number)) print(*range(1, int(input())+1), sep='')
a21610560f45d0c0a1305080efe9045f184c094a
suarlin29/python3
/tarea33ejercicios.py/edad exacta 27.py
197
3.65625
4
##suarlin paz ## 27 print ("bienvenido al programa".center(50, "*")) nacimiento = int(input("ingrese anio de nacimiento ")) DATO2 = 2019 edad = DATO2 - nacimiento print("tu edad es:.{}".format(edad))
fd1f369f5d960a4655ec15673942ee956c4a99a0
taunoe/Test-pyhon-2
/pt1/1.4a.py
163
3.5625
4
ainepunktid = input("Sisestage ainepunktide arv:") nadalad = input("Sisestage nädalate arv:") ajakulu = (int(ainepunktid)*26)/int(nadalad) print(round(ajakulu))
7d15e49bf978ed32b7ab9659f655205b1c6b6ae1
weed478/wdi4
/zad2.py
713
3.6875
4
end = None tab = [[2, 8, 24, 42, 1], [7, 8, 15, 3, 5], [3, 8, 7, 1, 6], [3, 5, 7, 9, 1], [1, 7, 5, 3, 332]] tabBe = [[2, 8, 24, 42, 2], [7, 8, 15, 3, 5], [3, 8, 7, 1, 6], [3, 5, 7, 9, 1], [1, 7, 5, 3, 332]] def only_odd(num): while num > 0: num, digit = divmod(num, 10) if digit % 2 == 0: ...
5774c4c68ffd1b19fd48165e638abd5ca4698c08
Vedarth/Deep-Learning
/Course_1/week_3/layer_sizes.py
833
4.09375
4
def layer_sizes(X, Y): """ Arguments: X -- input dataset of shape (input size, number of examples) Y -- labels of shape (output size, number of examples) Returns: n_x -- the size of the input layer n_h -- the size of the hidden layer n_y -- the size of the output layer """ #...
471aa47f4449ac04c5f00ecd1ffb43d47b3f79f0
deepwzh/leetcode_practice
/21.py
1,146
4.0625
4
# Definition for singly-linked list. # 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 """ # print(not l1, not l...
643f2f4eaf03e102e8ce5bf30bb4529c075f2070
TusharDimri/Python
/Raising Exceptions in Python.py
793
4.25
4
# Exceptions are raised in python using 'raise' keyword.Exceptions are user defined exception a = input("Enter your name") if a.isnumeric(): raise Exception("Name cannot be numeric") # Assume that the task following above code is bulky.It will save a lot of time if we raise excetpion it will prevent us # from di...
ed4d3496db68011bfb0cd4aeaf970d7eacc86a56
dongyifeng/algorithm
/python/interview/link/7_link_ring.py
1,165
3.890625
4
#coding:utf-8 class ListNode: def __init__(self,val): self.val = val self.next = None # 判断一个单链表中是否有环 # 这里也是用到两个指针。如果一个链表中有环,也就是说用一个指针去遍历,是永远走不到头的。因此,我们可以用两个指针去遍历,一个指针一次走两步,一个指针一次走一步,如果有环,两个指针肯定会在环中相遇。时间复杂度为O(n) def containsRing(root): if root is None:return False fast = root slow = root while fast is not Non...
eb6a991321ec6d1881631ba4e39b07e759685cd4
Algorithm2021/minjyo
/구현/1251.py
431
3.59375
4
from itertools import combinations answer = "" word = input() newWord = [] for part in combinations(range(1, len(word)),2): # word[:0] is empty list newWord.append((word[:part[0]])[::-1] + (word[part[0]:part[1]])[::-1] + (word[part[1]:])[::-1]) answer = newWord[0] for word in newWord[1:]: i = 0 while wor...
71e3d568e2430c04113b92a691b0abe6002ad708
rtejaswi/python
/class2.py
1,531
3.75
4
# parent class class Person( ): def __init__(self, name, idnumber,post,salary=False): self.name = name self.idnumber = idnumber self.post = post self.salary = salary def display(self): print(self.name) print(self.idnumber) print(self.post) print(s...
a67c178eb52e847d7d814a6d32f4f5e173a181d0
BKBetz/ML
/P3/test/neurontest_wrong.py
3,611
3.75
4
import unittest from P3.code.neuron import Neuron from P3.code.neuronlayer import NeuronLayer from P3.code.neuronnetwork import NeuronNetwork """ De neuron werkt niet alleen met 0 en 1 outputs maar kan ook bijvoorbeeld 0.3 als output krijgen. Dit komt doordat een neuron gebruikt maakt van de sigmoid functie ...
89a278410ca989bafd474faf0d6a164b54eb4c16
Klose6/Leetcode
/863_all_nodes_distance_in_bt.py
1,230
3.546875
4
""" 863 all node distance K in binary tree *each node value is unique """ import collections class Node(object): def __init__(self, val): self.val = val self.left, self.right = None, None class solution(object): def distanceK(self, root, target, K): def dfs(node, parent=None): if node: root.parent = ...
322ce6ec39a49ba60d6f1bdec75e44144ff3dc05
sogoodnow/python-study
/week1/week1_multi99.py
3,978
3.984375
4
# 使用while和for…in两个循环分别输出四种九九乘法表效果(共计8个)。 # 学员姓名:邱国昌 # 日期:2018-03-15 # 用于控制行间隔 LINE_SPACE = 25 def work1(): """ 1.九九乘法表 """ # ========for in 左上三角========= print("===="*LINE_SPACE+"\n") print("for in左上三角" + "\n") # 生成10行 for i in range(1, 10): # 生成列 for j in range(1, i+1...
d214cfe75dc6b11d620c75247b21f2953ceda2dc
izham-sugita/python3-tutorial
/py-function.py
1,737
4.125
4
''' def functionname(parameters): "function comment" function_suite return [expression] ''' def printme( str ): "This function prints the string input" print( str ) return def foo(arg1): return 2*arg1 #calling the function #str = "This is the string to print" #printme(str) #pass by value def changeme( ...
2b36fed842e7072b6c65905b3ef13ec29185f905
zzy1120716/my-nine-chapter
/ch09/0654-sparse-matrix-multiplication.py
1,854
3.78125
4
""" 654. 稀疏矩阵乘法 给定两个 稀疏矩阵 A 和 B,返回AB的结果。 您可以假设A的列数等于B的行数。 样例 A = [ [ 1, 0, 0], [-1, 0, 3] ] B = [ [ 7, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 1 ] ] | 1 0 0 | | 7 0 0 | | 7 0 0 | AB = | -1 0 3 | x | 0 0 0 | = | -7 0 3 | | 0 0 1 | """ """ 方法一:普通方法 """ class Solution: """ @pa...
8348cc761201d381073673ad444ea3837fb9bea3
MortZx/Project-Euler
/Python/problem001.py
622
4.0625
4
# -*- coding: utf-8 -*- """ Created on Fri Nov 23 12:15:26 2018 @author: MortZ Project Euler Problem 1 """ """ If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. """ from timeit i...
0da0d569b9c14fd0616615e3a810aaff1b28a70d
tsitokely/pdsnd_github
/bikeshare.py
10,332
4.28125
4
import time import pandas as pd CITY_DATA = {'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv'} def separator(size): if size.lower() =='big': print('-' * 40) elif size.lower() =='little': print('-' * 20) def get_filters(...
e3aa39ff8e3177cd33a0b55bf600d490f271ca55
julgachancipa/holbertonschool-machine_learning
/math/0x03-probability/normal.py
1,725
3.890625
4
#!/usr/bin/env python3 """Normal distribution""" pi = 3.1415926536 e = 2.7182818285 def erf(x): """error function encountered in integrating the normal distribution""" a = (2 / (pi**(1/2))) b = (x - ((x**3)/3) + ((x**5)/10) - ((x**7)/42) + ((x**9)/216)) return a * b class Normal: """Repres...
7593db82398cd5fc4d4f070ba89f8cee00856015
Randle9000/pythonCheatSheet
/pythonCourseEu/1Basics/17Regex/Examples.py
915
4.34375
4
s = "Regular expressions easily explained!" print("easily" in s) ######################### print() import re x = re.search("cat","A cat and a rat can't be friends.") print(x) x = re.search("cow","A cat and a rat can't be friends.") print(x) ############################# print() if re.search("cat", "A cat...
661c063e1769baac227226468e8b7036688371c8
rasibkn/rasib
/ir4.py
78
3.765625
4
a=12 b=0 if(a>b): print("a is greater than b") else: print("b is greater a")
f6d80c56d8959645c641a3fb0210985c32737e5e
penroselearning/pystart_code_samples
/14 Dictionary - Shopping Cart.py
502
4
4
# Shopping Cart shopping_cart = {'eggs':3.50, 'milk':4.50, 'cheese':3.75, 'yoghurt':2.75, 'butter':3.00, 'more cheese':1.75} shopping_cart.update({'ketchup':4.50}) shopping_cart.update({'milk':4.75}) total_bill = 0 print("Final Shopping Cart") print('-'*30) for goods,price in shopping_cart.items(): total_bill ...
c1a95ff927274e2212e29b4068a5ce8943f1e119
aryabiju37/Python-mini-Proects
/oop/animal_multiple_inheritance.py
746
4
4
class Aquatic: def __init__(self,name): self.name = name def swim(self): return f"{self.name} is swimming" def greet(self): return f"I am {self.name} of the sea!" class Ambulatory: def __init__(self,name): self.name = name def walk(self): return f"{self.na...
f182d6e25a8e1604bc2da6d14fffe60c405366d1
Songbz1999/pythonForFinance
/lesson2/PY-2-1.py
559
4.34375
4
# -*- coding: utf-8 -*- """ Created on Sat Jul 14 15:29:27 2018 @author: Thinkpad """ ''' 1. Write a program that asks the user for a long string containing multiple words. Print back to the user the same string, except with the words in backwards order. For example, say I type the string: My name is Steven Then ...
c6be48cffe3ba313002e695c88128d682c9f2c62
wihoho/LearningPython
/src/Syntax/4) ShowCurrentTime.py
326
3.703125
4
import time currentTime = time.time() totalSeconds = int(currentTime) currentSeconds = totalSeconds % 60 totalMinutes = totalSeconds // 60 currentMinute = totalMinutes % 60 totalHours = totalMinutes // 60 currentHour = totalHours % 24 print("Current time is",currentHour,":",currentMinute,":",currentSe...
ae77ad8f0577281f8286c3aef417bee9f884ee07
ZENALC/jsonpickle
/Play Environment/playCode.py
2,722
3.671875
4
# Demonstration Code import jsonpickle class Student: def __init__(self): self.name = None self.age = 50 self.hairColor = "Black" self.ethnicity = None self.eyeColor = "Black" self.enrolled = True self.x = [1, 2, 3, 4, 5, 6, 7] def __str__(self): ...
320877388ad7c70c6bdf488d10e534065f3b84e9
Kookey/pythonworks
/9/9.5/try/die.py
469
3.828125
4
from random import randint class Die(): """摇骰子""" def __init__(self, sides=6): self.sides = sides def roll_die(self): x = randint(1, self.sides) print(x) die = Die() die.roll_die() print("\n") for x in range(1, 11): die.roll_die() print("10面的色子") die_10 = Die(sides=10) f...
cb1b8757ad57bc180e6d5cc5b50d8946843e0642
daniil172101/RTR108
/darbi/Py4E/OOP/python_diary_OOP_1_20200722.py
400
4.125
4
stuff = list() # Construct an object of type list stuff.append('python') # Adds in a list an item 'python' stuff.append('chuck') # Adds in a list an item 'chuck' stuff.sort() # Sort list in alphabetical order # The next 3 lines prints the item of a list with a parameter of zero. ...
f7a0d41ae132905a2749f351e906dd37898ab46d
chenc19920308/python_untitled
/Function/Practice/fact_func.py
693
4.375
4
#use recursin # def factorial(n): # if n == 1: # return 1 # else: # return n * factorial(n-1) # number = int(input("your number:")) # print("your number's factorial:%d"%factorial(number)) # no recursion # def factorial(n): # result = n # for i in range(1,n): # result *= i # ret...
6aedcad22ce79e128bd2a9da5898a016ba8dd72b
Akash5454/100-Days-Coding
/pathSum.py
474
4
4
""" Path Sum: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. """ def hasPathSum(self, root: TreeNode, sum: int) -> bool: if not root: return False sum = sum - root.val if not root.left a...
273fd3c2ab00d368067a8c84ca337ed2201899f8
tianzhujiledadi/python
/排序算法比较/堆排序.py
1,263
3.984375
4
def MAX_Heapify(heap,HeapSize,root):#在堆中做结构调整使得父节点的值大于子节点 left = 2*root+1 right = left + 1 larger = root if left < HeapSize and heap[larger] < heap[left]: larger = left if right < HeapSize and heap[larger] < heap[right]: larger = right if larger != root:#如果做了堆调整则larger的值等于左节点或者右...
1618c67eef065a364eb5b21cb2d82371ca22fd17
billsu2013/pyschool
/04-04.py
229
3.8125
4
# -*- coding: utf-8 -*- """ Created on Thu Apr 12 12:58:16 2018 @author: dell """ def addNumbers(num): a=0 for i in range (1,num+1): a=a+i return a b=addNumbers(0) print (b)
f2e5f4910fbdd7cbdcd2571db51cf08039396dc0
aFuzzyBear/Python
/python/Scripts/ran_number.py
595
3.609375
4
#print random lottery numbers import random """ Make two lists One is a random number list with a maximum of 6 numbers Second list is 2 numbers randomly generated. """ lotto = range(0,52) print lotto def num_gen(): gen = random.randint(1,51) return gen ball1 = num_gen() ball2 = num_gen() ball3 = num_gen() ...
d9ccefb5e37d8d4efc1f84461501fcd763cf94f6
Ratnakarmaurya/Data-Analytics-and-visualization
/working with data/03_Html with pyhton.py
567
3.59375
4
import numpy as np from pandas import Series,DataFrame import pandas as pd from pandas import read_html #Lets grab a url for list of failed banks url ="http://www.fdic.gov/bank/individual/failed/banklist.html" """ IMPORTANT NOTE: NEED TO HAVE beautiful-soup INSTALLED as well as html5lib !!!! """ # Grab dat...
f82628cdefcfe7e2e3164179cf2dff742ed92f49
prashanthr11/HackerRank
/Python/Collections/Collections.deque().py
359
3.59375
4
from collections import deque l = deque() for i in range(int(input())): s = list(map(str, input().split())) if len(s) == 2: if s[0] == "append": l.append(s[1]) if s[0] == "appendleft": l.appendleft(s[1]) else: if s[0] == "pop": l.pop() els...
3c5295c33ee8875735b0f0615f6afa5ebbf7a874
JasmineIslamNY/Thinkful
/discount_calculator/discount_calculator.py
3,175
4.25
4
import argparse def calculate_discount(item_cost, relative_discount, absolute_discount): """ Calculate the discounted price of item given the item cost, a relative discount, and an additional price discount """ item_cost = float(item_cost) relative_discount = float(relative_discount) absol...
2d8936e602a5fe0d95f7e0b47fb18523dce0ebfe
channing342/Python
/Day6/exercise0602.py
273
3.703125
4
#-*- coding: UTF-8 -*- #File Name : exercise0601.py #Edit : Channing Liu #Time Date : 20160631 a = int(raw_input("Number a: ")) b = int(raw_input("Number b: ")) if a == b: print (" a = b ") elif a > b: print (" a > b ") elif a < b: print (" a < b ") else: print ( Null )
c8f319077ae4cd194bc3e9c2ebcdc97bb3fcff2d
JoKerDii/Thinkpy-mySol
/Exercise5.5.py
886
4.40625
4
def draw(t, length, n): """Draw a tree The branch length depends on both length arg and n arg (length*n) The number of node is n """ if n == 0: return angle = 50 t.fd(length*n) t.lt(angle) # recursion begins from "n-1" because the tree becomes binary from "n-1" # this i...
a6f1c479169374a74da41f29de127a78a66a3124
Ellviss/python
/l1/l4.py
378
3.578125
4
def get_sum(one,two,delimiter='&'): one = str(one) two = str(two) #res = str(print(f'{one}{delimiter}{two}')) return f'{one}{delimiter}{two}' get_sum("Learn","python",) print (get_sum("Learn","python",)) print(get_sum("Learn","python").upper()) def format_price(price): price=int(price) return 'Цен...
db8f85e78fa9bc967343333b9766e2c8cf4ecb63
sky-dream/LeetCodeProblemsStudy
/[0242][Easy][Valid_Anagram]/Valid_Anagram.py
1,192
3.640625
4
class Solution(object): def isAnagram(self, s, t): """ :type s: str :type t: str :rtype: bool """ if len(s)!=len(t): return False else: #结果字典 dic = {} #先遍历s,数每个字符出现的次数,存在字典dic中,key是字符,value是出现次数 for i...
877b71605f13814e9b802b96ef0d2f18f1aa4ece
Charles-IV/python-scripts
/recursion/fibbonachi.py
232
3.65625
4
from time import sleep def add(x,y): z = x + y # perform calculation print(z) # output result sleep(0.2) # HOLD! STOP! WAIT, to not kill my computer add(y, z) # perform next calculation print("0\n1") add(0, 1)
ea1d94b162095516451d8d4af21ed5693b5e19d6
BenThomas33/practice
/python/csdn/binary_tree2dlink.py
666
3.78125
4
""" # 1 convert a binary tree to double linked list """ import os import sys sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from structs import binary_tree def convert(root): a, b, c, d = root, root, root, root if root.left: a, b = convert(root.left) root.left = b...
4ca41cc5247699c3bfdf7480f0f4fd1200f278de
yejiiha/BaekJoon_step
/Practice 1/5543.py
526
3.734375
4
# Print minimum price price_list_burger = [] price_list_drink = [] price_list_set = [] sum = 0 for a in range(0, 3): a = int(input()) if 100 <= a <= 2000: price_list_burger.append(a) for b in range(0, 2): b = int(input()) if 100 <= b <= 2000: price_list_drink.append(b) for i in range(...
bbd79fb44eff6b792110bab2160eb5426f66f849
bowrainradio/Python_Adventure
/Day_02(fahrenheit-converter&BMI-calculator&Pizza-order).py
1,104
4.28125
4
#Fahrenheit converter f_temp = int(input("Temperature outside in Farenhite?\n")) c_temp = round(((f_temp - 32) * 5/9), 2) print(f"Your temperature in Celsius is: {c_temp}") height = float(input("What's your height in m(for example: 1.4)\n")) weight = float(input("What's your weight in kg\n")) #BMI bmi = round(weig...
021979a7afe0edc0ea645537bf48a264941d5b09
cook2298/Bellevue
/ClassProject.py
2,444
4.0625
4
''' This program connects to openweathermap API to allow the user to input city or zip code to get current weather data for that location Author: Jacob Cook Written: 10/13/2020 ''' import requests import json APIID = "c98593e412245c9ce904a86281016ff1" def inputData(): print("Please enter a zip code or ci...
e5054432dcd9dba811d509469dfb86d98a12730a
mRrvz/bmstu-python
/sem_02/lab_02/zashita.py
1,807
4.03125
4
from tkinter import * def change_text(list_to_sort): for i in range(len(list_to_sort)): label_sort["text"] += str(list_to_sort[i]) + " " label_sort["text"] += "\n\n" def bubble_sort(entry): label_sort["font"] = "Arial 10" list_to_sort = entry.get() list_to_sort = list(m...
4275ffe5d5dc971d153d1f5a1bd593eab4666901
WilliamPerezBeltran/studying_python
/prueba_evalart_2020.py
3,094
3.859375
4
import pdb from copy import copy, deepcopy myArray = [13,12,4,3,15] pivote = True data = None for x in myArray: if pivote: data = x pivote = False else: if x < data: data =x # return data print(data) # ============================== n = 5 fila = n columna = n matriz = [] for i in range(fila): matriz.ap...
ac04b41381fdf0d3d4f36fcecd14608c28d5bde5
mostiguy/Euler
/Euler project no 50.py
1,455
3.8125
4
# -*- coding: utf-8 -*- """ The prime 41, can be written as the sum of six consecutive primes: 41 = 2 + 3 + 5 + 7 + 11 + 13 This is the longest sum of consecutive primes that adds to a prime below one-hundred. The longest sum of consecutive primes below one-thousand that adds to a prime, contains 21 terms, a...
b4316aa8615e3f917da72a99e0649257da103811
Negar-Sadreddini/aparat-API
/FULL - Final Project.py.py
9,751
3.5
4
import requests import json, csv import pandas as pd import matplotlib.pyplot as plt import numpy as np import time informative_url = 'https://www.aparat.com/api#videobytag' # This is a link which explains how we can extract data from Aparat's API, By reading it we decided to scrap Aparat's videos by their defferent t...
34cf18d662080576faa63780a77856327b49aec3
z727354123/pyCharmTest
/2018-01/01_Jan/21/_04_eq.py
1,098
3.890625
4
class Person: def __init__(self, age=15): self.age = age # 默认比较 引用地址 def __eq__(self, other): print('__eq__', self.age, other.age, end=" , ") return False def __ne__(self, other): print('__ne__', self.age, other.age, end=" , ") return False def __gt__(self, o...
16cd06e7bb4be8f3baa3017b40032643e0a9a266
ElderVivot/python-cursoemvideo
/Ex094_ListaPessoasDict.py
1,477
3.90625
4
pessoa = {} lista_pessoas = [] soma_idade = 0 while True: # adiciona os dados da pessoa pessoa['nome'] = str(input('Digite o nome: ')) pessoa['sexo'] = str(input('Digite o sexo (M/F): ')) pessoa['idade'] = int(input('Digite a idade: ')) soma_idade += pessoa['idade'] # copia o dado da pessoa ...
928e1faf6558ba262ba7f70d2fdfe341b3fbfc72
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_200/5455.py
809
3.828125
4
# raw_input() reads a string with a line of input, stripping the '\n' (newline) at the end. # This is all you need for most Google Code Jam problems. t = int(raw_input()) # read a line with a single integer def tidynumber(n): number = str(n) if len(number) == 1: return True first = int(num...
ff13df3b814893b286b26bd4d7a071764b60b92c
Sebasfc10/inteligencia_python
/ejer.py
7,896
3.9375
4
# -*- coding: utf-8 -*- """ Created on Sat Sep 4 14:55:38 2021 @author: jeha2 """ y = (((5+2+5)**2) * 5+8/2 - 30) / 2 * 5 - 3 z = 5 n = ((((8+2-4)**2)*5+8+7/2 -30*5) / 2*5-3)**5 + 15 *3 - 9/3 m = ((z)**2)*3+n y = (((((z+2-n)**2)*m+8/2-30)/2*5-3)**5+15*3-9/3)**2-5/4 print(y) #ejercicios con solucion a la problematic...
a834dfb52b41f3251fc3b93280e02b51f16fbf3e
PotentialPie/leetcode-python
/algorithm/leetcode-14.py
1,349
3.84375
4
#coding=utf-8 # 这题能告诉我们什么呢? # 1. python的break只能跳出一重循环,但是return可以立刻终止,可以利用这个特性 # 2. 利用一个额外的flag变量来判断是否再break外一层 # 3. 判断输入是不是空list class Solution: def longestCommonPrefix(self, m): # """ # :type strs: List[str] # :rtype: str # """ # min_max_len = min([len(s) for s in strs]) ...
d158d822113431930de98b60f7faf0567c0aceb6
Devang-25/Interview-Process-Coding-Questions
/Amazon/Delete_Node_Without_HeadPointer.py
1,739
4.03125
4
class Node(object): def __init__(self,dataVal,nextNode=None): self.data = dataVal self.next = nextNode def getData(self): return (self.data) def setData(self,val): self.data = val def getNextNode(self): return (self.next) def setNex...
a29ce68fc18f7ca0c633037f4ed3ce6aa6140cd8
gabriellaec/desoft-analise-exercicios
/backup/user_395/ch20_2019_04_04_17_06_39_236290.py
139
3.828125
4
a = input('Qual seu nome?') if a == 'Chris' or a == 'chris': print ('Todo mundo odeia o Chris') else: print ('Olá, {0}'.format(a))
ccd5438c7a16943922815beb7a71a13061c5c252
hbradlow/solver
/server/parser/gui.py
2,335
3.5
4
import Tkinter as tk class Point2D: def __init__(self, position, radius=3, fill="red", outline="black"): self.position = position #a numpy array self.radius = radius self.fill = fill self.outline = outline def __repr__(self): return "<Point2D: " + str(self.position) + "...
7300cef5f44688fce8e6f4d308c21efa342774ae
khill-turbo/python-fun
/thirty-days/day10/binary-numbers.py
648
3.546875
4
#!/bin/python3 import math import os import random import re import sys def countConsecOnes(n): binaryN = f'{n:b}' #print("binaryN = ", binaryN) stringN = str(binaryN) #print("stringN = ", stringN) # get the length of the string j = len(stringN) while(j >= 1): # start from max len...
67160da368deb0057c85fc97f424bc888beb99cc
danylagacione/Codility
/Lesson3/TapeEquilibrium.py
2,221
3.65625
4
# Uma matriz não vazia A que consiste em N números inteiros é fornecida. A matriz A representa números em uma fita. # # Qualquer número inteiro P, tal que 0 <P <N, divide esta fita em duas partes não vazias: A [0], A [1], ..., # A [P - 1] e A [P], A [ P + 1], ..., A [N - 1]. # # A diferença entre as duas partes é o val...
e76aeb3a14edb222b40acb4cb3adada0492bed03
adebayo5131/Python
/Basic python.py
629
3.96875
4
greet = 'Hello my name is' for i in enumerate(greet): print(i) print('\n') for j in enumerate(greet[0:5]): print(j) #List Comprehension list = [1,2,3,4,5] print('\n') print([i**2 for i in list]) items = [['Bayo',20],['shaina',10]] print(items[1][1]* 2) print('\n') #Lambda(), Map() and Filter() for i i...
286222e0b8daa4a7cfab29fee794130f48e0acc9
Easwar737/Python
/Leetcode(Easy) - Python/Two sum.py
524
3.921875
4
"""Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.""" # I have manually given the input. This...
d76b0f3a4d1b9d0e7baf653019e2f703706a7356
abhijitdey/coding-practice
/facebook/arrays_and_strings/13_one_edit_distance.py
3,782
3.78125
4
""" Given two strings s and t, return true if they are both one edit distance apart, otherwise return false. One operation can be either a delete, an insert, or a replacement """ class Solution: def editDistance(self, word1: str, word2: str) -> int: """ Returns the min number of operations require...
6d659c409f316f9eb59e594105f1bf908f0c2619
Hecvi/Tasks_on_python
/task96.py
1,225
3.71875
4
# Даны два действительных числа x и y. Проверьте, принадлежит ли точка # с координатами(x,y) заштрихованному квадрату (включая его границу). # Если точка принадлежит квадрату, выведите слово YES,иначе выведите слово # NO. На рисунке сетка проведена с шагом 1 # Решение должно содержать функцию IsPointInSquare(x, y), воз...
996be59906d257e36c81bb25b30d7fa40c692a16
anonymokata/0a836320-4374-11ea-9cf5-1a2702f082d9
/WordSearchSolver.py
2,227
3.875
4
from WordSearchBlock import WordSearchBlock import sys class WordSearchSolver(object): """ This is the solver. It is instantiated with a text file containing the specified format. Once instantiated, it can solve() the puzzle, finding all of the words listed on the first line of the text file. """ ...
302096af42506826c91a50278c7d741fc6ae9bfc
AmelishkoIra/it-academy-summer-2021
/task1_hw5.py
934
4.125
4
"""Функции из Homework5 для тестирования""" def input_number(a): """ Написать программу которая находит ближайшую степень двойки к введенному числу. """ for i in range(0, 1000): if 2 ** i >= a: if 2 ** i - a > a - 2 ** (i - 1): return 2 ** (i - 1) ...
3d26d0f8c9c6bfd7c5c8b40767df45f6fa2a631d
AmirHossam/Tic-Tac-Toe
/main.py
4,737
4.15625
4
#to clear screen from IPython.display import clear_output import random def display_board(board): clear_output() print(' ' + board[7] + ' | ' + board[8] + ' | '+ board[9]) print('-----------') print(' ' + board[4] + ' | ' + board[5] + ' | '+ board[6]) print('-----------') print(' ' + boar...
decc8c9f66fe4f9445a21d915cf2a894de3c01d9
yaHaart/hometasks
/Module23/common_calc_func.py
675
3.90625
4
def calc(temp_list): if temp_list[1] == '+': summa = int(temp_list[0]) + int(temp_list[2]) elif temp_list[1] == '-': summa = int(temp_list[0]) - int(temp_list[2]) elif temp_list[1] == '*': summa = int(temp_list[0]) * int(temp_list[2]) elif temp_list[1] == '//': summa = in...
7cb1525c882944e79790b8aa6412b6e12bc78f05
diegobonilla98/Test_on_Reinforcement_Learning
/Environment.py
677
3.703125
4
# model of the world. Gives observations and rewards. Changes state based on actions. import random class Environment: def __init__(self): self.steps_left = 10 def get_observation(self): # current observation to the agent return [0., 0., 0.] def get_actions(self): # get t...
88f4f9c9c2e50927031ef3753cbdfa07b99952e0
nonvisual/algorithms
/data_structures/red_black_tree.py
5,179
3.9375
4
''' Created on Apr 10, 2018 Properties of red-black tree 1. Every node is either red or black. 2. The root is black. 3. Every leaf (NIL) is black. 4. If a node is red, then both its children are black. 5. For each node, all simple paths from the node to descendant leaves contain the same number of black nodes. @autho...
719ebea0caf67a6011f754a62fb53a06370dda5f
ThomasLee1998/Python-Project
/start of calculator.py
4,243
4
4
def add(): print 'Enter your first number.' num1 = int(raw_input()) x = 1 y = 2 list1 = [] while x == 1: print 'Enter another number. If you would like to find the answer, type "add"' num = raw_input() if num != 'add': if y == 2: list1.append(n...
9b748315182a69d402d898eedb1f6b53b36fce96
zerghua/leetcode-python
/N1971_FindifPathExistsinGraph.py
2,482
4.0625
4
# # Create by Hua on 3/21/22. # """ There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi. Every vertex p...
dca6d97965b6aabf937b887ad24790828ff18797
AnamitraMandal/Intro-to-Webd
/GCD_using_Recursion.py
150
3.890625
4
def GCD(a,b): if a%b==0: return b else: return GCD(b,a%b) n1=int(input()) n2=int(input()) gcd=GCD(n1,n2) print(gcd)
e3f133fd3ee8a59290ec6fdb1675e5dec8fafcf5
gsrr/leetcode
/leetcode/941. Valid Mountain Array.py
480
3.53125
4
import collections def ans(A): if len(A) < 3: return False i = 0 j = len(A) - 1 while i < len(A) - 1 and A[i + 1] - A[i] > 0: i += 1 while j > 0 and A[j - 1] - A[j] > 0: j -= 1 if i == 0 or j == len(A) - 1: return False return i == j clas...
d7590139c75e998120417f6c50a0e85ca9b50193
DJaymeGreen/WackyWheel
/ww.py
5,866
3.984375
4
"""D Jayme Green Implementation of a doubly, circularly Linked List in Python """ from myList import * import random class Player(): __slots__ = ("Money") """ Makes a player object which contains the amount of money param startMoney int initial money player will start with return player Pl...
7df773b65e7702200ba41fc806ea3e2ead470585
Aasthaengg/IBMdataset
/Python_codes/p03937/s124419629.py
792
3.53125
4
def main(): H, W = map(int, input().split()) board = list() for i in range(H): board.append(list(input())) stat = [[False for i in range(W)] for j in range(H)] go = True i = j = 0 stat[i][j] = True while go: if (i < H) and (j + 1 < W) and board[i][j + 1] == "#": ...
580d7c29c424e9f0351aec2a96161af24bf89fd6
MintuKrishnan/subrahmanyam-batch
/16.matrix/intro.py
505
4.0625
4
""" Matrix """ A = [ [1, 2, 3], [4, 5, 6], [8, 9, 10] ] row = 1 n = len(A) # no of rows m = len(A[0]) # no of cols # for i in range(m): # print(A[row-1][i]) # col = 3 # for i in range(n): # print(A[i][col-1]) # for i in range(n): # for j in range(m): # print(A[i][j], end=" ") ...
5d5e0faba6ea7abecc0ee5670f6fe9811235000c
Arctanxy/learning_notes
/machinelearning/study/lintcode/PAT/PAT_ADVANCED/cut integer.py
354
3.796875
4
def run(): N = int(input()) for i in range(N): num = input() num1 = int(num[:int(len(num)/2)]) num2 = int(num[int(len(num)/2):]) if num1 == 0 or num2 == 0: print('No') continue if int(num) % (num1 * num2) == 0: print('Yes') else...
db2feb86ead28b70d22a18a9717e876fb879953a
GlaucoPhd/Python_Zero2Master
/CreatingOurOwnObjects114.py
561
3.828125
4
# Always class name singular # __init__ Magic Method # First Parameter when we write a code Class # Define a self. only one user can be assigned to it # Write code dynamic, # Give a special attribute for a user only is available to him class PlayerCharacter: def __init__(self, name, age): self.name = name ...
a8aa8463649be98371ce3d51d11ef7e011eda24f
Gerald-Izuchukwu/Task-3
/No_5_sum_two_given_integers.py
307
4.15625
4
# A python that sums up up two integers # if the result is between 15 and 20, it returns 20 # if not it returns the answer # num1 = int(input("Please enter a number: ")) num2 = int(input("Please enetr the second number: ")) sum = num1 + num2 if sum in range(15,20): print(int(20)) else: print(sum)
45ecbe39604e235d51fa240dd1304543a98037c1
hijkzzz/leetcode
/LintCode/79. 最长公共子串.py
719
3.609375
4
class Solution: """ @param A: A string @param B: A string @return: the length of the longest common substring. """ def longestCommonSubstring(self, a, b): if len(a) == 0 or len(b) == 0: return 0 # write your code here # 使用c[i,j] 表示 以 Xi 和 Yj 结尾的最长公共子串的长度 ...
2e7a5d453353ed004cea32d3679e07e97f355ba7
ChannithAm/PY-programming
/Advance-Python/oop/property.py
907
3.515625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # File : property.py # Author : Channith Am <amcnith@gmail.com> # Date : 21.01.2019 # Last Modified Date: 22.01.2019 # Last Modified By : Channith Am <amcnith@gmail.com> class Email: def __init__(self, address): self._emai...
0531a368ff8ca410c4ee0a403e376e7562c35c89
Smarty18/Academy_Python
/Controllati_Lunedì22/IstogrammaConInput.py
591
3.96875
4
def istogramma(): var = True #variabile booleana che non diventa mai false per non bloccare il while st = "" while var: numero = int(input("Inserisci un valore:")) #numero di * if numero == 0: #comando per interrompere l'esecuzione e mandare in stampa l'istogramma brea...
5292cde519daba07a20ff81b020b2bbd79d34393
txjzwzz/leetCodeJuly
/Search_for_a_Range.py
1,735
4.0625
4
#-*- coding=utf-8 -*- __author__ = 'txjzw' """ Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithm's runtime complexity must be in the order of O(log n). If the target is not found in the array, return [-1, -1]. For example, Given [5, 7, 7, 8, 8, 10] and ta...
bcd8243e4845aeb36a48eaa08e7bb27830621fb0
hkdeman/algorithms
/python/data-structures/tree.py
600
3.640625
4
from tnode import TNode class Tree: def __init__(self): self.root = None self.size = 0 def get_root(self): return self.root def size(self): return self.size def set_root(self,node): self.root = TNode(node) self.size+=1 def __str__(self)...
88fef796bf89a2c3daaa46af1e481d24eba4a33f
Apostol095/gotham
/calculator.py
1,498
3.953125
4
def add(a, b): return a + b def sub(a, b): return a - b def mul(a, b): return a * b def div(a,b): return a/b calc_dict = { '+': add, '-': sub, '*': mul, '/': div, } def main(): check1= True while check1 == True: try: first_num...
48c1440f24f30794e4ca0e28ad22520598eb47f3
yaminikanthch/Python-Work
/sessions/tictactoe/board188v1
2,068
3.8125
4
#!/usr/bin/python import sys import os def won(player): cleanBoard(pos) print "Player %s won the game!" %(player) sys.exit() def draw_game(dg): cleanBoard(pos) print "The game is a tie break!" sys.exit() def cleanBoard(sel): print "\n" print " %s | %s | %s " %(sel[0],sel[1],sel[2]) print "...............
7246d7b2c17a0371d88a34f3596866502a803bb8
olivcarol/Project-Robotics-Company
/Project: Robotics Company.gyp
5,179
4.53125
5
#Create a python class called DriveBot. Within this class, create instance variables for motor_speed, sensor_range, and direction. All of these should be initialized to 0 by default. After setting up the class, create an object from the class called robot_1. Set the motor_speed to 5, the direction to 90, and the sensor...
1b4a658867e65d32f977b74d482d5587f481eaac
Eger37/algoritmization
/lab_6/lab_6_1.py
2,660
4.09375
4
# 1. За датою d, m, y визначити дату наступного і попереднього дня. В програмі врахувати # наявність високосних років. # Сугак Даниїл Васильович 1 курс група 122Б # def previous_day(day, month, year): # day -= 1 # month -= 1 # if day < 1: # month -= 1 # day = months_list[month][1] # if ...