blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
af9276ee2a6a4f8aacaad8389da4abb460e5df7e
constantlearning/uri-exercises-resolution
/01-INICIANTE/Python/1143.py
166
3.859375
4
# -*- coding:utf-8 -*- size = 0 while size < 1 or size > 1000: size = int(input()) for x in range(1, size + 1): print("%d %d %d" %(x, x ** 2, x ** 3))
323d4047f460510ae67076fb4df9f36b763dc519
lpython2006e/student-practices
/15_Nguyen_Tu_Giang/bai-2.8.py
993
4
4
# Write three functions that compute the sum of the numbers in a list: using a for-loop, a while-loop and recursion. # (Subject to availability of these constructs in your language of choice.) for loop import re def total_for(list_ele, count=0): for i in list_ele: if str(i).isdigit(): ...
e797173553a40f2cd7b12ff874c08f238fc8e45b
zhaoyanz405/note
/spider/multi_proc.py
1,203
3.859375
4
#! /usr/bin/python # -*- coding: utf-8 -*- # @author: Zhao Yan # @datetime: 8/31/18 10:36 AM import time, random from queue import Queue from threading import Thread class Producer(Thread): def __init__(self, name, queue): Thread.__init__(self, name=name) self.data = queue def run(self): ...
7bf556de28fab32cc5969033c4a18a4696473a0f
sarsembin/webdev2019
/week10/Informatics/loops/loop while/d.py
129
3.765625
4
a = int(input()) one = 1 while one <= a: if(one == a): print("YES") quit() one = 2*one print("NO")
8f4e960e44b09dc990a32ff8eff849cad1dc7957
senqtus/Algorithms-and-Data-Structures-Problems
/Clone_Graph.py
1,396
3.765625
4
""" Given a reference of a node in a connected undirected graph. Return a deep copy (clone) of the graph. """ from collections import deque class Node: def __init__(self, val, neighbors): self.val = val self.neighbors = neighbors class Solution: @staticmethod def clone_g...
aa906617f7f5818014e4402c364397237bb99ea9
Beichen365/Python
/Syntax/chap14/chap14.py
327
3.734375
4
class Bank: def __init__(self,username,number,amount): self.username = username self.number = number self.amount = amount myBank = Bank("Sun Beichen", "12345678", "1265.90") print("There is ",myBank.amount," in my bank.") print("The password is ",myBank.number) print("My username is ",myBa...
bfbd98cea13b84c2fa5af94043a0343d9252dbf1
KremenaVasileva/HackBG
/Week3/Monday/bank_account_tests.py
3,756
3.953125
4
from bank_account import BankAccount import unittest class TestBankAccount(unittest.TestCase): def setUp(self): self.my_account = BankAccount("Rado", 2000, "$") self.name = "Rado" self.balance = 2000 self.currency = "$" self.account_history = ["Account was created"] ...
a68b114893770e8359d50ca900d3f0797f78d81b
svantepihl/AdventOfCode2020
/python/day14/day14.py
4,011
4.09375
4
''' --- Day 14: Docking Data --- As your ferry approaches the sea port, the captain asks for your help again. The computer system that runs this port isn't compatible with the docking program on the ferry, so the docking parameters aren't being correctly initialized in the docking program's memory. After a brief in...
9ccb9b0f3329e3c31caed2a0703b39e181abfa67
affan10/SMAP-FYP
/Technical Analysis/daily_indicators.py
13,853
3.640625
4
import pandas as pd from datetime import datetime import csv from statistics import mean def csv_writer(path,header,data): #this function is to write the moving avg value vs date values to csv files with open(path, "wb") as out_file: writer = csv.writer(out_file, delimiter=',') writer.writerow(head...
faff6f0b0c4a54cfe2d09c07bad8213d49ab3d2c
Carlzkh/CrazyPythonNotes
/exercise/ten/10.4.py
617
4.09375
4
""" 4. 提示用户输入 1个字符串,程序使用正则表达式获取该字符串中第一次重复出现的英文字 包括大小写〉。 ['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'] """ import re strings = input('输入字符串:') for i in strings: if i.isalpha(): list1 = re.findall(i, strings, flags=re.I) if len(list1) > 1: ...
cd68ca4c27067b73442dd87a96ff6dd32415dc9d
JeremiahZhang/gopython
/python-programming-an-introduction-to-CS/src/ch05/month.py
538
4.125
4
# month.py # A program to print the abbreviation of a moth, given its number def main(): # The variable months is used as a lookup table months = "JanFebMarAprMayJunJulAugSepOctNovDec" n = eval(input("Enter a month number (1-12): ")) # Computer starting position of month n in months pos = (n - ...
01371f8b01013fe7ffed104470f73c52519b60a1
prathamtandon/g4gproblems
/Math/prime_factors.py
1,013
4.25
4
import unittest """ Given a number n, return its prime factors. Input: 12 Output: 2 2 3 Input: 315 Output: 3 3 5 7 """ """ Approach: 1. While n is divisible by 2, print 2 and make n equals n divided by 2. 2. Now n will be odd. Start dividing by 3 till sqrt(n), while n is divisible, in steps of 2. 3. After this, if n ...
e656b77ccd51315d09ab92d2f08f11ed7d95ebfe
bboyGit/statsLearning
/core/supervise/regression/spline.py
2,899
4.0625
4
import pandas as pd import numpy as np def spline(x, y, power, knot, const=True): """ Desc: Execute regression spline algorithm Parameters: x: A 1-D vector y: A columns vector power: An int representing the power of spline knot: Optional. If it's an int, it represents th...
d88208dfdbcb8a042e8c1cf1acd06209ecda28f3
cdklas1230/CS5001-Ciphers
/substitution.py
3,104
4.71875
5
''' This part contains the encrypt and decrypt function of Substitution cipher. The encryption and decryption rule is that the key must contain all 26 letters, no duplicates. If numbers presented in plaintext/ciphertext, they will remain unchanged. Only the letters will be encrypted/decrypted. ''' import utils def e...
6677b031343d30787c3ee65fd6d2ce27db4d1a9f
RegCookies/Offer-Sward
/2-D_array_find.py
308
3.703125
4
def Find(self, target, array): if array == [[]]: return False for i in range(len(array)): if array[i][0] > target: continue else: for j in range(len(array[i])): if array[i][j] == target: return True return False
bb12932e6f3fdd111ed50340db251bf84f6c59fe
GorchForch/PythonCalc
/calc.py
159
3.9375
4
def sum(a, b): return (a + b) a = int(input('Enter first number: ')) b = int(input('Enter second number: ')) print(f'Sum of {a} and {b} is {sum(a, b)}')
092de9b1337f0ab8419b5e9c5699ae14f781a0ac
samyak1903/Data-Types-1
/A5.py
321
3.875
4
#Q.5- Given are two one-dimensional arrays A and B which are sorted in ascending order. Write a program to merge them into a single sorted array C that contains every item from arrays A and B, in ascending order. [List] A=[10,23,35,46,58,69,80] B=[1,4,7,15,18,19,24,28,30] C=[] C.extend(A) C.extend(B) C.sort() print(C)...
9d7e17204cc48bdcff372eaa383e4c17b580463d
rayturner677/polishing_skills
/23_April/elevation_difference.py
499
4.03125
4
def find_under_sealevel(arr): sealevel = 0 count = 0 above_sealevel = True for i in arr: if i < sealevel: above_sealevel = False elif above_sealevel == False: if i > sealevel: count += 1 above_sealevel = True else: ...
1bf652da0c4a509c55ac37e374efa691242c12eb
YooGunWook/coding_test
/practice_coding_old/탐욕법/탐욕법_2번.py
2,485
3.703125
4
from string import ascii_uppercase def change_alpha(name): # 방향키를 어디로 해야 좀 더 효율적인지 판단하는 알고리즘. 이것보단 ord()를 써서 직접 구하는 것이 좀 더 효율적이고 코드도 짧아진다. # [min(ord(c) - ord('A'), ord('Z') - ord(c) + 1) for c in name] up = 0 down = 1 # 아스키 문자에서 모든 대문자 알파벳을 뽑는다. alpha_list = list(ascii_uppercase) i = ...
cb55a527d1b9a50f016e3fcd3de0f645b82b0a87
RicardoALaborde/ProgChallenges
/AutomateTheBoringStuff/Chapter11/linkVerification.py
1,286
3.859375
4
''' Write a program that, given the URL of a web page, will attempt to download every linked page on the page. The program should flag any pages that have a 404 “Not Found” status code and print them out as broken links. ''' import requests, bs4,sys,re #go to website as indicated on user input at the cmd line url = sy...
54990f42ceb163d7207c8165ce09228b7b7579a7
Encrux/Project_Euler
/project_euler/4_largest_palindrome_product.py
416
3.59375
4
import math import sympy def isPalindrome(n): list = [int(x) for x in str(n)] for i in range(0, len(list)): if i < len(list) / 2: if list[i] != list[len(list) - 1 - i]: return False return True palindromes = [] for i in range(100,999): for j in range(100,999): ...
14dfb58dba92d0edc1d62e38390304ba8a9ffaa6
Carole-Ouedraogo/PY4E
/ex_3_2.py
371
3.828125
4
xh = input("Enter Hours:") xr = input("Enter Rate:") try: fh = float(xh) fr = float(xr) except: print("Error, please enter numeric input") quit() # print(fh, fr) if fh > 40 : # print("Overtime") reg = fr*fh otp = (fh-40) *(fr*1.5) # print(reg, otp) xp = reg + otp else : # pri...
ccd42c1ccec5520c1af5e331ffccb8ffad909633
Gerj17/investment
/Personal Expenditure/write_to_csv.py
1,107
3.859375
4
# Write Main_doc data to Csv with open("main_doc.txt","r" ) as md: date = [] # used to temperatily hold the date to fill in for line in md: #if line[:-3 with open('Gerard Expenditure.csv','a') as t: # t.write(f'date , description , value \n') # Determine if a line ...
e56db34dc2bd4fe2b62ae5d9c7c0568a266a9444
nachogoro/euler_project
/Problem058.py
1,880
3.875
4
#!/usr/bin/python3 #coding:utf8 # http://projecteuler.net/problem=58 # # PROBLEM CONTENT: # Starting with 1 and spiralling anticlockwise in the following way, a square # spiral with side length 7 is formed. # # 37 36 35 34 33 32 31 # 38 17 16 15 14 13 30 # 39 18 5 4 3 12 29 # 40 19 6 1 2 11 28 # 41 20 7 8...
c306afa9cdbedaf27e81b3ef8a37f83374964009
shokir85/Python-Essentials
/Ex_Files_Python_Structures_Linked_Lists/Exercise Files/Ch04/04_05/Begin/sll.py
3,327
3.796875
4
class SLLNode: def __init__(self, data): self.data = data self.next = None def __repr__(self): return "SLLNode object: data={}".format(self.data) def get_data(self): """Return the self.data attribute.""" return self.data def set_data(self, new_data): "...
c05a00af53e1f23cb5bf50f0401985670c15e2ef
SonMinWoo/hanyang3-1
/os/practice/week13/opt.py
1,274
3.609375
4
''' Optimal algorithm ''' import sys pages = (7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1) size = 3 def search(now, pages): distance = 0 switch = True for i in pages: if i == now: break distance += 1 return distance def OPT(size,pages): SIZE = size memory = ...
064d6e8f2a11b036ee403d9bc7077d6d13b0b572
rahul166/Python-scripts
/create_mock_csv.py
1,704
3.640625
4
''' This is a script for generaing mock data/dataset as a csv file you have to pass the file name with a .csv extension for example test.csv You can add columns of your choice so you have to change both DictWriter and writerow Currently it is genrating a csv file with 3 cols BrnadID,ID(userID),Tran_date(transaction ...
9bb42734fc330a61f1c72ee86a1d7c7884aaa185
SampatSuthar/ml-demo
/logic.py
462
4.0625
4
## conditons when we have list of possible values ## practicing the condtinal logic in python state = 'Karnataka' if state.lower() in('rajasthan','gujrat','karnataka'): petorl_price = 108.18 print('Petrol price in ',state, 'is ', petorl_price) elif state.lower() == 'maharashtra': petorl_price = 111.30 ...
93039a31ebb56de2da60220d108bb7ef18a4609e
danielvargas97/ejemplosPython
/Substraction.py
4,782
3.625
4
# -*- coding:utf-8 -*- # #Substraction - Example# #EJEMPLO de Substraccion# #SE SUPONE QUE NO HAY NADA QUE AGREGAR NI NADA QUE QUITAR# #DENTRO DEL DISEÑO# from random import * class MazoAbs(object): def revolver_mazo(self): pass def llenar_mazo(self): pass def ver_mazo(sel...
6258e8705d190f057c5f1938715c10ba4b740dec
imldresden/mcv-displaywall
/multi_view_ctrl/grid_element.py
1,482
3.875
4
class GridElement(object): """ A element in a grid. """ def __init__(self, id, left, top, right, bottom): """ :param left: The left cell this elements is laying in. :type left: int :param top: The top cell this elements is laying in. :type top: int :param ...
2d6f80d89397b329742f7dc7aac10cfb53f6bd55
bilalahmad1994/learn-python
/Python object and dara structure/strings.py
407
3.734375
4
# print ('hello') # print('bilal ahmad') # print('ahmad') # from __future__ import print_function # print('here is the new line /n and here is the second line') s='hello world' # print(s) # print(s[0]) # # print(s[1:]) # # print(s[:5]) # # print(s[-1]) # print(s[::-1]) # # print(s[::2]) # # print(s[::-1]) # prin...
269e0c0d9d1e9fc3cc5403c803eefca25de095f3
fslichen/Python
/Python/src/main/java/For.py
788
4.34375
4
# Entire Loop strings = ['Apple', 'Pear', 'Orange'] for string in strings: print(string) print(len(string)) # Partial Loop strings = ['Apple', 'Pear', 'Orange', 'Cucumber', 'Banana', 'Tomato', 'Potato'] for string in strings[1 : 3]: print(string) # range(n) function ranges from 0 to n - 1. for i i...
3e052b13ed3e2fdcbb6a3a157cc76975dde6b37d
SrilekhaSundara-git/Srilekha
/Python_Challenges/Classic Problems/basic_mathematical_problem/sort_the_odd.py
508
4.40625
4
#Sort the odd #You will be given an array of numbers. You have to sort the odd numbers in ascending order while leaving the even numbers at their original positions. #How can I sort ascending the odd numbers in a list of integers, but leaving the even numbers in their original places? def sort_array(source_array): ...
b6d52bcf311e5fe837477d2164958e5e1964319c
anirudhn18/msba-python
/Lab3/Lab3_Ex4.py
400
4
4
def duplicate_names(name_list): name_counts = dict() for name in name_list: name_counts[name] = name_counts.get(name,0) + 1 dup_list = list() for name in name_counts: if name_counts[name] > 1: dup_list.append(name) return dup_list list_of_names = ['Bob'...
afeb031aa6c103a131f19c96ffb01fa80031bda6
Suryabratacharya101/python_assignment1
/new1.py
499
4.03125
4
# assignment 1 # Task 1 lst = [] for i in range(2000, 3201): if i % 7 == 0 and i % 5 != 0: lst.append(i) print(lst) # task 2 first_name = input("Enter your first name: ") last_name = input("Enter your last name: ") print('The reverse of your name is ' + last_name[::-1] + "\t" + first_name[::-1...
cea98d76e96c373b7625179855ad1c82a778e316
Abdulaziz-04/Algorithmic-Toolbox
/week2_algorithmic_warmup/2_last_digit_of_fibonacci_number/fibonacci_last_digit.py
267
3.9375
4
# Uses python3 import sys def get_fibonacci_last_digit_naive(n): a=0 b=1 for i in range(2,n+1): c=(a+b)%10 a=b b=c return c if __name__ == '__main__': n = int(input()) print(get_fibonacci_last_digit_naive(n))
225bc6b66555fc40b9ac761e589ff31f5c9c2fd6
goldmode321/The_TCN_project_2018
/TCN_xbox.py
1,694
3.640625
4
# This program work with any type of joystick directly , and it must can output the position of stick with numbers. # This is design with Xbox , 'a' button represent accelerate , while 'b' is opposite . x1,y1 is left stick position # z1 is the x-axis of right stick # The moving method is by "adding value" of each axi...
ba63130502481f59d5a4b284bda1ba48de305074
AmritRajeev/Random-Forest-classifier
/low.py
1,616
3.640625
4
import pandas as pd def u_cal(u, n): temp = u; for i in range(1, n): temp = temp * (u - i); return temp; # calculating factorial of given number n def fact(n): f = 1; for i in range(2, n + 1): f *= i; return f; d=[30,27,26,25,24,23,20,19,18,17,16,13] ...
a8934fba016a21d60632f757b4aa22733512722b
chilly99QWSA/charlin
/number of clones.py
389
3.671875
4
str=list(map(str,input("enter the string").split())) c=[] c.append(str[0]) for i in range(0,len(str)): if str[i] in c: continue else: c.append(str[i]) print(c) c.sort() for j in range(0,len(c)): count=0 for k in range(0,len(str)): if c[j]==str[k]: count=count+1 ...
845ad2e9f846ed42b2861954fbd607f772b08a4e
kokokocarev/cloud_store
/venv/zaelsit'.py
404
3.8125
4
dictionary = ['all', 'an', 'and', 'as', 'closely', 'correct', 'equivocal', 'examine', 'indication', 'is', 'means', 'minutely', 'or', 'scrutinize', 'sign', 'the', 'to', 'uncertain'] input_ = input().split() input1 = [] for i in input_: if i not in dictionary: input1.append(i) if ...
880d5511b5da0e6942737ce152be6183d4751570
Sabaoon96/University-of-Auckland
/COMPSCI 101/Assignment 01/skha787A1Q2.py
1,607
3.578125
4
""" Sabaoon Raza Khan - skha787 ID Number: 983957824 Program that simulates four transactions on a bank account. """ import random balance = 11568 random_transaction_amount1 = random.randrange (100, 151) random_number1 = random.randrange (-1, 2, 2) transaction1 = random_transaction_amount1 * random_num...
cf65f03559657500d7fc7a518ba3ec17004d9ee3
BhagyashreeKarale/list
/substring.py
947
4.28125
4
# Remove Substring # mainStr = ["the", "quick", "brown", "fox", "jumped", "over", "the", "lazy", "dog", "the", "dog", "slept", "over", "the", "verandah"] # subStr = "over" # Aapko aisa program likhna hai, jo subStr ki saari occurences ko mainStr se hata degi. Yaani uppar wale program ka output yeh hoga: # the quick b...
226cdb0e647d74210f0bc775d124cecd277e07d7
giuliacasale/ADM-HW2
/methods.py
25,310
3.90625
4
import pandas as pd import random import numpy as np import matplotlib.pyplot as plt #before starting: exploring datasets '''function that describes the columns of our datas and counts how many null values there are''' def describe_df(df_names): months = ['October','November'] for i in range(len(...
a74a4f9d825fd70a8a593b7c78bf9d761ad84cb1
gogganesko/DISCOVER-IT-2020-div-D
/E.D2.py
154
3.5625
4
arr = input().split(" ") a = int(arr[0]) b = int(arr[1]) c = int(arr[2]) d = int(arr[3]) result = (((a*d) + (b*c)) / (b*d))%((10**9)+7) print(int(result))
8675d32dbd0e357e9007533420c835945d07a97d
ES2Spring2020-ComputinginEngineering/project-1-liv-and-soham
/step1_theoretical_period.py
1,611
4.25
4
# Liv Moore and Soham Dave # There is one primary limitation with this model that could affect its # ecological validity (e.g. how well it translates to the real world). # We assumed that air resistance does not slow down the pendulum. Air # resistance continually acting on the pendulum is what causes it to # ...
e84699358cdc9f7d03018947c59f7e29dcb98e4f
Rauldsc/ExercisesPython
/basic1/ex20.py
327
3.6875
4
""" Write a Python program to get a string which is n (non-negative integer) copies of a given string. """ def stringCopies(aString, copies): if(int(copies) >= 0): return(copies*aString) else: return("No valide number") print(stringCopies("Hello World",-2)) print(stringCopies("Hello World...
924f15085bab95b553dfcb89c3b2741b7e5bf256
roy-sizemore/python_practice
/useless_trivia.py
862
4.375
4
# Useless Trivia # Gets information from the user and then prints dumb trivia based on the information provided name = input("Hi, what's your name? ") age = int(input("How old are you? ")) weight = int(input("Last question, how many pounds do you weigh? ")) print("\nIf ee cummings were to email you, he'd address you ...
4113c34096d6f61520d068d20ee4233d5b1d3a6a
iBoBoTi/Budget-App
/budget_app.py
2,923
4.09375
4
class Budget: """ A budget class to create objects of budget categories that can allow deposit, withdrawal, transfer between categories, as well as give a final balance for the category """ def __init__(self, name): self.name = name self.categories = [] # to tell you the transact...
aaa09fa20ad2be9c5b4425b759ff1b7904abbe9b
joemeens/guvi
/code/power2.py
116
3.765625
4
num1=int(input()) for i in range(100): if(num1==2**i): print("yes") break else: print("no")
7f66fc0832797c59e10f9951081e099153a2a43b
BimalDora/Python-Projects
/guess_the_number.py
1,016
4.15625
4
# Number Guessing Game import time, random, math print('***Welcome to Number Guessing Game***') time.sleep(1) lower = int(input("Enter lower bound: ")) upper = int(input("Enter upper bound: ")) secret_number = random.randint(lower, upper) total_guess_allowed = round(math.log2(upper - lower + 1)) guess_taken = 1...
51c68644b2c7f17e84b8a8506cf5c8e3e3bab23c
hepanIsOk/PythonWorkSpace
/PythonDemo/judgUp.py
246
3.65625
4
L = [0, 1, 2, 3, 4,4] L1 = list(sorted(L)) L2 = list(sorted(L,reverse=True)) print(L) print(L1) if L == L1: print("UP") elif L==L2: print("DOWN") else: print("WRONG") for i in range(len(L1)-1): if L1[i] == L1[i+1]: print("YES") break
41ab44239f7d2d2b96c4362fb5e486abfd9a597e
Vovanuch/python-basics-1
/happy_pythoning_cource/Part_7/7.2.1.For_range_reverse/7.2.1.for_range_reverse.py
1,184
3.609375
4
''' Последовательность чисел 3 🌶️ Даны два целых числа mmm и nnn (m>nm > nm>n). Напишите программу, которая выводит все нечетные числа от mmm до nnn включительно в порядке убывания. Формат входных данных На вход программе подаются два целых числа mmm и nnn, каждое на отдельной строке. Формат выходных данных Програ...
d21ca7cb7e039151a4f77c44fbe8cc83d923496e
Raihan9797/Python-Crash-Course
/5_if_statements.py
6,111
4.40625
4
# simple example cars = ['audi', 'bmw', 'subaru', 'toyota'] for car in cars: if car == 'bmw': print(car.upper()) else: print(car.title()) ## conditional tests # basically, if and else are based on a conditional test. # check equality car = 'bmw' car == 'bmw' car == 'audi' # check inequality ...
06b7ea1fdcd256c147356d01e12afe229fa99c25
PlusSP/Python
/lists/matrix.py
358
3.921875
4
# !/usr/bin/env python3 # coding: utf-8 # 7. Написать программу для транспонирования матриц. def transposition(list1): list_transp = [[] for i in range(len(list1[0]))] for y in range(len(list1[0])): for x in range(len(list1)): list_transp[y].append(list1[x][y]) return list_transp
8878b19e4ac58cd15aada89b39fb6c48348ec6df
mgmarques/ROT13
/rot13.py
589
3.875
4
# -*- coding: utf-8 -*- """ Spyder Editor Este é um arquivo de script temporário. """ # import string # s = string.ascii_uppercase # 65 a 90 # s = string.ascii_lowercase # 97 a 122 # s = "A vamos testar <br>!$" s="áâãà" def ROT13 (s = ""): t = "" for c in s: o = ord(c) if (o > 96 and o <...
0c387c9b93fa6bf0fd1cb552f896f1a860625eee
prashantgonga/python-practice
/course2/files/assignment1.py
455
4.6875
5
# 7.1 Write a program that prompts for a file name, then opens that file and reads through the file, # and print the contents of the file in upper case. # Use the file words.txt to produce the output below. fileName = input('Enter a file name: ') try : fileHandle = open(fileName, 'r') except : print(fileNa...
56e46414ba4fd757dc05aedc72d3e6e886ce2388
mbrsagor/PyLearn
/bongobd-codidng-test/problem_2.py
1,641
3.890625
4
class Person(object): def __init__(self, first_name, last_name, father): self.first_name = first_name self.last_name = last_name self.father = father person_a = Person("User", 1, None) person_b = Person("User", 2, person_a) def print_depth(data): c = 1 for key, val in data.items...
09181311ae8bb7d666ede3d3241c50cf98a926da
Andriy-Hladkiy/ITEA_Python_Basic
/topic_1/task_6.py
219
3.859375
4
# Напишите программу, которая переводит температуру в Кельвинах в Цельсии kelvin = int(input('Enter temperature: ')) celsius = kelvin - 273 print(celsius)
9a9dab649a8af771d65c6ee8722f693639701065
huangyisan/lab
/python/abcfunc.py
629
3.734375
4
import abc from abc import abstractmethod class MyABC(metaclass=abc.ABCMeta): def abc_method(self): pass @classmethod def __subclasshook__(cls,C): return True # 存在该装饰器的,则子类对象必须进行实例化,否则报错 @abstractmethod def do_somethng(self): print('yes') class C(object): def abc_...
a04a2660d2b264d0d04ac12d742f0fafeaf6e1c5
IamCarito/Python
/MaximoComunDivisor.py
930
3.8125
4
#MCD #Máximo Común Divisor #Número máximo por los que son divisibles 2 números. #Algoritmo de Euclides #Si tengo 2 número enteros positivos donde a>b>=0 #Entonces a =b*q+r donde q es la cantidad de veces y r es el resto #mcd(a,b) = mcd(b,r) def mcd(n1,n2): #Creamos la Variable donde guarde el resto (r) whil...
6c31bf91b08c678a25387cf3c5565ffa10e44ea1
ErinC123/Algorithm
/Leetcode/301-400/369. Plus One Linked List.py
1,129
3.65625
4
# Question: 369. Plus One Linked List # Difficulty: 201-300 # Tags: Linked List ''' Given a non-negative number represented as a singly linked list of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list. ''' # Definition for singly-linked list....
5f8fea76d8c83b1168f04585c4dd2fbfcedf4cd1
hgdsxf/python
/shuzu.py
410
3.84375
4
student=['aaa','bbb','ccc','ddd'] #查询 #print(student[0]) #print("最后一个元素:",student[-1]) #添加元素 student.append("eee") #print(student) #添加到指定位置 student.insert(0,"fff") #print(student) #修改元素 student[0]="AAAAA" #print(student) #删除最后元素 #student.pop(); #print(student) #删除指定位置的元素 #student.pop(1) pr...
e88fcacef0b7b1974976c94250c362886da5b4d6
Torroro2020/hackerrank
/Migratory Birds.py
763
3.578125
4
#!/bin/python3 import math import os import random import re import sys # # Complete the 'migratoryBirds' function below. # # The function is expected to return an INTEGER. # The function accepts INTEGER_ARRAY arr as parameter. # def migratoryBirds(arr): new_arr = [] dict_sample = {} for elem in arr: ...
e2ff0665195a44156facc650f4de21c26f5771af
jiinmoon/Python_Projects
/Code_Challenges/average_of_an_array.py
358
3.765625
4
# Problem #16 def rounding(num): r_num = round(num) if num - r_num >= 0.5: return r_num + 1 else: return r_num def main(): f = open('test_average_of_an_array.txt', 'r') f.readline() for line in f: li = list(map(lambda x: int(x), line.strip().split()[:-1])) print(rounding(sum(li)/len(li)))...
531fd5bd5ba33eb9d3b1eba028e1a8af6bf10aab
jshields/python_academic_examples
/examples/sort/bubble.py
3,486
4.5
4
def bubble_sort(lst): """ Bubble sort implementation Naive sorting algorithm Each of the n items could take n-1 (all other items) comparisons in worst case, n * (n-1) = n^2 - n = O(n^2) time complexity performance. When we've performed a swap, on the next pass i will point to where that e...
4ca9f47221b5a3ae9102b02e744533370bffb209
brpadilha/exercicioscursoemvideo
/DesafiosComFunctions/Desafio 016 - Truncar (inteiro) número.py
187
3.765625
4
def truncar (x): from math import trunc inteiro=trunc(x) print(f'O número inteiro de {x} é {inteiro}.') return n=float(input('Digite um número: ')) truncar(n)
0bc633683dd16a0b6b4b6807d9cb3acf15a69c19
jatin462/datastructureswithpython
/sortlinkedlistwhileaddingdata.py
1,168
4
4
class Node: def __init__(self, data, next): self.data = data self.next = next class linkedList: def __init__(self): self.head = None def sort(self, data): if self.head is None: n = Node(data, None) self.head = n return ...
86a12bfc853a2393fce4c870c608703a5a926d33
AndrejHafner/tetris-reinforcement-learning
/dqn/plot_exp_rate.py
272
3.640625
4
import matplotlib.pyplot as plt import numpy as np if __name__ == '__main__': x = np.arange(1, 2000) eps_start = 0.95 eps_end = 0.02 eps_decay = 400 y = eps_end + (eps_start - eps_end) * np.exp(-1. * (x / eps_decay)) plt.plot(x, y) plt.show()
e7841b30c406eed1370278076f434fc2fa2baa88
Simonster04/holbertonschool-higher_level_programming
/0x02-python-import_modules/3-infinite_add.py
234
3.609375
4
#!/usr/bin/python3 if __name__ == "__main__": from sys import argv lenav = len(argv) add = 0 for i in range(lenav): if i < 1: continue add = add + int(argv[i]) print("{:d}".format(add))
c57c61d86c5572b1948a7a0502578e0809ad170e
anton1k/python_crash_course
/part_1/04_6_test.py
75
3.703125
4
square = list(range(1, 21, 2)) print(square) for i in square: print(i)
64df971d98b1915c5759f8f4bca020b357ea27eb
harshaparuchuri007/Sentiment-Analysis
/Sentiment_code.py
8,106
3.578125
4
# -*- coding: utf-8 -*- """ @author: galahad """ #importing necessary libraries import re import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns import string import nltk import warnings import wordcloud warnings.filterwarnings("ignore", category=DeprecationWarning) #%matplotlib...
4bdfcf4ba531792aea6e7bd658f7225f6ff6eeed
Bitphreak/Project-Euler-Solutions
/python/problem_27/prob_27.py
1,209
4.21875
4
#!/usr/bin/python import sys def isprime(n): '''check if integer n is a prime''' # make sure n is a positive integer n = abs(int(n)) # 0 and 1 are not primes if n < 2: return False # 2 is the only even prime number if n == 2: return True # all other even numbers ar...
d12b5e7fa81924e1d282698ec61c08d94b9c3cf5
seddap/LPTHW
/ex15.py
639
3.859375
4
#Exercise 15: Reading Files from sys import argv script, filename = argv #open creates a file object txt = open(filename) print ("Here's your file {}:".format(filename)) print (txt.read()) print ("Type the filename again: ") file_again = input("> ") txt_again = open(file_again) print(txt_again.read()) txt.close...
b2e736c2be6a92c865b66a271a0dda5bbf7738a6
Bry-Dev/PythonApps
/GuessNumber/guess_game.py
2,751
4.15625
4
import secrets def do_fibonacci(): """ Do fibonacci """ fib_length = int(input("How Long? ( ͡° ͜ʖ ͡°) ")) b, a = 0, 1 for i in range(fib_length): print(b) sum = a + b a = b b = sum def create_random_int(n: int = 1000): """ Create random int based on the parame...
bff5815f632f6e46900d9d537841b4df4232340a
Guneesh/PythonPrograms
/reversestring.py
59
3.875
4
n=input("enter a string to reverse it: ") print((n)[::-1])
4ae5ceced0afcdfda9b19d4724f75c89b08e889a
iangohy/03.007_Design-Thinking-and-Innovation
/add_barcode.py
755
3.5625
4
import csv while True: with open('data.csv', 'a', newline='') as data: barcode = input("Enter barcode (enter q to quit): ") if barcode.lower() == "q": print("Thank you for your hard work!") print("Quitting...") quit() description = input("Enter product de...
6ad0fd594a546f210250d5a27bf5c28f6eac8d95
Kareemali20/GoMyCode-Submissions
/QUESTION 2.py
327
4.375
4
import numpy as np import pandas as pd # FUNCTION FOR CALCULATING THE FACTORIAL USING RECURSION def Factorial(Num): if Num == 0: return 1 else: return Num * Factorial(Num - 1) Number = int(input("Enter the number that you want to get the factorial of it : \n")) print(Factorial(Num...
6a8965d7837e6679142ab14b447e6766b2f8f4ad
itsme-vivek/Akash-Technolabs-Internship
/Day-3/3numcheckerLARGE.py
349
4.125
4
print("Find Greatest Number In 3 NUmbers") a=int(input("Enter 1st Number:")) b=int(input("ENter 2nd Number:")) c=int(input("Enter 3rd Number:")) if a>b: if a>c: print(a,"is larger") else: print(c,"is larger") else : if b>c: print(b,"is larger") else: print(c...
ffb59cd8b39952056734e51cd120a32c73666a55
swastikkalyane27/prbml
/oopsPython/sm/static_method.py
1,238
3.6875
4
## Static Method # class Test: # def __init__(self): # self.a = 5 # self.b = "shubham" # def operations(x,y): # print('the sum',x+y) # print('the product',x*y) # t = Test() # t.operations(10,2) # Test.operations(10,2) # class Test: # def m1(): # print('some method...
6f86c654cfe7d2529f05797b3f48e1cc1d354923
dtingg/Fall2018-PY210A
/students/Vincent_Aquila/session03/strformat_lab.py
2,532
4.15625
4
""" Python210A Vincent Aquila Fall2018 using Python 3.7.0 assignment objective: String Formatting Lab """ # task 1 print("---Task 1") """ Write a format string that will take the following four element tuple: ( 2, 123.4567, 10000, 12345.67) and produce: 'file_002 : 123.46, 1.00e+04, 1.23e+04' """ t1 = (2, 123.4567...
06a0571dbd6c0c36a1059e6a50ff992c1d70e6e7
HwangSangBin/Level-Test
/2750-2.py
742
3.8125
4
def bubble(list, num): j = num while j != -1: for h in range(j - 1): # 맨마지막 자리는 안해도 돼 if num_list[h] > num_list[h + 1]: # 앞에 거가 뒤에 거 보다 클 때 num_replace = num_list[h] num_list[h] = num_list[h + 1] # 뒤에 거를 앞자리에 넣어 ...
b16e2edd7c0e0b9f5d57d3476462a0d212c427a7
DavideTimo/hello-world
/Esercizio_12.py
1,156
3.78125
4
""" Questa è la doc_string del modulo. Questa descrizione è richiamabile con nomemodulo.__doc. **** Generatore di Istogrammi **** Scrivi una funzione che, data una lista di numeri, fornisce in output un istogramma basato su questi numeri, usando asterischi per disegnarlo. Ad esempio, data la lista [3,7,9,...
452be209b37af3d5eaaad44393e5ee2d6335e26a
summer-vacation/AlgoExec
/tencent/array_and_str/reverse_words.py
729
3.828125
4
# -*- coding: utf-8 -*- """ File Name: reverse_words Author : jing Date: 2020/3/18 https://leetcode-cn.com/explore/interview/card/tencent/221/array-and-strings/906/ """ class Solution: def reverseWords(self, s: str) -> str: if s is None or len(s) == 0: return s...
2dd5d04b748488dc5a1cccaaf41555276f9b4c45
vxvaibhavxv/Cache-Memory
/Cache Memory.py
26,677
3.65625
4
import math # Choosing the Cache Memory Mode mode = input(">>1<< Single Cache Memory\n>>2<< Multilevel Cache Memory\n\nChoice - ") # Single Cache Memory if mode == "1": size_main = int(input("Enter the size of Main Memory - ")) # Main Memory Size size_cache = int(input("Enter t...
9606b9981ae172b851019b75f4aa8fd3659ef169
joaogarciadelima/oopy
/exercicios/tombola/tombola_bug.py
1,418
3.859375
4
# coding: utf-8 """ =========================== Testando um tômbola com bug =========================== Para começar, vamos criar uma instância de tômbola. Nessa implementação, é necessário fornecer uma sequência de itens ao construtor:: >>> from tombola_bug import Tombola >>> bolas = [77, 88, 99] >>> t ...
bb1bfc6cde3fcc4bf2b4a808ad631b0caa0d2b80
cifpfbmoll/practica-3-python-rdtorres-cfgs
/P3EJ3.py
201
3.578125
4
import sys # Que función te informa del tipo de dato que tiene almancenado una variable? # La función es type n = "Roberto" a = 2 b = a / 1.5 print(type(a)) print(type(n)) print(type(b)) sys.exit()
40ce9ed3793687a63f6ba9ebf2d1497fa7e48369
dcribb19/plant-based-buds
/calculators.py
643
3.625
4
# calculators.py # Calculators for recommending protein intake based on body weight. def lbs_to_kg(lbs: float): '''Convert lbs to kg.''' return round(lbs / 2.205, 2) def daily_protein(kg: float, activity_level: str): ''' Return daily recommendation of protein based on weight and activity level. ...
3b61531cbd6b4b4605a41feb41a6d5fea4872cab
thesagargoyal/PYTHGON_LAB
/shop.py
123
3.875
4
b = list() a = "Yes" while(a=="Yes") : c=input() b.append(c) print("You want to continue shopping") a=input() print(b)
9d3e08733772ee97012797c1274cd639d845fbd0
erencemSalta/gemcoin
/backend/utils/hex_to_binary.py
714
4.09375
4
HEX_TO_BINARY_CONVERSION_TABLE = { '0':'0000', '1':'0001', '2':'0010', '3':'0011', '4':'0100', '5':'0101', '6':'0110', '7':'0111', '8':'1000', '9':'1001', 'a':'1010', 'b':'1011', 'c':'1100', 'd':'1101', 'e':'1110', 'f':'1111' } def hex_to_binary(hex_strin...
fead60fd8904ce622b40c3a47ff3364e78d64019
sandhyaramavathu/pythonprograms
/78.py
74
3.59375
4
n = int(raw_input()) if n%13 == 0: print("yes") else: print("no")
2cfdc0a1ee03d7e43f786a39e17ef9570ddd9280
eddyangang/article_summary
/api/scrape.py
461
3.640625
4
# This program will scrape a news article to get general information (i.e. author, date) and summarize the article using natural learning processing # Import the libraries import nltk from newspaper import Article def scrapeAndSummarize(url): # Get the Article article = Article(url) # Do some NLP ...
3f86d94ce7dcd98b1a5f6046518ef3d6818cc1b0
ChoiYoonJong/DataScience
/python_Pandas_Numpy/Pandas/hand_game.py
1,690
3.640625
4
import random while True: player = input(''' '1. 가위', '2. 바위', '3. 보', 4.횟수 입력 '9. 메뉴종료' ''') computer = random.randint(1, 3) computer = str(computer) if player == "1": player = "가위" elif player == "2": player = "바위" elif player == "3": player...
29e4cb5ff1f68097fc7edbeffbccdcca487ef4e9
henrypj/codefights
/Intro/02-EdgeOfTheOcean/matrixElementsSum.py
2,236
4.03125
4
#!/bin/python3 import sys """ # Description # # After they became famous, the CodeBots all decided to move to a new building # and live together. The building is represented by a rectangular matrix of # rooms. Each cell in the matrix contains an integer that represents the price # of the room. Some rooms are free (t...
2a4420cc6ed8f4d2958b47e1c60fa5fd41499ea4
bbthorne/ANN
/iris.py
3,319
3.953125
4
from IrisANN import * """ iris.py solves the "Gardens of Heaven". Follow the prompts for instructions! """ """ generate_set searches for a text file filename in the same directory as the program. The text file must have the format of that in the Fisher Iris database It then returns a shuffled list of pairs of input ve...
dd95ee79cbfd236d7ca2f773fb21b7747596e6da
guiilan/power-plant-plotter
/dados.py
861
3.625
4
import json import urllib.request as req def dados(): # Endereço do qual se obterá uma resposta no formato JSON. Representa o resumo url = "http://albertocn.sytes.net/2019-2/pi/projeto/geracao_energia.json" # Cria uma requisição para a URL passada e define no cabeçalho um browser conhecido como # ...
bc0718f09f2d5849b0a8232624f651b1b14efed9
adam-worley/com404
/1-basics/5-functions/2-nesting/bot.py
203
3.890625
4
def identify (): print("What lies before us?") x = input() print() if (x == "a large boulder"): print("It's time to run!") else: print("we will be fine") identify()
939c926e480a2719798f6d7caa9e738532071d51
livyt/backup-code
/euler/07/problem7.py
431
3.96875
4
import time def is_prime(n): if n==2 or n==3: return True if n%2==0 or n<2: return False for i in range(3,int(n**0.5)+1,2): # only odd numbers if n%i==0: return False return True start = time.time() which_prime = 10001 count = 1 prime = 2 it = 3 while count < which_prime: ...
9c1aac781ef857efe2f702863a1a79569b5cd447
khaston10/The_Secrets_of_Life_and_Death
/The_Secrets_of_Life_and_Death/Humanoid.py
3,941
3.859375
4
from Location import Location from LocationTypes import * class Humanoid: """ This class represents a humanoid. """ def __init__(self, name="no_name", gender="male", mood="content", health=100, visibility=100, player=False): self.name = name self.gender = gender self.mood = mood...
26d23827b96935371fa25ed25240160d85ab74aa
awsaavedra/coding-practice
/python/practice/redo_TheHardWay/6ex.py
379
3.671875
4
x = "There are %s types of people" % 10 binary = "binary" do_not = "don't" y = "Those who %s and those who do %s" % ( binary, do_not) print x print y print "I said: %r." % x print "I also said: '%s'." % y hilarious = False joke_eval = "Isn't this a funny joke?! %r" print joke_eval % hilarious w = "This is the le...
a92c8aa69f69c0a9d6e3635201a6261f2a8b469f
IshaanBAgrawal/Day-22
/The Pong Game/game_icons.py
940
3.96875
4
from turtle import Turtle class WinnerTurtle(Turtle): def __init__(self): super().__init__() self.color("white") self.hideturtle() def r_win(self): self.goto(x=200, y=0) self.write("You Win.", align="center", font=("Courier", 40, "normal")) self.goto(x=-200, y=...