blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
29f90515de93cb715e9294348d6c87d34f572073
dorabelme/Python-Programming-An-Introduction-to-Computer-Science
/chapter3_programming6.py
698
4.4375
4
# This program calculates the slope of a line through two points def main(): # Title of the program print("Slope Calculator") #Pbtain the coordinates of the 2 points from the user print("To enter the coordinates of the point (x1, y1) you will need to " +\ "type the coordinates without the parantheses seperated ...
79567dc19105b2df33b71883a8e38d00d5244a5c
koohanmo/pythonStudyNote
/PythonBasic/1. Print.py
1,026
4.0625
4
""" 파이썬의 주석은 #(라인) 과 (""" """)(블록) 을 사용할 수 있다. """ # input name = input('name?') print (name) #정수 값 입력받기 n = int(input('int : ')) print (n, type(n)) #줄바꾸기 하지 않고 print 마지막에 취하는 자동처리 문자 바꾸기 print (1,2); print (3,4) #두줄로 출력이 된다. print(1,2, end=' '); print(3,4) #한줄로 출력이 된다. #출력시키는 문자 사이에 구분자 넣기 print(1,2,3,4,5)...
7711f3f717eb6360702d77ca0af2a7bf4b230e4f
zeroam/TIL
/books/PythonCleanCode/ch5_decorator/decorator_side_effect_2.py
835
3.8125
4
"""Clean Code in Python - Chapter 5: Decorators > Example of desired side effects on decorators """ EVENTS_REGISTRY = {} def register_event(event_cls): """Place the class for the event into the registry to make it accessible in the module. """ EVENTS_REGISTRY[event_cls.__name__] = ev...
55e95803c383eac63e8264493ce015d5ce7ad484
sach999/ScriptingLab
/ScriptingLab/SEE/4a.py
295
3.9375
4
class rectangle: def __init__(self, length, breadth): self.length = length self.breadth = breadth def area(self): area = self.length*self.breadth print("Area is : ", area) ob1 = rectangle(2, 3) ob1.area() ob2 = rectangle(8, 7) ob2.area()
7390acf86140b910943a1fe1d484c9a327bcd69d
LizzieDeng/kalman_fliter_analysis
/docs/cornell CS class/lesson 5. User-Defined Functions/demos/pvr.py
491
4.0625
4
""" A module to demonstrate the difference between print and return The command print displays a value on screen, but it does not use that value when it evaluates the function. The command return instructs a function call to evaluate to that value. Author: Walker M. White Date: February 14, 2019 """ def print_plu...
cd4577412655c25992ace1a98e4c3c6e51c982b6
danila7777/pumpskill_1
/module2/dz_3_dictionary.py
927
3.953125
4
account1 = {'login': 'ivan', 'password': 'q1'} account2 = {'login': 'petr', 'password': 'q2'} account3 = {'login': 'olga', 'password': 'q3'} account4 = {'login': 'anna', 'password': 'q4'} user1 = {'name': 'Иван', 'age': 20, 'account': account1} user2 = {'name': 'Петр', 'age': 25, 'account': account2} user3 = {'name': ...
c823055c504bf16451c51a155ae0802843fb956f
K-State-Computational-Core/serialization-examples-python
/binary/Person.py
676
3.78125
4
class Person: def __init__(self, name, age, pet): self.__name = name self.__age = age self.__pet = pet @property def name(self): return self.__name @name.setter def name(self, name): self.__name = name @property def age(self...
bed20d6bc14435d320b27978c19c37f6d3ec7bac
ncruzz/python-challenge
/PyBank/main.py
1,194
3.953125
4
import os import csv print("Financial Analysis") print("------------------------") bankCSV = os.path.join('Pybank_data.csv') Months = [] Total_revenue = [] Monthly_Rev = [] with open(bankCSV, 'r') as csvfile: csvreader = csv.reader(csvfile, delimiter=',') header = next(csvreader) for row in csvreader...
11cc4e82a74f71bf0c395392b69bb827e5719544
ferryleaf/GitPythonPrgms
/arrays/rotate_array.py
1,792
4.15625
4
''' Given an unsorted array arr[] of size N, rotate it by D elements in the COUNTER CLOCKWISE DIRECTION. Example 1: Input: N = 5, D = 2 arr[] = {1,2,3,4,5} Output: 3 4 5 1 2 Explanation: 1 2 3 4 5 when rotated by 2 elements, it becomes 3 4 5 1 2. Example 2: Input: N = 10, D = 3 arr[] = {2,4,6,8,10,12,14,16,18,20} ...
5677688f087d18a77226cd2e6b9473733fc22426
gingerheef003/SomeRandomProjects
/PopulationGrowth/GeometricallGrowth.py
401
3.78125
4
#geometrical mean method from math import exp init_pop = float(input('Enter the initial population: ')) geom_mean = float(input('Enter the geometrical mean: ')) y = int(input('Enter the number of years: ')) pop = init_pop for i in range(y): a = i+1 pop = pop * (1 + geom_mean/100) print(f'Population after...
f2e3dfe97b89a6c6cf4543ef6b4cb84d6128b4d0
Aasthaengg/IBMdataset
/Python_codes/p03377/s286663310.py
128
3.515625
4
A,B,X=map(int,input().split()) if A>X: print("NO") elif A==X: print("YES") elif (X-A)<=B: print("YES") else: print("NO")
c221099522f823c4803c1b5a86ee5342d3da805d
OvchinnikovaNadya/coursePython1
/Example_24_test.py
485
3.671875
4
# Тест на базе unittest import unittest import strings class TestUpper(unittest.TestCase): def test_one_word(self): text = 'hello!' result = strings.upper_text(text) self.assertEqual(result, 'HELLO!') self.assertNotEqual(result, 'hello!') def test_multiple_worlds(self): ...
8e53f605efa497d5738758f46bbd9d70e6efbdd4
VineetMakharia/LeetCode
/144-Binary-Tree-PreOrder-Traversal.py
837
3.734375
4
class Node: def __init__(self, val = 0, left = None, right = None): self.val = val self.left = left self.right = right class Solution: def preorderTraversal(self, root): # Preorder is NLR if not root: return [] return [root.val] + self.preorderTraver...
59b0a79f96105041f1dac6eff42b806803c3db88
jeremyanywhere/GIAPractice
/giatest.py
2,526
3.8125
4
import random import time import string import sys def report(section, quiz, seconds): score = 0 q = 0 for r in quiz: q+=1 mark = "" if (str(r[1][0])==r[1][1]): score+=1 else: mark = '*' print (f" {q}) [{r[0]} = {r[1][0]} - your answer: {r[1][1]} {mark}") print("") print(f"Report: {section}")...
c29a5e3a2a8fdc1c50d55c51908381d70fdc0857
ZGingko/algorithm008-class02
/Week_06/221.maximal-square.py
1,333
3.640625
4
from typing import List class Solution: def maximalSquare(self, matrix: List[List[str]]) -> int: """ 221. 最大正方形 在一个由 0 和 1 组成的二维矩阵内,找到只包含 1 的最大正方形,并返回其面积。 示例: 输入: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0...
7eb853e9172203750c1b0334dbfbf99dc3489ec1
EdiTV2021/Python_2021
/While_ejer1.py
261
3.75
4
# -*- coding: utf-8 -*- """ Created on Mon Aug 2 18:21:51 2021 @author: Edison """ contar=int(input("ingrese el # de veces del contador: ")) contador=1 while contador<=contar: print (contador) contador+=1 #contador= contador+1
83e01f06beed645a5433d2fcd98dd8fc9f49790e
ctkhushboos/Python-Algorithms-And-Data-Structures-Club
/sorting/heap_sort.py
647
4.125
4
""" Sorts an array from low to high using a heap. A heap is a partially sorted binary tree that is stored inside an array. The heap sort algorithm takes advantage of the structure of the heap to perform a fast sort. To sort from lowest to highest, heap sort first converts the unsorted array to a max-heap, so that th...
881bdb21ac58e02f7046ab627519ce073fe76b62
adolfoDT/FrameworkSciencetest
/exercises_1.py
1,590
4.4375
4
__author__ = 'Adolfo Diaz Taracena' __version__ = '1.0' __all__ = ['Exercise 1', 'Triple_Number'] def triple_number_iterative(n,numbers): if n == 1: result = numbers[0] elif n == 2: result = numbers[0] elif n == 3: result = numbers[2] elif n > 3: ...
4323f0297170099370f68231a0ac7de111883f4e
Priyansi/pythonPrograms
/armstrong.py
430
3.515625
4
import sys START, LIMIT = int(sys.argv[1]), int(sys.argv[2]) def make_armstrong(a: int, b: int) -> [int]: return [x for x in range(a, b) if is_armstrong(x)] def is_armstrong(n: int) -> bool: return n == sum(cubes(digits(n))) def cubes(ds: int) -> int: return [d**len(ds) for d in ds] ...
1e5f2e0a148d9c54dc6b5d0605bd2b47e37ff750
zhuyoujun/complier_virtual
/leetcode/100_SameTree.py
1,430
3.96875
4
##https://oj.leetcode.com/problems/same-tree/ ##Given two binary trees, write a function to check if they are equal or not. ##Two binary trees are considered equal ##if they are structurally identical and the nodes have the same value. class TreeNode: def __init__(self,data): self.data = data self.left = None ...
666200e4b95f1857d0ebab829419acc4a356dabd
mrhallonline/Tkinter-measurement-conversion-widget
/convertWidget.py
829
4
4
from tkinter import * window = Tk() def convert_measurement(): convert_grams = float(input_kg.get())*1000 convert_pounds = float(input_kg.get())*2.20462 convert_ounces = float(input_kg.get())*35.274 t1.delete("1.0", END) t2.delete("1.0", END) t3.delete("1.0", END) t1.insert(END, convert_gr...
616de421080cff5e8627d5e8ad80ae40b880f2d0
vermouth1992/Leetcode
/python/522.longest-uncommon-subsequence-ii.py
2,650
3.71875
4
# # @lc app=leetcode id=522 lang=python3 # # [522] Longest Uncommon Subsequence II # # https://leetcode.com/problems/longest-uncommon-subsequence-ii/description/ # # algorithms # Medium (34.28%) # Total Accepted: 25K # Total Submissions: 73K # Testcase Example: '["aba","cdc","eae"]' # # Given an array of strings st...
80a8066c0826ba8be97fd203e76ae63b1c53ff11
Evalle/python3
/Sums/2.py
236
3.890625
4
#!/usr/bin/env python3 import time def sum_of_n(n): start = time.time() sumn = (n*(n+1))/2 end = time.time() return sumn, end - start for i in range(5): print("Sum is %d required %10.7f seconds" % sum_of_n(1000))
2049fc89a5a615f4d9276d4ef229daa916ab3212
NARESHSWAMI199/python
/python/error_expection.py/raise_error.py
388
3.765625
4
class Animal: def __init__(self,name): self.name = name def sound (self): raise NotImplementedError("sorry must implement sound mehod in your class") class Dog(Animal): def __init__(self,name,breed): super().__init__(name) self.breed = breed def sound(self): ...
e4d0ffcfc5349c269e134c45d98abb7fbc2b94b5
0ce38a2b/MITx-6.001
/Problem Set2/Problem 1.py
1,387
4.6875
5
''' To help you get started, here is a rough outline of the stages you should probably follow in writing your code: For each month: Compute the monthly payment, based on the previous month’s balance. Update the outstanding balance by removing the payment, then charging interest on the result. Output the month, the ...
259175abf10634dbca1214358fe07660d660f9f9
tigerjoy/SwayamPython
/cw_2021_08_07/bracket_mathcher.py
1,797
4.15625
4
def push(item): global top, STACK # We are inserting for the first time # Hence, set top to 0 # if top is None: if is_empty(): top = 0 # When inserting elements from second time # onwards, we increment top by 1 else: top += 1 STACK.append(item) print(item , "INSERTED INTO STACK") def pop():...
9acdf10e8e9c34b807dff03bea3b2986b6211b00
CiaronHowell/weather-app
/WeatherApp.py
2,159
3.921875
4
#GUI toolkit import tkinter as tk import http.client as httplib import json class WeatherGUI(tk.Frame): def __init__(self, parent): tk.Frame.__init__(self, parent) self.enter_city_label = tk.Label(self, text="Enter City") #Creating the textbox for the user to enter their city self...
050f290d2c62a791622898b8654dd3521dc0e44e
reyuan8/algorithms
/binary_search.py
448
3.859375
4
def binary_search(arr: list, item: int, low: int = 0, high: int = None) -> int: if high is None: high = len(arr) - 1 mid = (low + high) // 2 guess = arr[mid] if low > high: return None if guess == item: return mid if guess > item: high = mid - 1 return bin...
f1e24c7fcbd729d079ec892f6c01e547f2f1696a
englens/cardy-cards
/game_objects/player.py
9,076
3.546875
4
from . import row from . import shop from . import card from sqlite3 import DatabaseError DEFAULT_NO_ROWS = 1 PLAYER_WINDOW_WIDTH = 40 class Player: """Object oriented representation of a player.""" def __init__(self, sql_connection, sql_id): self.conn = sql_connection self.cursor = self.conn...
f5d503585e2752b84a3f52b0106494fe2a36e653
Gadiel09/PROJETOS-COM-GUI
/JOGO__JOKENPO(GUI).py
7,648
3.546875
4
from tkinter import * import time import random def TESOURA(): if btn_tesoura["text"] == "TESOURA": papel = 0 tesoura = 1 pedra = 2 jogadas = [ tesoura, papel, pedra ] comp = random.choice(jogadas) name_papel = "0" name_tesoura = "1" name_pedra = "2" if tesoura == comp: name = name_...
9adbd905be5d7e2aa9c6b66364dce5951d3838f9
acappp/AFPwork
/Part 4 + 5, Dna Sequencing HW.py
1,114
4.09375
4
# Keeps all suspects on record, Only one now for simplicity Suspect = "GCGGCTGATGCGCAAGACGATAGGCGGGGTTATAGCGCGGCAGCGCGTTCTCCTGAGGTCATCCTGGTCCTACTATACAACCGAGAGGACTGATT" \ "GATTGACAACGCTGCGATTACACAGACGGAGCATAACTGTGTATCTCCTATGGCCCCTTCACATAGACAACGGAGCCCGAGTATGGACGCGCAGG" \ "TTAACACCTGGCTCCAGAATACTTCACTA...
a644aeb7e261d3585c5723f208de2c0d3266e0ec
tsutterley/read-ICESat-2
/icesat2_toolkit/convert_delta_time.py
2,356
3.734375
4
#!/usr/bin/env python u""" convert_delta_time.py (04/2022) Converts time from delta seconds into Julian and year-decimal INPUTS: delta_time: seconds since gps_epoch OPTIONS: gps_epoch: seconds between delta_time and GPS epoch (1980-01-06T00:00:00) ICESat-2 atlas_sdp_gps_epoch: 1198800018.0 OUTPUTS: ...
0698e5171fae8aee9f949b3512c56bfd3a3ddb23
RimaMondal/Python_Learn
/first.py
158
3.640625
4
print('Hi') print("rima") print(2+3) print(5//2) print(2**3) print("navin's laptop") print('navin "laptop" ') print('navin\'s "laptop" ') x=2 y=0 print(x+y)
f1ba78802350c15ae36be5b91a98ee17de210312
ramyasutraye/python--programming
/hunter level/reverseeverywordinthestring.py
165
3.53125
4
str=raw_input().split() length=len(str) for i in range(0,length): s=str[i] l=[] for i in range(1,len(s)): l.append(s[-i]) l.append(s[0]) print "".join(l),
850af8c62eaf07ba77e6f610bb9abd72dbf4287d
shivapk/Programming-Leetcode
/Python/arrays/maxSumsubarray[n,1].py
573
3.796875
4
#Maximum sum subarray #outputs size #output of [1,2,3,-1] is 6 #time=O(n) #space=O(1) #Basically, keep adding each integer to the sequence until the sum drops below 0. #If sum is negative, then should reset the sequence. class Solution: def maxSubArray(self, nums): ans=nums[0] s=0 #sum for ...
f29d1c02ebe5083a089c504c8880095a6a0b57c9
UFResearchComputing/py4ai
/solutions/130_solution_07.py
388
4.0625
4
def print_egg_label(mass): #egg sizing machinery prints a label if(mass>=90): return("warning: egg might be dirty") elif(mass>=85): return("jumbo") elif(mass>=70): return("large") elif(mass<70 and mass>=55): return("medium") elif(mass<50): retur...
fc0e859727d06d2e7d13b9f6afb518bceed25c38
zhengw060024/pythoncookbookpractice
/exCookbook4.12.1.py
178
3.828125
4
#在不同的迭代器中迭代 from itertools import chain a = [1,2,3,4] b = ['x','y','z'] for x in chain(a,b): print(x) #使用这种方法可以减少独立的循环数目
19c8825cd5c3c690d3e783517f87a61c9fe82e0c
sharondevop/learnpythonthehardway
/ex20.py
995
4.1875
4
from sys import argv script, input_file = argv # Create a function to print the contant of a file. def print_all(f): print f.read() # Create a function to postion the read a head to the start of a file. def rewind(f): f.seek(0) # Create a function to print one line. def print_a_line(line_count, f): prin...
13302ec0c4c3299e328cf39e7600d807a4509ec8
lynnxlmiao/Data-Analysis
/Notes/Data Wrangling (SQL)/Relational DB SQL/L9 Quiz/Getting Musicians.py
1,359
3.53125
4
## Now that we know that our customers love rock music, we can decide which musicians to ## invite to play at the concert. ## Let's invite the artists who have written the most rock music in our dataset. ## Write a query that returns the Artist name and total track count of the top 10 rock bands. QUERY =''' SELE...
25759d8ca5dbfa5a3d74e2c275dffa505784f668
tanu1208/Python
/Kattis/Planina.py
270
3.734375
4
initial_side = 2 #at initial state a side ocntains 2 points iteration = int(input()) num_of_points = initial_side for i in range(iteration): points = (initial_side + (initial_side - 1)) num_of_points = points**2 initial_side = points print(num_of_points)
16fdcb8fa39eeff6ccb2ce4292bea1e96f0d7af5
nkyimujin/yimujin1
/python-learn/列表-堆栈.py
335
3.5
4
a = [1, 3, 4, 5, 7] print(a) print(a.append((int(input('请输入要添加到列表的数字\n'))))) if True: print(a) a.append(1) print(a) a.sort() x = len(a) # len(list)统计列表中的元素数量 while x > 0: x = x - 1 print(a.pop()) print('此程序为添加一个元素到列表尾部,并从尾部删除元素')
861be75b5801db07df390122a60559ea9569fd35
mocap-ca/pythonSchool
/class4/lambdas.py
229
3.625
4
from functools import partial def val(a): return int(a) a = ["100", "4", "11", "2", "15", "6"] for i in sorted(a, key=val): print(i) for i in sorted(a, key=lambda v: int(v)): print(i) print(lambda v: int(v))
b517dae71b2b9fea038c590fe9809acb82e9588d
thiagor83/estudos
/PhytonExercicios/ex044.py
824
3.734375
4
print('{:=^40}'.format(' THIAGO ')) for c in range(1, 6): #conta de 1 a 5 porque no 6 sai do laço print(c) print("Fim") for c in range(6, 0, -1): #conta de 6 a 1 ou seja voltando número e para no 1 porque no 0 sai do laço print(c) print("Fim") for c in range(0, 7, 2): # conta de 0 a 6 de dois em dois pri...
1eb3299b9d8cb40f84449eb69a9eee510bd1bbf8
marcobelo/DSA
/Search_Algorithms/1-sequentialSearch.py
361
3.84375
4
def sequentialSearch(data, item): for value in data: if item == value: return True, 'Found {}'.format(item) return False, 'Not found {}'.format(item) input = [12, 7, 5, 9, 51, 8, 1, 10] item_1 = 5 item_2 = -4 bol, result = sequentialSearch(input, item_1) print(result) bol, result = seque...
f3feb87e1a059f8a98bdcbc1eb87ea4e0fe7471f
MariusCPop/F4
/FileHandling/00_basics.py
1,199
3.8125
4
### File handling basics https://realpython.com/working-with-files-in-python/ https://realpython.com/read-write-files-python/ my_file = open('test.txt') try: print(my_file.read()) print("It worked") # print(my_file.read()) # print("It did not print") # my_file.seek(0) # print(my_file.read()) ...
4795f968344891bb1ea93cc975408e869073f35e
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_201/1276.py
1,647
3.515625
4
import math def distance(N, K): """ returns min(Ls, Rs), max(Ls, Rs) """ if N == 1: return 0, 0 if K == 1: return (N-1)//2, N//2 lv = int(math.log(K, 2)) # how many levels we'll go down this "binary tree split" # note that if K == 2**N-1, we'll technically complete the last level, # bu...
916538cb3f4245ab0f861654253b42845361e3fd
mc422/leetcode
/209_Minimum_Size_Subarray_Sum.py
728
3.53125
4
# 209. Minimum Size Subarray Sum import sys def minSubArrayLen(s, nums): """ :type s: int :type nums: List[int] :rtype: int """ i, j = 0, 0 sum = 0 ans = sys.maxint while j < len(nums): sum += nums[j] while i <= j and sum >= s: if sum == s: ...
7cc4557dccb3ad03f7ca5e11e6241ac25c1e5441
harish988/Code-Kata
/beginner/beginner8.py
69
3.765625
4
n = int(input()) sum = 0 for i in range(1,n+1): sum += n print(sum)
841c8cd742074f8266e1955cc5d98be56752c450
SamuelPollock/python
/python_class.py
1,342
3.90625
4
# -*- coding:utf-8 -*- # Python类里self和cls都可以用别的单词代替,类的方法有三种, # # 一是通过def定义的,需要至少传递一个参数,一般用self,必须通过一个类的实例去访问; # # 二是在def前面加上@classmethod,需要至少传递一个参数,一般用cls,支持类名和对象两种调用方式; # # 三是在def前面加上@staticmethod,参数可以为空,支持类名和对象两种调用方式; class A: member = "Hello" def __init__(self): print "__构造函数__" def print1(s...
d9a670cad982b46d78aba952b4e7276183f5e088
stevenwongso/Python_Fundamental_DataScience
/4 NumPy/35.numpy_np_random.py
439
3.65625
4
import numpy as np a1 = np.random.random(10) # random 10 elements which value between 0-1 print(a1) x1 = np.random.rand(10) # random 10 elements which value between 0-1 x2 = np.random.rand(2,4) # 2 array with 4 random (0-1) val on each array print(x1) print(x2) y1 = np.random.randint(10, size=10) y2 = n...
36e3f0354a3e020ee3968e8efccb4e73c18c88d8
TheRealAlexSong/Learning-Python
/collatz.py
607
4.375
4
# Collatz Sequence from Automate the Boring Stuff chapter 3 # define the collatz function def collatz(number): if number % 2 == 0: print(number // 2) return (number // 2) elif number % 2 == 1: print(3 * number + 1) return (3 * number + 1) # prompt user to input numbe...
9248166ac95a3b867794e7308456a5fd33ef69fc
wilfredlopez/python-exersises
/shape_calculator.py
1,590
3.84375
4
# https://repl.it/repls/ShrillDarkcyanVirtualmachine#main.py import math class Rectangle: def __init__(self, width: int, height: int): self.width = width self.height = height def set_width(self, width: int): self.width = width def set_height(self, height: int): self.heigh...
19da616bfb414255fff92ef08120507197cb021a
bijilbabu/LearningPython
/Nijil's Assignment/Question_5.py
316
3.609375
4
#Name: Nijil K Babu #PGID: 71721084 #Question 5 def triangle(a,b,c): if ((a + b > c ) and (a + c > b) and (b + c > a)): return "Yes" else: return "No" #test cases print("Triangle can be created!!!",triangle(7,10,5)) # yes print("Triangle can be created!!!",triangle(5,3,8)) # ...
82ce98ff48291049bb0ee7d8837288de4d54928e
ashokbezawada/Data-Structures
/Array/zeroes_to_end_subarray.py
525
4.125
4
# The main goal of this function is to move all zeroes to the end of the sub array # for example lst = [0,4,0,1,2,0,3] output should be [4,1,2,3,0,0,0] # The function takes argument as an array that has to be moved def move_zeroes_to_end(lst): boundary = len(lst) - 1 for i in range(len(lst)-1,-1,-1): ...
11b7879bcbca4c540b1cfe9666755aec0a4f3e63
kimberlymartin/Lab-8
/Python Lab 8 Game.py
2,306
3.8125
4
import random print "A monster approaches! Prepare to fight!" damageByMonster = random.randint(1,35) playerHealth = 100 monsterHealth = 100 punchDmg = 5 swordDmg = 10 fireballDmg = 30 mana = 5 print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" print "You have " + str(playerHealth) + " health." print "The...
ac8867375d1e7645fc7f8d57f2308bef33a375f7
odify/PORT-OF-PYTHON
/CLI/story-cli/story.py
863
3.59375
4
#!/usr/bin/env python3 from random import choice import pyfiglet result = pyfiglet.figlet_format("Story generator") print(result) # print("\n") # describtion-row print("------------------------------------") def story_gen(): wer = ['Ferdi', 'Rene', 'Malina', 'Sarah'] was = ['aß Obstsalat mit Stäbchen', 'fl...
d301533dabc446a245ffc40bed1feb1b6ed4df86
jalicea/lab_14_all_parts
/go_for_gold.py
636
4.375
4
""" go_for_gold.py ===== Translate an athlete's finishing placement (1st, 2nd and 3rd) into its Olympic medal value: 1 for gold, 2 for silver, 3 for bronze and anything else means no medal. Do this by asking for user input. For example: What number should I translate into a medal? >1 gold What number should I tr...
486cb01ba1860d6554909d4ac4a5c7af3dc4f069
lmcci/py_code
/05语法高级/py11_递归.py
235
3.609375
4
# 函数内部调用自身 # 递归都要有一个出口 一个条件不满足的时候不再调用自身 # 数字累加 1 ~ N def get_sum(num): if num == 0: return 0 return num + get_sum(num - 1) print(get_sum(4))
c154fca568db57741a217a96cb40d2ce8d0644d3
ken626014896/python-practice
/leetcode/请用一行代码 实现将1-N 的整数列表以3为单位分组.py
172
3.8125
4
# [ab for i in range(5)] # ab不一定要是与i有关 #以下为例子 print([1 for i in range(5)]) print([[x for x in range(1, 100)][i:i + 3] for i in range(0,101, 3)])
02294da9d918a987b69db6ebfe84bbcb97cf65f6
LawCheung1996/PYFE-Practice
/Chapter2Exercise2.py
78
3.703125
4
print ("Enter your name: ") username=input() print ("Hello " + str(username))
87c4c08c04b7cf56a9d8f5ec8636771b027b3371
Takudzwamz/Algorithms-in-python1
/_2laba.py
1,636
3.96875
4
from random import randint while True: print("Options:") print("Enter '1' for first easy option: ") print("Enter '2' for second pro programmer option: ") print("Enter '3' toend the program: ") user_input = input(": ") if user_input == "5": break elif user_input == "1": symbo...
51365c6bd84287c7563c2a105bf7c8c8ef4188f5
i-aditya-kaushik/geeksforgeeks_DSA
/Matrix/Codes/mat_spiral.py
2,762
4.40625
4
""" Spirally traversing a matrix Given a matrix mat[][] of size M*N. Traverse and print the matrix in spiral form. Input: The first line of the input contains a single integer T, denoting the number of test cases. Then T test cases follow. Each testcase has 2 lines. First line contains M and N respectively separated b...
4f8ceb2f216a2f8d87271d63f1f603dfbeb93532
trendels/aoc2020
/day16/day16.py
4,414
3.546875
4
#!/usr/bin/env python3 from collections import defaultdict from functools import reduce import operator def parse_input(f): rules = {} ticket = None nearby_tickets = [] state = "rules" for line in f: line = line.strip() if not line: continue if line == "your tic...
28ca45eeac8780d776d6b2914fcb4c82bb236a86
rsmith92/CD_Simulator
/PythonChangeDirectorySimulator/change_directory.py
7,445
4
4
# Directory class represents each hypothetical directory class Directory: # the init method deals with the root node as well as all others def __init__(self, a_name, a_parent): # all nodes will start with a given name and a self.name = a_name self.children = [] # this branch is...
1bba20270cbfcfdcb7a4556a8d784269005cc394
Zigje9/Algorithm_study
/python/dijkstra.py
1,133
3.515625
4
import heapq INF = 2e9 graph = { 1: {2: 2, 4: 1, 3: 5}, 2: {1: 2, 4: 2, 3: 3}, 3: {1: 5, 2: 3, 4: 3, 5: 1, 6: 5}, 4: {1: 1, 2: 2, 3: 3, 5: 1}, 5: {4: 1, 3: 1, 6: 2}, 6: {5: 2, 3: 5} } # 한 정점으로부터 모든 노드 까지의 최단거리 def dijkstra(city, start): route = {} for node in city: route[nod...
984c941993cc33ef311c79e419b49530b6097b31
sarathsankar3690/Djangopython
/Flow controls/Looping/checking prime number.py
206
3.9375
4
n=int(input("Enter the number: ")) flg=0 for i in range(2,n): if (n%10==0): flg=1 break else: flg=0 if (flg==0): print("prime number") else: print("not prime number")
c122ee40ab67d42045fc8b6fe8d01f3132c5caad
sushilrajeeva/Python-Infosys
/3. Iteration Control Structure/Exercise 1/SumOfNumbers.py
351
4.21875
4
def find_sum_of_digits(number): sum_of_digits=0 n=number while(n>0): sum_of_digits+=n%10 n=n//10 #Write your logic here return sum_of_digits #Provide different values for number and test your program sum_of_digits=find_sum_of_digits(123) print("Sum of digits:",sum_of_digits) ...
fc3b5af058118e95a8189637ec12f743b9082065
Pasupathi9897/testdemo
/w1.py
222
3.65625
4
print(round(2.2222,3)) x=5 print(eval('x+4')) n=[1,2,3,4,5] sum=0 for var in n: sum+=var else: print("no items left") print(sum) x=1.2334432432123 print("the value is %.100f"%x) print((1,2,3)+(1,2,3))
8fafdc6d0823bb253a233a694fd88f3731815992
okaysidd/Interview_material
/Extras/231. Power of Two.py
513
4.03125
4
""" 231. Power of Two Given an integer, write a function to determine if it is a power of two. Example 1: Input: 1 Output: true Explanation: 20 = 1 Example 2: Input: 16 Output: true Explanation: 24 = 16 Example 3: Input: 218 Output: false """ class Solution: """ Trivial question but trick of (binary) & is importa...
44480c5458ebf91592395358710602a83c39c175
Andremarcucci98/CursoEmVideo
/PythonAulas_Desafios/Desafios/Desafio18.py
238
4.03125
4
from math import cos, sin, tan, radians n = float(input('Digite um ângulo: ')) c = cos(radians(n)) s = sin(radians(n)) t = tan(radians(n)) print(f'O ângulo digitado é {n}° \ncosseno = {c :.3f} \nseno = {s :.3f} \ntangente = {t :.3f}')
6c158792aff125dd268ee059b1a8373f4c5c2735
Programmer-Admin/binarysearch-editorials
/Top View of a Tree.py
515
3.65625
4
""" Top View of a Tree We perform a regular BFS, with the position of the nodes relative to root. We overwrite the value if it hasn't been seen to emulate the projection. """ class Solution: def solve(self, root): top={} q=[(root, 0)] while q: node,pos = q.pop(0) if...
0c85ac7369704b6fd9ba2c3b75263973edd04f97
Sangmin-Lee/MyPython
/Test0909/Test0909/Test0909.py
2,521
3.703125
4
dic1 = {} dic2 = dict() dic = {'name':'pey', 'phone':'01051035773'} print(dic['name']) #pey dic['birth'] = '1212' print(dic) #랜덤출력 del dic['name'] print(dic.keys()) #key값 print(dic.values()) #value값 b = list(dic.keys()) #리스트로 반환 print(b) b = dic.items() #튜플로써 묶여진 형태의 값을 반환 print...
aae9c9849851abd6c33e5b00bfedb49068b6c64e
william-learning/python
/cel_to_fahr.py
245
3.59375
4
def cel_to_fahr(C): if C < -273.15: return "That temperature doesn't make sense!" else: F = C * 9 / 5 + 32 return F temperatures = [10,-20,-289,100] for c in temperatures: print(cel_to_fahr(c))
96eabcb4d50080c8c4a099a4df505c292d9b6ae6
sandipthapa99/365-Days-of-Coding
/126-No numerals.py
475
4.25
4
dict = {'1':'one','2':'two','3':'three','4':'four','5':'five', '6':'six','7':'seven','8':'eight','9':'nine','0':'zero',} text = input("Original text: ") myList = text.split() for words in myList: if words in dict: text = text.replace(words,dict[words]) print(text) # ------ # Input: # ------------...
526527484c6a3cd323b62ef36fc772ab343e7934
adam147g/ASD_exercises_solutions
/Offline tasks/Offline_task_10/zad10.py
3,614
3.703125
4
class BSTNode: def __init__(self, key): self.key = key self.left = None self.right = None self.parent = None def find(root, key): while root is not None: if root.key == key: return root elif key < root.key: root = root.left else: ...
9b91ee6f405e2901bfd78aff05be3378772f7153
clopez5313/Python
/1. Become a Python Developer/10. Python - Decorators/Introduction/myDecorator.py
357
3.9375
4
def my_decorator(func): '''Decorator function''' def wrapper(): '''Return string F-I-B-O-N-A-C-C-I''' return 'F-I-B-O-N-A-C-C-I' return wrapper @my_decorator def pfib(): '''Return Fibonacci''' return 'Fibonacci' print(pfib()) # Use the decorator without the annotation. # output = ...
feb39bb7051d0841da66748965a6a7ada4c69083
LuanRamalho/Quadrado-2
/Quadrado 2.py
231
3.671875
4
from turtle import * def quadrado(lado): #Desenha um triangulo de lado. color('black', 'green') begin_fill() for i in range(3): forward(lado) left(90) end_fill() quadrado(220) done()
52a481b6a5d95773ddeace42a92422e38671a525
floydchenchen/injury-predictor
/data/machine-learning.py
1,750
3.640625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Mar 28 22:47:59 2018 @author: chenshihao """ # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset # dataset = pd.DataFrame.from_csv('data_set.csv') dataset = pd.read_csv('new_set.cs...
4079334ea24401ff3d6c7f9ead305d4ce5c52653
arkeros/project-euler
/problems/power_digit_sum.py
287
3.5
4
from utils import iter_digits __author__ = 'rafa' def solver(): """ 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2^1000? """ assert sum(iter_digits(2**15)) == 26 return sum(iter_digits(2**1000))
11fb919ef6077248b980434d3493157fc075aec5
setti11/Mypractise
/ex3_6.py
130
3.921875
4
print ("Hello World, I am doing tables multiplication values") num = 3 for i in range(1,11): print (num,'x',i,'=',num*i)
db6fac26a5341f9c7f04a720dc052a133edee8e5
cocoon333/lintcode
/526_solution.py
1,411
3.953125
4
""" 526. Load Balancer 中文 English Implement a load balancer for web servers. It provide the following functionality: Add a new server to the cluster => add(server_id). Remove a bad server from the cluster => remove(server_id). Pick a server in the cluster randomly with equal probability => pick(). At beg...
dbe13a5912977cf782fdfe09063a28b0e64ae803
JackieBinBin/zzh1988
/fin_290_hw2/fin_290_05_a.py
1,511
3.96875
4
# The lazy way # import numpy as np # # a = [52,69,35,65,89,15,34] # b = np.mean(a) # c = np.median(a) # print(b) # print(c) ###################################### N = int(input('Please input a interger number: ')) # Generate a random list of numbers of length N import numpy as np # 通过numpy的randint方法,生成100内的随机数 N个...
f0ae1a547241825cd80d83c529e5c533f82ac341
eronekogin/leetcode
/2020/search_a_2d_matrix_ii.py
1,075
4
4
""" https://leetcode.com/problems/search-a-2d-matrix-ii/ """ from typing import List class Solution: def searchMatrix(self, matrix: List[List[int]], target: int) -> bool: """ Since all the rows and columns are sorted, starting scanning the top right corner: 1. If the target i...
810cad40ab244d84dfba557b8faeba3a55476e42
tliu57/Leetcode
/GAlgorithms/NextPermutation/test.py
758
3.515625
4
class Solution(object): def nextPermutation(self, nums): length = len(nums) if length < 2: return i = length - 1 while i > 0: if nums[i-1] < nums[i]: break else: i -= 1 if i == 0: self.reverseSort(nums, 0, length-1) return else: val = nums[i-1] j = length - 1 while j >= i: ...
e56ed204f455487a897de469b7eebaec782115a5
GlebovAlex/2020_eve_python
/Lasya_Homework/SumNonNegetive.py
575
4.21875
4
''' Write a Python program to get the sum of a non-negative integer ''' def sumdigits(num, result): """ :param num: input number :param result: sum of digits in input number :return: returns result This function calculates the sum of all digits in a number """ while num > 0: ...
c8374cf5c47b2113c4f8a14949dc3c3f4a31977a
zhangyue0503/python
/ex/test11.py
192
3.828125
4
import time starttime = time.time() print('start:%f' % starttime) for i in range(10): print(i) endtime = time.time() print('end:%f' % endtime) print('total time:%f' % (endtime-starttime))
97d69cf0cfa86723b630a429bbd0b1c3ee1054c1
morganpare/7CCSMCMP_Programming_For_Data_Scientists
/week_1/lab_1.py
5,823
4.40625
4
print 'hello world' myname = 'Elizabeth' print 'Hello ' + myname my_first_name = 'Morgan' my_last_name = 'Pare' print 'Hello ' + my_first_name + ' ' + my_last_name yourname = raw_input ('What is your name?: ') print 'Hello ' + yourname your_first_name = raw_input ('What is your first name?: ') your_surname = raw_in...
89405b7d469623665db9a9b7c29bbb8eeaaee36a
Msamaritan/100-days-of-Python
/Day1_Band_Name_Generator.py
229
3.609375
4
print("Welcome to the custom band name generator!!\n") city = input("Please enter the city that you grew up in : \n") pet_name = input("Please enter your pet name! \n") print("The possible band name could be "+city+" "+pet_name)
77173e314955cff01a4516ed4bfc3a9b58834d49
NathanJiangCS/Algorithms-and-Data-Structures
/Insertion Sort.py
248
3.953125
4
#Insertion sort. Runs in O(n^2) time def insertion_sort(a): l = len(a) for i in xrange(1,l): j = i while j > 0 and a[j-1] > a[j]: a[j], a[j-1] = a[j-1], a[j] j = j-1 return a testArray = [1,3,5,2,4,6] print insertion_sort(testArray)
12971c5594e71be6af26218d6db339808921e934
uros96/OPPFA
/vezba01/zad1.py
281
3.890625
4
import sys if __name__=="__main__": n=input("Enter an number: ") n=int(n) i=0 sum=0 for i in range (0,n+1): sum+=i print("Sum of first "+ str(n) +" numbers is: "+ str(sum)) else: print("Something does not work. :/")
f4c27e130107a7488c97c0822e8ae640a03ff597
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/hamming/890d3856661e49dba91162bc1d52462a.py
109
3.625
4
def distance(string1, string2): return len([str1 for str1, str2 in zip(string1, string2) if str1 != str2])
324952853f9fed41f7c1c570389451475b6464b8
EugenSusurrus/project_euler_solutions
/P_1_25/P17_numberLetterCounts.py
3,508
4
4
""" If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used? NOTE: Do not count spaces or hyphens. For example, 342 (t...
41baee81296cde863b8a7495709e21519e51ce91
ihomya/LearnPython
/oop/hello.py
1,549
3.53125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ' a test module ' # 表示模块的文档注释,任何模块代码的第一个字符串都被视为模块的文档注释 __author__ = 'Michael Liao' # 使用__author__变量把作者写进去 import sys def test(): args = sys.argv # sys模块有一个argv变量,用list存储了命令行的所有参数 if len(args) == 1: print('Hello, world!') elif len(arg...
595434dabc24b9010105918ea778b38bd2080f00
MisterMomito/Learning
/Algorithms and Data Structures/Sorting Algorithms/QuickSortJoe.py
1,004
3.8125
4
def quick_sort(a): quick_sort2(a, 0, len(a) - 1) def quick_sort2(a, low, high): if high - low < 20 and low < high: quick_selection(a, low, high) # this is an improvement for smaller sets. # this used to be just the bottom if statement elif low < high: p = partition(a, low, high) ...
4012b29939f554736383a096069c529d9b190e76
Mageshwaran1997/magesh_codekata
/palindrome.py
133
3.5
4
n= int(input()) temp= n rev= 0 while (n>0): dig= n%10 rev= rev*10+dig n= n//10 if (temp==rev): print ("yes") else: print ("no")
5041d65eec4ca8ad84359090677daf8357b44174
anarkigotic/python-advance
/images/main.py
745
3.671875
4
from PIL import Image # ============== ABRIR UNA IMAGEN Y MOSTRARLA ========== # try: # img = Image.open("images/imagen2.jpg") # img.show() # except IOError: # print("No es posible abrir la imagen") # ========== Modo de las imagenes ============= try: img = Image.open("images/imagen3.jpg") img.con...
2c79896352bb999cc4cfcab5a8d3fef707d0a78a
sund0g/python
/revstr.py
3,122
4.5
4
# Example of in-place array reversal. Note that while sys.argv[] is considered # a list in Python, technically it is implemented from C as an array. # # Time/space complexity: O(n) where n is the length of the array, and the # array is only in the buffer. # # TODO: add recursion method import sys def convert_to_strin...
ccb36d9ad388d7089ba1441cb15b631721e3460a
thalals/Algorithm_Study
/SaeHyeon/문자열/1181.py
293
3.5625
4
import sys input=sys.stdin.readline t=int(input()) word=[] for _ in range(t): s=input().rstrip() word.append(s) new_word=list(set(word)) # new_word.sort(key=lambda x:len(x)) # new_word.sort(key=lambda x: x) e=sorted(new_word, key=lambda x: (len(x),x)) for i in e: print(i)
7e4d900510d1a36adb46a49d340a6451769ba1a2
muchiNoChi/uberAnalysis
/Uber_pickups_decision_tree_regressor.py
8,574
3.5625
4
#!/usr/bin/env python # coding: utf-8 # In[1]: get_ipython().run_line_magic('matplotlib', 'inline') # In[2]: import numpy as np import pandas as pd import math import operator from datetime import datetime # # Loading the data # For this problem '*Uber Pickups*' dataset was chosen. It represents the data for...
dbd312faa731678a3e0a907bd6461624f8a61a1c
betatester25/Python_training
/start.py
218
4.09375
4
age = 27 name = 'Eugene Kuznetsov' print('Возраст {} -- {} лет'.format(name, age)) print('{} станет программистом Python №1 в России и уедет работать в Google'.format(name))