blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
ffcc4cb870f2ad333ab172c9c8abc3f2f926bf27
manish-panwar/python-examples
/src/hello-world.py
159
3.765625
4
name = "Manish" age = 30 print("This is hello world!!!") print(name) print(float(age)) age = "31" print(age) print("this", "is", "cool", "and", "awesome!")
4ceb3618b3d52cdac1210e4c918e10d33e70c22c
igorvac/exerciciosPythonBrasil
/ex13.py
175
3.984375
4
base = int(input("Insira a base: ")) ex = int(input("Insira o expoente: ")) result = base print(base ** ex) for i in range(1, ex): result = result * base print(result)
90ee4032c6a3ce4198800133a874a03285661d22
pulinghao/LeetCode_Python
/657. 机器人能否返回原点.py
722
3.640625
4
#!/usr/bin/env python # _*_coding:utf-8 _*_ """ @Time :2020/8/28 9:40 上午 @Author :pulinghao@baidu.com @File :657. 机器人能否返回原点.py @Description : """ class Solution(object): def judgeCircle(self, moves): """ :type moves: str :rtype: bool """ dirs = {'R': [1, 0], 'L': ...
167437ae9a29eb6e927bd78897112ef901cce07a
arunpoy/python_code
/String/duplicatesinstring.py
332
3.984375
4
def duplicatesInString(string): duplicates = {} for char in string: if char in duplicates: duplicates[char] +=1 else: duplicates[char] = 1 for key, value in duplicates.items(): if value > 1: print(key, value) string = "arunkumar" duplicatesInStr...
a4981cb62759acd4c042597b3ba1066804607fc5
bopopescu/DojoAssignments
/Python/OOP/product.py
1,000
3.671875
4
class Product(object): def __init__(self, price, item_name, weight, brand, status): self.price = price self.item_name = item_name self.weight = weight self.brand = brand self.status = "for sale" def sell(self): self.status = "sold" return self de...
55006880880321391052721a0f1c20e5d4274e5d
N3mT3nta/ExerciciosPython
/old/ex017.py
281
3.8125
4
from math import hypot co = float(input('Cateto oposto:')) ca = float(input('Cateto adjacente:')) #h = (co**2 + ca**2) ** (1/2) #print('O quadrado da hipotenusa deste triângulo vale {:.2f}'.format(h)) h = hypot(co, ca) print('A hipotenusa desse triângulo vale {:.2f}'.format(h))
51e65920758f95d570020487e861cd46ea55e444
JasonHassell228/Advent-of-Code-2020
/Day8/prob1.py
863
3.5
4
f = open("input", "r") currLine = 0 acc = 0 lines = [] explLines = [] # Explored lines for line in f.readlines(): lines.append(line) while True: if currLine not in explLines: explLines.append(currLine) else: print("repeating on line", currLine) print("acc:", acc) break ...
7f9983fd39049ad6c5f6f1284b36a72a8524099c
andris19/my_programs
/Assignments/assignment3.py
239
3.953125
4
a0 = int(input("Input a positive int: "))# Do not change this line counter = 0 while a0>1: if counter%2 == 0: a0 = a0/2 counter += 1 print(a0) else: a0 = 3*a0+1 counter +=1 print(a0)
74c941ff15c02db51e8ca7c83eaa96f4b86fb0c5
Savas21/Web-Development
/02-FLASK&PYTHON/5.sequences.py
281
3.890625
4
#String ,tuple and list in python name="Alice" coordinates=(10.0,20.0) names=["Alice","Bob","Charlie"] #zero index system #note :if you execute your code on python interpeter you dont need to use "print "statement print (name[0]) print (coordinates[1]) print (names[1])
75668270dc34f84d8fef1389583d20f95f166981
SammyHerring/LinearAlgebraSolver
/LinearAlgebraSolver.py
7,195
3.75
4
import sys ###Linear Algebra Solver using MCAD Method ##Built and tested to run in the Python 3.6.2 Shell ###Origninal Potential Input Value of A (coefficients of x, y, z) ##Assignment Example q1A = [[-1, 0, 2], [0, 1, -4], [5, 3, 1]] ##Alternative Example q2A = [[1, 2, 2], [3, -2, 1], [2, 1, -1]]...
196a646f52241fe93ec29ec0ae0e5d9e3946ca1f
CiQiong/Python
/quadratic2.py
374
3.984375
4
#quadratic2.py import math def main(): print(" \n") a,b,c=eval(input("Please enter the coefficients(a,b,c):")) delta=b*b-4*a*c if delta>=0: discRoot=math.sqrt(delta) root1=(-b+discRoot)/(2*a) root2=(-b-discRoot)/(2*a) print("\nThe solutions are:",root1,root2) else: ...
cf9ed2a2dbc5a487bab1972cf8f93b5ff936ae33
juanwolf/exercism
/python/high-scores/high_scores.py
469
3.65625
4
class HighScores(object): def __init__(self, scores): self.scores = scores def personal_top_three(self): return self._get_best_scores(3) def latest(self): return self.scores[-1] def personal_best(self): return self._get_best_scores(1)[0] def _get_best_scores(self,...
14e7d7f485c2eee9b6b5657aa8700b445973dad6
NoumannAli/python_projects
/bmiCalculator.py
943
4.25
4
#Requirements #Write your code below this line 👇 # Under 18.5 they are underweight # Over 18.5 but below 25 they have a normal weight # Over 25 but below 30 they are slightly overweight # Over 30 but below 35 they are obese # Above 35 they are clinically obese. #User Inputs height = float(input("enter your height in ...
dccbead5c136171b6b0ecfebd998cf8d051bb0ce
missArthas/LeetCode
/PythonVersion/easy/Q557ReverseWordsinaString3.py
432
3.671875
4
class Solution(object): def reverseWords(self, s): """ :type s: str :rtype: str """ if(s==None or s==""): return s temp=s.split(' ') result="" resultLen=len(result) for t in temp: result=result+t[::-1]+" " resul...
55c795976c254b3a033cdfdc1ca8aa945a733a20
csohb/Programmers
/Programmers/groom/numberBaseball.py
935
3.65625
4
import random rn=["0","0","0"] rn[0] = str(random.randrange(1, 9, 1)) rn[1] = rn[0] rn[2] = rn[0] while (rn[0] == rn[1]): rn[1] = str(random.randrange(1,9,1)) while (rn[0] == rn[2] or rn[1] == rn[2]): rn[2] = str(random.randrange(1,9,1)) def baseBall(com): count=0 scount=0 bcount...
22070ec3bee2de115bc51f57a42cf514c85de737
JordiNeil/PlatziCourses
/Curso_python/PythonDjangoCourse/tortuga.py
358
3.828125
4
# -*- coding:utf-8 -*- import turtle def main(): window = turtle.Screen() dave = turtle.Turtle() make_square(dave) def make_square(dave): len = int(input("Tamaño cuadrado")) for i in range(4): make_line_and_turn(dave, len) def make_line_and_turn(dave, length): dave.forward(length) dave.left(90) if __n...
db80a6eff1ae559ca01bc790dc0714a26d036ff5
Abhikarki/CS50-Introduction-to-Computer-Science
/pset 6/DNA/dna.py
2,349
3.875
4
import csv import sys #exit the program if number of command line arguments!=3 if len(sys.argv) != 3: print("Usage: python dna.py data.csv sequence.txt") sys.exit(1) #function to count and return the max STR repetitions def find_num_of_occurrence(seq, s): tmp_num, i, num = 0, 0, 0 #length o...
8ee5dcf7f80eabe3515d08adb70ce8934301234b
kriti-ixix/python2batch
/python/sumOfNumbers.py
210
3.96875
4
sumOfNumbers = 0 i = 0 limit = int(input("Enter a number: ")) while i<=limit: sumOfNumbers += i i += 1 print("Value of i: ", i) print("Sum: ", sumOfNumbers) #for i in range(limit+1)
a1e147de5780ed2840f42a8739dd39fbd0987d50
CarlosUrda/Coursera-Especializacion-Python-para-Todo-el-Mundo
/Libro Python para Informaticos/Capitulo 10/ejercicio10-3.py
1,467
3.84375
4
#!/usr/bin/env python #coding=utf-8 # Mostrar la frecuencia de las letras en un archivo. __author__ = "Carlos A. Gómez Urda" __copyright__ = "Copyright 2016" __credits__ = ["Carlos A. Gómez Urda"] __license__ = "GPL" __version__ = "1.0" __maintainer__ = "Carlos A. Gómez Urda" __email__ = "ca...
638cd82594d426b03aa471ead40ee21e696ca814
hyuraku/Python_Learning_Diary
/section1/dictionary.py
1,183
4.125
4
#辞書型のデータの基本的な作り方。 d={'x':10,'y':20} print(d) print(type(d)) #> <class 'dict'> print(d['x'],d['y']) #xの値を100にする。 d['x']=100 print(d['x'],d['y']) #> 100 20 #'z':200 を追加する d['z']=200 #'1':50 を追加する d[1]=50 print(d) #> {'x': 100, 'y': 20, 'z': 200, 1: 50} #これも辞書型データの作り方 d2=dict(a=10,b=20) print(d2) #> {'a': 10, 'b': 20...
cffa25ff2c94a6baceaf38f27989a3380aeeadc7
numRandom/new_pythonCode
/07_语法进阶/sin_03_修改全局变量.py
280
3.765625
4
# 全局变量 num = 10 def demo(): # 修改全局变量,使用 global 声明一下变量 global num num = 99 print("demo ==> %d" % num) print("函数前的全局变量 num = %d" % num) demo() print("函数后的全局变量 num = %d" % num)
af31909d349aea0314cc8b6e38fd532830373530
sudeepto22/CurrencyExtract
/model/currency_model.py
454
3.5
4
class Currency(object): def __init__(self, currency_code: str, value: float): self.currency_code = currency_code self.value = value def __str__(self) -> str: return 'CurrencyModel(currency_code: {}, value: {})'.format( self.currency_code, self.value ) ...
8c32b355d06584c0742bb63625652595bc6322b9
Akarami000/datastructture-python
/exception.py
664
3.703125
4
# try: # print(x) # except: # print("i am akshya") ####################################3 # try: # f= open("ng.txt") # f.write("i am akshay") # except: # print("this is a try block") # finally: # f.close() # ###################################### # while(True): # try: # us...
45adefcb747daaf35e145dbea043bf84cc72ff1d
jiongyzh/leetCode
/Merge k Sorted Lists.py
633
3.78125
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def mergeKLists(self, lists): """ :type lists: List[ListNode] :rtype: ListNode """ all_node_vals = [] head =...
d507766da98abb9f5c3b27e0063d22bccf87265d
LucianaMurimi/python-for-IoT
/lesson2_GUI.py
818
4.03125
4
#Graphical User Interface from tkinter import * #creating an object of type tkinter window = Tk() #object = class window.configure(background = 'pink' ) window.title('Graphical User Interface') window.geometry('550x550') #size of the window #creating buttons btn1 = Button(window, text = 'Send', wid...
c0052306257af9e39eed446b1509ac425feaf49c
Xnuvers007/expert-winner
/Games/Python3/Canon.py
2,367
3.765625
4
from random import randrange from turtle import * from freegames import vector from tkinter import * import tkinter.messagebox import pyfiglet root = Tk() tkinter.messagebox.showinfo('ATTENTION...!!!', 'Selamat Datang Di game Canon Ball') tkinter.messagebox.showinfo('Tutorial', 'CARA BERMAINNYA MUDAH, PENCET MOUSE KIR...
619504a8a7193dd36edd193f65e86e1508369c05
uc-davis-space-and-satellite-systems/efos
/communications/image_compression_native.py
777
4.1875
4
from PIL import Image ''' This function will compress an image located at <path>/<image_name>/ by lowering its [quality] factor. The new compressed image is saved under <path>/COMPRESSED<image_name> ''' def compress_image(path, image_name, quality): abs_path = path + image_name # Opening image, read mode. ...
c4a98be41b06d922c425e973ee603c3c7f401793
amitks815/Old_programs
/String/str2.py
104
3.859375
4
str=input("enter the string") if len(str)<2: n=3 print(str*n) else: get=str[0:2] print(get*3)
ed66adfe0947d9a9041d41e01955837c4755501b
fairlearn/fairlearn
/test/unit/reductions/moments/data_generator.py
2,336
4.03125
4
# Copyright (c) Microsoft Corporation and Fairlearn contributors. # Licensed under the MIT License. import numpy as np import pandas as pd def simple_binary_threshold_data( number_a0, number_a1, a0_threshold, a1_threshold, a0_label, a1_label ): """Generate some simple (biased) thresholded data. This is ...
358b3541c650d9230bd7c01fc882d3f9a3a86450
iCodeIN/Project-Euler-1
/Problem Set/Problem 5.py
177
3.65625
4
def multiple(n): for i in range(1, 21): if n%i != 0: return 0 return n n=1 while(True): if multiple(n): print(n) break n+=1
d7a57740a8ed3bdc2d04eb83cf4eac4c0c1d1897
saikiran6666/rama
/program35.py
178
3.828125
4
#write a program on square od dictionary values print only keys def sqrkeys(): d=dict() for i in range(1,21): d[i]=i**2 for k in d: print(k) sqrkeys()
b0fcd8090397c989109f7aff27659677c5837201
kakashi-01/python-0504
/shanghaiyouyou/题库/实战4.py
2,056
3.703125
4
#coding=utf-8 #author:Kingving time:2020/7/27 0:23 '''给定一个数组奇数为是升序,偶数位是降序,(如:1,8,3,6,5,4,7,2)如何让其升序变成(1,2,3,4,5,6,7,8);''' a=[1,8,3,6,5,4,7,2] s=range(len(a) - 1) print(s) for i in range(len(a) - 1): for j in range(len(a) - 1-i): if a[j]>a[j+1]: a[j],a[j+1]=a[j+1],a[j] print(a) def Sort_Fun...
a9479f9e11cf17eb05a2534a86700885fed9bc02
jadhavjay0253/python_playground
/Learning/Function Practise Set/pr_02.py
342
3.96875
4
# WAP to convert celcius into fahrenheit def convrt(c): return (c * (9/5)) + 32 c = int(input("Enter Celcius ")) x = convrt(c) print(round(x,2))# puts value upto only 2 decimal # prevent python from preventing going on next line: print("Its on new line..",end="") print(" Im not on new line") # stops ...
ee45e27fcef5b21d4d1ae613a895d4a49189bb36
sukritinain/Hadoop
/Assignment-I/RelationalJoin/task8/reducer.py
751
3.546875
4
#!/usr/bin/python import sys List = [] temp = '0' for line in sys.stdin: data = line.strip().split() if (temp == data[0]): if len(data) == 3: studentID, course, grade = data List.append([course,grade]) elif len(data) == 2: studentID, sname = data else : print sname,'-->', for i in List: pri...
d38859e5a22f38db945d29abc8caf195a69ead36
tomasspangelo/Industrial-Optimization
/Heuristics/container.py
934
3.78125
4
class Container: """ Data oriented class for keeping track of the containers. """ def __init__(self, id, weight): self.id = id self.weight = weight @staticmethod def sort_array_weight_descending(b): """ Sorts array according to weight, descending. :param ...
3c3a66c0bea0eee42047af87463469b474fbccf1
chandratop/RC4
/Corollary5.py
2,918
3.59375
4
# Corollary : # # Once a value of j gets repeated in three consecutive rounds (r, r +1 and r +2), # # no value can immediately be repeated in subsequent two rounds (for N > 2). # # In other words, if jr = jr+1 = jr+2 it is not possible to have jr+3 = jr+4. # * Modules imported from random import shuffle # * Funct...
702c41011836bb6794a24c4a47d890b3d27a15e0
suvistack/edyoda-assignment2
/tic tac toe/tic tac toe.py
4,142
3.96875
4
#!/usr/bin/env python # coding: utf-8 # In[3]: from tkinter import * tic_tac_toe = {'7': ' ' , '8': ' ' , '9': ' ' , '4': ' ' , '5': ' ' , '6': ' ' , '1': ' ' , '2': ' ' , '3': ' ' } tic_tac_toe_keys = [] for key in tic_tac_toe: tic_tac_toe_keys.append(key) def printBoard(ttt): p...
4910d30d4d7d0d29a5271615042b76a8b7a0cbc8
fxmike/bootcamp
/github challenge/#13.py
432
3.9375
4
# Question: # Write a program that accepts a sentence and calculate the number of letters and digits. # Suppose the following input is supplied to the program: # hello world! 123 # Then, the output should be: # LETTERS 10 # DIGITS 3 s = input() let_ct = 0 num_ct = 0 for letter in s: if letter.isalpha(): le...
bd1db0208fbadf3b1c7461887a68cec6a36857ea
die4700/CSC308Final
/CSC308Final/gui.py
835
3.8125
4
# Alexander Dietz # Brittani Kiger # Christopher Lytle # Import Tkinter from tkinter import * root = Tk() root.geometry("400x200") def retreive_input(): subreddit_input = subreddit.get("1.0", "end-1c") print(subreddit_input) string_search_input = string_search.get("1.0", "end-1c") print(str...
10255509ba3e94068842846bd775ca514fb0be74
garona2dz/ChongChongChong
/studyprocess1/shiTouJianDaoBu.py
430
4
4
import random print ("石头:1;剪刀:2;布:3") player=int (input("请输入要出的拳头👊:")) computer=random.randint (1,3) print("玩家出的是:%d ,电脑出的是:%d" %(player,computer)) if ((player==1 and computer==2) or(player==2 and computer==3) or(player==3 and computer==1)): print ("你赢了!") elif (player==computer): print("彼此彼此!"...
8bcecc30eb2c876100190e7ebbbacd6170bde7aa
bowei437/Applied-Software-Design--ECE-3574
/Sampling/masterHW/Documents/ece2524midterm/bin/change_grade.py
553
4.1875
4
#!/usr/bin/env python # ECE 2524 Homework 3 Problem 1 # Thomas Elliott import argparse import sys import fileinput parser = argparse.ArgumentParser(description='Change some grades') parser.add_argument("argName") parser.add_argument("argGrade") parser.add_argument("infile", nargs='*') args = parser.parse_args() for...
c41bbe9eafcc7a6fd85dfc6df05d4f1e4de756c3
camerongridley/Formula-One-Home-Advantage
/src/data_cleaner.py
1,858
4.09375
4
class DataCleaner: """ A class used to represent an Animal ... Attributes ---------- says_str : str a formatted string to print out what the animal says name : str the name of the animal sound : str the sound that the animal makes num_legs : int the ...
deefba83a3680b23cb2cee2f332e8c728dc48604
amigojapan/amigojapan.github.io
/8_basics_of_programming/cont.py
129
4.03125
4
cont=True while cont==True: print("continue? 1)Yes 2)No:") user_input=input() if user_input=="2": cont=False
f10d519e1734ca73dccc67fa3f744d7706bc3ecf
Easytolearndemo/Practice_Python_code
/13.new_prime.py
155
3.90625
4
c=0 n=int(input("Enter the number")) for i in range(1,n+1): if n%i==0: c=c+1 if c==2: print(f"prime {n}") else: print(f"not prime {n}")
de6562c606afd091b6dafff115898ad7862d9a00
daniellehoo/python
/week 1/dinner_party.py
341
3.609375
4
import random dish = ["Spaghetti alla Carbonara", "Meatloaf", "Tuna Nicoise Salad", "Lobster Mac and Cheese", "Green Curry"] guests = ["Sally", "Sam", "Bill Clinton", "Barron Trump", "Dan Harmon"] random_meal = random.choice(dish) random_guest = random.choice(guests) print(f"Let's make {random_meal} and invite {ran...
92f859750753eb4dc814f29ac368c718bbe96d6f
vamshi99k/python-programs
/matrix1 - Copy.py
210
3.59375
4
n=int(input()) mylist=[] for i in range(n): l=input().split() l=list(map(int,l)) mylist.append(l) for i in range(len(mylist)): for j in range(len(mylist)): print(mylist[i][j],end='') print()
a5b1029c5171deda96e7b3896f8cc9478182f4f9
bascker/py-note
/src/base/map.py
535
3.78125
4
#!/usr/bin/python """ map 语法: map(function, list), 将集合元素映射成另一种值 2.x: 返回列表 3.x: 返回迭代器 """ import os import sys sys.path.append(os.getcwd()) from src.utils.applogger import AppLogger LOG = AppLogger("map") def main(): num = [1, 2, 3] vals = map(lambda n: n * 2, num) # list 兼容 python2/3x 处理 dou...
ecc82fb2924bf28cc3057450ea75796164963400
jeanbcaron/course-material
/exercices/040/solution.py
163
3.75
4
# -*- coding: utf-8 -*- """ Created on Mon Sep 22 15:09:11 2014 @author: jean-baptiste """ a = 0 for i in range(101): if i % 2 == 0: a = a+i print(a)
5c1b06d2b3c1db4a952d43d8222832f38184996b
LiliGuimaraes/100-days-of-code
/USE-CABEÇA-PENSE-PYTHON/ITERACAO-AVANCADA/read_csv_bahamas.py
1,256
3.5
4
from datetime import datetime import pprint # 1 forma # import csv # with open('buzzes.csv') as raw_data: # for line in csv.DictReader(raw_data): # print(line) # Sem usar CSV READER, crie seu próprio código para ler o csv # A saída deve conter letras iniciais maiúsculas para o campo DESTINATION # horário...
24ecc565785dcd40476266fc4c61683fdeeeb010
ToWorkit/Python_base
/操作符/将字符串转为小写.py
302
4.0625
4
l = ['Hello', 'World', 'You', 'Ok'] print([item.lower() for item in l]) # 跳过不能操作的整数项 # 非字符串类型没有lower() 方法 l_02 = ['Hello', 'World', 20, 'You', 'Ok', [2], {3}, 'NICE'] # 处理类型是字符串的 print([item.lower() for item in l_02 if isinstance(item, str) ])
91ac10d81b17a59776f6e1000ac8dac7f16b5f90
FuneyYan/Python-
/hello.py
33,858
3.984375
4
import math ''' name=input('please enter you username:') print(name) a=100 if a>=1: print(0) else: print(1) print(10.0/3.0) print('i\' am \"ok\"!') #字符串原样输出 \\r\\ print(r'\\r\\') #占位符 s1=72 s2=85 r=(s2-s1)/100 print('hello,{0}成绩提升了{1:.1f}%'.format('james',r)) #占位符 print('hello,%s的成绩是%.1f' % ('james',11.22)); # 打印...
cbad8c0e143d5ad3a7fd81f0a4f4145a7d85890d
Strawika/amis_python
/km73/Hirianska_Viktoriia/9/task1.py
281
4.125
4
x1 = float(input("Enter x1: ")) y1 = float(input("Enter y1: ")) x2 = float(input("Enter x2: ")) y2 = float(input("Enter y2: ")) def distance(x1, y1, x2, y2): return ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5 print("Distance is: ", distance(x1, y1, x2, y2)) input()
cde80719230dcf08c77b0eb165fa015ab2f752b9
BelfortJoao/Curso-phyton-1-2-3
/codes/Ex064.py
205
3.78125
4
n = 0 s = 0 h = 0 while n != 999: n = int(input('Digite um numero para somar [ou digite 999 para parar].')) s += n h += 1 print('Você digitou {} numeros e a soma foi de {}'.format(h, s-999))
961f37681d3c9739b553a902bae313ae4511cc3b
chiranjeetborah/Informatics_Practices
/class12/Lab Problems/Pandas/l.py
920
4.40625
4
#Aim: Write a python program to iterate over a dataframe containing names and marks, which then calculates grades as per marks (as per guidelines below) and adds them to the grade column. # Marks > =90 grade A+ # Marks 70-90 grade A # Marks 60-70 grade B # Marks 50-60 grade C # Marks 40-50 grade D # Marks <40 grade E...
21569a5c0f62a26b40e670d2c44b19f3f0d0b0af
mk8877/Computational-Physics
/chapter16/found_error_2.py
1,076
3.875
4
from numpy import * import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation Nx =101 T = np.zeros((Nx,2),float) k = range(0,Nx) fig = plt.figure() xlist = [] ylist = [] def init(): for j in range(0,50): for i in range(0,50): xx = i+j yy = i...
bbb9d56070844923df592b27e3103911c07277de
ConorWallwork/PCS
/brokenkeyboard2.py
684
3.625
4
from sys import stdin, stdout for _ in range(int(input())): word1, word2 = input().split() len1 = len(word1) len2 = len(word2) if word1[-len1] != word2[-len2]: print("NO") continue while(len2 >= len1 and len1 != 0): if word2[-len2] == word1[-len1]: ...
713d6e5c5a37eb44701948641f019b6e8f129c00
gaopenghigh/algorithm
/lc/binary_tree/lc_543_diameter-of-binary-tree.py
1,364
3.9375
4
# 543. 二叉树的直径 # 难度 简单 # 给定一棵二叉树,你需要计算它的直径长度。一棵二叉树的直径长度是任意两个结点路径长度中的最大值。这条路径可能穿过也可能不穿过根结点。 # 示例 : # 给定二叉树 # # 1 # / \ # 2 3 # / \ # 4 5 # 返回 3, 它的长度是路径 [4,2,1,3] 或者 [5,2,1,3]。 # 遍历所有节点,计算经过每个节点的深度,同时计算最长路径的长度(经过的节点数 - 1),使用一个全局变量记录最大值。 # Definition for a binary tr...
86d586bef3a180cd724de2d4767419e4630b667a
gokay/python-oop
/oop6_decorators_getters_setters_deleters.py
1,067
3.828125
4
# Python OOP 4 Inheritance and subclasses import datetime class Employee: def __init__(self,first, last): self.first = first self.last = last @property def email(self): return '{}.{}@email.com'.format(self.first,self.last) @property def fullname(self): return ...
6cf1e6dce755fdd09172c9535d0f48682a324755
Austinll0/AdventOfCode
/2022/python/day08/day8revb.py
1,608
3.640625
4
def score(height, view): for i in range(len(view)): if int(view[i]) >= height: return i + 1; return -1; out1 = 0; out2 = 0; map = ""; width = 0; height = 0; with open("day8in.txt") as f: line = f.readline().strip(); width = len(line); while(line): map += line; hei...
349998df48885dd21d98458ecbf1205abeea234d
tami888/PE
/Problem006.py
723
3.671875
4
# -*- coding: utf-8 -*- """ 最初の10個の自然数について, その二乗の和は, 12 + 22 + ... + 102 = 385 最初の10個の自然数について, その和の二乗は, (1 + 2 + ... + 10)2 = 3025 これらの数の差は 3025 - 385 = 2640 となる. 同様にして, 最初の100個の自然数について二乗の和と和の二乗の差を求めよ. """ def problem6(n): num1 = 0 num2 = 0 for i in range(1, n+1): num1 += i * i # 二乗の和をn...
00b20ac5a5aaadf9741d26c737af6b5eae2db571
amshrestha2020/IWAssignment-Python-
/DataTypes/SmallestNumberList.py
247
4.125
4
'Program to get the smallest number from a list' def main(): h = input("Enter an integer for list(space separated):") p = list(map(int, h.split())) print("The smallest number from a list:", min(p)) if __name__=="__main__": main()
0f17a51dd92971cd04ef8da54e76bd7f8c18e9be
hanglekhanh/py-oop-student
/modelStudent/meeting.py
897
3.84375
4
'''./Meeting.py''' class Meeting: ''' this module use for managing meeting in company''' count_meeting = 0 def __init__(self, start_time, end_time, id_meeting, name_meeting): # id_meeting : id number of meeting # start_time : start time of this meeting # end_time : end ...
19c5514e64ce2edfa28044561f5040a502686f1b
INFO3401/problem-set-10-SRInfo3401
/regressionAnalysis.py
12,790
4.125
4
#Monday: #Submit the following functions as part of a file called regressionAnalysis.py. You will use this data to make some predictions about the nutritional aspects of various popular Halloween candies. Your code will contain three objects: #sources: http://scikit-learn.org/stable/auto_examples/linear_model/plot_ols....
1725021b6c0d1952a57de1a1b52c05c05431deff
jaquish/sandbox
/euler/5.py
1,620
3.8125
4
# What is the smallest positive number that is evenly divisible # by all of the numbers from 1 to 20? # My Note: This could be brute-forced. However, the answer is also the # product of the factors with the highest powers, each raised to that highest power. # Processing Time: # bruteforce - ~ 1.5 hours # slight...
cdd5da8f032a3a4faeed425e2d299e534076c3cb
rain-point/first
/dcsx.py
145
3.734375
4
a = 1 b = 1 n = int(input('请输入斐波那契数列的项数:')) print(a, b, end=' ') for k in range(3, n+1): c = a+b a = b b = c
4a709ced79a10b6617a2250456839a61b374f3c8
bezzzon/python-basics
/home_work1/task5.py
1,370
4.125
4
""" - Запросите у пользователя значения выручки и издержек фирмы. - Определите, с каким финансовым результатом работает фирма (прибыль — выручка больше издержек, или убыток — издержки больше выручки). - Выведите соответствующее сообщение. - Если фирма отработала с прибылью, вычислите рентабельность выручки (соотношение...
d3435d6830fef34a1157238155f3e72ca06becc3
earmingol/cell2cell
/cell2cell/io/directories.py
1,135
4.4375
4
# -*- coding: utf-8 -*- import os def create_directory(pathname): '''Creates a directory. Uses a path to create a directory. It creates all intermediate folders before creating the leaf folder. Parameters ---------- pathname : str Full path of the folder to create. ''' i...
e41f1b6ba23886c02314e0f3e88cb16fe182ae97
veronicabaker/Introduction-to-Computer-Programming
/Computer Programming/blackjack.py
4,419
4.03125
4
""" blackjack.py (12 points) ===== Complete the program below to simulate a single hand of blackjack. The code for creating a deck of cards and dealing cards is written for you. You can see the slides discussing the code here: http://foureyes.github.io/csci-ua.0002-spring2015-007/classes/20/lists_strings_random.html#...
cac1f0a9e9ce9c661911f714d1aa3f842efa1490
1lch2/PythonExercise
/leetcode/binary_tree/199.py
1,184
3.875
4
# 给定一棵二叉树,想象自己站在它的右侧,按照从顶部到底部的顺序,返回从右侧所能看到的节点值。 # 示例: # 输入: [1,2,3,null,5,null,4] # 输出: [1, 3, 4] # 解释: # 1 <--- # / \ # 2 3 <--- # \ \ # 5 4 <--- from typing import List # Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x ...
ac8c04dcf114cfef2f4b321171cde3e5c02b4132
OdhiamboJacob/HandsOnPython
/HOME 1 IF...ELSE.py
978
3.625
4
import random comodity = input('enter good name') goodcode = eval(input('please input good code to know the price')) cake = 1 milk = 2 flour = 3 jik = 4 mandazi = 5 egg = 6 sweet = 7 book = 8 pen = 9 ndovu = 9.1 if comodity == (cake or milk or flour or jik or mandazi or egg or sweet or book or pen or ndovu...
51b2e0f18eec49d7c9f72421f33108066f9488f1
lovemin1003/lovemin34
/python 01 turtle graphic/소용돌이 그리기.py
412
3.671875
4
# -*- coding: utf-8 -*- """ Created on Sun Dec 15 17:52:37 2019 @author: COM """ import turtle t=turtle.Turtle() a=int(input("소용돌이 선 몇 개?:")) """각도""" b=15 """이동 거""" c=10.0 for i in range (a): t.forward(c) t.right(b) c+=0.1 if(i%3==0): t.color("orange") elif(i%3==...
a390531e357098edced6a585b201a5bca386b18d
alexkorsky/Scripts
/DLNF/npplay/backpropStepForAdissionData.py
3,731
3.828125
4
import numpy as np # this line reads binary.csv from data_prep import features, targets, features_test, targets_test # this is a network with 3-point input to hidden layer with # two nodes and then going to signle output node np.random.seed(21) def sigmoid(x): return 1 / (1 + np.exp(-x)) # Hyperparameters ...
0aa5bac9e78375c0314826353f346adca07e23b0
AntoniyaV/SoftUni-Exercises
/Fundamentals/Mid-Exam-Preparation/August-2020-01-computer-store.py
668
3.953125
4
total_price = 0 command = "" while True: command = input() if command == "special" or command == "regular": break price = float(command) if price <= 0: print("Invalid price!") else: total_price += price taxes = total_price * 0.2 total_with_taxes = total_price + taxes if n...
b960c3c78add79ee36d18553bf890a6747d475ac
IvanPadalka/RSA-coding
/RSA-encryption.py
3,006
3.515625
4
import sys def isPrime(number): if number > 1: for i in range(2, number): if (number % i) == 0: return -1 break else: return 1 else: return -1 def findGCD(x, y): while y != 0: c = x % y x = y y = c ...
e8efca49d7e5f7798f0e8d133df7e9214476b1c6
skillup-ai/tettei-engineer
/appendix/zip_1.py
153
3.890625
4
list_1 = ["a", "b", "c", "d"] list_2 = ["x", "y", "z", "w"] for foo, bar in zip(list_1, list_2): print(f"{foo}, {bar}") ''' a, x b, y c, z d, w '''
d2a61560509921818618219ca6c0bbfde66579ee
HongleiXie/MOOC
/Algorithm/binary_search.py
1,386
3.859375
4
# binary search nums = [17, 20, 26, 31, 44, 54, 55, 77, 93] target = 55 def binary_search_recur(nums, target): """ 递归版本 返回找到True或者没找到False 如果要求返回下标不适用递归法 """ left = 0 right = len(nums)-1 if left < right: mid = (left + right) // 2 # 取偏小的那个整数 if nums[mid] == target: ...
ba45bac1e0a6848ce48a37c6aba5044e5489b6b9
GoosePlaysMC/Character-Generator
/main.py
2,574
3.671875
4
import os.path import random p = "\n> " print("Welcome to the RPG Character Generator!") race = "undefined" strength = 0 dexterity = 0 constitution = 0 intelligence = 0 wisdom = 0 charisma = 0 def decide_race(): global race race = input("What race would you like your character to be? (human, elf, orc)" + p)...
c074f400d8d8de1cd0b96e3514f5d9576ab99f7c
Bhushan2581/Python-tuts
/29_Comparison_Operator/main.py
124
3.859375
4
#Operator Name Example # == Equal x == y x = 5 y = 3 print(x == y) # false x = 3 y = 3 print(x == y ) # true
ba2fa96af43c32a732b222d529809749f7e1af6e
vishalkarda/DailyPracticeProblems
/September/26Sept2019_Queue_using_stacks.py
518
4.1875
4
""" Implement a queue class using two stacks. A queue is a data structure that supports the FIFO protocol (First in = first out). Your class should support the enqueue and dequeue methods like a standard queue. """ class Queue: def __init__(self): self.stack_en = list() def enqueue(self, val): ...
b6ab9942b7dff6451e8b8029bafb106a85ae82ec
DEEPAKRAAJM/Basic-PythonPrograms
/numberpattern.py
316
3.96875
4
#### Printing a number pattern #### '''n =input("Enter numo of rows: ") i=j=1 for i in range (0,n): num=1 for j in range (0,i): print (num) num=num+1 ''' def pat(n): i=j=1 for i in range (0,n): num=1 for j in range (0,i): print (num) num=num+1 print ("\r") n=input ("Enter the no: ") pat (n)
285491a0f28d6053adc7bc3550261f77248f5435
KimPopsong/CODE_UP
/3321.py
648
3.609375
4
import math toppingKind = int(input()) s = input().split() doughPrice = int(s[0]) toppingPrice = int(s[1]) doughKcal = int(input()) toppingKcal = [] for i in range(toppingKind): toppingKcal.append(int(input())) toppingKcal.sort() sumPrice = doughPrice sumKcal = doughKcal bestPizza = math.floor(sumKcal / sumPri...
46018d988840c6a89556b57bc104587ef37259b9
Harish-Sahu-Pixel/Leetcode
/Jan leetcoding challenge/16_Jan_2021_problem.py
409
3.609375
4
''' Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. ''' class Solution: def findKthLargest(self, nums: List[int], k: int) -> int: length = len(nums) heapq.heapify(nums) i = 1 while i <= len...
39f36d5c0de023e14ce1cdb95278681fc4ed820c
Trshant/programming_problems
/tower_hanoi_recursive.py
1,450
3.6875
4
class Peg(): def __init__(self): self.pegcontent = [] def last_disk_size(self): length = len( self.pegcontent ) if( length == 0 ): return 0 else: return self.pegcontent[length-1] def insert(self, disk_to_be_inserted ): self.pegcontent.append( ...
e4858bec49be7819f0498ae94eabceb309901ab3
kazitanvirahsan/OOP
/python/Singleton.py
427
3.546875
4
class Singleton: class __Inner: def __init__(self,arg): self.value = arg def __str__(self): return repr(self) instance = None def __init__(self , arg): Singleton.instance = Singleton.__Inner(arg) def getInstance(self,arg): return Singleton.instance x = Sing...
5a3130a73bce2e381da081708de00e23cfc600d7
zzz686970/leetcode-2018
/371_getSum.py
344
3.71875
4
def getSum(a, b): ## way1 # return sum([a,b]) ## way2 ## reference https://leetcode.com/problems/sum-of-two-integers/discuss/132479/Simple-explanation-on-how-to-arrive-at-the-solution/168383 while b != 0: carry = a & b a = (a ^ b) % 0x100000000 b = (carry << 1) % 0x100000000 return a if a <= 0x7FFFFFFF e...
56a93c76ffba6b3859b335b1ab394dfe48a2648f
SuleymanSuleymanzade/oop_it_19
/second_task/object_chaining.py
946
3.828125
4
class Calculator: def __init__(self, num): self.__num = num def add(self, num): self.__num += num return self def multiply(self, num): self.__num *= num return self def minus(self, num): self.__num -= num return self def result(self): ...
dec3dfabf6de23c95e1767ed7fdc62f861234cbe
namseohyeon/python_class
/5주차/self-study5-3.py
263
3.640625
4
a = int(input("숫자를 입력하세요:")) for i in range(2, a): if a % i == 0: b = 1 break else: b = 0 if b == 1: print("%d는 소수가 아닙니다" %a) else: print("%d는 소수입니다" %a)
aa5909f830504d397cd497d69dae66ed5b25659e
seanchoi/algorithms
/MissingInteger/missingInteger.py
308
3.796875
4
def missingInt(A): A = list(set(A)) missingElem = 0 for i in range(len(A)+1): if A[i-1] < 0: missingElem = 1 elif not i+1 in A: missingElem = i+1 return print(missingElem) missingInt([1,3,6,4,1,2]) missingInt([1,2,3]) missingInt([-1, -3])
9fa22cc4452eaeb79535935874ee0798dd4b314f
romanmussi/estudio-py
/src/turtles.py
360
3.84375
4
''' Created on 9 may. 2019 @author: Roman Mussi ''' import turtle bob = turtle.Turtle() #print(bob) def square(t, length): for i in range(4): t.fd(length) t.lt(90) def polygon(t, length, n): for i in range(n): t.fd(length) t.lt(360/n) #square(bob, 50) po...
a196a1feb3c89ebd646472b5f676cef0eeeda9bb
kauravankit25/Python
/untitled.py
565
3.828125
4
from random import randint def play(num): pguess = flag = True while flag: guess = int(input("Guess the number:")) if guess == num: print("CONGRATULATIONS!!!\nYou have Won") break elif abs(guess - num) < abs(pguess - num): print("W...
7e8bf4876c4f42487f4c7e9a616afaef10e9c7f7
herolibra/PyCodeComplete
/Others/Classes/class_method.py
378
3.515625
4
# coding=utf-8 """ 类方法是将类本身作为对象进行操作的方法。类方法使用@classmethod装饰器定义, 其第一个参数是类,约定写为cls。类对象和实例都可以调用类方法 """ class MyClass(object): @classmethod def get_max_value(cls): return 100 print MyClass.get_max_value() cl = MyClass() print cl.get_max_value()
e0b5592758da5a11bfb0e9b3ccab76bcf7727bb2
ethand54/Year9DesignCS-PythonED
/SlopeCalculator.py
470
4.15625
4
import os print("Slope Calculator:") os.system("say Hello welcome to my slope calculator please type in the points to find slope") #Input x1 = input("Input x1: ") x1 = int(x1)#casting y1 = input("Input y1: ") y1 = int(y1) x2 = input("Input x2: ") x2 = int(x2) y2 = input("Input y2: ") y2 = int(y2) #Process rise = ...
0d04fed7e3f65b694feb6286f70d38ab1ba07a0a
mathyomama/scripts
/other/passByReference.py
758
4.03125
4
myList = [1, 2, 3] def changeListReference(something): "changes the reference of something" something.append([1, 2, 3]) print("Inside:", something) return def changeListValue(something): "changes the value of something within the function" something = [4, 5, 6] print("Inside:", something) return #changeListRe...
4b17e1e2b32ec24de1d0f5c5259cfca64e746898
shashaaankk/Python-Basics
/factorial.py
192
4.15625
4
def factorial(n): factorial=1 if(n==0): return factorial else: while n>=1: factorial*=n n=n-1 return(factorial) print(factorial(3))
0e883bd08d385bdfda194313ac974e20e636c137
Nico52105/Ucatolica
/IS.PY
992
4.0625
4
#-----------------------------------# #Nicolas Fiquitiva Segura #625120 #Analisis y Diseo De Algoritmos #Universidad Catolica De Colombia #-----------------------------------# import random import time def Ondenar(Lista,Tam): To=time.clock() for i in range(Tam): Compara = Lista[i] P...
18e488d6f9684c6fa8909320c1fbe6dd91d8967d
k-shah7/Sorting
/Sorting/max_heap.py
2,756
4.0625
4
data = [4, 3, 8, 9, 2, 4, 10] # def max_heapify(data, verbose=False): # """Turn list into a max heap""" # def maxify(data, parent): # """Ensure parent node is greater than child nodes""" # left = parent * 2 + 1 # right = parent * 2 + 2 # if data[parent] < data[left...
ea8cd49f4be27a8b65641167b2574e7321abbadd
StasPI/Stepik.org
/Программирование на Python/дележ пирога.py
245
3.859375
4
a = int(input()) b = int(input()) x1 = a if a == b: print(a) elif a % b == 0 or b % a == 0: if a > b: print(a) else: print(b) else: while x1 % b != 0: x1 += a if x1 % b == 0: print(x1)
a318e2d5e22ddb7aec4e871d5a0168a7c3d897be
peterhchen/100-Python-Basic
/21-30/ch22_while/22_while.py
92
3.796875
4
# initialization, condition, increment i = 1 while i <= 5: print ('Hello') i=i+1
1cdb43689a3d671465d7686810a19f3506640c6d
suyashgupta01/DFA-and-NFA-using-Python
/DFA.py
1,438
3.8125
4
N = input("Enter number of states N in the DFA (the states will be 0 through N-1): ") # states = 0,1,2,....N-1 num_of_accepting_states = input("Enter number of accepting states: ") accepting_states = [] for i in range(int(num_of_accepting_states)): accepting_states.append(input("Enter accepting state " + str(i) +...
0543a257b9b83b7a594b0dfa4a3eb3550b9ba758
praveenct7/265450_Ltts_python_learning
/If_else_if/Check_abbreviation.py
273
3.953125
4
def full_form(str): if str == "Brb": print("Be right back") elif str == "OOTD": print("Outfit of the day") elif str == "Ikr": print("I know right") else: print("Sorry, couldn't find the answer") str = input() full_form(str)