blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
adfc200cf4be55de65e19c6dfc81c41f6cea7892
texttest/storytext-selftest
/tkinter/widgets/menubutton/target_ui.py
1,807
4.375
4
#$Id: menubartk.py,v 1.1 2004/03/18 05:44:21 mandava Exp $ #this is program that creates a menubar using Tkinter widgets. # a menubar is just a frame that holds menus. #We will then pass menubar to all of the subsequent menus we'll define #(File, Edit, Help, etc.) as the parent function. #A menu in Tk is a combination ...
true
9a42f4f082403c60ff224c7447e096ce03b3f3ce
JadeHayes/coding-challenges
/is_pal.py
985
4.34375
4
# Write an efficient method that checks whether any permutation ↴ of an input string is a palindrome. ↴ # You can assume the input string only contains lowercase letters. # Examples: # "civic" should return true # "ivicc" should return true # "civil" should return false # "livci" should return false def is_palindr...
true
7bbaccc3164f4988c2e749630b552875e8211466
JadeHayes/coding-challenges
/lazy-lemmings/lemmings.py
832
4.21875
4
"""Lazy lemmings. Find the farthest any single lemming needs to travel for food. >>> furthest(3, [0, 1, 2]) 0 >>> furthest(3, [2]) 2 >>> furthest(3, [0]) 2 >>> furthest(6, [2, 4]) 2 >>> furthest(7, [0, 6]) 3 """ def furthest(num_holes, cafes): """Find longest distance...
true
6a8d4210f42d8e66b0cc62770bbf33ce16a5de1e
JadeHayes/coding-challenges
/problem_solving_datastructures_algorithms/time_it.py
1,804
4.1875
4
# timeit.py # check to see that list index is constant time O(1) '''To use timeit you create a Timer object whose parameters are two Python statements. The first parameter is a Python statement that you want to time; the second parameter is a statement that will run once to set up the test''' import timeit def test1(...
true
741f97f3646be248079fccbf8f0a3bd4a53f1b8b
vipsh18/cs61a
/recursion/max_product_non_consecutive.py
487
4.28125
4
def max_product(s): """ Return the maximum product that can be formed using non-consecutive elements of s. >>> max_product([10,3,1,9,2]) # 10 * 9 90 >>> max_product([5,10,5,10,5]) # 5 * 5 * 5 125 >>> max_product([]) 1 """ if len(s) <= 2: return max(s) if len(s) >= 1 else ...
true
3dd0ab5d307c0d28f2c1811150b3dd437689fa87
vipsh18/cs61a
/labs_hw/disc06.py
642
4.25
4
def merge(a, b): """ >>> def sequence(start, step): ... while True: ... yield start ... start += step >>> a = sequence(2, 3) # 2, 5, 8, 11, 14, ... >>> b = sequence(3, 2) # 3, 5, 7, 9, 11, 13, 15, ... >>> result = merge(a, b) # 2, 3, 5, 7, 8, 9, 11, 13, 14, 15 >>>...
false
6e61a9a7fe86684d6f8fb97ea19b19b39151868e
vipsh18/cs61a
/iterators_generators/accumulate.py
467
4.21875
4
from operator import add, mul def accumulate(iterable, f): """Takes in an iterable and a function f and yields each accumulated value from applying f to the running total and the next element. >>> list(accumulate([1, 2, 3, 4, 5], add)) [1, 3, 6, 10, 15] >>> list(accumulate([1, 2, 3, 4, 5], mul)) [...
true
13f8c02e9d192c60f1eedfbe7a7489ad3f6d17c5
kevinfrancis/practice
/dp/robot_path.py
1,723
4.1875
4
#!/usr/bin/env python import sys # From Cracking the Coding interview # Given # maze r rows & c cols. maze[i][j] = { 0, if cell is traversable, # 1, if it is an obstacle } # robot standing at 0th row, 0th col. # robot can only move right or down # (i.e. next step from (i...
true
6a792aee0b04ec52b8b18864ec84dea61a93e340
kulkarnidk/datastructurePrograms
/Binary_Search_Tree.py
651
4.25
4
def factorial(num): """ @:param calculates the factorial of num :param num:input for factorial method for calculation of factorial :return:returns factorial number of num """ res = 1 for i in range(1, num + 1): res = res * i return res tree_values=[] tree_count=[] num=int(input("...
true
b72d5c8a330df8c72151a16fef910973d2715954
indraputra147/pythonworkbook
/chapter1/ex23.py
434
4.15625
4
#Exercise 23: Area of a Regular Polygon """ Write a program that reads length of a side(s) and n number of sides from the user then displays the area of a regular polygon constructed from these values. """ n = int(input("Enter the number of sides of polygon: ")) s = float(input("Enter the length of the side of polyg...
true
3b9b1932f329ea632d86779847afa9aa6ef96a9e
indraputra147/pythonworkbook
/chapter2/ex48.py
1,211
4.40625
4
#Exercise 48: Birth Date to Astrological Sign """ The program will ask the user to enter his or her month and day of birth Then report the user's zodiac sign """ MONTH, DAY = input("Enter your birthday: ").split() DAY = int(DAY) if MONTH == "December": print("Capricorn") if DAY >= 22 else print("Sagittarius") e...
false
54ee4d44ee7e5851ad55dc04c85eaeb46bcb1c46
indraputra147/pythonworkbook
/chapter2/ex52.py
923
4.125
4
#Exercise 51: Letter Grade to Grade Points """ The program begins by reading a letter from the user then compute and display the equivalent number of grade points """ GRADE = input("Enter the letter of your grade (from A to F): ") if GRADE == "A" or GRADE == "A+": print("Your grade points is 4.0") elif GRADE ==...
true
e7bbcbcd43636310ba8cc439390c7f378d8ece51
indraputra147/pythonworkbook
/chapter1/ex15.py
356
4.1875
4
#Exercise 15: Distance Units """ Input of measurements in feet output in inches yards, and miles """ #input in feet from the user ft = float(input("Measurement in feet: ")) #compute the output inch = ft * 12 yrd = ft / 3 mile = ft / 5280 print("output:") print("%.2f" % inch + " inches") print("%.2f" % yrd + " yards"...
true
9f220aac7313af46cd9f016eb678f6285605c6b2
indraputra147/pythonworkbook
/chapter1/ex27.py
617
4.4375
4
#Exercise 27: When is Easter? """ The program reads the year from the user Then display the date of Easter in that year using Anonymous Gregorian Computus Algorithm """ #import math y = int(input("Input a year: ")) a = y % 19 b = y // 100 c = y % 100 d = b // 4 e = b % 4 f = (b + 8) // 25 g = (b - f + 1) // 3 h = (1...
false
bcd8616ee86c889b7db353718696c0f911aca56a
jeetmehta/Cracking-The-Coding-Interview
/Arrays and Strings/check_permutation.py
1,168
4.125
4
# CTCI - Chapter 1: Arrays and Strings # # Question 1.2 # PROBLEM STATEMENT: Given two strings, write a method to decide if one is a permutation of the other. # HINTS: #1, #84, #122, #131 # Checks if two strings are permutations of each other using hash maps # O(n) time, O(n) space def checkPermutations(firstString, s...
true
42b468d4eb709699c95eb5e9ce96418616f412d5
poojasaini22/edx-Introduction-to-Python-Absolute-Beginner
/str_analysis.py
723
4.21875
4
#Create the str_analysis() function that takes a string argument. In the body of the function: #Program: str_analysis() Function def str_analysis(arg): while True: if arg=="": str_analysis(input("enter")) break elif arg.isdigit()==True: if int(arg)<=99: ...
true
6b94a8fe1cab6d15504c19b40d8f8fcd79fb2094
aa-glitch/aoc2019
/day03/wire.py
2,262
4.21875
4
from typing import List, Tuple, Dict def find_crossings(wire1: List[Tuple], wire2: List[Tuple]) -> List[Dict]: """Return all crossing points with distance and steps. Find all coordinates where the given wires cross. For each point, determine the manhattan distance to the origin ('dist') and the combined ...
true
8da0cf849cc0860ce41f08330f62e762cefc8721
Darya1501/Python-course
/lesson-7/task-8.py
503
4.21875
4
# Минимальное и максимальное в последовательности n = int(input()) if n < 2: print('Последовательность должна состоять минимум из 2 цифр') else: min = max = int(input()) for i in range(n-1): a = int(input()) if a < min: min = a if a > max: max ...
false
b2d4216d9398e55f905a5d96c816f35217a60a77
apollovsilva/Python
/Aula 6/Exercícios em preparação/exrpreparacao5_aula6.py
677
4.15625
4
import turtle import math def polyline(t, length, n, angle): for i in range(n): t.fd(length) t.lt(angle) def polygon(t, length, n): angle = 360/n # ângulos externos de um polígono regular de n lados polilyne(t, length, n, angle) def arc(t, r, angle): arc_length = 2 * math.pi * r * an...
false
a794b59ccd1ced0828a677dfbbfe7c5ef25dd349
adibsxion19/CS1114
/Labs/lab9q2.py
1,029
4.1875
4
# Aadiba Haque # CS - UY 1114 # 3 March 2020 #Lab 9 Q2 def digit1(string): #sig: str even_num = '' odd_num = '' for char in string: if char== '0' or char == '2' or char =='4' or char == '6' or char =='8': even_num += char elif char == '1' or char == '3' or char =...
false
f8933fd2bd5739e868eb4f9b563538f849a18308
adityakumar1990/iNueron
/list/sort_nested_list_one_level_nesting.py
587
4.21875
4
def sort_nested_list(input_list): sorted_list=[] for e in input_list: if type(e) not in (str,int,float): ##print(e) #sorted_list.append(e.sort(reverse=True)) ##This will not work because e.sort(reverse=True) return none and none will be appended ...
true
2ddc67b20fd96368558f5173c3964e666b027c7e
taoes/python
/007_函数式编程/练习_001.py
459
4.1875
4
#!/usr/bin/env python # encoding: utf-8 """ @author: 周涛 @contact: zhoutao825638@vip.qq.com """ # 利用map()函数,把用户输入的不规范的英文名字,变为首字母大写, # 其他小写的规范名字。输入:['adam', 'LISA', 'barT'] # 输出:['Adam', 'Lisa', 'Bart']: def normalize(name: str): result = name[0].upper() + name[1:].lower() return result # 测试: L1 = ['adam'...
false
71044a5a1e03a9709daed327f969fa43e69eb644
taoes/python
/006_高级特性/003_列表生成器.py
882
4.125
4
#!/usr/bin/env python # encoding: utf-8 """ @author: 周涛 @contact: zhoutao825638@vip.qq.com """ # 生成0-10的平方数 # 普通方式遍历生成 def normal_function(): result = [] for x in range(10): result.append(x * x) return result # 使用列表生成器 def list_generator(): return [x * x for x in range(10)] # 生成0-20之间的偶...
false
3516fa49f214a7eb57d4592843ae3b498ca10853
EmmanuelSHS/LeetCode
/lint_implement_trie.py
1,397
4.25
4
""" Your Trie object will be instantiated and called as such: trie = Trie() trie.insert("lintcode") trie.search("lint") will return false trie.startsWith("lint") will return true """ class Trie: def __init__(self): self.root = {} self.END = '/' # @param {string} word # @return {void} # Inserts a word ...
true
d1a3694b40a21fe1d3f8b45555ff24e91ca9bc04
meralegre/cs50
/pset6/cash/cash.py
968
4.1875
4
from cs50 import get_float def main(): change = get_positive_float("Change : ") print('input change : ', change) # Convert this input from float to int cents = round(change*100) print('input round : ', cents) # Coins possible quarter = round(0.25*100) dime = round(0.10*100) nickel = round...
true
b21f6d981ce96ee41c58779e81f33067d313b2de
hendalf332/tratata
/projShift.py
2,932
4.125
4
#!/usr/bin/env python import os import string def clr(): if os.name == "nt": os.system("cls") else: os.system("clear") alphabet=list(string.ascii_lowercase) alphabet.append(' ') alphabet_upper=list(string.ascii_uppercase) punct=list(string.punctuation) for x in range(0,9): punct.app...
true
28604e80f9bd046f00dfff0b82b8cbf53f0edc4e
DanceSmile/python
/klass/klass_attribute.py
382
4.15625
4
''' 由于Python是动态语言 根据类创建的实例可以任意绑定属性。 ''' # 实例属性,  class Student(object): def __init__(self, name): self.name = name s = Student('Bob') s.score = 90 # 类属性 # 定义了一个类属性后,这个属性虽然归类所有,但类的所有实例都可以访问到 class Student(object): name = 'Student'
false
25f67ce7883f88337f0be49e79b2611f2d74ba1a
shashank136/Personal_code
/algorithms/python_code/bubblesort.py
625
4.40625
4
class Bubblesort(object): """ It's an inplace sorting algorithm time complexity of bubble sort is O(n^2) space complexity of bubble sort is O(1) """ def __init__(self): n = int(input("enter the number of elements: ")) a = [] for i in range(n): a.append(int(input("enter the number: "))) print...
false
8b980f1f09d963af977052476b8c42e785fbc6c4
ashwinraghav08/calculator
/calculator_v2.py
799
4.21875
4
def add(num1, num2): print (num1+num2) def minus(num1, num2): print (num1-num2) def multiply(num1,num2): print(num1*num2) def divide(num1,num2): print(num1/num2) def get_input(): num1 = input("Enter num1: ") #print(num1) num2 = input("Enter num2: ") #print(num2) operation=input...
true
136a6666e7a3a6b73a440e1ac57f493076c4c0a7
LukeJermaks/Programming
/Nested If Statement.py
900
4.21875
4
#Loop thing I guess. #By Luke Jermaks def NestedLoop(): score = int(input("Input Score\n >>>")) if score > 89: #Needs to be > 89 due to the grade being only over 90 for a grade 9 print("Grade 9") #You could also use => or =< and then the lower bound...
true
1c71af4bafdb4d4d3d18d82a89b64542efebf219
mottola/dataquest_curriculum
/python_basics/python-methods.py
1,566
4.46875
4
# OBJECT METHODS IN PYTHON (METHODS CALL FUNCTIONS ON OBJECTS) # OBJECT str # _______________________ # capitalize(), replace() # OBJECT float # _________________________ # bit_length(), conjugate() # OBJECT list # ________________ # index(), count() # LIST METHODS # ______________ fam = ['liz', 1.73, 'emma', 1.6...
true
b98021728ffe1479acfa222d7f8489c85030ca22
FOSS-UCSC/FOSSALGO
/algorithms/ar-expsq/python3/exponentiation_by_squaring.py
378
4.375
4
def exponentiation_by_squaring(base, power): res = 1 while(power > 0): if(power % 2 != 0): res *= base #if power is ODD, multiply res with base base *= base # square the base power = power // 2 # halving power (integer) return res def main(): print(exponentiation...
true
3c0138867df695fb0cb1a5892f8fcdca124d73cd
cheungh/python
/bubble_sort.py
835
4.125
4
""" Very inefficient sort method do not use for sort for list larger than 200 items use quick sort or merge sort instead """ def bubble_sort(A): # for n element in list n = len(A) bound = n - 1 # let i be iterate counter of outer loop # set swap to false to detect if swap occurred swap = False ...
true
24ae4b94795980b14021e543dee79d894447c383
lianhx/Python_Learning
/1.上课/第一次课/2.py
410
4.1875
4
import math # 导入math模块 side1 = int(input("请输入一个边长:")) # 得到一个边长 side2 = int(input("请输入另一个边长:")) # 得到第二个边长 angle = int(input("请输入夹角:")) # 得到夹角的值 a = 2*side1*side2*math.cos(angle*math.pi/180) side3 = math.sqrt(side1**2 + side2**2 - a) # 利用余弦定理计算第三条边长 print(side3) # 打印第三条边长
false
2c0dc53acf5118aba7cf67124186a723ba97d633
Eliasin/fun-things
/mark_catastrophe.py
2,114
4.15625
4
from functools import reduce english_marks = [31, 20, 44, 49, 50, 33, 45, 21, 3, 17, 40] math_marks = [26, 25, 30, 50, 41, 29, 19, 26, 38, 35, 42] print("I have a set of english marks and a set of math marks, both are out of 50.") def convert_marks_to_percentage(marks): result = [] for mark in marks: result....
true
82ad2118b1979ffb7016418c9fe95cb3b682cc58
zju-stu-lizheng/python_2021
/面向对象/多态.py
1,665
4.59375
5
''' 多态:顾名思义就是多种状态、形态,就是同一种行为 对于不同的子类【对象】有 不同的行为表现 要想实现多态 必须得有两个前提需要遵守: 1.继承:多态必须发生在父类和子类之间 2.重写:子类需要重写父类的方法 多态的作用: 增加程序的灵活性 增加程序的扩展性 ''' # 案例演示 class Animal: ''' 父类[基类] ''' def say_who(self): print('我是一个动物....') pass pass class Duck(Animal): ''' 鸭...
false
c1ae10792f7f8b259d278431bfbd1fba180b4776
zju-stu-lizheng/python_2021
/day03/parameter.py
1,787
4.3125
4
''' 参数的分类: 必选参数、默认参数【缺省参数】、可选参数、关键字参数 参数:其实就是函数为了实现某项特定的功能,进而为了得到实现功能所需要的数据 ''' # 1 必选参数 # def sum(a,b): # 形式参数:只是意义上的一种参数,再定义的时候是不占内存地址的 # sum = a+b # print(sum) # pass # # # # 2 默认参数【缺省参数】 # def sum1(a=20,b=30): # 缺省参数始终放在参数列表的尾部 # print('默认参数使用=%d'%(a+b)) # pass # # # # ...
false
5b87ae1a4cfc1e7e44aed75a70fd5cbe37d32024
zju-stu-lizheng/python_2021
/day02/tuple.py
885
4.40625
4
''' 元组是一种不可变的序列,在创建之后不能做任何的修改 1.不可变 2.用()来创建,数据项用逗号分隔 3.可以实任何的类型 4.当元组中只有一个元素是,要加上逗号,否则会被当做整形来处理 5.可以支持切片 ''' # 元组的创建 ,不能进行修改 # tupleA = () tupleA = ('abcd', 89, 9.12, 'peter', [11, 22, 33]) # print(type(tupleA)) # print(tupleA) # 元组的查询 # for item in tupleA: # print(item,end=' ') # print(tupleA[2]...
false
b86b1c817be6bd24b9d05bb518b542cadb684483
zju-stu-lizheng/python_2021
/day03/函数01.py
969
4.40625
4
''' 什么是函数:一系列python语句的组合 一般是完成具体的独立的功能 为什么要使用函数: 代码的复用最大化以及最小化冗余代码 函数定义 def + 关键字 + 小括号 + 冒号 + 换行缩进 + 代码块 def 函数名 (): 代码块 函数调用 本质上就是去执行函数定义里面的代码块,再调用函数之前,必须先定义 ''' # 函数的定义 def printInfo(name,height,weight,hobby,profess): ''' 这个函数是用来打印个人信息的,是对小张信息的打印 :return: ''' # 函数代码块 ...
false
6733cf341bc1480fb93b411cf9101ab699825d01
stewartyoung/leetcodePy-easy-1-20
/Algorithms/LongestCommonPrefix.py
1,117
4.1875
4
stringList1 = ["flower", "flow", "flight"] stringList2 = ["dog", "racecar", "car"] def longestCommonPrefix(stringList) -> str: # If string list doesn't contain anything, return empty string if not stringList: return '' # Take the last item in the stringList lastIte...
true
b383deb55bf6598f2779a726503d383486f6419b
anupatboontor/workshop
/For/for_exercise.py
448
4.15625
4
# 2.จงเขียนตารางสูตรคูณให้ผลลัพท์ที่ออกมาเป็นแบบตัวอย่างด้านล่างโดยใช้คำสั่ง for for number in range(2, 13): for i in range(1, 13): result = number * i print("%d x %d = %d" % (number, i, result)) print(" ") print("-------------------------------------------------------")
false
82b13aae211e42ae1d23045f6da88847341863d1
cs-fullstack-2019-fall/python-coding-concepts1-weekly-5-Kenn-CodeCrew
/question9.py
355
4.21875
4
# ### Problem 9: # Ask the user for a positive number. Create an empty array and starting from zero, add each number by 1 into the array. Print EACH ELEMENT of the array. userInput = int(input("Enter a positive number")) emptyArray = [] for index in range(userInput+1): emptyArray.append(index) for eachElement in...
true
e42dab7c2dcc8a68da514bee6ac854292e137d6e
milkrong/Basic-Python-DS-Algs
/InsertionSort.py
366
4.125
4
def insertion_sort(arr_list): for i in range(1, len(arr_list)): cur = arr_list[i] position = i while position > 0 and arr_list[position - 1] > cur: arr_list[position] = arr_list[position -1] position -= 1 arr_list[position] = cur return my_list my_list =...
false
eabf756621d3a5f4598cc40eceb636f91a5a61e0
milkrong/Basic-Python-DS-Algs
/BubbleSort.py
497
4.28125
4
def bubble_sort(input_list): is_sorted = False length = len(input_list) - 1 while not sorted: is_sorted = True # assume it is sorted for i in range(length): if input_list[i] > input_list[i+1]: is_sorted = False # find a position not sorted input_...
true
9f5d85dd02c35ca6b6590b55823732ddf369fa45
christopher-besch/arg_toolset
/substitution_cipher.py
2,879
4.125
4
""" substitute every letter with it's number from the alphabet and the other way around """ # assign each char a letter def substitute(string, substitutes=None, joint=''): # replace substitutes with default if substitutes is None: substitutes = { "1": 'A', "2": 'B', ...
false
99fdab510f07e294362319bd0ff41e979b287693
Clucas0311/PythonCourse
/pizza_toppings.py
532
4.40625
4
# Write a loop that prompts the user to enter a series of pizza toppings until # they enter a "quit" value. As they enter each message, print a message saying # You'll add that topping to their pizza message = """\nWelcome to Pizza Shack! What kind of toppings would you like to add to your pizza?:""" message += "\n En...
true
ed71d577919662e06562094429f460f30ea0d0d3
Clucas0311/PythonCourse
/2-10.py
823
4.28125
4
# Write a progran that produces 48 cookies with the ingredients listed # 1.5 cups of sugar # 1 cup of butter # 2.75 cups of flour regular_amt_cookies = 48 regular_amt_sugar = 1.5 regular_amt_butter = 1 regular_amt_flour = 2.75 # Prompt the user on how many cookies that they will like to make? amount_of_cookies = floa...
true
418c73d1e577cf0a3140e9f0cc85510248f6d6ce
Clucas0311/PythonCourse
/2-7.py
321
4.25
4
# A cars MPG can be calcuated: # MPG = Miles driven / Gallons of gas used miles_driven = float(input("How many miles did you drive: ")) gallons_of_gas = float(input("How many gallons of gas did you use?: ")) miles_per_gallon = miles_driven / gallons_of_gas print(f"The number of miles driven: {miles_per_gallon} MPG")...
true
890f88c45a3b66e02e75dc05d5bb7711e38e5d7a
Clucas0311/PythonCourse
/restaurant2.py
1,009
4.125
4
class Restaurant: # Make a class called restaurant def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type def describe_restaurant(self): print(f"{self.restaurant_name} is a beautiful restaurant, perfect for large parti...
true
956916707ffe3eee148dbb01650936533e3fc656
aruwentar/PythonSmallProjects
/Hangman/main.py
2,038
4.125
4
import re def get_word_to_guess(): # STUB return "barnacle" def convert_word_to_char_list(word): char_list = list() for char in word: char_list.append(char) return char_list def get_user_guess(): user_guess = str() while True: user_guess = input("Please guess your letter: ...
true
e64ff752b5f33dbdef61008dc6b8692779658d1c
lucasgarciabertaina/python-exercises
/guides/guide05/g05e02.py
1,663
4.6875
5
""" Los siguientes ejercicios son en su mayoría para reutilizar los enunciados de guías anteriores, aplicando en la solución el uso de funciones. En los primeros 5 ejercicios trabajamos con el texto: “Quiero comer manzanas, solamente manzanas.”, considerar que una palabra es toda secuencia de caracteres diferentes de l...
false
1e5343c11b7c4d3817a8f93ad982856115acf114
lucasgarciabertaina/python-exercises
/guides/guide05/g05e10.py
234
4.15625
4
""" 10. Cargar una lista con números. Invertir los elementos (sin usar reverse). Mostrar. """ def reverse(numbers): reverse = [] for i in range(len(numbers)-1, -1, -1): reverse.append(numbers[i]) print(reverse)
false
9305e2365cfbc47cfc4f7572d05427dba0b12f98
lucasgarciabertaina/python-exercises
/guides/guide05/g05e09.py
640
4.3125
4
""" 9. Dada una lista cargada con números enteros, obtener el promedio de ellos. Mostrar por pantalla dicho promedio y los números ingresados que sean mayores que él. Dos funciones: promedio y mayorQue. """ def average(numbers): total = 0 for number in numbers: total += number return total/len(nu...
false
70f9907e1b27b3421e4e4ae7a3babd81b62cff1d
lucasgarciabertaina/python-exercises
/guides/guide02/g02e03.py
250
4.15625
4
""" Mostrar por pantalla una lista de 20 números enteros consecutivos, comenzando con un número ingresado por teclado. """ number = int(input('Enter a number: ')) i = 1 while i != 20: print('Number ', number) i += 1 number = number+1
false
65359d84f0f12ff18a98c0f1acc21b288d6fe447
ErickMwazonga/sifu
/strings/string_compression.py
1,685
4.3125
4
''' 443. String Compression Link: https://leetcode.com/problems/string-compression/ Given an array of characters chars, compress it using the following algorithm: Begin with an empty string s. For each group of consecutive repeating characters in chars: If the group's length is 1, append the character to s. Otherwise...
true
5215f67912c760305c6c22390711d8a11e4e546e
ErickMwazonga/sifu
/graphs/currency_conversion.py
2,424
4.15625
4
''' Currency Conversion Resource: https://www.youtube.com/watch?v=L9Me2tDDgY8 Paramenters: 1. array of currency conversion rates. E.g. ['USD', 'GBP', 0.77] which means 1 USD is equal to 0.77 GBP 2. an array containing a 'from' currency and a 'to' currency Given the above parameters, find the conversion rate t...
true
0cb142038b9c99afb71841bd9f194a9fec21e695
ErickMwazonga/sifu
/strings/reversed_words.py
1,412
4.21875
4
''' Write a function reverse_words() that takes a message as a list of characters and reverses the order of the words in place. message = [ 'c', 'a', 'k', 'e', ' ', 'p', 'o', 'u', 'n', 'd', ' ', 's', 't', 'e', 'a', 'l' ] reverse_words(message) -> 'steal pound cake' ''' from typing import NoReturn def revers...
true
21b13df050bb393416e65d2671f6d7928fb34f6a
ErickMwazonga/sifu
/math/reverse_integer.py
738
4.21875
4
''' 7. Reverse Integer Link: https://leetcode.com/problems/reverse-integer/ Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0. Assume the environment does not allow you to store 64-bit integer...
true
229e22715ff921f6dde25bdc8aa8b034832e3abb
ErickMwazonga/sifu
/hashmaps/jewels_and_stones.py
849
4.125
4
''' 771. Jewels and Stones Link: https://leetcode.com/problems/jewels-and-stones/ You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the stones you have are also jewels. The let...
true
a160d41841365f6bc5537b472fb9f94df459bbee
ErickMwazonga/sifu
/binary_search/sqrt/sqrt.py
1,343
4.15625
4
''' 69. Sqrt(x) Link: https://leetcode.com/problems/sqrtx/ Given a non-negative integer x, compute and return the square root of x. Since the return type is an integer, the decimal digits are truncated and only the integer part of the result is returned. Write a function that takes a non-negative integer and returns ...
true
22a28928de9b7cd4513c0aed9dddcbded63314b1
ErickMwazonga/sifu
/recursion/learning/count_occurrences.py
692
4.25
4
''' Given an array of integers arr and an integer num, create a recursive function that returns the number of occurrences of num in arr Example input -> [4, 2, 7, 4, 4, 1, 2], num -> 4 output = 3 ''' def countOccurrences(arr: list[int], num: int, i: int = 0): if i == len(arr): return 0 if arr[i] == ...
true
458be929b5f24b02589aa291010b2f4b7ba882de
ErickMwazonga/sifu
/graphs/shortest_path.py
1,563
4.125
4
''' shortest path https://structy.net/problems/shortest-path Write a function, shortestPath, that takes in an array of edges for an undirected graph and two nodes (nodeA, nodeB). The function should return the length of the shortest path between A and B. Consider the length as the number of edges in the path, not the ...
true
6e64d56410b082881f0a2316e8011f1691333f80
davidhansonc/Python_ZTM
/random_game.py
946
4.15625
4
''' * File Name : random_game.py * Language : Python * Creation Date : 05-01-2021 * Last Modified : Wed Jan 6 22:46:12 2021 * Created By : David Hanson ''' from random import randint def run_guess(guess, answer): try: if 1 <= int(guess) <= 10: if int(guess) == int(answer): ...
true
16465477947bb81b1ea52473ed2e77fa7cb329c6
ON1y01/web-code-editor
/files/2.py
592
4.3125
4
#2 print('Задание 2. Данo натуральное число. Найдите остатки от деления этого числа на 3 и на 5.') a = float (input ('Введите натуральное число: ')) while (a<0 or a%1 !=0): print ('Вы ввели ненатуральное число') a = float (input ('Введите НАТУРАЛЬНОЕ число: ')) if (a>0 and a!=0 and a%1==0): b = a%3 c = a%5 ...
false
6fa0434dd00c0c40d6c22d5c8dbb8732f0e208d0
mohit266/Python-course-Edugrad
/Edugrad_1.py
458
4.125
4
""" QUESTION 1: Swap the case of the string that comes as an input and return the string while making sure that the first letter of the string stays Uppercase. Example - Input - "PyThON" Output - "PYtHon" """ def main(i): result = "" for ch in range(len(i)): if ch == 0: result += i[ch].upp...
true
0b877c9ef0b1af75f29325827b3249ef230c8844
Mattia-Tomasoni/Esercizi-Python
/es31.py
1,271
4.4375
4
''' TESTO: Fornisci la rappresentazione in binario di un numero decimale. Dopo aver acquisito il valor del Numero da trasformare, si esegue la divisione del numero per 2 e si calcola quoziente e resto.Il resto è la prima cifra della rappresentazione binaria ì. Si ripete il rpocedimento assegnando il quoziente ottenuto ...
false
c2f4904730f474b18290c7fc549086c1666d5cbc
chiragnarang3003/assignment6
/assign6.py
2,982
4.375
4
''' #Question1:->Create a function to calculate the area of a sphere by taking radius from user. ''' def area_sphere(num): '''Calculate the area of the sphere using Fuctions''' pi=3.14 temp=4*pi*num*num return temp radius=int(input("Enter radius of the sphere : ")) output=area_sphere(radius) print("The ...
true
e34cde867262e8ae91ddb55f5d5d2898e7d7eec7
SebastianN8/calculate_pi
/calculate_pi.py
1,312
4.34375
4
# # calculate_pi.py # # Created by: Sebastian N # Created on: April 19 # # This program calculates pi according to iterations # # This is where math.floor comes from import math # Function that contains the loop in order to get the result of a gregory leibniz series def calculate_pi(iterations_passed_in): # Variable...
true
f525f2bc24bb8d015a687a475ae0e136f2b28983
ritesh2905/StringPractice
/05FindingSubstring.py
205
4.125
4
# Substring in a string str1 = 'the quick brown fox jumps over the lazy dog' str2 = input('Enter a substring : ') if str2 in str1: print('Sunsting is present') else: print('Substring not found')
true
2683b4888e1654b57783905aacbf7d79f21d145c
Priyankasgowda/90dayschallenge
/p50.py
1,834
4.375
4
# Activity Selection Problem | Greedy Algo-1 # Greedy is an algorithmic paradigm that builds up a solution piece by piece, always choosing the next piece that offers the most obvious and immediate benefit. Greedy algorithms are used for optimization problems. An optimization problem can be solved using Greedy if the pr...
true
4c7d779f8dfcabda3e19ec33136ef11687926ea0
Priyankasgowda/90dayschallenge
/p38.py
1,548
4.25
4
# Maximum Length Chain of Pairs | DP-20 # You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. A pair (c, d) can follow another pair (a, b) if b < c. Chain of pairs can be formed in this fashion. Find the longest chain which can be formed from a given set of pairs....
true
ad9ad5ca321ec835fb046ea810b261ae4323c592
AlexanderTankov/HackBulgaria-Haskell
/Intro/03-NameMatching/taskThree.py
761
4.15625
4
CHAR_FOR_NEXT_SYMBOL = '^n' NUMBERS = '1234567890' def get_language(): result = '' input_for_language = input() for char in range(0, len(input_for_language)): if input_for_language[char] == '^': result += input_for_language[char - 1] return result def check_for_word(): langua...
false
703522416cba310ae0f9b3b3bdf8647a6188d445
phamva/phamvietanh---fundamentals---D4E12
/Session 4/homework/dict2.py
369
4.15625
4
number = [1, 6 , 8 , 1 , 2 , 1 , 5 , 6] # Write a program to count number occurrences in a list with count() # a = input("enter your number") # occurrences = number.count(1) # print(a , "appear" , occurrences , "times in my list",) # without count a = input("enter your number") number_occurrences = int(0) for x in nu...
false
14846edd4e097696ae93306aa20b91ff2c407736
phamva/phamvietanh---fundamentals---D4E12
/Session 2/Homework/homeworkBMI.py
324
4.15625
4
H = int(input("height")) W = int(input("weight")) CM = H/100 BMI = W/CM**2 print("BMI") if BMI < 16: print("Severely underweight") elif BMI >= 16 and BMI <=18.5: print("Underweight") elif BMI >= 18.5 and BMI <= 25: print("Normal") elif BMI >= 25 and BMI <= 30: print("Overweight") else : print("sdfsd...
false
e2ebb7ff00d992d713817b9b062f9f2807945802
carloxlima/curso_python
/exercicio033.py
1,339
4.125
4
n1 = int(input("Digite um número: ")) n2 = int(input("Digite um segundo número: ")) n3 = int(input("Digite um ultimo número: ")) if n1 > n2 : if n1 > n3: if n3 > n2: print("O primeiro número é o maior. N: {}".format(n1)) print("O segundo é o menor. N {}".format(n2)) else: ...
false
081e9ab63f45f82814274dd037af5a9ca22599ee
JoachimIsaac/Interview-Preparation
/arrays_and_strings/reordering_words_in_a_sentence.py
2,806
4.3125
4
""" Problem 3: Reverse the ordering of words in a sentence. For example: Input: "The weather is amazing today!" Output: "today! amazing is weather The" UMPIRE: Understand: --> can we get an empty string? yes --> can we get a single letter ? yes --> so we need to reverse the entire sentence but keep the words in t...
true
9ede3d57572351010d154f023ef131ca957316e8
JoachimIsaac/Interview-Preparation
/LinkedLists/86.PartitionList.py
1,986
4.125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next """ UMPIRE: --> we are getting a singlely linked list --> the calue x is asusumed to always be there --> what if we get an empty linked list (just return it ) same w...
true
58cb43bc2a31cdc0f4533666686ebff5e559d521
TahirCanata/Class4-CS101Module-Week9
/Stack2.py
1,864
4.3125
4
class Stack: #2 Class kullaniyoruz, Stack Classinda, Class queue methodlarini kullaniyoruz def __init__(self): #Esasen cikarma islemi disinda fark yok self.q = Queue() #Stackte en son gireni ilk cikarmak icin dequeu ve enqueue islemlerini kullaniyoruz def empty(s...
false
6db5b0a035b58bd2cf1e2ec243591726cf5beced
prajjwolmondal/Rock-Paper-Scissors
/rps.py
2,148
4.46875
4
# This is a rock paper scissors game in Python #Goal #Ask the player if they pick rock paper or scissors #Have the computer chose its move #Compare the choices and decide who wins #Print the results #Subgoals #Let the player play again #Keep a record of the score e.g. (Player: 3 / Computer: 6) import random def use...
true
70274cd39aa0d24b2209df12a3ef8b601bcc0e5a
suziW/myLeetCode
/155.py
990
4.21875
4
class MinStack: def __init__(self): """ initialize your data structure here. """ self.stack = [] self.minRecord = [float('inf')] def push(self, x: int) -> None: self.stack.append(x) if x <= self.minRecord[-1]: self.minRecord.append(x) ...
false
4339bebc75fb603808739f5289ece703c2bbeaaf
ram4ibm/codeworks
/challenge3/dict_of_dict_value.py
1,310
4.25
4
#!/usr/bin/env python # Incomplete : 40 min # VARIABLES #input_nested_var = dict(input("Enter the Nested input object: ")) #input_nested_key = input("Enter the Nested input key: ") #input_nested_var = {"a": {"b": {"c": "d"}}} input_nested_var = {"a": {"b": {"c": {"d": "e"}}}} #input_nested_var = {"a": {"b"...
true
2476666d622309d940c03489242121a701127610
KolluriMounish/Python-problem-Solving
/problem_1.py
893
4.4375
4
#TODO: Given an array containing unsorted positive or negative integers with repeated # values, you must arrange the array in such a way that all non-zeroes should be on the left- # hand side of an array, and all zeroes should be on the right side of the array. Order of non- # zero elements does not matter. You are ...
true
6b1dd83d8d95cc518483ec2ff963631702ca00aa
Malbshri/malbshri
/day 30.py
741
4.15625
4
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> # week 5 >>> # day 30 >>> >>> for x in range (6) : print(x) 0 1 2 3 4 5 >>> >>> for x in range (2, 6) : print(x) 2 3 4 5 >>> >>> for x...
false
bc25e8e24dccca506cbce23efa340fa6470f2b68
Malbshri/malbshri
/lesson 59.py
880
4.1875
4
import re #Replace all white-space charactor with the digit "9": str = "The rsin in Spain" x = re.sub("\s", "9", str) print(x) import re #Replace the first two occurrence of white-space charactor with the digit 9" str = "The rain in Spain" x = re.sub("\s", "9", str, 2) print(x) import re #The search() function retu...
true
9857a478ff0a80d9962a333bb2afe8f294694d0e
CleverOscar/python-udemy
/exercise/conditional.py
893
4.25
4
## -*- coding: utf-8 -*- #x = 5 #y = 6 # #print('x =',x,'y =', y) #print('X is less than Y:', x<y) #print('X is greater than Y:',x>y) # #var_1 = 7 #var_2 = 7 # #print('Var_1:', var_1, 'Var_2:', var_2) #print(var_1 < var_2) #print(var_1 > var_2) #print(var_1 == var_2) #print(var_1 <= var_2) #print(var_1 >= var_2) #print...
true
3bd04acf2d465c96e2914be6ade4d9283c7b72ec
cyndichin/DSANano
/Data Structures/Recursion/Deep Reverse.py
1,749
4.71875
5
#!/usr/bin/env python # coding: utf-8 # ## Problem Statement # # Define a procedure, `deep_reverse`, that takes as input a list, and returns a new list that is the deep reverse of the input list. # This means it reverses all the elements in the list, and if any of those elements are lists themselves, reverses all t...
true
01d65dd447d6bf558e67cc65829446c92eb62c8d
Ham5terzilla/python
/4th Lesson/Ex7.py
672
4.125
4
# Заполнить массив из 5 элементов случайными числами в интвервале -100 100. Найти сумму всех отрицательных элементов # массива. Если отрицательных элементов массива нет, вывести собщение "отрицательных элементов нет". from random import * def randomm(): lst = [int(random() * 200 - 100) for i in range(5)] s = ...
false
abebd06788fd47dbab9773fc1f64e100de2476e2
ATLS1300/pc04-generative-section12-kaily-fox
/PC04_GenArt.py
2,262
4.125
4
""" Created on Thu Sep 15 11:39:56 2020 PC04 start code @author: Kaily Fox ********* HEY, READ THIS FIRST ********** My image is of a star and a moon in the night sky. I decided to do this because the sky is one of my favorite parts of nature. Its' beauty is so simplistic yet breath taking. The natural phenomenas t...
true
bd70add033e41749a61588e508b6bf8779cab5e2
LuceroLuciano/bonitoDevoradorDePalabras
/funcionInput.py
1,228
4.21875
4
#print("Tell me something...") #something = input() #print("Mmm...", something, "...really?") #the fuction input() whit an argument """ something = input("Tell me something...") print("Mmm...", something, "...Really?") """ #Calculado la hipotenusa con vlores ingrsados """" cateto_a = float(input("Inserta la longitud ...
false
1202fa13f40bb0f3d5138213af0ce12798beb6d0
alexdemarsh/gocode
/blogmodel.py
2,498
4.5
4
''' Blog Model Create a class to interface with sqlite3. This type of object is typically called a Model. The table in sqlite3 will have two columns: post_name and post_text Discuss with your neighbour on how to solve this challenge. To connect Python to SQL, reference the following: http://www.pythoncentral.io/...
true
3c07f4c0549d6d02ca7ca975b83af3943f3dd12b
STMcNamara/cs50-Problems
/pset6/vigenere/vigenere.py
1,462
4.1875
4
import sys from cs50 import get_string # Define a main function to allow returns def main(): # Return 1 if incorrect number of arguments provided if len(sys.argv) != 2: print("Please provide one command line argument only") sys.exit(1) # Return 1 if the key is not letters ony key = s...
true
2d499a16ab2c0af88d8fe1dc1bb1f755cc1fe0b3
awsaavedra/coding-practice
/python/practice/2ndEditionLearningPythonTheHardWay/ex32.py
492
4.125
4
# creating non-empty arrays the_count = [1, 2, 3, 4, 5] fruits = ["Apples", "Oranges", "Tangerines", "Pears"] change = [1, "two", 3, "four"] for number in the_count: print "This number %d " % number for fruit in fruits: print "This fruit: %s" % fruit for i in change: print "I got %r" %i elements = [] for i i...
true
1f838acbcd6fc68280d7425dab45414467815a0e
awsaavedra/coding-practice
/python/practice/2ndEditionLearningPythonTheHardWay/ex15.py
423
4.15625
4
filename = raw_input("Please give me the filename you would like to open:") txt = open(filename) print "Here's your file %r:" % filename print txt.read() print "I'll also ask you to type it again:" file_again = raw_input("> ") txt_again = open(file_again) print txt_again.read() txt.close() #How do I use this .c...
true
cf27a6755dde266d83965d3bf01f2c9e8ef238cc
nalisharathod01/Python-Practice
/Python Programming/Integers.py
833
4.28125
4
#intergers integerNumber = 1 intNum = 2 floatNumbers = 1.0 secondFloat = -229.0 print(integerNumber) print(intNum) print(floatNumbers) #find types of the strings string = "hello" print(type(string)) print(type(secondFloat)) #only multiplication can be done with integers and string #integers operations #with divisio...
true
c0a2c9e9293a663314aca23381c1499ff53947ae
nalisharathod01/Python-Practice
/Python Programming/ifStatements.py
1,007
4.21875
4
#if condition: #doApproritateThing #elif differentCondition: #else of #doMoreStuff #elif condition3: # morestuff #else: #doBaseCase/FallBack number = 6 if number == 7: print ("this number is 7") elif type(number) == type(7): print("same Type") elif number ==6: ...
true
14fdb7bfed2aaeb14425d81d9c5273d2e08ce3d3
adriaanbd/data-structures-and-algorithms
/Python/data-structures/linked-lists/is_circular.py
1,185
4.28125
4
from singly_linked_list import LinkedList def is_circular(linked_list: LinkedList) -> bool: """ Determine wether the Linked List is circular or not Args: linked_list(obj): Linked List to be checked Returns: bool: Return True if the linked list is circular, return False otherwise """...
true
6e3b2f1686fd54223fe0474b6e250c6d2cd642b1
brandonkwleong/coding-practice
/sorting/quick-sort.py
2,701
4.3125
4
#/opt/bin/python """ QUICK SORT This script implements the quicksort algorithm. Quicksort requires the 'partition' method, which is described below. (Merge sort requires the 'merge' method). Time Complexity: O(n * log(n)) Worst case: O(n^2), depending on how the pivots are chosen Note that in the gene...
true
6308212919ba70665bb36456607cbaf77b90e49a
aah/project-euler
/python/e002.py
1,410
4.125
4
#!/usr/bin/env python3 """Even Fibonacci Numbers Project Euler, Problem 2 http://projecteuler.net/problem=2 Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in t...
true
cd8c6c803c3d603ae3fd5363308bf6a85a8a9701
isrt09/Python_Problem_Solving_Exercises
/Python with 70+ Problems/Dictionary.py
1,394
4.125
4
# Dictionary Part 1(Do this exercise in computer) # Do the following 1.Create a dictionary which consist of Item(keys) and Quantity(values) of items in the shop. Items Quantity soap 10 bread 5 shampoo 8 2.Create another dictionary which c...
true
b4d5f1f31f567a1b5b6fa573c9af39767425ab80
willmartell/pyexercises
/100ex_28.py
228
4.125
4
"""define a function that can accept two strings as input and concatenate them and then print it in the console""" string1 = "hello" string2 = "world" def concat_str(s1,s2): return s1+s2 print concat_str(string1,string2)
true