blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
f4c346fc78529e71dd1d96a5d76f8f1a6ea71fb2
queise/WorldMood
/wm_func.py
12,465
3.78125
4
#!/usr/bin/python import sys import csv import re def F_createdictfromcsv(file): # creates a dictionary from the csv file with info about the journals jdict = {} with open(file, 'rb') as csvfile: reader = csv.reader(csvfile) for row in reader: jdict[row[0]] = row[1:] return jdict def F_getdi...
80bf607590809f38162c4b44e0690a49c125fc4f
unpreghini/htanh-fundamental-c4e21
/session2/sum_range_method2.py
135
3.796875
4
range_input = int(input("Enter range limit: ")) sum_range = sum(range(range_input + 1)) print("Sum of numbers in range is", sum_range)
33f7fdd5f91e08490f3357f7b17159c2a4b429c9
csreyno/Digital-Crafts-Classes
/programming101/modifying-lists.py
924
4.375
4
# my_pets = ["kira", "bullet", "potsy"] # my_pets.append("rainbow") #uses .append() method to add to the list # print(my_pets) # my_dogs = ["kira", "bullet"] # my_cat = ["rainbow"] # my_pets = my_dogs + my_cat #concatenation does not modify the original list, it creates a new one # print(my_pets) # new_set_pets ...
f0d31eed49c495e01ae49cecb933145ada771a44
Jeffrey-A/Introduction_to_programming-I_Programs
/chapter 7/#5.py
532
4.125
4
import math def main(): print("This program calculates your BMI.") weight = eval(input("Enter your weight in pounds: ")) height = eval(input("Enter your height in inches: ")) bmi = (weight * 720) / height**2 if bmi >= 19 and bmi <= 25: print("Your BMI is {0:0.2f}, within the health...
c25309c8d8b853d5b73e284ef089e589e7c21f72
Renita1206/Python-Games
/Hangman.py
1,024
3.59375
4
import random lives=7 l=[] def display(a): print(a) def generateAns(w): a="_"*len(w) return a def updateAns(c,w,ans): for i in range(len(w)): if(c==w[i]): ans=ans[0:i]+c+ans[i+1:] return ans print("The Categories are:") print("1.Countries") print("2.Famous People") choice=in...
a862da27cd938d498b5942f4ec770eddb1b9c4cc
dominic-sylvester-finance/autodcf
/autodcf/company/income_statement.py
4,445
4.03125
4
import datetime def now(offset=0): """Utility for getting current time or current time minus offset number of years. Args: offset (int): Number of years to subtract from current year. Defaults to 0. Returns: date (datetime.datetime): Date offset from today by offset number of years (or t...
293f6f4749f7c03995e4050476c7a09682f50c7a
nirmitapr2003/7DayCodingchallenge
/program18.py
377
3.875
4
# 18.Python Program to Find Armstrong Number in an Interval l=int(input("Enter the lower limit: ")) u=int(input("Enter the upper limit: ")) temp=0 order=0 digit=0 sum=0 for num in range(l, u+1): digit=num while digit>0: temp=int(digit%10) order=temp*temp*temp sum=sum+order digit=int(digit/10) if n...
65debffbb0a2f077c36facfbcdfa44142975711b
denvercoder9/python
/datastructures/peekable.py
651
3.796875
4
class Peekable(object): """Peekable but otherwise perfectly normal iterator""" def __init__(self, it): self.it = iter(it) self.peeked = None def __iter__(self): return self def peek(self): self.peeked = next(self.it) return self.peeked def next(self): ...
9bcf6fa21ecd0a799e2d7ad4f10ebd45f651604c
cpiscos/PythonCrashCourse
/Lesson 10/favorite_number.py
834
3.6875
4
import json filename = 'favorite_number.json' def get_stored_number(): """Gets stored number in filename""" try: with open(filename) as f_obj: favorite_number = json.load(f_obj) return favorite_number except FileNotFoundError: return None else: return favor...
7da8b99c02a58f57057791304402e8216d63223f
sammienjihia/dataStractures
/Graphs/dijkstra.py
6,057
4.09375
4
""" Dijkstra's algorithm can be considered an implementation of a BFS whereby instead of using a FIFO queue, we use a priority queue """ class dijkstra: def __init__(self, graph): self.graph = graph self.visited = set() self.priority_queue = [0] def bubble_up(self, last_index): ...
104596197155dc02f5692303aaedd651dfce8c83
pobiedimska/python-laboratory
/laboratory4/task2.py
1,371
3.875
4
def StrSpn(main_string: str, string_chars: str): main_string = main_string.split(' ') string_chars.replace(" ", "") for string in main_string: good_string = True for char in string: if not string_chars.__contains__(char): # символ зі слова не знаходиться у ...
24ac7d8b0037bee388c49abb7948896dab46cf45
Guilt-tech/PythonExercices
/Exercices/Secao04/exercicio31.py
210
4.125
4
print('Digite um número inteiro, que irá aparecer o seu antecessor e o seu sucessor') num = int(input('Número: ')) a = num - 1 s = num + 1 print(f'O antecessor do número {num} é: {a} e o sucessor é: {s}')
a85b6f504446a3bf1e9d00b4d1d236c80dfb3df0
Vishal97Singh/OnlineQuiz
/main.py
1,430
3.90625
4
from Tkinter import* import tkMessageBox top=Tk() def main(): top.destroy() import main def login(): top.destroy() import login def register(): top.destroy() import register def about(): top.destroy() import about l=Label(top, text="Welcome to Quiz",fg="black",font=("ROSEWOOD STD REGUL...
b0a2634f423a688b012cf7c43ea73277ea523bad
itohdak/mnist_euslisp
/nn_class.py
7,933
3.546875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import numpy as np n_neuron = 800 noise_rate = 0.00 # ノイズ割合 lr = 0.003 # ReLUを用いる場合は学習率を小さくしないとWが発散してしまう mr = 0.5 # 慣性項係数 # 活性化関数 # ランプ関数(中間層) class ReLU: def __call__(self, x): return x * (x > 0) def diff(self, x): # 微分 return 1. * (x > 0) ...
adafa91e2c7157504c12abcf96e8883c116d2a52
Apple7724/Probe
/15_string_подсчет одинаковых слогов.py
463
3.71875
4
word = input('введите слово ') number = len(word) k = 0 n = 0 count = 0 for k in range (0, number): first = word[k:k+2] for n in range (k, number): second = word[n+1:n+3] print (k, 'first=',first) print (n, 'second=',second) if f...
9b575b2c578977f98588fbe0ddecc90da6b050c3
aes421/Maze-Solving-Robot
/scripts/labutils.py
217
3.90625
4
#!/usr/bin/env python import math def wrap_angle(angle): r_angle = angle while r_angle <= -math.pi: r_angle += 2*math.pi while r_angle >= math.pi: r_angle -= 2*math.pi return r_angle
282fc0a41fcbef25aa90ee009217326a87c8df1c
VertikaJain/python-basics
/loops.py
674
4.28125
4
# A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string). people = ["abc", 1, "xyz", 2] for person in people: # do not use brackets in python syntax in for loop print(person) # Break statement for person in people: if(person is "xyz"): break...
ab23b1f3555e0b163d3479879398d32bd0798a7b
Sakkadas/leetcode
/Easy tasks/richest-customer-wealth.py
654
3.84375
4
""" You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the ith customer has in the j bank. Return the wealth that the richest customer has. A customer's wealth is the amount of money they have in all their bank accounts. The richest customer is the customer that has the maximum we...
2b3c260f38d9da1d34fbf7419336db748eac0d23
yuyangh/csci201finalproject
/WebScrapping/web_scraping_testing.py
1,335
3.84375
4
import json def check_json_existence(file_path): ''' by specifying the file address, open the file to see whether it has corresponding class information :param file_path: :return: boolean ''' with open(file_path, mode="r") as file: lines = file.readlines() if len(lines) > 100...
87c389307e3e47c134cb5554106dd9bef9e4a39c
MrHamdulay/csc3-capstone
/examples/data/Assignment_1/clleli002/question2.py
691
4.25
4
#Program to check the validity of a time entered by the user as a set of 3 integers. #Name: Elizabeth Cilliers #Student Number: CLLELI002 #Date: 26 February 2014 def time(): if hours<0 or hours>23: print("Your time is invalid.") elif minutes<0 or minutes>59: pri...
43b41ed6e872a3b9fb5caa01ce7d9399a0accf57
woider/runoob
/case_10/sub_5.py
491
3.78125
4
''' 题目:输入三个整数x,y,z,请把这三个数由小到大输出。 程序分析:我们想办法把最小的数放到x上,先将x与y进行比较,如果x>y则将x与y的值进行交换,然后再用x与z进行比较,如果x>z则将x与z的值进行交换,这样能使x最小。 ''' arr_str = input('请输入三个整数:\n') arr = arr_str.split() for i in range(len(arr)): arr[i] = int(arr[i]) arr.sort(reverse=False) print('排序结果:\n' + str(arr))
2b1d350d06f5d2d91d5220ba017c57edfe3c8be6
alecbarreto/abarreto
/ToJadenCase.py
382
4.0625
4
def toJadenCase(string): lst = [] count = 0 for word in string.split(" "): for letter in word: lst.append(letter) lst[count] = lst[count].upper() count += len(word)+1 lst.append(" ") lst.pop(-1) string = '' return string.join(lst) print...
45b37c8545ce632a57f7773a77b6c55fc060512a
Do-code-ing/Python_Built-ins
/Methods_Tuple/count.py
175
3.6875
4
# tuple.count(element) # tuple에 있는 element의 갯수를 반환한다. # 없는 경우, 0을 반환한다. a = (1,1,2,3,4,5) print(a.count(1)) # 2 print(a.count(6)) # 0
5d3c4796374196a3633719c5f7a7b8409fa68d5d
clevercoderjoy/Competitive-Coding
/GFG_sort_0_1_2.py
428
3.6875
4
def sort_0_1_2(arr,size): i = 0 zero = 0 two = size - 1 while i <= two: if arr[i] == 0: arr[i], arr[zero] = arr[zero], arr[i] i += 1 zero += 1 if arr[i] == 2: arr[i], arr[two] = arr[two], arr[i] two -= 1 else: ...
d6a49883c39aae7c921638457e8da002d6290e4f
mwendt23/Max-Wendt-Repository-p2
/Euler5.py
219
4
4
def divisible(number): for i in range (2, 21): if number % i != 0: return False return True number = 2 ≈while True: if divisible(number): break number += 2 print(number)
e136863c0085870d5dd337def668a961c91ac48a
aaronko423/Battleship
/app/controller2.py
3,335
3.9375
4
#! usr/bin/env python3 from gameboard2 import GameBoard import os g = GameBoard() def user_gameplay(): print("\nWelcome to battleship!\n") player1_name = input("Player 1, please enter your name: \n") player2_name = input("Player 2, please enter your name: \n") os.system("clear") g.print_pl...
b2cc416848d61dec8c4996f248f8471022d8d945
jonathonlefler/translator
/main.py
4,029
3.609375
4
#!/usr/bin/env python3 """ Written by Tray(zi)o - Lefler The goal of this program is to take in Manga raws and translate them, spitting out new images with the translated text. Functionality: Read in and generate image library of Hiragana, Katakana, and Romaji using a single font library Finds one match using `あ.png`(...
485563a8c731798fc2c0adaacebe8dd947b3390e
girish-patil/git-python-programs
/Python_Assessment/Q7.py
843
3.96875
4
# -*- coding: utf-8 -*- """ Created on Mon Oct 09 13:00:03 2017 @author: Girish Patil """ #7.Write a program to display an user-defined Exception #below code is written to ask user to enter number to guess the number stored, #to help, we give hint to them greater than that number or less than that number #user def...
8deb3eb3eaaa6acf984178be582e3e096ba7c52c
matrx-software/matrx
/matrx/utils.py
1,543
3.875
4
import itertools import math def get_distance(coord1, coord2): """ Get distance between two x,y coordinates """ dist = [(a - b) ** 2 for a, b in zip(coord1, coord2)] dist = math.sqrt(sum(dist)) return dist def get_room_locations(room_top_left, room_width, room_height): """ Returns the locations ...
7a306d85792fc3a52e17c6ec0a82344b96b994ed
stradtkt/Algorithm-Python
/chapter-2/fibonacci.py
149
3.84375
4
def fibonacci(num): sums = 1 i = 0 j = 1 while num > 1: sums = i + j i = j j = sums num-=1 return sums print(fibonacci(4))
0498665c2df0179a2c3e98b71dd5c155b0de436d
ZhengyangXu/LintCode-1
/Python/Maximum Subarray Difference.py
1,448
3.640625
4
""" Given an array with integers. Find two non-overlapping subarrays A and B, which |SUM(A) - SUM(B)| is the largest. Return the largest difference. """ class Solution: """ @param nums: A list of integers @return: An integer indicate the value of maximum difference between two Subarrays ...
1c3dc60fabfdab7d1e8f95123859230229b8cafe
qiufengyu21/LeetCode-1
/BinaryTreeLevelOrderTraversalII/bfs.py
1,864
3.890625
4
Use a List as Queue, then do the BFS iteratively. # @param root, a tree node # @return a list of lists of integers def levelOrderBottom(self, root): if root == None: return [] ans = [] cur = [] q = [root, None] while len(q) > 0: node = q.pop(0) if node == None: i...
336d3310ea1d69668b7975075f4d906b9fa99547
Kumar1998/github-upload
/python7.py
430
3.9375
4
print("Type integers, wach followed by Enter; or just Enter to finish") total=0 count=0 while True: line=input("integer:") if line: try: number=int(line) except ValueError as err: print(err) continue total += number count +=1 ...
e2c46e9c3c12ed70166afee419a09e346f651ad9
gdh756462786/Leetcode_by_python
/Bit Manipulation/Single Number.py
760
3.984375
4
# coding: utf-8 ''' Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? ''' class Solution(object): ''' 对数组元素执行异或运算,最终结果即为所求。 由于异或运算的性质,两个相同数字的异或等于0,而任意...
002ddc23cd4343f1310030f6ec1f2c9594046124
aadithpm/leetcode
/OA/Clutter/LastLetters.py
182
3.703125
4
def lastLetters(word): if len(word) == 2: return ' '.join(letter for letter in word[::-1]) return ' '.join(letter for letter in word[len(word) - 1:len(word) - 3:-1])
3f8ca1c8c8a4d4df75063f1733348dbb8606b6d1
asifrasheed6/PL
/Lab1/Exercise5.py
403
3.9375
4
#Authors Abdullah Khan, Asif Rasheed #Programming Languages (CMP 321) Lab 1 Exercise 5 s = 'Welcome to Python' print('The String: ', s) print('All characters between index 6 and 10: ',s[6:10]) print('All Characters after the 4th character: ',s[4:]) print('Last 5 characters: ',s[-5:]) print('All characters at Even inde...
52c02be313f887ea6681ae1317b4876a924f0fb1
guohaoyuan/algorithms-for-work
/python/值传递引用传递.py
264
3.59375
4
a = 1 b = [1, 2, 3] def test_data(b): b = b + 1 return b def test_list(c): c.append(10) return c if __name__ == '__main__': data_trans = test_data(a) print(a, data_trans, a) object_trans = test_list(b) print(b, object_trans, b)
c8c8ead133ea6e3fd74fb4811a7ef5977d1f1c89
Adeelanwar/Numerical-Analysis-2020
/Bisection.py
915
3.59375
4
import math def bisection(f, xp, xn, e): n = 0 error = 10000 xm = 0 while abs(error) > e and n < 1000: if(f(xp) * f(xn) < 0): xm = (xp + xn) / 2 if(f(xp) * f(xm) < 0): xn = xm elif(f(xm) * f(xn) < 0): xp = xm n += 1...
56dd06d705859d8351ac024d71b2b52f22fb4eca
Lunchesque/udemy
/fullpythontutorial/built_in_functions/abs_sum_round.py
394
3.765625
4
def max_magnitude(nums): return max(abs(num) for num in nums) print(max_magnitude([200, 23, -400, 300])) def sum_even_values(*values): return sum(val for val in values if val % 2 == 0) print(sum_even_values(1,3,4,6,7)) def sum_floats(*floats): return sum(arg for arg in floats if type(arg) == float) print(...
052d1bc3a24ed5342dfd5281791754a00893bdc7
praveendhananjaya/Machine-learning-and-data-mining
/Machine_learning_lab/week2/Linear_Regression/logistic_regression.py
2,665
3.828125
4
# logistic regression # Import standard data sets from sklearn import datasets # Import the Logistic regression model from sklearn.linear_model import LogisticRegression # Split data set into a train and test set from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score import...
b9b9dd8694da483a1e7dd40aad5b86bd34a98d91
Tanmay12123/-100-day-code-challange
/challange_12/main.py
992
4.21875
4
# student_dict = { # "student": ["Angela", "James", "Lily"], # "score": [56, 76, 98] # } #Looping through dictionaries: # for (key, value) in student_dict.items(): #Access key and value # pass import pandas # student_data_frame = pandas.DataFrame(student_dict) #Loop through rows of a data frame # fo...
d12435c7cc17f57a9ffe97daf2e0de1f7a935b83
weilyu/hackerrank_python
/basic_data_types/Finding_the_percentage.py
298
3.75
4
# https://www.hackerrank.com/challenges/finding-the-percentage n = int(input()) book = dict() for i in range(n): curr = input().split() name = curr[0] avg_score = (float(curr[1]) + float(curr[2]) + float(curr[3])) / 3 book[name] = avg_score print("%.2f" % round(book[input()], 2))
e542800e92b5c3cd6e1a71368b78209a058806db
Abhishikta456/swapping-files
/swappingFile.py
497
3.546875
4
def SwapFileData(): fileOneData = input("Enter your file name : ") fileTwoData = input("Enter your file name : ") with open(fileOneData,'r') as sampleA: data_sampleA = sampleA.read() with open(fileTwoData, 'r') as sampleB: data_sampleB = sampleB.read() with open(...
597d1d26769f884760533f66a7f7c1d8ed498ea0
Crackeree/Solved-problems-python
/structur.py
390
3.796875
4
"""a=int(input("enter a num: ")) i=0 j=0 while(i<=a): j=0 while(j<=i): print("*",end=(".")) j=j+1 k=i while(k<(a-1)): print(" \n") k=k+1 i=i+1 """ """n=int(input()) for i in range(1,n+1): print("*"*i) n=n-1 for i in range(n,0,-1): print("*"*i) """ n=int(input()) for i ...
ca400774c7d9d13be3b545895ebd898f7eb07979
DevBaki/Python_Examples_Basic
/liists.py
537
3.828125
4
if __name__ == '__main__': N = int(input()) lists = [] for i in range(N): letter = input().split(' ') if letter[0] == 'insert': lists.insert(int(letter[1]), int(letter[2])) if letter[0] == 'remove': lists.remove(int(letter[1])) if letter[0] == 'append': lists.append(int(le...
71995c93851049f9d1e23ff1acdd42ae50bbd246
jingong171/jingong-homework
/唐聿澍/2017310404-唐聿澍-第二次作业-金工17-1/city.py
612
4
4
#城市名字,定义列表 cities = { 'Beijing':{ 'country':'China', 'population':'20,000,000', 'fact':'big', }, 'London':{ 'country':'UK', 'population':'8,300,000', 'fact':'ease', }, 'NewYork':{ 'country':'US', 'population':'8,50...
fcb45e3ce6415bc01da4562e5c438e257e6d1f52
eysta00/T-111-PROG-Haust-2019
/Exam Code/div_by_17.py
96
3.609375
4
num = 0 while True: if num % 17 == 0 and 100 <= num <= 999: print (num) num += 1
54c5cfd8f99a1e76550841596a58c55896001ce5
cescobar99/Ejercicios_IA
/isogram/isogram.py
189
3.921875
4
def is_isogram(string): mem = {} for letter in string.lower(): if not letter in " -" and letter in mem: return False mem[letter] = True return True
43160a08a25e8051700aab85b4c0104811474af6
NonPersistentMind/Python
/Programming_Python/C1_Database/OOP_tryout/person_start.py
1,017
3.625
4
class Person: def __init__(self, name, age, job=None, pay=0): self.name = name self.job = job self.age = age self.pay = pay def lastname(self): return self.name.split()[-1] def giveRaise(self, percent): self.pay *= 1 + percent/100 def __str__(self): ...
1a85dc0e46533b715caae0e0207af15e108b2b11
RRoundTable/CPPS
/week6/Combination_Sum.py
3,045
3.71875
4
""" link:https://leetcode.com/problems/combination-sum/ Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target. The same repeated number may be chosen from candidates unlimited number of time...
05e9ec67b25db333d40e26ded1e2a4830fe61005
wangtonylyan/Algorithms
/algorithms/dynamic/dim1.py
4,971
3.578125
4
if __name__ == '__main__': import sys import os sys.path.append(os.path.abspath('.')) from algorithms.utility import * ######################################################################################### ## LeetCode 70 ## 给定n级阶梯,每次1或2级,总共有几种达顶方式 class Problem1(Problem): def check(self, n): ...
87005322e5386741ae5e98c98b6b5f1edc2bcf9a
christinegithub/python_fundamentals1
/exercise6-2.py
1,176
4.46875
4
# You started the day with energy, but you are going to get tired as you travel! Keep track of your energy. # If you walk, your energy should increase. # If you run, it should decrease. Moreover, you should not be able to run if your energy is zero. # ...then, go crazy with it! Allow the user to rest and eat. Do whatev...
d761193b5b945752d6bc2ad70f9965de6d36625a
VitorSchweighofer/exertec
/Exercicio3/Exercicio 3/exe8.py
444
4.03125
4
a = float(input('Insira o primeiro lado do triangulo: ')) b = float(input('Insira o segundo lado do triangulo: ')) c = float(input('Insira o terceiro lado do triangulo: ')) if ((b - c) < a < b + c): if (a==b==c): print('Seu triangulo é equilátero') elif (a!=b!=c): print('Seu triangulo é escaleno') elif...
2dba274c10bbd845194fe3082b2e96ac9cd4d215
danielmlima1971/CursoemVideo-Python-Exercicios
/Mundo 1/Ex020.py
489
3.953125
4
# EXERCICIO 020 # Exercício Python 20: O mesmo professor do desafio 19 quer # sortear a ordem de apresentação de trabalhos dos alunos. # Faça um programa que leia o nome dos quatro alunos e # mostre a ordem sorteada. import random a1 = input('Nome do Aluno 01: ') a2 = input('Nome do aluno 02: ') a3 = input(...
63cb97b240b84133a3a9e0650baf32d5e56678a0
alexshchegretsov/Teach_Me_Skills_Python_homeworks
/src/hw_3/task_3_4.py
184
3.875
4
string = input('Enter any string:\t') central_char = string[len(string) // 2] print(central_char) if central_char is string[0]: string_slice = string[1:-1] print(string_slice)
9de5636b690e24cabfdb8c54b0740bf98ed54f54
LarisaOvchinnikova/python_codewars
/Initialize my name.py
289
3.625
4
https://www.codewars.com/kata/5768a693a3205e1cc100071f def initialize_names(name): arr = name.split() if len(arr) == 1: return arr[0] new_name = arr[0] + " " for el in arr[1:-1]: new_name += el[0] + ". " new_name = new_name + arr[-1] return new_name
0546636d05bdd849dfe635aeea689ac9db999a18
Light-Alex/offer
/test62-1.py
1,015
4.03125
4
''' 题目: 字符流中第一个不重复的字符 请实现一个函数用来找出字符流中第一个只出现一次的字符。 例如,当从字符流中只读出前两个字符"go"时,第一个只出现一次的字符是"g"。 当从该字符流中读出前六个字符“google"时,第一个只出现一次的字符是"l"。 输出描述: 如果当前字符流没有存在出现一次的字符,返回#字符。 ''' # 方法一: 使用Python的filter函数 class Solution: # 返回对应char def __init__(self): self.s = '' def FirstAppearingOnce(self): # writ...
dea097a19f54b0562875043532710f90137af7a4
javierramon23/Python-Crash-Course
/10.- Ficheros y Excepciones/addition.py
338
3.765625
4
number_one = input('Introduce el primer operando: ') number_two = input('Introduce el segundo operando: ') try: result = int(number_one) + int(number_two) except ValueError: print('Opps, ha surgido algun problema con los operandos.') else: print('El resultado de sumar {} + {} es: {}'.format(number_one, num...
b98c658970d91bdbfd103a2e00022f4258147150
yangbaoxi/dataProcessing
/python/字符串/格式化字符串/expandtabs.py
467
4.1875
4
# 字符串中的 tab 符号('\t')转为空格,tab 符号('\t')默认的空格数是 8。 # str.expandtabs(tabsize=8) # 参数: # tabsize -- 指定转换字符串中的 tab 符号('\t')转为空格的字符数。 # 返回值:该方法返回字符串中的 tab 符号('\t')转为空格后生成的新字符串。 # 示例 str = "my name is \t 杨宝" print(str) # my name is 杨宝 print(str.expandtabs(4)) # my name is 杨宝
ad477017acef4bbc8f0c9309238f292814f40595
filiperecharte/FEUP-FPRO
/FPROPlay/Py02/Hypothenuse.py
202
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Oct 10 01:01:07 2019 @author: filipe """ import math sides= int(input()) hypot = math.sqrt(sides**2+sides**2) print(round(hypot,2))
6b6f531cb41a6b60704b3a0ce1f0644e1b0ca646
RmanKarimi/CodeWarsFundamental
/score.py
950
3.953125
4
""" Greed is a dice game played with five six-sided dice. Your mission, should you choose to accept it, is to score a throw according to these rules. You will always be given an array with five six-sided dice values. Three 1's => 1000 points Three 6's => 600 points Three 5's => 500 points Three 4's => 400 points...
c1d1de5215461b7b0d730c89ccfcf0413c94753a
salei0926/Algorithm
/polindrome_number.py
805
3.828125
4
class PalindromeNumber(): def determine(self,integer): integer = str(integer) for i in range(int(len(integer)/2)): if integer[i]!=integer[-1-i]: print(False) return False print(True) return True class Solution: def isP...
a2dfbdc1e07158fff5dc33ecdace78f13ace0357
gofr1/python-learning
/db/csv_write.py
1,374
3.703125
4
#!/usr/bin/env python3 import csv outputFile = open('output.csv', 'w', newline='') outputWriter = csv.writer(outputFile) outputWriter.writerow(['spam', 'eggs', 'bacon', 'ham']) outputWriter.writerow(['Hello, world!', 'eggs', 'bacon', 'ham']) outputWriter.writerow([1, 2, 3.141592, 4]) outputFile.close() # output.cs...
b147a8989650246730ab1d8b15d09f52b38ada6d
mango51/pythonPractice
/파이썬/pythonpractice05_bingo.py
457
3.734375
4
lyrics = input('가사 입력 : ') word = input('찾고 싶은 단어 : ') numbers = lyrics.count(word) while(1): guess = int(input('찾는 단어가 몇 번 나왔을까요? : ')) if guess > numbers: for i in range(1,guess): print(i,end='') print('중에 있습니다.') elif guess < numbers: print(guess,'보다 큽니다'...
738c8a34d8d0a00b9e260dc295ec998b18beb57c
FLAYhhh/DataMining
/FP-growth/fptree_structure.py
2,339
3.53125
4
class Item: """ Node of FP-tree """ def __init__(self,id): self.id = id self.count = 1 self.children = [] self.father = None def get_id(self): return self.id def get_count(self): return self.count def get_children(self): return self....
9a561e9e9a8318f70387315c75e9e6ed59ef5722
GersonFeDutra/Python-exercises
/CursoemVideo/2020/world_1/ex017.py
491
4.46875
4
from math import hypot opposite_side: float = float(input('What is the length of the opposite side of the rectangle triangle? (cm) ')) adjacent_side: float = float(input('What is the length of the adjacent side of the rectangle triangle? (cm) ')) # Manually calculating # print(f'The hypotenuse of the triangle i...
73d8af0f80d75e81cf68834d5ace2a728b3c7df0
lizenghui1121/DS_algorithms
/数据结构/栈/02.最短无序连续子数组.py
1,393
3.859375
4
""" 给定一个整数数组,你需要寻找一个连续的子数组,如果对这个子数组进行升序排序,那么整个数组都会变为升序排序。 你找到的子数组应是最短的,请输出它的长度。 示例 1: 输入: [2, 6, 4, 8, 10, 9, 15] 输出: 5 解释: 你只需要对 [6, 4, 8, 10, 9] 进行升序排序,那么整个表都会变为升序排序。 @Author: Li Zenghui @Date: 2020-07-16 15:04 """ def findUnsortedSubarray1(nums): sorted_nums = sorted(nums) left = 0 right = len(nums) ...
c7259f1a4e4f381a3f746bfb66e12452bcf90436
ababa831/atcoder_beginners
/contest_132/a.py
209
3.515625
4
# AC S = input() set_s = set(S) if len(set_s) == 2: for val in set_s: if S.count(val) != 2: print('No') exit() else: print('No') exit() print('Yes')
0609a5bd66373ef82fa73ae02bad867cbf23be07
Akluba/pythonProjects
/reusable-library/lib.py
2,909
3.734375
4
class BacFormula(object): def __init__(self): #variable to be set by functions self.__gender_constant = 0 self.__standard_drinks = 0 def convert_sex(self, sex): '''converts sex string from user into gender constant num for BAC calculation''' #gender constant is part of bac equation, the value is determin...
d5f13e41ab5674caaad979deadbe464b5f2ff6b8
sounak95/PythonCodingTraining
/Coding/collections/practice4.py
335
3.828125
4
#https://www.hackerrank.com/challenges/word-order/problem n= int(raw_input()) from collections import OrderedDict my_order = OrderedDict() for i in range(n): name=raw_input() if name not in my_order: my_order[name] = 1 else: my_order[name] += 1 print len(my_order) print ' '.join(map(str,my_o...
e7d51e9d5ea88c0c584daead96e640453dbb4d94
rafaelmorgado/logica-algoritmos
/EstruturaDeRepeticao/l3ex14.py
404
4.15625
4
''' 14) Faça um programa que peça 10 números inteiros, calcule e mostre a quantidade de números pares e a quantidade de números impares. ''' contp = conti = 0 for x in range(1, 11): num = int(input("Entre com um número: ")) if num % 2 == 0: contp = contp + 1 else: conti = conti + 1 print("\nQuantidade ...
0a436a6b91f74765427aa20324b6bdb4352db661
slawry00/CSCI305
/Lisp/linked_list.py
5,473
4.15625
4
#Spencer Lawry #CPE103 #Lab03 #Instructor: Brian Jones import math # An AnyList is either None or a Pair(first, rest) where first can be any type class Pair: def __init__(self, first, rest): self.first = first # some value self.rest = rest # an AnyList def __eq__(self, other): return (ty...
31cd30877f6373f69f728b276925afde5b4b614d
MrHamdulay/csc3-capstone
/examples/data/Assignment_3/mrnjem001/question4.py
438
3.96875
4
n=eval(input("Enter the starting point N:\n")) m=eval(input("Enter the ending point M:\n")) print("The palindromic primes are:") for nmbr in range(n+1,m): if nmbr>1: for i in range(2,nmbr): if (nmbr%i)==0: break else: x=str(nmbr) if nmbr=...
08f782d3ce2e45cdd6651ef38ebb7720fa6db44b
lucasmoura/machine-learning
/model/training_data.py
2,947
3.984375
4
from numpy import loadtxt, c_, ones from utils import featureNormalization class TrainingData(): FILE_LOADED_SUCCESSFULLY = 0 def __init__(self): self.x = None self.y = None self.x_normalized = None self.mean_values = None self.standard_deviation_values = None ...
524fadc622f8f7d69c816f98451d584c1f389be7
usedvscode0/01_W3Cschool_python
/scr/py02_BasicDataType05_Set01.py
527
3.890625
4
# coding=utf-8 # Sets(集合) # 集合(set)是一个无序不重复元素的集。 # 基本功能是进行成员关系测试和消除重复元素。 # 可以使用大括号 或者 set()函数创建set集合,注意:创建一个空集合必须用 set() 而不是 { },因为{ }是用来创建一个空字典。 student = {'Tom', 'Jim', 'Mary', 'Tom', 'Jack', 'Rose'} print(student) # 重复的元素被自动去掉 print('Rose' in student) student2 = {'Tom', 'Jim', 'Mary', 'Tom', 'Jack', 111} print...
a49a81064b038173fb12e2014b50a85d0f166e6c
asheed/tryhelloworld
/function1.py
700
4.0625
4
def print_root(a, b, c): r1 = (-b + (b ** 2 - 4 * a * c) ** 0.5) / (2 * a) r2 = (-b - (b ** 2 - 4 * a * c) ** 0.5) / (2 * a) print('해는 {} 또는 {}'.format(r1, r2)) x = 2 y = -6 z = -8 print_root(x, y, z) # a = 1 # b = 2 # c = -8 #print_root(1, 2, -8) # print_root() # a = 2 # b = -6 # c = -8 #print_root...
ceba4f6d6722b1fe3366068a45e1a4d7765c3141
hchayan/Data-Structure-and-Algorithms
/(구)자료구조와 알고리즘/(구)Algorithms/정렬 알고리즘/bubble_sort/bubblesort.py
410
3.78125
4
# bubble sort def bubbleSort(x): for i in range(len(x) - 1): swap = False for j in range(len(x) - i - 1): # j의 탐색범위를 0~n, 0~n-1.. 로 줄여나간다. if x[j] > x[j+1]: # 인접한 두수에서 작은수가 큰수보다 뒤에 있을때 x[j],x[j+1] = x[j+1],x[j] swap = True if swap == False: break return x x= [5,2,8...
5a1df6d8cbff491319ccfd0afe9739079aa0e44e
ChimdinduDenalexOrakwue/AES-Encryption-Decryption
/utils.py
856
3.796875
4
""" Utils for AES 128/256 encryption/decryption. """ most_significant_mask = 0xf0 least_significant_mask = 0x0f # block of Zero-byte padding padding = [ [b'\x00', b'\x00', b'\x00', b'\x00'], [b'\x00', b'\x00', b'\x00', b'\x00'], [b'\x00', b'\x00', b'\x00', b'\x00'], [b'\x00', b'\x00', b'\x00', b'\x10']] def...
9d8eb017ec6a5683627896fd45eb98918e906250
yuede/Lintcode
/Python/Container-With-Most-Water.py
469
3.5
4
class Solution: # @param heights: a list of integers # @return: an integer def maxArea(self, heights): # write your code here maxarea = 0 left = 0 right = len(heights) - 1 while left < right: maxarea = max(maxarea, min(heights[left], heights[right]) * (right ...
28e4e0e7d1976fc28b4d862dc5894c29dcc3a603
satyambhatt5/Advance_Python_code
/15. Thread/11. joinMethod.py
301
3.671875
4
# Creating a thread by creating a child class to Thread class # Importing Thread Class from threading Module from threading import Thread class Mythread(Thread): def run(self): for i in range(5): print("Child Thread") t = Mythread() t.start() t.join() for i in range(5): print("Main Thread")
41ac0d42ba390465f8a9ac9049146e5b6d70ba92
DontTouchMyMind/education
/geekbrains/lesson 8/filter_example.py
238
4.21875
4
numbers = (1, 2, 3, 4, 5, 6, 7, 8, 9) def is_even(number): return number % 2 == 0 result = filter(is_even, numbers) print(list(result)) names = ['', 'Max', 'Kate', 'Rich', 'Any'] print(list(filter(lambda x: len(x) > 3, names)))
ee195dc2153e707742e8feac9be33045b07f2957
johnand517/drl_dqn_navigation
/model.py
1,317
3.546875
4
import torch from torch import nn from torch.nn import functional as F n1 = 256 # Number of nodes in first layer of neural network n2 = 128 # Number of nodes in 2nd layer of neural network class DQN(nn.Module): """Actor (Policy) Model""" def __init__(self, state_size, action_size, seed): """Initia...
ca02c0a89bceb762cc949a9d178feab9a9c53ed4
Shovon588/Programming
/Codeforces with Python/LCM Cardanility.py
536
3.53125
4
from math import sqrt as s,gcd def lcm(a,b): return (a*b//gcd(a,b)) while(1): n=int(input()) if n==0: break else: temp=int(s(n)) push=[];flag=0 for i in range(1,temp+1): if n%i==0: push.append(i);flag+=1 if i*i!=n: ...
f4a786af72ff5eda5ac0945dde314936f2a6e828
schadr/interview
/q011.py
547
4.21875
4
# given a list of words and a word find all the anagrams of the given word # that are contained in the list of words def find_anagrams(words, word): # first we build a hash table that maps the sorted characters of a word to a list of # words containing the same characters and character frequencies (aka annagrams) ...
04a5d8049aff0b48362aa94fe056036f310d9e44
kunalpohakar/All-about-Python
/.history/Python basics 2/Ternary_operator_20210504145047.py
384
3.71875
4
# Ternary Operator / Conditional Expression Ternary operators also known as conditional expressions are operators that evaluate something based on a condition being true or false. It was added to Python in version 2.5. It simply allows to test a condition in a single line replacing the multiline if-else making the cod...
6fc76a64f25b4da03fef825defe62db159b884af
VadimVolynkin/learning_python3
/05_libraries/x_ itertools.py
1,702
3.828125
4
# https://www.youtube.com/watch?v=HGOBQPFzWKo 1:37 https://pythonworld.ru/moduli/modul-itertools.html from itertools import ( product, permutations, combinations, combinations_with_replacement, accumulate, groupby, count, cycle, repeat ) # product - перебирает все комбинации значений # a = [1, 2, 3] #...
63bb0c732178d5ef706fc6e772781fbeff576699
NeutrinoPhysics/incubator-challenge
/section2.py
2,175
3.796875
4
import numpy as np def road(N=10, M=5, T=20): """ N : number of positions int M : number of cars int T : number of total rounds int """ positions = np.arange(N)+1 # --- inititation step occupied = np.zeros(N, dtype=bool) occupied[:M]=~occupied[:M] step = 0 # --- loop while step < T: step+=1...
e13b7c7849c700284f76893a48fda01610d4695f
zhangzongyan/python20181119
/base/day03/tuple.py
402
4.21875
4
''' 有序的不可变的序列类型: 元组tuple ''' t = () print(type(t)) t1 = (1,) print(type(t1)) t2 = tuple([1,2,3,4, 'hello']) print(t2) # 索引 切片 print(t2[0]) print(t2[::-1]) print(t2) # 成员运算符 for t in t2: print(t) print('*****************************') t3 = (5,6,2,12,7,8,7,1,100) print(max(t3)) print(min(t3)) print(len(t3)) prin...
96515a6d6690c8150301dc11d7769f4e889b0674
jeeves990/tkinterTutorial
/tkinterTutorial/tkinterTutorial_3_10.py
3,223
3.71875
4
# -*- coding: utf -8 -*- """ ZetCode Tkinter e-book This script creates a simple animation. Author: Jan Bodnar Last modified: November 2015 Website: www.zetcode.com """ import tkinter as tk from PIL import Image , ImageTk from tkinter import Tk, BOTH , CENTER from tkinter.ttk import Frame , Label from GlobalErrorHand...
6fbe683f13b068c0f3fca9cb631c79c6bade1845
khlee12/python-leetcode
/929.py
1,115
3.71875
4
''' 929. Unique Email Addresses https://leetcode.com/problems/unique-email-addresses/ ''' class Solution: def numUniqueEmails(self, emails): """ :type emails: List[str] :rtype: int """ # save output at a set # loop each address # split using '@' # get ...
c968bd2d4eb8dcbbd7a432436651e97d52c45c50
wilsonify/euler
/src/euler_python_package/euler_python/easiest/p030.py
1,552
4.1875
4
""" Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits: 1634 = 1^4 + 6^4 + 3^4 + 4^4 8208 = 8^4 + 2^4 + 0^4 + 8^4 9474 = 9^4 + 4^4 + 7^4 + 4^4 As 1 = 1^4 is not a sum it is not included. The sum of these numbers is 1634 + 8208 + 9474 = ...
463a3b3083d870eb473955fa1696c455e378dacb
bireme/icd-ws
/numbase.py
1,533
3.9375
4
#!/usr/bin/env python # coding: utf-8 # this module allows base conversion using arbitrary digits, unlike Python's # built-in `int` which is limited to digits from 0-9 and A-Z in that order. import string # just lowercase numbers and digits BASE36 = string.digits+string.ascii_lowercase # no vowels, to avoid forming...
1c7d274fe36f28a0fee3e80665d7dff2eb14c001
suvimanikandan/INTERMEDIATE_PYTHON
/FORMAT.PY
804
4.28125
4
# Format # New style is with .format() and old style is with % operator. # use braces as placeholders a = "Hello {0} and {1}".format("Bob", "Tom") print(a) # the positions are optional for the default order a = "Hello {} and {}".format("Bob", "Tom") print(a) a = "The integer value is {}".format(2) print(...
fe396bd3a993366618f3bc064a64d3b540b30870
Tsavoka/Kata
/1_odd_number.py
341
3.96875
4
# Given an array, find the integer that appears an odd number of times. def find_it(seq): uniq = [] for i in seq: if i not in uniq: uniq.append(i) for i in uniq: if seq.count(i) % 2 != 0: return i print(find_it([1,1,1,1,1,1,10,1...
e546fb2fd131e6768aede8eb4e4dff507842f143
paulovlobato/cesar-questions
/questao5.py
2,417
4.21875
4
#!/usr/bin/python3 __author__ = "Paulo Sarmento" __email__ = "pvlobato@gmail.com" ''' Since Python does not not have a builtin LinkedList it was created the concept of nodes to better simulate the LinkedList behaviour ''' # Source: https://gist.github.com/ashwinwadte/6c7bb7c6464760a2c0733f8dfa33682e class No...
e25a6ee8274bf1cf053dd176d7c6a24a9fb21670
zoown13/codingtest
/src/target_number.py
933
3.75
4
count = 0 def solution(numbers, target): answer = 0 init_num = numbers.pop() DFS(numbers, init_num, target, '+') # print(count) DFS(numbers, -init_num, target, '-') answer = count return answer def DFS(numbers, sum_value, target, orders): global count if len(numbers) == 0 an...
3ae1b6b1ca929f775054d460f0a322ebbe4005a1
niteshkumar2000/MachineLearningAlgorithms
/3.GradientDescent/GradientDescent.py
3,068
4.15625
4
# objective is finding the best-fit line using Gradient Descent given X & Y values import numpy as np def gradient_descent(x,y): # Step 1 --> Start with some values of m & b. Here it is m_current & b_current m_curr = b_curr = 0 # Step 2 --> You have to define how many baby steps that you are going ...
459639cbaa2da991e02aac6f718f31c723b4438f
hoangantran1109/Symbolic-programming-language
/src/hw04_text_search/comprehensions.py
1,695
4.40625
4
# This exercise contains 5 Tasks to practice a powerful feature of Python: comprehensions. # With these, multiple-line for-loop constructions can be expressed in expressive one-liners. def multiply_by(x, list1): """ Multiplies each value in list1 by x and returns it as a new list. """ return [x*i for ...
c760784fd642de0237d9857b8db522fb022b4829
Mohammad2527/python_bootcamp_day_3
/treasure_island.py
1,097
4.3125
4
print("Welcome to Treasure Island.\n Your mission is to find the treasure.") direction = input('You\'r at a crossroad, where do you want to go? Type "left" or "right".\n') if (direction == "left"): cross = input('You\'ve come to a lake. There is an island in the middle of the lake. Type "wait" to wait for th...
981026485fdddc586a9f5e776c87f63b924296db
freshkimdh/Python_Basic
/BaekJoon/if/if_1.py
322
3.703125
4
# 두 정수 A와 B가 주어졌을 때, A와 B를 비교하는 프로그램을 작성하시오 A,B = map(int,input().split()) if A < B : print("<") elif A > B : print(">") elif A == B : print("==") # 'cc'로 2개의 변수로 구분 # a, b = input("나이를 입력해주세요").split('cc') # print(a, b)