blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2308bfd300a6d82a56a61418d48453d514b6cc0e
shen-huang/selfteaching-python-camp
/exercises/1901050155/1001S02E05 _string.py
1,969
3.625
4
text = ''' The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although p...
40786db442c8695d03f6dacdd6a2a895363777b4
shen-huang/selfteaching-python-camp
/exercises/1901040033/1001S02E04_control_flow.py
567
3.515625
4
print('九九乘法表') for i in range(1,10): #####当i在1到9的范围 for j in range(1,i+1): #####当j在1到i+1的范围 print('{}*{}={}'.format(i,j,i*j),end='\t') ###按格式输出 print('') ############################ print(' ') #空一行 print('九九乘法表去偶数') i=1 #####用while判断 i为偶数时不计算 while i<=9: #i小于等于9且i不为偶数,j<=i j=1 while j<=i: ...
3dd05955bad59f09ac2ff5795b8d07262032afb4
shen-huang/selfteaching-python-camp
/19100401/SunElliot/d3_exercise_calculator.py
1,104
4.21875
4
# Python program for simple calculator # Function to add two numbers def add(num1,num2): return num1 + num2 # Function to subtract two numbers def substract(num1,num2): return num1 - num2 # Function to mutiply two numbers def multipfy(num1,num2): return num1 * num2 # Function to devide two numbers ...
8b5d4fbba0abe4cf6aa3806eff892ce52c4b122f
shen-huang/selfteaching-python-camp
/19100203/shanchongyue/d2_exercise_hello_python.py
61
3.71875
4
print('HELLO WORLD!') x=0 while x<=10: print(x) x+=1
c3c7477d2a438304cc8901c0f0d7ee66f9ffb6c7
shen-huang/selfteaching-python-camp
/19100304/baichampion/d5_exercise_array.py
459
3.8125
4
list_0 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] list_0.reverse() #调用翻转函数 print(list_0) list_0 = [str (x) for x in list_0] #不是很能理解为什么需要它的存在? str_0 = ''.join(list_0) print(str_0) str_1 = str_0[3:9] str_2 = str_1[::-1] #将索引位置进行翻转 print(str_2) int_0 = int(str_2) print("转换为二进制:",bin(int_0)) print("转换为八进制:",oct(int...
75d36ebbfa9a86adaaa95dcf3cb8ee0a2cb55a48
shen-huang/selfteaching-python-camp
/exercises/1901090055/1001S02E05_array.py
493
4
4
list = [0,1,2,3,4,5,6,7,8,9] #翻转数组 list1 = list[::-1] print(list1) #取出第三个到第八个 list2 = list1[2:8] print(list2) #再翻转 list3 = list2[::-1] print(list3) #转换为int类型 for i in list3: list4 = int(i) print(list4) #转换成二进制 for i in list3: list4 = int(i) print(bin(list4)) #转换成八进制 for i in list3: list4 = in...
72801c56f1bcfcf313c3c1b0876202752ee1fd0e
shen-huang/selfteaching-python-camp
/exercises/1901040033/1001S02E03_calculator.py
656
4.125
4
def add(x,y): return x + y def subtract(x,y): return x - y def multiply(x,y): return x * y def divide(x,y): return x / y print("choose operator:") print("1.add") print("2.sub") print("3.multi") print("4.div") choice = input("input ur choice(1/2/3/4):") num1 = int(input("input 1st number: ")) num2 = i...
592a83b5ecb0865ea0e50b2a9abd75964b71085a
shen-huang/selfteaching-python-camp
/19100402/zhengguanya/d5_Python/1001S01E05_string.py
797
3.9375
4
#!/usr/bin/python # -*- coding: UTF-8 -*- #读取文件 file = open(r'''C:\Users\ZGY\Documents\GitHub\selfteaching-python-camp\19100402\zhengguanya\d5_Python\123''','r+',encoding="utf-8") lines = file.readlines() print(lines) # print(lines) strr=''.join(lines) type(strr) print(strr) #第一步 strr1 = strr.replace('better','worse'...
91ee6226a79e3894315f15aa16b6170b350dedfa
shen-huang/selfteaching-python-camp
/19100101/raoxin007/d5_exercise/d5_exercise_stats_text.py
1,297
3.75
4
text = ''' The Zen of python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases arent't special enough to break the rules. Although p...
606de2cde0d421de54b557f83689211c90bd043f
shen-huang/selfteaching-python-camp
/exercises/1901100105/1001S02E03_calculator.py
1,104
4.21875
4
# 单行注释 ''' 这是多行注释 注释的作用仅是方便理解代码,并不参与执行 ''' """ 也是多行注释 """ # 计算器确定三个输入值,分别是运算符、运算符左边的数字和右边的数字 # 把内置函数input接收的 输入字符 赋值 给 变量 operator = input('请输入运算符(+、-、*、/):') #input里面的字符串的作用是再等待输入的时候进行提示 first_number = input('请输入第一个数字:') second_number = input('请输入第二个数字:') a = int(first_number) #int的作用是把 str类型转换成int类型 b = int(seco...
adf887ba3312900f5ed2795f026dc3f815901a6c
shen-huang/selfteaching-python-camp
/exercises/1901010116/1001S02E05_array.py
694
3.90625
4
#创建一个包含0 ~ 9的数组 m_list = list(range(0,10)) #将数组翻转 m_list.reverse() # reverse()只对当前序列操作,并不返回一个逆序列表;返回值是 None print(m_list) #将翻转后的数组拼接成字符串 m_list_str = [str(i) for i in m_list] m = ''.join(m_list_str) print(m) #用字符串切片的方式取出第三到第八个字符 n = m[2:8] print(n) #将获得的字符串进行翻转 n1 = n[::-1] print(n1) #将结果转换为int型 n2 = int(n1) prin...
1389032b9e00f135dd5dd4a72088a5809f1ab563
shen-huang/selfteaching-python-camp
/exercises/1901090036/1001S02E05_stats_text.py
1,476
3.65625
4
text=''' The Zen of Python,by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although pra...
4152213f87662e95401fadd788d02f0234c158cf
shen-huang/selfteaching-python-camp
/exercises/1901050047/1001S02E06_stats_word.py
3,500
3.96875
4
# 1. 统计英文单词词频 # 2. 统计中文汉字字频 text = ''' The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to...
5bbac2cf354c07dc3dfa3e2a8e62ae12b07c0343
shen-huang/selfteaching-python-camp
/exercises/1901100043/1001S02E06_stats_word.py
2,586
4
4
# 统计text中每个英语单词出现的次数 # 返回一个按词频降序排序的数组 def stats_text_en(text): words = [] # 1): text to list elements = text.split() # 2): del symbol such as ,.*-! in every words for e in elements: for s in ',.*-!': e = e.replace(s,'') if(len(e)): words.append(e) # 3): ...
4d189e95e2395d32ed3e39fac9e7383f883d4c15
shen-huang/selfteaching-python-camp
/exercises/1901100029/1001S02E05/1001S02E05_array.py
634
3.578125
4
sample_list = [0,1,2,3,4,5,6,7,8,9,] reversed_list = sample_list[::-1] print('列表翻转 ==>', reversed_list) joined_str = ''.join([str(i) for i in reversed_list]) print('翻转后的数组品鉴成字符串 ==>', joined_str) slice_str = joined_str[2:8] print('用字符串切片的方式取出第三到第八个字符 ==>', slice_str) reversed_str = slice_str[::-1] print('字符串翻转 ==>',...
15eaa98375c59fd22f4ebc268ccf1faa52fec0fc
shen-huang/selfteaching-python-camp
/19100103/Cobraorg/d5_exercise_string.py
1,766
3.53125
4
#1.将字符串样本text里英文单词中包含ea的英文单词剔除 def cut_and_clean(s): s=s.split() i=0 while i<len(s): s[i]=s[i].strip('*-.') if s[i]=='': s.remove('') else: i=i+1 return s #2.将s字符串中包含keyword的词删除 def delet_word(s,keyword): i=0 while i<len(s): if 'ea' in s[...
c69929eac709b68d07f396e91d86e708bf883f65
shen-huang/selfteaching-python-camp
/exercises/1901010114/1001S02E04_control_flow.py
180
3.734375
4
for x in range(1, 10): while x % 2 == 0: break else: for y in range(1, x+1): print('{}*{}={}\t'.format(y, x, x*y), end='') print()
4d96d408d52953ff82a98b2eb71af7cc94c9c8f1
shen-huang/selfteaching-python-camp
/19100302/aosjiabei/d5_exercise_array.py
355
3.546875
4
arry = [0,1,2,3,4,5,6,7,8,9] arry.reverse() arry=[str (x) for x in arry] str1 = ''.join(arry)#列表拼接为字符串 str2=str1[3:9] str3=str2[::-1] int1=int(str3) print(arry) print(str1) print(str2) print(str3) print(int1) print("转换为二进制 :",bin(int1)) print("转换为八进制 :",oct(int1)) print("转换为十六进制:",hex(int1))
b035829b4ba0c18205adb268d5f85b333adc24c0
shen-huang/selfteaching-python-camp
/exercises/1901090036/1001S02E05_array.py
431
3.78125
4
array=[0,1,2,3,4,5,6,7,8,9] array.reverse() #翻转 print(array) array=[str(i)for i in array] #join不能直接拼接数字型数组,需要用到for in函数 array=''.join(array) #将列表连接生成一个新的字符串 print(array) x=array[2:8] #切片 print(x) y=x[::-1] print(y) z=int(y) #整数 print(z) two=bin(z) #二进制 eight=oct(z) #八进制 sixteen=hex(z) #十二进制 print(two) print(eight)...
bea80d9dae0f84f1a6801b1e04d42db6d8672401
shen-huang/selfteaching-python-camp
/19100201/jiap/d4_exercise_control_flow.py
742
3.9375
4
# This is ex4 for control flow #-*- coding:utf-8 -*- print("9*9 Multiple formula") for num_a in range(1, 10): for num_b in range(1, num_a+1): if num_b == num_a: endstr = "\n" else: endstr = "\t" print("%d * %d = %d" % (num_b, num_a, num_a * num_b), end = endstr) # 这里使用了 if 语句去控制print() 最后的输出结果。 print("...
210a0cf1443aace72289d0d35cf93d3552467069
shen-huang/selfteaching-python-camp
/19100302/catynchyna/d5_exercise_stats_text.py
1,823
3.921875
4
# copied @echojce 19100101 and not wholy understood yet # tried to convert into some part of mine # assigned a variable "text" with value text = ''' The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat...
dbf743d62ed3546ade676e4014c34364facf0d12
shen-huang/selfteaching-python-camp
/exercises/1901040006/1001S02E04_control_flow.py
379
3.96875
4
#使用for循环打印九九乘法表 for i in range(1, 10): for j in range(1, i + 1): print(i,'*', j, '=', i * j, end = '\t') print() print('\n') #使用while循环打印奇数行九九乘法表 i = 1 while i < 10: if i % 2 == 1: for j in range(1, i + 1): print(i,'*', j, '=', i * j, end = '\t') print() i = i ...
00624ca59649f6b0859ac20bb8efa97cc9ca6f9f
shen-huang/selfteaching-python-camp
/exercises/1901090043/1001S02E04_control_flow.py
653
3.875
4
#for 循环打印乘法表 for a in range(1,10): for b in range(1 , a+1): if(b == a): print(a," * ",b," = ",a * b) else: print(a," * ",b," = ",a * b,end = " ") #打印分隔符 print() s = 'while循环控制输出奇数列表' print(s.center(150,'*')) print() c = 1 d = 1 while (c < 10): while (d < 10): ...
4e9ea15286158c63558721a897a243f0a9fe99f1
shen-huang/selfteaching-python-camp
/exercises/1901100004/1001S02E04_control_flow.py
1,086
3.71875
4
#<<<<<<< master print('打印九九乘法表') for i in range(1, 10): print('第%d行'% i, end='\t') for j in range(1, i + 1): print(i, '*', i * j, end='\t') print() print('\n打印跳过偶数行的九九乘法表') i = 1 while i < 10: if i % 2 == 0: print() else: for j in range(1, '*...
dc422d51044ca7f26a2f9c6e154436c65c8ee63b
jgat/notepad--
/notepad--.py
1,143
4.0625
4
#!/usr/bin/env python """Notepad-- : A very simple text editor.""" import sys if sys.version_info < (3,): import Tkinter as tk import tkFileDialog as filedialog else: import tkinter as tk from tkinter import filedialog def create_gui(root): """Set up the GUI and functionality.""" root.title("N...
21acc379b9cbc6b33c89fcceaa44991216129342
arpit-pi/Tensorfow-Learn
/deepnet.py
2,322
3.5
4
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("/tmp/data/",one_hot=True) n_nodes_hl1 = 500 n_nodes_hl2 = 500 n_nodes_hl3 = 500 n_classes = 10 batch_size = 100 x = tf.placeholder('float',[None,784]) #height , width*length y = tf.placeholder('flo...
fb9e609fe49c74b945188615711aa6b6eeb46ebe
aishwarya0408/Tic-Tac-Toe
/FirstProject.py
3,250
3.796875
4
from IPython.display import clear_output def TicTacToe(board): clear_output() print(board[7]+' $ '+board[8]+' $ '+board[9]) print('----------------') print(board[4]+' $ '+board[5]+' $ '+board[6]) print('----------------') print(board[1]+' $ '+board[2]+' $ '+board[3]) ...
506194c16a08750507668596707a5c783f288949
techartorg/Advent_of_Code_2019
/rwhite_18.py
4,008
3.59375
4
import heapq from collections import defaultdict from typing import Dict, Tuple, Set, Any, List def find_minimum_steps(data: List[str]): key_positions = {} bot_cnt = 0 # Part 2 adds some more robots. for x in range(len(data)): for y in range(len(data[x])): if data[x][y].islower(): ...
858e2f5045f4b7193feef5555c1103a4ae85fb6f
techartorg/Advent_of_Code_2019
/gamato_14.py
6,071
3.640625
4
""" ### Day 14: Space Stoichiometry ### --- Part One --- As you approach the rings of Saturn, your ship's low fuel indicator turns on. There isn't any fuel here, but the rings have plenty of raw material. Perhaps your ship's Inter-Stellar Refinery Union brand nanofactory can turn these raw materials into fuel....
0d69cb5ff2622644772e8aef979703db0167f07e
jmiths/PE
/Problem66.py
739
3.578125
4
#!/usr/bin/python3 # x^2 - D * y^2 = 1 import math squaring = {} squares = {} for n in range(1,10000000): temp = n**2 squares[temp] = n squaring[n] = temp big_x = 0 big_d = 0 not_found = [] for d in range(1,1001): if math.sqrt(d).is_integer(): continue found = False for y in range(1,...
5f27d2eea0524c3ae5bf6204adc84a35380a58ab
jmiths/PE
/HalfSieve.py
1,071
4.15625
4
#!/usr/bin/python import math primes = [1]*301 primes[0] = 0 ''' Sieve primes using only odd numbers by reducing values to index based on formula: Value = (2 * Index_val) + 1. Squares of these values can be found at Index_Sq = Index_val * ( 2 + ( 2 * Index_val)). This was arrived at by starting with a bit-vector o...
7fa80a958ae7019a11b4f5ea37a08693d3eee19c
jjohn342/GirlsWhoCode
/listchallenge.py
356
3.875
4
#imports the ability to get a random number (we will learn more about this later!) from random import * aRandomIndex = randint(1, 2) #Create the list of words you want to choose from. food_list = ("tiramisu", "ramen",) dinner_list = ("macaroni", "rice") breakfast_list = ("toast", "yogurt") #Generates a random integer. ...
336ac6f88065a0ec00a186568312a790e2f6c3e3
KevinKahn88/ProjectEuler
/Problem19.py
634
3.8125
4
''' Created on Sep 15, 2015 @author: Kevin ''' def leapyear(num): return (num%4 == 0) & ((num%100!=0) | (num%400==0)) if __name__ == '__main__': monthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] dayTrack = 1 sunTrack = 0 dayTrack = (dayTrack+sum(monthDays))%7 year = 1901; ...
f8cb4229e21b60f8d1beea15c8e593f5cfcf96e7
echogwu/sortingAlgorithm
/shellSort.py
1,083
3.828125
4
#!/usr/bin/python ########################################################### # ########################################################## def partition(myList): leng = len(myList) increment = leng/2 while increment > 0: start = 0 while start < increment: print("start = %d, in...
24030c961e0dcfff8efc5517e9c588600eecd7f1
vladkudiurov89/PY111-april
/Tasks/b2_Taylor.py
544
4.0625
4
"""Taylor series""" from math import factorial def ex(x) -> float: """Calculate value of e^x with Taylor series :param x: x value :return: e^x value""" ox = 1 n = 1 for i in range(10): ox += (x ** n) / factorial(n) n += 1 return float(ox) def sinx(x) -> float: """Calculate ...
3f31926ec7dce71d7cdf3c23b31bf1ffee4ec315
vladkudiurov89/PY111-april
/Tasks/a1_my_queue.py
726
4.1875
4
"""My little Queue""" little_queue = [] def enqueue(elem) -> None: """Operation that add element to the end of the queue :param elem: element to be added :return: Nothing""" if little_queue is not None: little_queue.append(elem) def dequeue(): """Return element from the beginning of the queue :return: dequ...
e773f1c4986f0e73c4f72dcb668981babc7c6fec
unni-krrish/stock-forecasting-app
/sample_unittest.py
2,686
3.546875
4
import unittest from command_line import cmd_handler from datetime import datetime as dt class TestCMD(unittest.TestCase): def setUp(self): self.ob = cmd_handler() def test_validate_ticker(self): self.assertEqual(self.ob.validate_ticker('AaPl'), "AAPL") self.assertIsNone(se...
e6643db096334fadf7eb476318becd493d687a66
Robotrek-TechTatva/robo_sapiens
/Question3_Competetive_Programming/solution.py
1,240
3.828125
4
import csv _inp=input() with open(_inp) as csvfile: readCSV = csv.reader(csvfile, delimiter=',') x1 = [] y1 = [] i=0 for column in readCSV: x1.append(column) tri=x1[1:] def area(x1, y1, x2, y2, x3, y3): return abs((x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1...
2927b91e1002c5f8cff98600d0b27d73c0a3c659
andresberejnoi/Alife-Simulations
/simple_genome/decoders.py
6,474
3.53125
4
""" Collection of phenotype gene decoders. Right now each decoder is a small class with a `decode` method. However, since each class has just one method, it might be better to turn each decoder into a simple function and make the code leaner. I will see if the __repr__ method provides sufficient advantages to keep t...
201bca557469055ab0ef37c5a6de8163ddd3b27d
JakNowy/python_learn
/asynchronism/multiprocessing_parallelism.py
2,515
4.34375
4
import multiprocessing import time import concurrent.futures # READ BOTH WAYS OF RUNNING MULTIPROCESSING TO HAVE A PROPER UNDERSTANDING # # PART 1: MANUAL MULTIPROCESSING # # Define function to be executed in a process. # def do_something(seconds): # print(f'Sleeping {seconds} sec') # time.sleep(seconds) # ...
c8561a09e3dc8ba722377861249675b5f229d497
vedmara/ALgorithms_python_lessons_1-8
/lesson_2/less_2_task_2.py
443
4.09375
4
# Посчитать четные и нечетные цифры введенного натурального числа. # Например, если введено число 34560, в нем 3 четные цифры (4, 6 и 0) # и 2 нечетные (3 и 5). n = int(input()) even=odd=0 while n>0: if n%2 == 0: even += 1 else: odd += 1 n = n//10 print("четных - ", even, "нечетных - ", o...
f9914929b8e4ccbac97f1a9e0bb7d21a03308daf
vedmara/ALgorithms_python_lessons_1-8
/lesson_2/less_2_task_6.py
1,361
4.03125
4
#В программе генерируется случайное целое число от 0 до 100. # Пользователь должен его отгадать не более чем за 10 попыток. # После каждой неудачной попытки должно сообщаться, больше или меньше введенное пользователем число, чем то, что загадано. # Если за 10 попыток число не отгадано, вывести правильный ответ. #imp...
17fc521e1f8339fe1e033a81fb4136d517cecbc6
LeeBumSeok/team5
/week2/20171660-이건민-assignment2.py
428
3.640625
4
''' 20171660 이건민 Factorial''' num = int(input("숫자를 입력하세요 : ")) # 숫자 입력받음 sum = 1 # 조건문에서의 곱을 위해 1을 저장 for i in range(1, num +1): #조건문을 실행 할 수록 곱해지게 sum =sum*i if not num == -1: #-1을 예외로 두고 프린트 print(" %d! = %d" %(num,sum...
67f100db18c4fcc3fd9122613fe4530a77a0a027
RazePilot/Learning-Python
/ex20.py
1,099
4.125
4
from sys import argv # makes ipnut_file the thing we type with argv script, input_file = argv # pylint: disable=unbalanced-tuple-unpacking # defines print_all so it reads and prints any file def print_all(f): print f.read() # makes rewind seek to line 0? I think? def rewind(f): f.seek(0) # defines print_a_...
7389c564e06a34c1f0d9d352cdcb074d26523a67
rpalmer0812/Learning
/Dictionary Exercises/pynative-1.py
139
3.59375
4
keys = ['Ten', 'Twenty', 'Thirty'] values = [10, 20, 30] dict = {} for i in range(len(keys)): dict[keys[i]] = values[i] print(dict)
05404438d9bcb91ced0dbe46c2019b13e5ed2cb5
cabirerguven/Class4-PythonModule-Week2
/soru1.py
1,275
4.09375
4
# Write a programme to generate the lucky numbers from the range(n). # These are generated starting with the sequence s=[1,2,...,n]. # At the first pass, we remove every second element from the sequence, resulting in s2. # At the second pass, we remove every third element from the sequence s2, resulting in s3, # we...
51c0d5dc4bcccf5081f740b34b48c49f095f2b9a
bpalomino5/Artificial-Intelligence
/4-in-a-line/4inaline.py
5,688
3.53125
4
# Author: Brandon Palomino # Date: 9/1/17 # Description: Program where user plays 4 in a line game against CPU that uses alpha-beta pruning to calculate best moves from copy import deepcopy import time letters = ["A","B","C","D","E","F","G","H"] negInfinity = -99999999 posInfinity = 99999999 timeLimit = 30 def setu...
c3e6acc8a14b4af13c0dceae6520113dae96ddb3
gregmoncayo/Python
/Python/ex copy.py
930
3.890625
4
#!/bin/python3 import math import os import random import re import sys # # Complete the 'missingWords' function below. # # The function is expected to return a STRING_ARRAY. # The function accepts following parameters: # 1. STRING s # 2. STRING t # lis = [] mis = [] tis = [] def missingWords(s, t): if (s ==...
e71ed36a5fb0849b8c33d5a079877aedbeac9212
gregmoncayo/Python
/Python/queque.py
1,770
4.125
4
import queue class Queue: # Default Constructor def __init__(self): self.lis = [] # Prints the Queue def SeeQueue(self): for x in range(0, len(lis)): print(lis[x]) # Checks if the list is empty def IsEmpty(self): if (len(lis) == None): ...
deb252dc32ebd3e1a0845325359b62b37c960173
daniela2001-png/holbertonschool-higher_level_programming
/0x0B-python-input_output/9-add_item.py
474
3.796875
4
#!/usr/bin/python3 """ a script that adds all arguments to a Python list, and then save them to a file """ from sys import argv load_from_json_file = __import__('8-load_from_json_file').load_from_json_file save_to_json_file = __import__('7-save_to_json_file').save_to_json_file filename = "add_item.json" try: ...
108692728094961a229f382f25331b02d6347383
daniela2001-png/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/2-print_alphabet.py
105
3.875
4
#!/usr/bin/python3 for each_letter in range(97, 123): print('{:s}'.format(chr(each_letter)), end='')
c7973a21fd9683687d474510d1be1918e360cb58
daniela2001-png/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/2-matrix_divided.py
1,264
4.09375
4
#!/usr/bin/python3 """ Function that divides a matrix (list with sublist) each number shoul be a integer or float """ def matrix_divided(matrix, div): """ give a number with your respective number to divide """ e = 'matrix must be a matrix(list of lists) of integers/floats' if type(matrix) is not ...
00d44e30cfbae3ee3b0029437b58bfd73fa2ba82
erenyceylan/python-exercises
/prime_factor.py
600
3.90625
4
def raw_to_power(somelist): powers = [] sentence = "" j = 0 for i in sorted(set(somelist)): powers.append(somelist.count(i)) while j < len(powers): sentence += "%d^%d "%(sorted(list(set(somelist)))[j],powers[j]) j += 1 return sentence def prime_factor(num): some = [] i = 2 while i in range(2,num+1): ...
10284a77537fae7968a050cf6df58496b650e4fe
pnikhare/sorting-algorithms-analysis
/insertionSort.py
306
4.1875
4
#!/usr/bin/python ## INSERTION SORT # Input : Array of Integers - arr # Output : Returns sorted array def insertionSort(arr,low,high) : for i in range(1,high+1): keyValue = arr[i] j=i-1 while j>=0 and keyValue<=arr[j]: arr[j+1]=arr[j] j=j-1 arr[j+1]=keyValue #print(arr) return arr
5de2ad929645e95948df76c67cf8aefc00f1ed35
LeahTerra/Python-Projects
/SolutionToNim.py
5,278
3.734375
4
# # So this is minimax, a solution to the game of nim. The game of nim is # simple strategy game where two players (min and max in this case) must # divide the remaining objects using two different numbers until somebody # cannot do more. # # This program calculates every single possible outcome that ...
ddb5fc1d0144f43a37acc64e38ab09085b765d08
oknono/99-python-problems
/problem05.py
301
4.25
4
# Reverse a list def reverse(some_list): return list(reversed(some_list)) if __name__ == "__main__": print "reverse [1, 2, 3, 4] : {0}".format(reverse([1, 2, 3, 4])) print "reverse [] : {0}".format(reverse([])) print "reverse [[1, 2], [3, 4]] : {0}".format(reverse([[1, 2], [3, 4]]))
e661f911ddc539fb8305dfb1cfde50b11169aa20
madhurigollakota/stumbling-coder
/AI_ML/Python/GradeCalculator.py
419
3.921875
4
x=input("Enter score:") try: intx=float(x) except: intx=-1 def computescore(score): if score>=0 and score<=1 : if score>=0.9 : return "A" elif score>=0.8 : return "B" elif score>=0.7 : return "C" elif score>=0.6 : return "D" ...
5608f0056ddea967925dbb2e182956ebed726044
madhurigollakota/stumbling-coder
/AI_ML/Python/SelectionSort.py
420
4.21875
4
#In every iteration of selection sort, #the minimum element (considering ascending order) from the unsorted subarray is picked #and moved to the sorted subarray. x=[3,90,21,57,45,8,34,58] print("Before",x) def selectionSort(arr): for i in range(len(arr)): for j in range(len(arr)): if arr[i]<ar...
273e079c566af2769caf709870ab00de43f3d406
madhurigollakota/stumbling-coder
/AI_ML/Python/SumAvgCountCalculator.py
396
3.890625
4
import numpy as np arr=[] while True: x=input("Enter a number:") if x=='Done': print(arr) break else: try: float_x=float(x) arr.append(float_x) except: print("Bad number") numpy_arr=np.array(arr) print("Sum is ",numpy_arr.sum()) print("Coun...
184882ed4d3a0cf6d2bc9505d8dfd354de570256
rayvega/project-euler-solutions
/source/problem5/solution5a.py
1,336
3.5625
4
""" project euler problem # 5 https://projecteuler.net/index.php?section=problems&id=5 description: 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? algorithm: s...
bd4be38e34db0ae3098ab5d253bb13f82dd663c9
NandiniSHinduja/adventure-game
/adventuregame.py
1,467
4.1875
4
print("welcome to my game") name = input("what is your name?") age = input("what is your age?") print("hello", name, "you are", age) answer = input("would you like to play this game?yes/no") if answer == "yes": choice = input("great! would you like to go left or right?") if choice == "left": pri...
dae07bf3294515ee648b1af40a038d0360f570cb
AHKerrigan/Think-Python
/exercise4_5.py
688
4.1875
4
"""This module contains a code example related to Think Python, 2nd Edition by Allen Downey http://thinkpython2.com Copyright 2015 Allen Downey License: http://creativecommons.org/licenses/by/4.0/ This program will draw a Archimedian spiral """ import turtle def spiral(t, a, b, n, length): """draws a spiral wit...
722e133e64d23d1858d97d96d9b5cced83ee796e
AHKerrigan/Think-Python
/exercise12_4.py
2,883
4.125
4
""" This is a solution to an exercise from Think Python, 2nd Edition by Allen Downey http://thinkpython2.com Copyright 2015 Allen Downey License: http://creativecommons.org/licenses/by/4.0/ Exercise 12-4: What is the longest English word, that remains a valid English word, as you remove its letters one at a time? ...
65ea0e92549e393489d39287a1439826736fdea8
AHKerrigan/Think-Python
/exercise11_1.py
834
4.09375
4
""" This is a solution to an exercise from Think Python, 2nd Edition by Allen Downey http://thinkpython2.com Copyright 2015 Allen Downey License: http://creativecommons.org/licenses/by/4.0/ Exercise 11-1 Write a function that reads the words in words.txt and stores them as keys in a dic‐ tionary. It doesn’t matter ...
c0418bf9b4b2ab3b3e6f5f40cde8230c78f831e2
AHKerrigan/Think-Python
/exercise10_6.py
1,095
4.21875
4
""" This is a solution to an exercise from Think Python, 2nd Edition by Allen Downey http://thinkpython2.com Copyright 2015 Allen Downey License: http://creativecommons.org/licenses/by/4.0/ Exercise 10-6: Two words are anagrams if you can rearrange the letters from one to spell the other. Write a function called is...
bc4a59c8e2814f8f8d8c3ad9510ada31f43b1ae6
AHKerrigan/Think-Python
/exercise9_8.py
1,799
4.53125
5
""" This is a solution to an exercise from Think Python, 2nd Edition by Allen Downey http://thinkpython2.com Copyright 2015 Allen Downey License: http://creativecommons.org/licenses/by/4.0/ Exercise 9-8: “I was driving on the highway the other day and I happened to notice my odometer. Like most odometers, it shows ...
88203883b3e5628669919399dd7debe69a2139e0
AHKerrigan/Think-Python
/exercise5_2.py
1,021
4.5
4
""" This is a solution to an exercise from Think Python, 2nd Edition by Allen Downey http://thinkpython2.com Copyright 2015 Allen Downey License: http://creativecommons.org/licenses/by/4.0/ Exercise 5-2: 1: Write a function that takes a, b, c, and n and checks if Fermat's Last Theorem holds 2: Write a function th...
4732c2d0ec04c8307ba363f60f698cf6d9008d76
AHKerrigan/Think-Python
/example11_1.py
354
3.640625
4
""" This is a solution to an example from Think Python, 2nd Edition by Allen Downey http://thinkpython2.com Copyright 2015 Allen Downey License: http://creativecommons.org/licenses/by/4.0/ Chapter 11 Example 1: Write histograms more concisly """ def historgram(s): d = dict() for c in s: d[c] = d.get(c, 0) + ...
8b193d5a30084533ce1fd883f06df0ec7a27ea1e
AHKerrigan/Think-Python
/exercise6_4.py
708
4.3125
4
""" This is a solution to an exercise from Think Python, 2nd Edition by Allen Downey http://thinkpython2.com Copyright 2015 Allen Downey License: http://creativecommons.org/licenses/by/4.0/ Exercise 6-4: A number, a, is a power of b if it is divisible by b and a/b is a power of b. Write a function called is_power t...
dd592145f4dc5c1c7f718e0bdea143f929627aea
AHKerrigan/Think-Python
/exercise7_2.py
1,145
4.4375
4
""" This is a solution to an exercise from Think Python, 2nd Edition by Allen Downey http://thinkpython2.com Copyright 2015 Allen Downey License: http://creativecommons.org/licenses/by/4.0/ Exercise 7-2: Write a function called eval_loop that iteratively prompts the user, takes the resulting input and evaluates it ...
2ebe4db1f7c07c56a80cb016ef28f05ef3eca70f
geekvinay/practice-your-basics
/python/quesn20.py
601
4
4
#Name: Yash Agrawal #Roll: EC20B1059 #Question 20 ''' You are given a list of n-1 integers and these integers are in the range of 1 to n. There are no duplicates in the list. One of the integers is missing in the list. Write an efficient code to find the missing integer. ''' def find_missing_number(passed_list): ...
0b08fd4d4ba1279f6ffa6d1f945306baed4e2930
ejud/Walk-Score-Coding-Challenge
/graph.py
3,907
4.0625
4
class Graph: """A mutable, unweighted, directed graph type""" def __init__(self): self.graph = {} def addEdge(self, a, b, attribute=None): """Adds a single edge to the graph if it does not already exist. If the edge already exists, it is updated with the new attribu...
6c497cc3f4b1bba47bf4dc49b56765c96cc38d60
ypratham/python-aio
/CLI/Bank Backend System/bbs.py
3,917
3.796875
4
# Student's Bank Backend System import csv account_fields = ['accountnumber', 'accounttype', 'pannumber', 'holder', 'age', 'emailid', 'phone', 'address', 'balance'] account_database = 'bank.csv' def displaymenu(): print("Welcome to Student's Bank Backend System\n") print("1. Open Account\n...
8409b3f8e91ada1060fa1343f53d0874b3050224
ypratham/python-aio
/Beginner/Calculator/calculator.py
1,926
4.1875
4
print('=' * 28) print('Welcome to Smart Calculator') print('=' * 28) print('Instruction:' '\n➤ Enter 0 to stop the input and calculate') store = [] def addition(): print('Addition Menu') number = float(input('Enter a number: ')) input_count = 0 answer = 0 while number != 0: answer ...
764953ce5a0bf286a1597cfb7377421830664d31
ypratham/python-aio
/Beginner/BMI Calculator/bmi.py
536
4.3125
4
height = float(input("Enter your height in centimeters: ")) weight = float(input("Enter your Weight in Kg: ")) height /= 100 bmi = weight / (height * height) print("Your Body Mass Index is: ", bmi) if bmi > 0: if bmi <= 16: print("You're severely underweight.") elif bmi <= 18.5: print("You're un...
d4962d0663ac9ce9b60f1034a75b3a8d6aa1df51
tommyokk/IS51Test1
/exam1.py
1,282
4.28125
4
""" We are trying to figure out which of these two salary options will make you more money. Option one will make you 100 hundred dollars per day. Option 2 will start of with one dollar and double every day. Determine which option will pay you more. Use functions named option 1 and 2 to calculate the money earned...
0b74caa6fcc28c5bb548dbc28dd313c7a807bd83
MicroTransactionsMatterToo/all_the_languages
/PYT.py
205
3.671875
4
def remove(item, input_list): return [x for x in input_list if x != item] def split(input_string): return [x for x in input_string] def stringToNumList(input_string): return [ord(x) for x in input_string]
2147e828d5b45690de5df721f86934d29b403957
UL-CS5722/car-renting-system
/ola_rent/wishlist/memento.py
2,682
3.75
4
from __future__ import annotations from abc import ABC, abstractmethod from datetime import datetime car= None carlist = list() class Wishlist(): def __init__(self): self._car_list = carlist # getter method def get_car(self): return self._car_list # setter method def...
972a15085edcff6618d019cbcd9fa6b55ea1aec7
UL-CS5722/car-renting-system
/ola_rent/booking/price.py
1,386
4.125
4
"""A separate class for Price""" class Total: """Constructor function wth price and discount""" def __init__(self, price, cust_id, cust_type = None): """take price and discount strategy""" self.price = price self.cust_type = cust_type self.cust_id = cu...
f434926e966d7cb4e2f948588e84f95858fc80b9
ohtap/ohtap
/Incorporating HM into Corpus/parse_hm.py
4,307
3.734375
4
import pandas as pd import os from os import path import sys colsToUse = ["Accession#", "Name", "Story_ID", "Story_Transcript"] # Columns to access from the data file intervieweeSet = {""} # Set of interviewee names """ Given a string containing the name of an interviewee, remove extraneous titles, middle names, and ...
55d0120aedf4571780c3ae6381bb3b10b208e66f
Josephicus/Python
/calculator.py
590
3.625
4
#calculator #informacje startowe print('Calculator') #wyświetlenie opcji print('Dodawanie (1)') print('Odejmowanie (2)') print('Mnożenie (3)') print('Dzielenie (4)') print('Potęgowanie (5)') print('Pierwiastkowanie (6)') #wybór działania choice = input('Wybierz co chcesz zrobić:') print(choice) # Liczby liczba1 = i...
f34573dd6d237d76bcc1ea1347027f3ce53f7c75
harerakalex/code-wars-kata
/python/dbl_linear.py
1,050
4.09375
4
''' Consider a sequence u where u is defined as follows: The number u(0) = 1 is the first one in u. For each x in u, then y = 2 * x + 1 and z = 3 * x + 1 must be in u too. There are no other numbers in u. Example: u = [1, 3, 4, 7, 9, 10, 13, 15, 19, 21, 22, 27, ...] 1 gives 3 and 4, then 3 gives 7 and 10, 4 gives 9 a...
df1653eedfd81d5ec19a91632a4786a4cfe0946d
harerakalex/code-wars-kata
/python/find_all.py
1,391
4.5625
5
''' We want to generate all the numbers of three digits where: the sum of their digits is equal to 10. their digits are in increasing order (the numbers may have two or more equal contiguous digits) The numbers that fulfill the two above constraints are: 118, 127, 136, 145, 226, 235, 244, 334 Make a function that r...
d297f9e20da995d1b2a4f1d9e1834885363b5794
harerakalex/code-wars-kata
/python/calculating_with_functions.py
1,508
4.4375
4
''' This time we want to write calculations using functions and get the results. Let's have a look at some examples: seven(times(five())) # must return 35 four(plus(nine())) # must return 13 eight(minus(three())) # must return 5 six(divided_by(two())) # must return 3 Requirements: There must be a function for each nu...
8c208a247046e7f6b79f3d439075954dec872ad4
abinaya0702/pythonCodePractices
/posList.py
470
4.125
4
#python code to generate the positive numbers in a list #first list list1 = [12,-7,5,64,-14] print("the original list") print(list1) no =0 print("the positive numbers:") for no in range(0,5): if(list1[no]>0): print(list1[no], end = "," ) no = no +1 #second list list2 = [12,14,-95,3] print("\nthe original ...
50ad2817366d259762b0dc88417890f9b0bab096
profnssorg/valmorMantelli1
/exer616.py
1,319
4.15625
4
###Titulo: Altera a listagem 6.44 ###Função: Este programa altera a listagem 6.44 e ordena listas do maior para o menor valor ###Autor: Valmor Mantelli Jr. ###Data: 05/01/2019 ###Versão: 0.0.1 ### Declaração de variáve l = [1, 2, 3, 4, 5] fim = len(l) #1 Marca a quantidade de elementos ### Atribuição de valor ...
3ba6c81c7fc08bd27eed3a3dd6b7812da2636251
profnssorg/valmorMantelli1
/exer607.py
688
3.984375
4
###Titulo: Testador ###Função: Este programa testa se uma sequencia de parenteses esta na ordem correta ###Autor: Valmor Mantelli Jr. ###Data: 01/01/2019 ###Versão: 0.0.2 ### Declaração de variáve seq = 0 conj = [] x = 0 ### Atribuição de valor seq = str(input("Digite a sequencia de parênteses que você deseja ...
e3b4a4cf8b4bbaf7920618b7b748a304037493a3
profnssorg/valmorMantelli1
/exer406.py
488
3.953125
4
###Titulo: Preço de passagem ###Função: Este programa calcula o preço de uma passagem para diferentes distâncias ###Autor: Valmor Mantelli Jr. ###Data: 08/12/20148 ###Versão: 0.0.1 # Declaração de variável dist = 0 preço = 0 valor = 0 # Atribuição de valor a variavel dist = int(input("Diga a distância a ser perco...
bc2189447fe63b3565832f85ec45fa600b67d3a3
profnssorg/valmorMantelli1
/exer701.py
425
3.734375
4
###Titulo: Procura de strings ###Função: Este programa procura uma string dentro de outra ###Autor: Valmor Mantelli Jr. ###Data: 07/01/2019 ###Versão: 0.0.1 ### Declaração de variáve f = "" s= "" p = "" ### Atribuição de valor f = "AABBEFAATT" s = "BE" p = f.find(s) ### Processamento e saída if p < 0: pri...
4e88276d4b0064e6731a8a188a11ab96ef8fec29
profnssorg/valmorMantelli1
/exer515.py
653
4.03125
4
###Titulo: Maquina registradora ###Função: Este programa simula uma máquina registradora ###Autor: Valmor Mantelli Jr. ###Data: 24/12/2018 ###Versão: 0.0.6 # Declaração de variáve p = 0 c = 0 q = 0 soma = 0 # Atribuição de valor a variavel e processamento while True: c = int(input("Digite o código do produto o...
147482d772385f37f6147abb15606791e4db7275
profnssorg/valmorMantelli1
/exer601.py
493
3.828125
4
###Titulo: Lista ###Função: Este programa modifica a listagem 6.6 para ler 7 notas ao invés de 5 ###Autor: Valmor Mantelli Jr. ###Data: 27/12/2018 ###Versão: 0.0.2 ### Declaração de variáve notas = [0, 0, 0, 0, 0, 0, 0, 0] soma = 0 x = 0 ### Atribuição de valor e processamento while x < 7: notas [x] = float(in...
f75af950cf6373dc60ae731fd64a96ed918df43c
profnssorg/valmorMantelli1
/exer811.py
668
4.09375
4
###Título: Função ###Descrição: Este programa valida uma string ###Autor: Valmor Mantelli Jr. ###Data: 15/01/2018 ###Versão 0.0.5 ### Declaração de variáveis ### Entrada de dados print ("Programa verifica se a palavra inserida esta dentro do intervalo determinado") min = int(input("Diga o número minimo de letras ...
e9edd99b50f16894f899e67a704179133f8f16db
profnssorg/valmorMantelli1
/exer602.py
637
4.1875
4
###Titulo: Lista ###Função: Este programa forma uma terceira lista a partir das duas primeiras ###Autor: Valmor Mantelli Jr. ###Data: 31/12/2018 ###Versão: 0.0.2 ### Declaração de variáve list1 = [] list2 = [] list3 = [] n = 0 x = 0 ### Atribuição de valor while True: n = int(input("Digite os valores da list...
61a4b706d61083c675821896e6bd8fdfa24f48a3
profnssorg/valmorMantelli1
/exer410.py
836
4.03125
4
###Titulo: Conta de luz ###Função: Este programa calcula a conta de luz de acordo com a categoria e o consumo ###Autor: Valmor Mantelli Jr. ###Data: 08/12/20148 ###Versão: 0.0.3 # Declaração de variáve k = 0 preço = 0 # Atribuição de valor a variavel k = float(input("Informe a quantidade de energia consumida em ...
bca094c6bf7ffa8704a69c70450eddcf8ba8e864
profnssorg/valmorMantelli1
/exer810.py
434
4.125
4
###Título: Função ###Descrição: Este programa apresenta a sequencia de Fibonacci sem recursão ###Autor: Valmor Mantelli Jr. ###Data: 15/01/2018 ###Versão 0.0.12 ### Declaração de variáveis a = 0 b = 1 soma = 1 ### Entrada de dados fim = int(input("Quantos termos da sequencia de Fibonacci você gostaria de obter? "...
3f4bdf9eeeed78cbe67995312c4f88b5d9ad9749
saravananmanikandan/SAR-CODE
/python_factorial_recursion.py
135
3.953125
4
#date:28-02-2021 def fac(n): return 1 if n == 1 else n*fac(n-1) n = int(input("Enter the factorial number:")) print(fac(n))
c73c066fac718a14183675cc879807c560f23df7
ParulBhaskar/Python-Assignments-IIT-G
/Assignment 6.py
543
3.765625
4
#To create a list of length 15 and sort in ascending order List = [22,12,34,52,21,67,32,1,4,87,65,89,23,56,76] for j in range(len(List)): #initially swapped is false swapped = False i = 0 while i<len(List)-1: #comparing adjacent elements if List[i]< List[i+1]: #S...
914c9a4d8bf78d45333bc757c6029e323c8b84eb
flaxdev/N-g.datamining
/src/iterators.py
2,195
3.671875
4
from src.geometry import Position class PropertyIterator(): """ Class PropertyIterator Linearly iterates over properties from start to end in n steps """ def __init__(self, iterators): self.iterators = iterators self.steps = sum(map(lambda x: x.steps, iterators)) self._currentIterator = self.i...
17c5896eae24c61fde8847dc3645415657930c32
NotGeobor/Bad-Code
/Barely Better Timer.py
1,632
3.734375
4
import time def start(): startnumber = input("Start at what number (HH:MM:SS)? ") if startnumber[-3] == ":" and startnumber[-6] == ":" and int(startnumber[-2:]) <= 59 and int(startnumber[-5:-3]) <= 59 and int(startnumber[-2:]) >= 0 and int(startnumber[-5:-3]) >= 0 and int(startnumber[:-6]) >= 0: retur...
fb8a0ef5b771bb4c5368d6384e96c8bc99985602
NotGeobor/Bad-Code
/Physics equations/vf vi a t/vf = vi a t.py
119
3.53125
4
vi = float(input("vi? ")) a = float(input("a? ")) t = float(input("t? ")) vf = (vi + (a * t)) print() print(vf) print()