blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
06f5a29c7f7dc8f1b2458f1689cf7df529e62b5e
asperaa/programming_problems
/tree/zigzag_traversal_of_tree.py
1,293
3.9375
4
"""Zigzag traversal of tree""" from collections import deque class TreeNode: def __init__(self, val): self.val = val self.left = None self.right = None def zigzag(root): if not root: return root result = [] level = [] queue = deque() queue.append(root) ...
fa3403ed0039f21928a102e1c84c42827ea6d55d
komtaki/atCoder
/contest_abc/153/d.py
231
3.609375
4
def solve(H): ans_attack = 0 hp = H enemy = 1 while hp > 1: hp = hp // 2 ans_attack = ans_attack + enemy enemy = enemy * 2 return ans_attack + enemy H = int(input()) print(solve(H))
2475e8224b37268619a53919f76c4e51391a7505
ay701/Coding_Challenges
/number/fibonacci.py
713
3.875
4
# Use recursion def fib(n): if n in [0, 1]: return n return fib(n-1)+fib(n-2) # print fib(5) # Use iterative def fib_iterative(n): n1 = 0 n2 = 1 cnt = 0 if n < 0: raise Exception('Error number') while cnt < n: print(n1) nth = n1 + n2 n1 = n2 ...
4ad92217ace34156b69228a48ba0cb2fe844cb2a
the-hobbes/hadoop_mapreduce
/part_2/reducer_hits_per_file.py
1,014
3.8125
4
#!/usr/bin/env python ''' Answer the following with this reducer: 1) Write a mapreduce to display thenumber of hits for each different file on the website Expected input is: filename timestamp Output should look like: filename total(number_of_hits) ''' import sys def reducer(): ''' Sum the total ins...
5b6eac3e41a094a3005143b9f23c1128a55c15ff
skariyadan/StaCIA
/queryparser.py
7,862
3.5
4
import re import nltk ''' parseQuestions(): parses query.txt file and creates 2 data structures, a questions dictionary keyed by linenumber and contains a list with the question and response; parse variable names from query.txt into a list ''' def parseQuestions(): questions = {} variables = [] i = 0 ...
f5027edebed58f6bb21c6812becd45789f90b2e3
weverson23/ifpi-ads-algoritmos2020
/Atividade_Semana_08_e_09/uri_1178.py
365
3.640625
4
def metade(x): # função que divide os valores e adiciona em cada # posição do vetor e depois imprime o resultado vet = [] for i in range(100): vet.append(x) x = x / 2 for i in range(100): print('N[{}] = {:.4f}'.format(i,vet[i])) def main(): # entrada do valor ...
03f42d8fce0813e508db18eb3c95c48b30965686
badrjarjarah/SchoolHomwork
/Python/hw5a.py
4,242
4.03125
4
# Joseph Leiferman # Student ID: 00990636 # Discussion Section: A06 import time # Two words are neighbors if they differ in exactly on letter. # This function returns True if a given pair of words are neighbors def areNeighbors(w1, w2): count = 0 for i in range(len(w1)): if w1[i] != w2[i]: ...
b731350924bf3fff5df624cc0a4008015e5fd817
Abigye/Games
/RockPaperScissors/RockPaperScissors.py
2,200
3.984375
4
import random def game(): total_count = 0 user_count = 0 computer_count = 0 while total_count <=10: List = ["Rock","Paper","Scissors"] computer = random.choice(List) print ("Rock , Paper, Scissors ?") player = input () print(f'You played {player}, the computer...
2b40546c8492e48396467400b349479c29df4f11
rsata/kais-gradebook
/Final.py
2,395
3.796875
4
#Reginal Database Management System #6/1/2016 #Kai Sata #Program that takes data and can edit it then report it each time it is called #KS import all external programs that will be called later on in the user choice import Add_class import Class_report import Delete_class import Add_student import Delete_student impor...
1d9195cd72352ee5ab2a2ca48f9c92185995f0f7
MarcosNocetti/PY
/joguinho do mal.py
607
3.5625
4
#--coding:utf8;-- #qpy:3 #qpy:console import subprocess import sys e = input("Arquivo ou programa? \n").lower() if e == "programa": while a == True : print( "TAKSBAR" ) a = input( "Entre com o nome do programa \n" ) if a == "exit": a = False else: subprocess.r...
4bab62a009ce751855f45a2cdcf8e9673ebaceb6
borislavstoychev/Soft_Uni
/soft_uni_basic/While Loop/exercise/04. Walking.py
609
4
4
steps_needed = 10000 steps_counter = 0 steps_home = 0 while steps_counter < steps_needed: command = input() if command == 'Going home': steps_home = int(input()) steps_counter += steps_home if steps_counter < steps_needed: print(f'{steps_needed - steps_counter} mor...
00810e6d82eadcefd857be63319e07356c69cf77
stewartad/goodcop-dadcop
/player.py
3,247
3.515625
4
import pygame, constants class Player(pygame.sprite.Sprite): # constrctor class that takes x, y coordinates as parameters def __init__(self, x, y): # call parent constructor pygame.sprite.Sprite.__init__(self) # set sprite image and rectangle self.image = pygame.image.load("good...
b2a3bdfcf6de7c67077936020bda8f20df741a04
arsoljon/My-scary-python
/firststars.py
446
3.546875
4
# This does a star with Juan & I. import turtle turtle.write("hello world", "center") #turtle.shapetransform(25, 10, 15, 1) turtle.color("red", "green") turtle.colormode("blue") turtle.speed(20) for i in range(5): turtle.forward(200) turtle.right(144) turtle.clear() for i in range(5): turtle...
545abee6b90ff06959c2700961e5c88986dd3281
denetti/PythonHSE
/W1/1-8 sumofnum.py
106
3.5625
4
num = int(input()) sumc = 0 while (num != 0): sumc = sumc + num % 10 num = num // 10 print(sumc)
3d431df9ba38d3c51cfff4aea06386c49d420fbf
andrewupk/HackerRank
/Python/Collections/WordOrder.py
358
3.734375
4
from collections import OrderedDict if __name__ == '__main__': N = int(input()) words = OrderedDict() for i in range(N): word = input() if word in words: words[word] += 1 else: words[word] = 1 print(len(words)) for word, count in words.items(): ...
af3b31bdea030e65d585160dbaf57ace35b70b55
brewswain/PCC
/Part II - Projects/Project 1 - Alien Invasion/Chapter 14 - Scoring/Notes/2 Leveling Up/1_modifying_the_speed_settings.py
3,013
4.25
4
""" We'll first reorganize the Settings class to group the game settings into static and changing ones. We'll also make sure that settings that change over the course of a game reset when we start a new game. Here's the __init__() method for settings.py: """ # settings.py def __init__(self): """Initialize the ga...
8f885550b4262c31355a4cbba8e3d51c30c3c56f
Quidge/cs50
/pset6/similarities/score
960
3.609375
4
#!/usr/bin/env python3 import sys from argparse import ArgumentParser from helpers import distances def main(): # Parse command-line arguments parser = ArgumentParser() parser.add_argument("FILE1", help="file to compare") parser.add_argument("FILE2", help="file to compare") args = vars(parser.p...
311fba0777ef7a120c51436743d9ceb3e0fd3470
ArseniyCool/Python-YandexLyceum2019-2021
/Основы программирования Python/4. While-loop/Скидки!.py
550
4.125
4
# Программ считает сумму товаров и делает скидку 5 % на товар,если его стоимость превышает 1000 price = float(input('Введите цену на товар:')) cost = 0 while price >= 0: if price > 1000: cost = cost + (price - 0.05 * price) else: cost = cost + price price = float(input('Введите цену ...
f349f90fbf58d53717ad36548a9837e498c8d707
lukegao/leetcode-practices
/linkedlist.py
3,786
4.03125
4
class Node(object): """docstring for Node""" def __init__(self, val): self.val = val self.next = None def __repr__(self): if self.next is not None: return f"{id(self)}: value={self.val}, next={id(self.next)}" else: return f"{id(self)}: value={self.v...
bc366a88886f35a0139811d7ebf3f77dbc32fcce
PowerSnail/tool_scripts
/py/rm_duplicate_env_val.py
941
3.5625
4
#!/usr/bin/env python3 """Remove duplicated value in environment variable This script preserves the ordering of the environment variable. Only Compatible with python3.7 or later, as this script uses the order-preserving feature added in python3.7. Input is taken from standard input as a single line of ":"-delimited...
1c783c650ed4c775c29743bb83c8170495f84b43
richard-paredes/CS-Fundamentals
/IntroToProgramming/Week14/assignment10.py
2,891
3.859375
4
# -*- coding: utf-8 -*- """ Richard Paredes PSID: 1492535 COSC 1306 Assignment #10 """ def generateTriangle1(triangle): a,b,c = triangle ''' [ 1 -2 2 2 -1 2 2 -2 3 ] ''' _a = a - 2*b + 2*c _b = 2*a - b + 2*c _c = 2*a - 2*b +...
32011f88f37646db35052bc761164eebec10c7c0
JazzFiend/AdventOfCode
/2016/Day08_TwoFactorAuthentication/Screen.py
1,044
3.5
4
import sys class Screen(): # Constructor def __init__(self, height, width): self.display = [['.' for x in range(width)] for y in range(height)] self.HEIGHT = height self.WIDTH = width # Public Methods def displayScreen(self): for line in self.display: for pixel in line: sys.stdou...
112901592133b84d0e8219e331c3ca65407e21c9
SigmaQuan/NTM-Keras
/datasets/repeat_copy.py
3,561
3.6875
4
# -*- coding: utf-8 -*- import numpy as np from utils import initialize_random_seed # Initialize the random seed initialize_random_seed() def generate_one_sample(dimension, sequence_length, repeat_times): """Generate one sample of repeat copy algorithm. # Arguments dimension: the dimension of each ...
7cba4ff49fe5909489c0ef2eac3cd4fa0897af13
mecozma/100DaysOfCode-challenge
/day3/q13.py
588
4.0625
4
""" 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 """ def count_alfa_and_digits(): letters, digits = 0, 0 input_values = [i for i in input("Pleas...
30242c4cab7c38094cfd8c349eb0ad1cd3f610e3
wburford1/CSCI375_QA_System
/QuestionProcessor.py
2,174
3.625
4
# HomeworkFive import nltk from nltk.corpus import stopwords import string # a class for processing questions class QuestionProcessor: # constructs a QuestionProcessor object for 'question' # q is a question def __init__(self): self.question = None self.key_words = [] self.stop_w...
0af7f021fef95aa00530ca1f28947e0eb252a4e6
HarikrishnaRayam/Data-Structure-and-algorithm-python
/Binary Tree/Lectures/Print Node at depth k.py
769
3.65625
4
# -*- coding: utf-8 -*- """ Created on Sun Apr 26 00:24:22 2020 @author: cheerag.verma """ class BinaryTree: def __init__(self,data): self.data = data self.left = None self.right = None def takeInput(): root = int(input()) if root ==-1: re...
8e44b9168fdff7b9e57cfa2a3ea6b497f5d9e085
Lucces/leetcode
/merge_88.py
966
3.875
4
#!/usr/bin/env python # coding=utf-8 class Solution(object): def merge(self, nums1, m, nums2, n): """ :type nums1: List[int] :type m: int :type nums2: List[int] :type n: int :rtype: void Do not return anything, modify nums1 in-place instead. """ if m =...
3c72755faaa5c4e0e3ee20d262064bfc9c4091dc
cyrnicolase/leetcode
/169/169.py
652
3.6875
4
#!/usr/bin/python class Solution(object): def majorityElement(self, nums): """ :type nums: List[int] :rtype: int """ count_values = {} for num in nums: if count_values.has_key(num): count_values[num] += 1 else: ...
e2bc5da0d4ce924d8bb9873a41a663d9b02d9618
umunusb1/PythonMaterial
/python2/02_Basics/01_Arithmetic_Operations/j_complex_numbers.py
964
4.375
4
#!/usr/bin/python """ Purpose: Demonstration of complex numbers Complex Number = Real Number +/- Imaginary Number In python, 'j' is used to represent the imaginary number. """ num1 = 2 + 3j print "num1=", num1 print "type(num1)=", type(num1) print num2 = 0.0 - 2j print "num2 = ", num2 print "type(num2) = ", type(nu...
422c80d04488829e8065d15186e2bde30d970888
kishorepro/learningGithub
/src/ifels.py
255
4.09375
4
grade= input("Enter your grade: ") if grade >= 90: print ("A") elif grade >= 80: print ("B") elif grade >= 75: print ("BC") elif grade >= 85: print ("CB") elif grade >= 70: print ("C") elif grade >= 60: print ("D") else: print ("F")
73e1fdc1c4fa312f56c490bec97b739c2be5f039
Divyaansh313/100DaysofCode
/RockPaperScissors.py
2,917
4.1875
4
""" Implements the game of Rock-Paper-Scissors! History: This classic game dates back to the Han Dinesty, over 2200 years ago. The First International Rock-Paper-Scissors Programming Competition was held in 1999 and was won by a team called "Iocaine Powder" The Game: Each player choses a move (simultaneously) from t...
e795a762a18354f494c96e285a617074634d20c8
Tuchev/Python-Basics---september---2020
/07.Exams/Programming Basics Online Exam - 15 and 16 June 2019/01. Movie Profit.py
344
3.875
4
film_name = input() num_of_days = int(input()) num_of_tickets = int(input()) price_for_ticket = float(input()) percent_for_cinema = int(input()) sum_of_all = num_of_days * num_of_tickets * price_for_ticket profit = sum_of_all - (sum_of_all * percent_for_cinema / 100) print(f"The profit from the movie {film_nam...
716327832e739d163bc309902115b88760f29bfb
ctbeiser/Evolution_full
/11/evolution/traitcard.py
1,484
3.84375
4
from .trait import Trait # Because range is inclusive only on the bottom FOOD_VALUE_RANGE = range(-8, 8+1) class TraitCard: def __init__(self, food_value, trait): """ Represents a Card with a Trait and a quantity of Food :param food_value: An Integer between -8 and 8 :param trait: A Trait...
354e21f2823534da9f431acde5687411e95b60cd
AidanCurley/Codio
/polymorphism_2_overriding_dunders.py
781
3.71875
4
class Characters: def __init__(self, phrases): self._phrases = phrases def total_chars(self): total = 0 for phrase in self._phrases: total += len(phrase) return total def __gt__(self, other): return self.total_chars() > other.total_chars() def __lt_...
95ee624b4650c322f47f1e76c89e97edac43ee1f
joshsanyal/pythonroom
/things.py
285
4.09375
4
# author: joshsanyal thingstodo = ["watch a Rockets game", "visit the southern hemisphere", "go camping"] for thing in thingstodo: answer = input ( "Would you want to " + thing + "?" ) if answer == "yes": print "Then do " + thing if answer == "no": print "Then don't " + thing
796ae277c7b42cb3e892032de37c229b82f0aed5
cedadev/cmip6-data-transfer-mgmt
/scripts/query_sdt.py
988
3.53125
4
import sqlite3 from sqlite3 import Error class ConnectDB(object): def __init__(self, database_file=False, verbose=False): self.database_file = database_file self.verbose = verbose self.conn = self.connect_to_database() def connect_to_database(self): if self.verbose: ...
66d407d714258a6aceea8e800a10ba5994af040a
ecastillob/project-euler
/101 - 150/112.py
1,846
4.40625
4
#!/usr/bin/env python # coding: utf-8 """ Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 134468. Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, 66420. We shall call a positive ...
ad4f61bbec452521c9bd6673717c712c5f1ef6fe
liaison/LeetCode
/python/199_Binary_Tree_with_Right_Side_View.py
634
3.5625
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def rightSideView(self, root: TreeNode) -> List[int]: results = [] def DFS(node, d...
87b73f58573920489cb7c29fa4f8a27ec1253597
ganeshtunuguntla/Diabetes-Prediction
/project/graph.py
523
3.5
4
import matplotlib.pyplot as plt import numpy as np import pandas as pd # Data df=pd.DataFrame({'x': range(1,11), 'y1': np.random.randn(10), 'y2': np.random.randn(10)+range(1,11), 'y3': np.random.randn(10)+range(11,21) }) # multiple line plot plt.plot( 'x', 'y1', df, marker='o', markerfacecolor='blue', markersize=12...
a4df84bf65629a146d05f723a441f3b18d62db79
marco-lavagnino/advent-of-code-2020
/day3/run.py
764
3.5625
4
# https://adventofcode.com/2020/day/3 #%% with open("sample.txt") as f: lines = f.read().split("\n") #%% with open("input.txt") as f: lines = f.read().split("\n") # %% row = 0 column = 0 trees = 0 while row < len(lines): if lines[row][column] == "#": trees += 1 column = (column + 3) % len(li...
563e54e7ac52bdae8c659c5658aa5a311246aa97
cmjao/Python-practicespace
/ch7_list_001.py
212
4
4
birth_year = 1992 years_list = [years for years in range(birth_year, birth_year + 5)] print("Print years list :", years_list) print("Print third item :", years_list[2]) print("Print last item :", years_list[-1])
c739025009ab6a31182180aedb360a5164704005
shulme33/Programming
/Python/cci_1-2.py
4,635
3.78125
4
# Samuel Hulme # Cracking the Coding Interview # Question 1.2 # # Given two strings, wite a method to decide if one is a permutation of the other. # # Thoughts: # 1.) The simple answer is to sort the strings and then check them one letter at a time. This could be done in # O(nlogn) for the sort an...
5a71efd94cdeda2ade61ec8e122438f31aa20dbc
BREG001/osp_repo_sub
/py_lab2/my_pkg/bin_conv.py
770
3.8125
4
#!/usr/bin/python3 def bin_conv(): bin = int(input("input binary number:")) bin_ = bin temp = 0 oct = 0 i = 0 asdf = 0 while (bin_ >= 1): for j in range(0, 3): temp += (bin_ % 10) * pow(2, j) bin_ = int(bin_ / 10) oct += (temp * pow(10, i)) i += 1 temp = 0 print("=> OCT> %d" % oct) bin_ = bin...
92b077752573078adc4e32eec6f82be54cf824c4
jeetsaha5338/College_Study
/TRAINNING/ML/Globesyn/work/REGRETION/ML_sanu/temp.py
228
3.875
4
import matplotlib.pyplot as plt #%matplotlib inline x=range(0,100,1) y=[x+1 for x in range(0,100,1)]#this is known as list argument plt.plot(x,y) z=[x+200 for x in range(0,100,1)] plt.plot(x,z) plt.show() LOL KID
57e64b636d5012b2d816f88d7d89388894ad428e
yingang/python-challenge
/11.py
453
3.59375
4
from PIL import Image im = Image.open("cave.jpg") (width, height) = im.size # put even/odd in same image (left/right) output = Image.new(im.mode, (width, height//2)) # even for y in range(0, height, 2): for x in range(0, width, 2): output.putpixel((x//2, y//2), im.getpixel((x, y))) # odd for y in range(...
1833c736b7daab7377235e39fbd809a7e104abd4
nrouleau/rosalind
/2TranscribingDnaIntoRna.py
206
3.609375
4
dna_string = raw_input() rna_string = [] for nucleotide in dna_string: if (nucleotide == 'T'): rna_string.append('U') else: rna_string.append(nucleotide) print ''.join(rna_string)
7eeaedec78c8ea24b4db2df5eecefbff7a7120a5
random-forest-ai/python_course
/Chapter_2/Boolean/Boolean.py
699
4.21875
4
if __name__ == '__main__': # == / != / < / <= / > / >= operator (Change the operator as you wish!) # print(7 == 7) # print(7 == 8) # print(7 == 7.0) # print("ABC" == "ABC") # print("ABC" == "ABCD") # print("ABC" == "abc") # print((5, 3, 2) == (5, 3, 2)) # print((5, 3, 2) == (5, 3, 2....
521ab13981c1f2d4c66c2df7cd6f2eeb92a1882d
gangooteli/ClassificationHousingDataset
/demo.py
2,341
3.65625
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt import tensorflow as tf dataframe = pd.read_csv('data.csv') dataframe = dataframe.drop(['index','price','sq_price'], axis=1) dataframe = dataframe[0:10] dataframe dataframe.loc[:, ('y1')] = [1,1,1,0,0,1,0,1,1,1] dataframe.loc[:,('y2')] = datafram...
97fbbd18e3965cd3dbb0a5a5eb52d27e2f290840
why2lyj/Bloxorz
/solver.py
2,055
3.53125
4
# coding=utf-8 from state import State from utility import Direction class Solver: # Simple Depth First Search to calculate time @staticmethod def dfs(state: State): while state.states: player, bridge = state.states.pop() state.load_state(player, bridge) for direction in ['up', 'down', 'left', 'right']...
0b43cce63b5e8a71eac3cdf37a1aff2ddcb81088
areebahmad01/TSF
/Task 1(% vs score).py
1,484
3.828125
4
#!/usr/bin/env python # coding: utf-8 # Prediciton using supervised learning by AREEB AHMAD # In[4]: import pandas as pd import numpy as np import matplotlib.pyplot as plt #importing all the libraries # In[5]: link = "http://bit.ly/w-data" dataset = pd.read_csv(link) #storing data from link in dataset # In[6...
2294a19efd69e7dffd40b3622665e8060fc719b5
brucekk4/pyefun
/pyefun/encoding/compress/zip.py
2,489
3.703125
4
import os import sys import zipfile # # def rename(pwd: str, filename=''): # """压缩包内部文件有中文名, 解压后出现乱码,进行恢复""" # # path = f'{pwd}/{filename}' # if os.path.isdir(path): # for i in os.scandir(path): # rename(path, i.name) # newname = filename.encode('cp437').decode('gbk') # os.renam...
42a863830825b7fb5f483af75e1185ec5335d483
ZYZhang2016/think--Python
/chapter04/Exercise4.3.5.py
585
3.9375
4
#coding: utf-8 from swampy.TurtleWorld import * import math world = TurtleWorld() def polyline(t,n,length,angle):#t:turtle;n:n边正多边型 print t for i in range(n): fd(t,length) lt(t,angle) def polygon(t,n,length): angle = 360.0/n polyline(t,n,length,angle) def arc(t,r,angle):#t:turtle;r:r半径;angle:圆弧的角度 circumfer...
82fc9f064a6c678d581bde28d542b40d82f9383d
pjjefferies/python_practice
/binary_matrix_ops_elder_add.py
874
3.515625
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 19 23:14:52 2019 @author: PaulJ """ import unittest def elder_age(m, n, l, t): pass class TestMethods(unittest.TestCase): tests = {(8, 5, 1, 100): 5, (8, 8, 0, 100007): 224, (25, 31, 0, 100007): 11925, (5, 45, 3, 100000...
8e76d3338294614422df04814ba4eb04ff7789f5
amalphonse/Python_WorkBook
/37.py
626
4.15625
4
# -*- coding: utf-8 -*- """ Created on Fri Feb 17 16:39:38 2017 @author: ANju """ #Create a function that takes a text file as input and returns the number of words #contained in the text file. Please take into consideration that some words can #be separated by a comma with no space. For example "Hi,it's me." would...
6b94f445f427dcd3005a3ec2a3c912e297a70ac1
ibrahimuslu/udacity-p1
/problem_1.py
7,185
3.671875
4
class DoubleNode: def __init__(self, key,value): self.value = value self.key = key self.next = None self.previous = None class DoublyLinkedList: def __init__(self): self.head = None self.tail = None def append(self, value): if self.head is None:...
d2428c07892bdac82d32af9b898579f8cee60c4b
xizhang77/LeetCode
/UnionFind/128-longest-consecutive-sequence.py
1,645
3.796875
4
# -*- coding: utf-8 -*- ''' Given an unsorted array of integers, find the length of the longest consecutive elements sequence. Your algorithm should run in O(n) complexity. Example: Input: [100, 4, 200, 1, 3, 2] Output: 4 Explanation: The longest consecutive elements sequence is [1, 2, 3, 4]. Therefore its length i...
09d36035423e0d7ef57b798e8bb86548dbd873b2
AvishaSharma23/Hacktoberfest21
/Palindrome_Number.py
447
3.90625
4
class Solution: def isPalindrome(self, x) -> bool: reversed = 0 original = x if(x<0): return False while (x>0): reversed = reversed*10 + x % 10 x = x // 10 if(reversed == original): return True else: return ...
696d042bc97125a643ab2c2e3553da01f5c4afe9
msahu2595/PYTHON_3
/193_16_class_variable.py
917
3.90625
4
# # class variable # # circle # # area # # circum # class Circle: # pi = 3.14 # def __init__(self, radius): # self.radius = radius # def calc_circumfrence(self): # return 2*Circle.pi*self.radius # c1 = Circle(4) # c2 = Circle(5) # print(c1.calc_circumfrence()) class Laptop: ...
5ce9b893c674db26feb6e71c124f2a029d67aabf
tnotstar/tnotbox
/Python/Learn/LPTHW/ex11_dr03.py
198
3.859375
4
name = input("What's your name? ") salary = input("What's your current salary? ") company = input("Where do you work? ") print(f"Hello, I'm {name}, currently I work at {company} earning {salary}.")
c419e1a011594dd46eab4ba82d826a869241f985
hosmanadam/coding-challenges
/@HackerRank/Problem Solving/20_circular-array-rotation/main.py
224
3.546875
4
"""https://www.hackerrank.com/challenges/circular-array-rotation/problem""" def circularArrayRotation(a, k, queries): a_rotated = [a[i - (k % len(a))] for i in range(len(a))] return [a_rotated[i] for i in queries]
b5deecc7d00f598cb5d15d951fcb9aef488ca90b
arnoringi/forritun
/Assignment 3 (While loops)/3_2) First n even numbers.py
177
4.09375
4
num = int(input("Input an int: ")) # Do not change this line count = 0 even = 0 # Fill in the missing code below while count < num: even += 2 count += 1 print(even)
300cf7eb84977f3133e687ce4876e59b6511a515
FantasyEngineer/pythonProject
/输入与输出.py
1,062
3.890625
4
import math s = 'Hello, Runoob' print(str(s)) print(s.__repr__()) # rjust是右对齐 # for x in range(1, 11): # print(repr(x).rjust(2), repr(x * x).rjust(3), end=' ') # print(repr(x * x * x).rjust(4))® # for x in range(1, 111): # print('{0:2d} {1:3d} {2:4d}'.format(x, x * x, x * x * x)) print('{}网址: "{}!"'.for...
c01c69f9d7c65db5d5e00125f944f2119c8efaf7
Tiezzi96/SlidingPuzzle
/main.py
24,024
3.890625
4
from __future__ import print_function from __future__ import generators import sys import time import os import psutil from copy import deepcopy import random import bisect import pickle infinity = 1.0e400 def update(x, **entries): """Update a dict; or an object with slots; according to entries. >>> update(...
90c4df64b45d0a11a27e493dbf166c8e3c96b887
JorgeChaparroS/PythonBasics
/3. Estructuras de Control/fizzbuzz2.py
196
3.921875
4
numero = int(input("Ingrese un número: ")) salida = "" if numero % 3 == 0: salida += "Fizz" if numero % 5 == 0: salida += "Buzz" if salida == "": salida = str(numero) print(salida)
71f77ff4bf6361d92260720a4e60967f82783592
ZU3AIR/DCU
/Year2/ca268Labs/Sorting/merge/QueueBasedMergesort.py
427
4.0625
4
from Queue import Queue def split(q): """ A split function which will split a queue into two. The function returns a tuple containing the two queues. """ que1 = len(q) que2 = len(q) que3 = len(q) Q = Queue() Q2 = Queue() for i in range(len(q)): if i % 2...
6e8084c443a861fde75949190aa8ba2f9893f714
WesWang93/Python
/Projects/Card_Game/test_card.py
2,364
4.125
4
''' Test for Card class in card.py ''' import pytest from card import Card def test_inputs(): ''' Test different formats of suit and rank of same card to see if they are still equal ''' spade_ace_a = Card("Spade", "A") spade_ace_b = Card("SPADE", "a") assert spade_ace_a == spade_ace_b ...
913c438bd6441bda67259a24e00ef6dc25001382
coprobo/DaftCode_Python
/zajęcia nr 4/zadanie domowe nr 4/Zad2.py
2,053
4.0625
4
# Chcemy napisać sprawdzarkę do testu znajomości stolic europejskich. # Format listy stolic taki jak w pliku stolice.csv # Format pytań taki jak w pliku pytania.csv # Format odpowiedzi taki jak w pliku odpowiedzi.csv # Napisz funkcję check_homework, która przyjmuje trzy argumenty: # - capitals_csv to ścieżka do ...
d09bb3ab9831a60344e749753ba6b0b5d66e11ec
sodri126/hackerrank
/print_bilangan_triangle.py
273
3.6875
4
import sys if __name__ == "__main__": n = int(input()) + 1 for i in range(0, n): cal = n - i for j in range(0, cal): print(end=' ') for k in range(0, i): print(k+1, end=' ') print() # create triangle numer
c68b06a717574572326373c4fd06c9f2c9a9e986
SpikyClip/rosalind-solutions
/bioinformatics_textbook_track/BA1M_implement_NumberToPattern.py
673
4.09375
4
def number_to_pattern(index,pattern_len): '''Converts an index number for k-mer of giving length to its corresponding pattern''' pattern = '' letter_value = {0: 'A', 1: 'C', 2: 'G', 3: 'T'} # Starts reconstructing the symbols from the last letter of the k-mer for i in range(pattern_len): ...
b9f66d1b92597f6bc8cb4da517317b2337c9f129
dukeofdisaster/CodeWars
/sumTwoSmallest.py
856
4.15625
4
# The challenge is to define a function that takes the sum of the two # smallest numbers in an array of integers and returns said sum. # We are not allowed to modify the original array def sumTwoSmallest(numbers): copiedArray = numbers lowest = min(copiedArray) copiedArray.remove(lowest) nextLowest = ...
a22284040293fd7415822ba0b62e0d500b5dd9d1
thraddash/python_tut
/14_ojbect_oriented_programming/method_overiding.py
673
4.21875
4
#!/usr/bin/env python # Method overriding class Math: def __init__(self, x, y): self.x = x self.y = y def sum(self): return self.x + self.y class MathExtend1(Math): # Child class def __init__(self, x, y): super().__init__(x,y) def subtract(self): return se...
f7fe60a3eca66a7a905c36916e6d0ac441d02e6b
huazhige/EART119_Lab
/mid-term/martinezverenise/martinezverenise_22776_1312454_PartB-1.py
2,658
3.921875
4
# -*- coding: utf-8 -*- """ - we will be finding the roots for each of the three given functions - f1 = x**5 +(2/5)*x**2 - 2 - f2 = exp((-1/10)*x) +x - f3 = 10*sin((1/4)*x)+ .1*(x+12) - all within the interval [-10,10] """ import matplotlib.pyplot as plt import numpy as np def f1(x): return x...
43352811b2b3969bb991fae10ef8615d4d450f84
yaksas443/SimplyPython
/rectangle.py
514
4.15625
4
# Source: Understanding Computer Applications with BlueJ - X # Find the area, perimeter and diagonal of a rectangle import math l = int(raw_input("Enter the length of rectangle (cm): ")) b = int(raw_input("\nEnter the breadth of rectangle (cm): ")) area = l * b perimiter = 2 * (l + b) diagonal = math.sqrt(l*l + b*b)...
ad4de85771be40247c74448caf2d561ca2b06cf8
ZanetaWidurska/ZanetaWidurska
/test_point.py
4,866
3.6875
4
# -*- coding: utf-8 -*- from point import Point, normalize_angle def test_should_check_constructor_without_z(): # given point_a = Point('A', 1, 1) # when # then assert point_a.name == 'A' assert point_a.x == 1 assert point_a.y == 1 assert point_a.z == 0 def test_should_check_constru...
8bcdb21d520dc720e80f83546f311d1a77979e51
Angelday8/hatnotation
/Password_Generator_python-hatnotation_v3.py
1,373
3.578125
4
import string import secrets import sys import math #Author: © Steven J Hatzakis, 2020 alphabet = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "!", '"', "#", "$", "%", "&", "'", "("...
ac9c4d4e6aff256dc81758536c68b96a8ab72b4a
vladsadretdinov/skillsmart-education
/algorithms/5-extended.py
2,216
3.8125
4
import unittest class Queue: def __init__(self): # инициализация хранилища данных self.queue = [] def enqueue(self, item): # вставка в хвост self.queue.append(item) def dequeue(self): # выдача из головы if self.size() == 0: return None ...
f56a398a019f0d3094e401f52ac062c3f1898a4e
bijiuni/preprocess_brain
/Basic_suggested_answer.py
1,523
4.09375
4
import numpy as np #Task 1 #We define an array1 array1 = np.array ( [[1., 1., 1.], [1., 1., 1.]], dtype=int) #Use ones function to define array_ones so that it is equal to array1 array_ones = np.ones ( (2,3) ) #Make this true print (np.array_equal(array_ones, array1) ) #Task 2 #We define an arra...
3e3d0d3da4855fb08f4ba0dff4935bb8e9141b44
Antohnio123/Python
/Practice/n.vasyaeva/HWLec3.py
1,667
4.03125
4
# Числа # 1 print("Enter the number of seconds:") x = int(input()) hours = x // 3600 minutes = x % 3600 // 60 print("It is", hours, "hours,", minutes, "minutes.") # 2 print("Enter the number of degrees:") y = int(input()) n = y // 30 #кол-во часов m = y % 30 // float('0.5') #кол-во мин print("It is", n, "...
1abdf2eb9732c77595174bed0dae4ee0d3efbfc0
zlezero/Methodes_Numeriques
/average_1_to_N.py
194
4.21875
4
nbr = input("Enter a number > 1 : ") def average_1_to_N(n): sum = 0 for i in range(1, n + 1): sum += i return sum / n print("The average is : ", average_1_to_N(nbr))
4560a6ebbc818a071df9b12f764a1d376ff1fcdf
Enedavid/helloworld
/ps0.py
217
4.09375
4
# -*- coding: utf-8 -*- import math x = input("Enter numner x: ") y = input("Enter number y: ") x_power_y = int(x) ** int(y) print("x**y = " + str(x_power_y)) print("log(x) " + str(math.log(int(x),2)))
3595475991a3e65dcb2de467194e90ff3bf631f0
vikioza/portfolio_mazes
/maze_viz.py
2,911
3.71875
4
import pygame from tile import * from math import ceil WIDTH = 720 BORDER_MARGIN = 20 MAZE_MARGIN = 5 WIN = pygame.display.set_mode((WIDTH, WIDTH)) pygame.display.set_caption("Pathfinding Algorithm Visualization") RED = (255, 0, 0) GREEN = (0, 255, 0) BLUE = (0, 255, 0) YELLOW = (255, 255, 0) WHITE = (255, 255, 255) ...
3adaf85184174615ac3cd25b5810115b569dccde
ksparkje/leetcode-practice
/python/too_easy/q78.py
679
3.703125
4
# 78. Subsets # Medium # # Given a set of distinct integers, nums, return all possible subsets (the power set). # # Note: The solution set must not contain duplicate subsets. # # Example: # # Input: nums = [1,2,3] # Output: # [ # [3], # [1], # [2], # [1,2,3], # [1,3], # [2,3], # [1,2], # [] # ] class ...
980e0b7114fbc4ba30ce07ad4fd3ab05b2624a32
kevinwsouza/phytonEX
/mediana.py
700
3.5
4
import sys def main (): numberLines = sys.stdin.readline() numbers = [] typeList = '' numberLines = int(numberLines) if(numberLines % 2 == 0): typeList = 'pair' else: typeList = 'odd' while(numberLines > 0): newNumber = sys.stdin.readline() numbers.append(newNumber) numberLines = numb...
e83abc88d93732ecea940247046ee47f003db0ae
pablodarius/mod02_pyhton_course
/Curso Udemy/SQLite Leccion 01/Leccion3.pyw
616
3.734375
4
import sqlite3 # conexion y se creara si no existe la BBDD conexion = sqlite3.connect("usuarios.db") cursor = conexion.cursor() """ cursor.execute("SELECT * FROM personas WHERE id=1") per = cursor.fetchone() print(per) """ cursor.execute("SELECT * FROM personas WHERE edad=34") per = cursor.fetchone() print(per) per = ...
01650206a8387a9cc686b84e15e24ad6ca03fbc8
JakobKallestad/Python-Kattis
/src/LineSegmentDistance.py
2,447
3.65625
4
from math import sqrt def direction(x1, y1, x2, y2, x3, y3): val = (y3 - y1) * (x2 - x1) >= (y2 - y1) * (x3 - x1) if val == 0: return 0 #colinear elif val < 0: return 1 #anticlockwise else: return 2 #clockwise def perpendicular_intersection_distance(x1, y1, x2, y2, x3, y3): ...
d786e2158f126fc7c27f3518b3f3930ef4e5dd34
Putnic/python_learning
/generators/generator_ex.py
1,793
4.4375
4
from sys import getsizeof from typing import List # Generator Expressions gen_exp = (x * x for x in [1, 2, 3, 4, 5]) print('Generator Expressions', gen_exp) print('gen_exp:', getsizeof(gen_exp)) # gen_exp = (x * x for x in [1, 2, 3, 4, 5]) # [1, 4, 9, 16, 25] # print(list(gen_exp)) # *****************************...
46974ba349374634780d329800b4b001ac1738b5
stensaethf/Palindrome-DP
/longestpalindrome.py
2,927
3.921875
4
''' longestpalindrome.py Frederik Roenn Stensaeth 09.27.15 A Python program to find the longest palindrome subsequence of a string. Algorithm is implemented using dynamic programming. ''' import sys import time def longestPalindrome(string): """ longestPalindrome() finds the longest palindrome subsequence of a giv...
33ef7710ba42fcfe554a0e8eb24b573bdd5820aa
carodewig/advent-of-code
/advent-py/2019/day_11.py
3,360
3.5625
4
""" day 11: space police """ from enum import Enum import attr import math from day_05 import IntcodeComputer, test_intcode_computer class Color(Enum): BLACK = 0 WHITE = 1 def to_str(self): if self.value: return "+" return " " @attr.s(slots=True) class Location: # grid...
d986f207e36f2c459ad1419435d775faae24bdb5
mbwight/Python_Scripts
/Flask/km_to_miles.py
1,492
3.828125
4
__author__ = 'Mark' from flask import Flask from flask import request app = Flask(__name__) app.debug = True #####Creates the function form_example under the first forward slash in this path #####The function puts all of the html to ask the user to input a distance in kilometers #####There is a button that a...
541989b0b36f05005356530baaf6424570924902
lennykey/Webprogrammierung
/src/fibonacciGenerator/fiboGenerator.py
425
3.734375
4
''' Generatorfunktion fuer Fibonaccizahlen ''' def fibogen(): step0 = 0 step1 = 1 step2 = step0 + step1 counter = 0 while True: if counter == 0: yield 0 counter += 1 elif counter == 1: yield 1 counter += 1 else: yield step2 step0 = step1 step1= step2 step2 = step0 + step1 ...
d31853d7676ffc28d916dada16454f3c8db0839f
morenoh149/learnPythonInOneHour
/helloworld10.py
2,281
4.09375
4
import random import sys import os class Animal: __name = "" # double underscore indicates this is a private variable __height = 0 __weight = 0 __sound = 0 def __init__(self, name, height, weight, sound): self.__name = name self.__height = height self.__weight = weight self.__sound = sound def set_nam...
dae42c9d22b36e6e66241f702330220fb15daf49
vikkir/D2_project
/1. Read_csv_to_JSON_tw.py
2,599
3.59375
4
#Read CSV into JSON #Tom Wallace #Finished 21/09/18, annotations updated 26/09/18 #This file reads a CSV into a Pnadas dataframe, modifies it and saves it out to a JSON with the index format. It then reads it back in from JSON to a dataframe to test if the translation works. ################################# Import pa...
cf18ae28b2108e98f3a8354d2611f5e16a3cedb6
kanybek740/Chapter4_Task1
/Task1.py
888
3.84375
4
# Создайте класс Student, конструктор которого имеет параметры name, lastname, # department, year_of_entrance. Добавьте метод get_student_info, который # возвращает имя, фамилию, год поступления и факультет в # отформатированном виде: “Вася Иванов поступил в 2017 г. на факультет: # Программирование.” class Student():...
83cff2e490205132301068417e0cbc1d582e5ffe
varshilgandhi/Introduction-of-K-Means-Clustering
/What is K-means clustering .py
1,291
3.65625
4
# -*- coding: utf-8 -*- """ Created on Sat May 8 02:08:26 2021 @author: abc """ import pandas as pd #read out dataset df = pd.read_excel('K_Means.xlsx') print(df.head()) #Plot our dataset import seaborn as sns sns.regplot(x=df['X'], y=df['Y'], fit_reg=False) #fit_reg means do you want to divide it...
400ed8fa47d3d4c90488b381c07418b4711e1164
JpradoH/Ciclo2Java
/Ciclo 1 Phyton/Unidad 1/Ejercicios/clase 1.py
788
4.25
4
#comentarios """comentarios""" #formas de imprimir print("Hello world")#es la mas comun print('boba 70 hijueputa') print('''te amo y te extraño mucho''') print("""mi gorda bella""") #concatenar print("jorge2"+" "+"Prado") #tipos de variables A=3 #entero o int B=3.5 #decimal o float C=False #boleano o bool print(A) ...
8eabca456605dc4348b9c26c35aafd2c49d2703c
kiptetole/Ejercicios-POO-2
/Ejercicios Practicos/Python/Ejercicio_Tiempo/Tiempo.py
2,679
4.15625
4
''' Clase Tiempo tres variables locales Horas Minutos Segundos Metodos: - Suma minutos segundos. - Resta minutos segundos. @author: Jose Notario Millan. ''' class Tiempo(): ## Constructor de la clase Tiempo ## def __init__(self,h,mun,seg): contador = 0 while ...
5a6e073fea8640a8a765f131f58d504a915c80fd
bichwa/Examples
/python/examples/draw_text.py
1,129
3.640625
4
""" * scratch_n_ sketch * * simple demo scripting in python language * """ from board import * #init mbd = scratch_n_sketch() #connect board mbd.connect() #start print('Draw Text demo') #clear screen #myBoard.clearScreen() mbd.backGroundColor(20, 20, 20) mbd.textBackColor(20, 20, 20) mbd.setFont(mbd.font_big); mbd.rot...
94eddac1115d9c1ecf2fba43ff4bc99faeae3505
dlordtemplar/python-projects
/Functions/is_member.py
700
4.1875
4
''' Implement a function is_member(x, somelist) that returns True if x is an element of somelist, False otherwise. (2 Points) >>> is_member(2, [1, 2, 3]) True >>> is_member(4, [1, 2, 3]) False Note that this is exactly what the in operator does. >>> 2 in [1, 2, 3] True >>> 4 in [1, 2, 3] False For the sake of the ...
b46bfe05281d970506f7ff06d05b39addd3de653
rammanur/PYTHON_FUN
/socket_test_multiproc.py
1,860
3.59375
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 26 14:34:03 2013 Demo server to demonstrate accepting of incoming socket requests and responding to them with interesting stuff. @author: rammanur """ import socket, sys, time, os def standard_handler(pid, conn, addr_info): conn.send("%d: STD: You are connected fr...
25fb8391021e590426d416b8e4180375fcb95156
pactonal/cse231
/proj05.py
2,298
3.875
4
#!/usr/bin/python3 '''Put overall header comments here.''' import string def open_file(): '''Insert function DocString here.''' opened = 0 while opened != 1: try: filename = input("Enter a file name: \n") f = open(filename, "r") opened = 1 except IOError...