blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
32825ec6823749ec084a80d18865a23f05851a6e
Tetyana-I/first-python-syntax-exercises
/words.py
469
4.5
4
def print_upper_words(words, must_start_with): """Print each word (on a separate line uppercase) from words-list that starts with any letter in must_start_with set """ for word in words: if (word[0] in must_start_with) or (word[0].upper() in must_start_with): print(word.upper()) # this sho...
true
8f38be0f4bc6445f279cf523fbb830dbc8482e94
robpalbrah/RedditDailyProgrammer
/easy/dp_293_easy.py
1,713
4.15625
4
""" [2016-11-21] Challenge #293 [Easy] Defusing the bomb https://tinyurl.com/dp-293-easy """ # Status: Done # allowed_wires = {cut_wire_color : [allowed_wire_color, ...], ...} allowed_wires = {None : ['white', 'black', 'purple', 'red', 'green', 'orange'], 'white' : ['purple', 'red', 'green', 'orange']...
true
31adb720c1fca5d66db953e58fb4e409cded43f2
RobertHostler/Python-Data-Structures
/StacksAndQueues/QueueFromStacks.py
1,100
4.15625
4
from Stacks import Stack class QueueFromStacks(): # This is a queue implemented using a stack. This is a # common interview question or puzzle, and I thought I # would attempt it myself. def __init__(self, N): self.N = N self.stack1 = Stack(N) self.stack2 = Stack(N) def __...
true
5c7774fab73738e6e625f2eb9e90fc7433f6e2e3
pzhao5/CSSI_Python_Day_4
/for_split.py
595
4.46875
4
my_string = raw_input("Type something: ") # upper() method on string would capitalize the string. # print "{} {}".format("", "") is the way to format a string. # Unlike JS, Python does not support ++, thus you should use += 1 instead print "Print words in upper case" index = 0 for word in my_string.split(): # return ...
true
2c18b87f54a76008e1e255b08b7491922f905e0d
danielzyla/Python_intermediate
/11.py
1,223
4.125
4
##choice =''' ## ##choose on from the list: ##'load data' -\t\t 1 ##'export data' -\t\t 2 ##'analyze & predict' -\t 3 ## ##''' ## ##optlisted={'1':'load data', '2':'export data', '3':'analyze & predict'} ## ##choicenr=input(choice) ## ##while choicenr: ## if not choicenr.isdigit(): ## print('it is not number'...
true
ed553ef5a29820c3f52f2b19dfc0867eda49a5d5
Vagacoder/Python_for_everyone
/P4EO_source/ch11/sec05/permutations.py
1,002
4.34375
4
## # This program computes permutations of a string. # def main() : for string in permutations("eat") : print(string) ## Gets all permutations of a given word. # @param word the string to permute # @return a list of all permutations # def permutations(word) : result = [] # The empty string has a si...
true
50e1100ebc2bf59007e20c74181dd9720813a924
Vagacoder/Python_for_everyone
/P4EO_source/ch06/how_to_1/scores.py
1,106
4.21875
4
## # This program computes a final score for a series of quiz scores: the sum after dropping # the two lowest scores. The program uses a list. # def main() : scores = readFloats() if len(scores) > 1 : removeMinimum(scores) removeMinimum(scores) total = sum(scores) print("Final score:",...
true
5a87579b0e1cc3816dc15f3dd5726a622c0b815d
Vagacoder/Python_for_everyone
/Ch11/P11_16.py
2,652
4.125
4
## P11.16 # revise evaluator.py by adding operations of % and ^ (power) def main() : expr = input("Enter an expression: ") tokens = tokenize(expr) value = expression(tokens) print(expr + "=" + str(value)) ## Breaks a string into tokens. # @param inputLine a string consisting of digits and symbols # @r...
true
a48ba5b2bef7306a04b613e4764a5172c9f12b27
Vagacoder/Python_for_everyone
/P4EO_source/ch11/sec03/palindromes2.py
1,688
4.34375
4
## # This program uses recursion to determine if a string is a palindrome. # def main() : sentence1 = "Madam, I'm Adam!" print(sentence1) print("Palindrome:", isPalindrome(sentence1)) sentence2 = "Sir, I'm Eve!" print(sentence2) print("Palindrome:", isPalindrome(sentence2)) ## Tests whether a...
true
c8779a53a5928f26a9bde553ca810f751c1ac65f
Vagacoder/Python_for_everyone
/P4EO_source/ch06/sec04/reverse.py
1,079
4.40625
4
## # This program reads, scales and reverses a sequence of numbers. # def main() : numbers = readFloats(5) multiply(numbers, 10) printReversed(numbers) ## Reads a sequence of floating-point numbers. # @param numberOfInputs the number of inputs to read # @return a list containing the input values # def rea...
true
b834f91ed9708136aa32f8d2b8a6a3fb9add2ea3
Vagacoder/Python_for_everyone
/Function3.py
981
4.21875
4
## Ch05 R5.2h # calculate the weekday of date def weekDay(year, month, day): d = day print(d) m = shiftMonth(month) print(m) c = year // 100 if month == 1 or month == 2: y = year%100 -1 else: y = year%100 if y < 0: y += 100 c += -1 print('y',y) ...
false
1feb20bdb6281f6323f50c84278816dc128e218d
Vagacoder/Python_for_everyone
/P4EO_source/ch08/sec01/spellcheck.py
1,152
4.46875
4
## # This program checks which words in a file are not present in a list of # correctly spelled words. # # Import the split function from the regular expression module. from re import split def main() : # Read the word list and the document. correctlySpelledWords = readWords("words") documentWords = readWo...
true
eea9344b03ebe54c9727d8ec1539e001fe3db9e0
Vagacoder/Python_for_everyone
/Ch12/insertionsort.py
474
4.4375
4
## # The insertionSort function sorts a list, using the insertion sort algorithm. # # Sorts a list, using insertion sort. # @param values the list to sort # def insertionSort(values): for i in range(1, len(values)): next = values[i] # Move all larger elements up. j = i while j ...
true
6a18e1cc99ec66f2dd69949cb9c472dd6dcc19de
Vagacoder/Python_for_everyone
/Ch12/P12_1.py
751
4.1875
4
# -*- coding: utf-8 -*- ## P12.1 # selection sort for descending order from random import randint def selectionSortDes(values) : for i in range(len(values)) : maxPos = maximumPosition(values, i) temp = values[maxPos] # swap the two elements values[maxPos] = values[i] values[i] = temp ## Fi...
true
40828a4f4b94cff92a03e7c273ac262e8d894744
Vagacoder/Python_for_everyone
/P4EO_source/ch12/sec06/linearsearch.py
448
4.28125
4
## # This module implements a function for executing linear searches in a list. # ## Finds a value in a list, using the linear search algorithm. # @param values the list to search # @param target the value to find # @return the index at which the target occurs, or -1 if it does not occur in the list # def linearSe...
true
fce8841d3f60fd63bcf052baafc1ebc3705a264e
Vagacoder/Python_for_everyone
/P4EO_source/ch04/sec01/doubleinv.py
505
4.15625
4
## # This program computes the time required to double an investment. # # Create constant variables. RATE = 5.0 INITIAL_BALANCE = 10000.0 TARGET = 2 * INITIAL_BALANCE # Initialize variables used with the loop. balance = INITIAL_BALANCE year = 0 # Count the years required for the investment to double. while ba...
true
b23d88c162bcb6ff327a45f577e7e39ea17a1b59
anand14327sagar/Python_Learning
/Tuples.py
230
4.125
4
mytuple = (10,10,20,30,40,50) #to count the number of elements print(mytuple.count(10)) #the output will be 2 #to find the index # mytuple.index(50) #the output will be 5. since the index number at 50 is 5.
true
9e1af1f511a41856d2c0e75384f63f8d1d1ae4e0
reddyprasade/Turtle_Graphics_In_Python3
/Circles.py
863
4.25
4
# Python program to user input pattern # using Turtle Programming import turtle #Outside_In import turtle import time import random print ("This program draws shapes based on the number you enter in a uniform pattern.") num_str = input("Enter the side number of the shape you want to draw: ") if num_st...
true
8a6f6d7cb6db08dd01f59a56144cc532804f6928
ncommella/automate-boring
/exercises/hello.py
319
4.1875
4
print('Hi, what\'s your name?') userName = input() #displays length of userName print('What\'s up, ' + userName + '? The length of your name is ' + str(len(userName))) #asks for age print('What is your age?') userAge = input() print('In one year, you will be ' + str(int(userAge)+ 1) + ' years old.')
true
a51b1ddb7223ca8b07590ba82e2b2842f7c51d18
DustyHatz/CS50projects
/python/caesar.py
1,392
4.40625
4
# This program will creat a "Caesar Cipher" # User must enter a key (positive integer) and a message to encrypt from cs50 import get_string from sys import argv, exit # Check for exacctly one command line argument and make sure it is a positive integer. If not, exit. if len(argv) == 2 and argv[1].isdigit(): # Co...
true
9225eeccba5923ace5e1b5189926fe1342fa5dbd
godwinreigh/web-dev-things
/programming projects/python projects/tkinter practice/4. Creating Input Fields.py
588
4.34375
4
from tkinter import * root=Tk() #creating entry widget for input fields #we can change the size of it using the width= and function #we can also change the color using bg and fg #we can also change the border width using borderwidth= function e = Entry(root, width=50, bg='Blue', fg='White', borderwidth = 5) e.pack() #...
true
891ec9eb9e870d6a0e6b5ce3b09f2e07a32fb035
godwinreigh/web-dev-things
/programming projects/python projects/tkinter practice/2. Positioning with tkinter's grud system.py
340
4.25
4
#grid system is like a grid think of your program as a grid from tkinter import * root = Tk() #creating a label myLabel1 = Label(root, text='Hello World') myLabel2 = Label(root, text='My name is John Elder') #shoving it onto the screen #this were using grid system myLabel1.grid(row=0, column= 0) myLabel2.grid(row=1, co...
true
e96eab67caa80b14babe7375ddf669d06bbd0465
godwinreigh/web-dev-things
/programming projects/python projects/tutorials(fundamentals)/14.Buildingbettercalculator.py
475
4.40625
4
numA = float(input("Please enter a number ")) operator = input("Please print an operator ") numB = float(input("Please enter the another number ")) if operator == "+": print(numA + numB) elif operator == "-": print(numA + numB) elif operator == "*": print(numA * numB) elif operator == "/": print(numA /...
true
b03ef6a6f955644c5f3ff28075c0b33c0be05b9e
godwinreigh/web-dev-things
/programming projects/python projects/tutorials2/15. Dictionnaries.py
1,506
4.21875
4
#they are really good for: #super organized data (mini databases) #fast as hell (constant time) #sorted dictionary from collections import OrderedDict groceries = {'bananas': 5, 'oranges': 3 } print(groceries['bananas']) #to avoid syntax error that is because the element is not in th...
true
17fb36ba7be775e159d675b035f7c8ac920785af
JBustos22/Physics-and-Mathematical-Programs
/root-finding/roots.py
1,529
4.4375
4
#! /usr/bin/env python """ This program uses Newton's method to calculate the roots of a polynomial which has been entered by the user. It asks for a polynomial function, its derivative, and the plotting range. It then plots it, and asks the user for a value. Once a value is entered, the root closest to that value is e...
true
3f7efff67d6ccd7cc349131237d356e34908635d
JBustos22/Physics-and-Mathematical-Programs
/plots and data/fractal.py
753
4.28125
4
#! /usr/bin/env python """ This program plots a fractal pattern using matplotlib Jorge Bustos Feb 12, 2019 """ from __future__ import division,print_function import matplotlib.pyplot as plt import numpy as np import math as m plt.scatter(-1,0,c="b",s=.1) plt.scatter(0,m.sqrt(3),c="b",s=.1) plt.scatter(1,0,c="b",s=10)...
false
43def0189ddebca9e6d900604d692c9a9d2e1a36
JBustos22/Physics-and-Mathematical-Programs
/computational integrals/hyperspheres.py
779
4.21875
4
#! /usr/bin/env python """ This program uses the numerical monte carlo integration function from the numint module. It calculates the volume of an unit sphere for dimensions 0, through 12, and creates a plot of hypervolume vs dimension. Jorge Bustos Mar 4, 2019 """ from __future__ import division, print_function impo...
true
6f42fe89b6be6ebf1d26bced38b9b523400b1903
ASamiAhmed/PythonPrograms
/sets.py
965
4.15625
4
variables = {'a','b','c','d','c'} print(variables) # remove the repeated variables variables.add('z') print(variables) # to add a new letter b = frozenset('asdsafadgwas') print(b) # frozenset conversion print({1,2,3,4} & {3,4,5,6}) # & is sign of intersection print({1,2,3} | {2,3,4}) # | is sign of uni...
false
ae9b70d3d0a73ca6f696a681d3e82c4969b99716
ASamiAhmed/PythonPrograms
/feet_inch_cm.py
278
4.28125
4
''' Write a Python program to convert height (in feet and inches) to centimetres. ''' number = int(input("Enter number: ")) feet = number*30.48 print("The number you entered in centimeter is",feet) inch = number*2.54 print("The number you entered in centimeter is",inch)
true
e9a31c7404309047d598f507aed85fbf0630ac40
tgandrews/Project-Euler
/Problem 6/Difference between sum of square and square of sum.py
654
4.21875
4
# Difference between sum of square and square of sum # (1^2 + 2^2) - (1 + 2)^2 import time; def Sum(maxVal): resultSquares = 0; resultSum = 0; i = 0; while i <= maxVal: resultSquares += (i * i); resultSum += i; i = i + 1; print 'Sum: ' + str(resultSum); print 'Sum of...
true
6ac88a30fc498f0ae5505bf7813c82f52d631676
yiming1012/MyLeetCode
/LeetCode/贪心算法/455. 分发饼干.py
1,723
4.15625
4
""" 455. 分发饼干 假设你是一位很棒的家长,想要给你的孩子们一些小饼干。但是,每个孩子最多只能给一块饼干。 对每个孩子 i,都有一个胃口值 g[i],这是能让孩子们满足胃口的饼干的最小尺寸;并且每块饼干 j,都有一个尺寸 s[j] 。如果 s[j] >= g[i],我们可以将这个饼干 j 分配给孩子 i ,这个孩子会得到满足。你的目标是尽可能满足越多数量的孩子,并输出这个最大数值。   示例 1: 输入: g = [1,2,3], s = [1,1] 输出: 1 解释: 你有三个孩子和两块小饼干,3个孩子的胃口值分别是:1,2,3。 虽然你有两块小饼干,由于他们的尺寸都是1,你只能让胃口值是1的孩子满足。 所以你应该输...
false
34c52fae8d33c2f0390b13e2d1adaa3089805f5c
yiming1012/MyLeetCode
/LeetCode/树(Binary Tree)/199. Binary Tree Right Side View.py
2,027
4.21875
4
''' Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. Example: Input: [1,2,3,null,5,null,4] Output: [1, 3, 4] Explanation: 1 <--- / \ 2 3 <--- \ \ 5 4 <--- 通过次数26,604提交次数41,423 ...
true
c9f5377545185d4cdca2bcfb228ddc43cd6b65b4
yiming1012/MyLeetCode
/LeetCode/哈希表(hash table)/1338. 数组大小减半.py
1,712
4.25
4
""" 1338. 数组大小减半 给你一个整数数组 arr。你可以从中选出一个整数集合,并删除这些整数在数组中的每次出现。 返回 至少 能删除数组中的一半整数的整数集合的最小大小。   示例 1: 输入:arr = [3,3,3,3,5,5,5,2,2,7] 输出:2 解释:选择 {3,7} 使得结果数组为 [5,5,5,2,2]、长度为 5(原数组长度的一半)。 大小为 2 的可行集合有 {3,5},{3,2},{5,2}。 选择 {2,7} 是不可行的,它的结果数组为 [3,3,3,3,5,5,5],新数组长度大于原数组的二分之一。 示例 2: 输入:arr = [7,7,7,7,7,7] 输出:1 解释:我们只能选择...
false
fedbe2bccf489f778cba98d6ebc58fa8915e9ab3
yiming1012/MyLeetCode
/LeetCode/贪心算法/452. 用最少数量的箭引爆气球.py
2,714
4.125
4
""" 在二维空间中有许多球形的气球。对于每个气球,提供的输入是水平方向上,气球直径的开始和结束坐标。由于它是水平的,所以y坐标并不重要,因此只要知道开始和结束的x坐标就足够了。开始坐标总是小于结束坐标。平面内最多存在104个气球。 一支弓箭可以沿着x轴从不同点完全垂直地射出。在坐标x处射出一支箭,若有一个气球的直径的开始和结束坐标为 xstart,xend, 且满足  xstart ≤ x ≤ xend,则该气球会被引爆。可以射出的弓箭的数量没有限制。 弓箭一旦被射出之后,可以无限地前进。我们想找到使得所有气球全部被引爆,所需的弓箭的最小数量。 Example: 输入: [[10,16], [2,8], [1,6], [7,...
false
7b53844e39454329c18574049ece774d5acc34f8
yiming1012/MyLeetCode
/LeetCode/设计/341. 扁平化嵌套列表迭代器.py
2,015
4.5
4
""" 341. 扁平化嵌套列表迭代器 给你一个嵌套的整型列表。请你设计一个迭代器,使其能够遍历这个整型列表中的所有整数。 列表中的每一项或者为一个整数,或者是另一个列表。其中列表的元素也可能是整数或是其他列表。   示例 1: 输入: [[1,1],2,[1,1]] 输出: [1,1,2,1,1] 解释: 通过重复调用 next 直到 hasNext 返回 false,next 返回的元素的顺序应该是: [1,1,2,1,1]。 示例 2: 输入: [1,[4,[6]]] 输出: [1,4,6] 解释: 通过重复调用 next 直到 hasNext 返回 false,next 返回的元素的顺序应该是: [1,4,6]。 ...
false
1c42c564af105d39f03b5d3a96775179d4a39582
yiming1012/MyLeetCode
/LeetCode/栈/单调栈(Monotone Stack)/496. 下一个更大元素 I.py
2,435
4.1875
4
""" 给定两个 没有重复元素 的数组 nums1 和 nums2 ,其中nums1 是 nums2 的子集。找到 nums1 中每个元素在 nums2 中的下一个比其大的值。 nums1 中数字 x 的下一个更大元素是指 x 在 nums2 中对应位置的右边的第一个比 x 大的元素。如果不存在,对应位置输出 -1 。   示例 1: 输入: nums1 = [4,1,2], nums2 = [1,3,4,2]. 输出: [-1,3,-1] 解释: 对于num1中的数字4,你无法在第二个数组中找到下一个更大的数字,因此输出 -1。 对于num1中的数字1,第二个数组中数字1右边的下一个较大数字是 3。 ...
false
47f28239360c82afb9e16dac6fec9557b2217310
yiming1012/MyLeetCode
/LeetCode/数学/1185. 一周中的第几天.py
1,328
4.1875
4
""" 1185. 一周中的第几天 给你一个日期,请你设计一个算法来判断它是对应一周中的哪一天。 输入为三个整数:day、month 和 year,分别表示日、月、年。 您返回的结果必须是这几个值中的一个 {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}。 示例 1: 输入:day = 31, month = 8, year = 2019 输出:"Saturday" 示例 2: 输入:day = 18, month = 7, year = 1999 输出:"Sunday" 示例 3: 输入:day = 15, ...
false
6da0cb332487b42897331ba993693676ef3937f0
yiming1012/MyLeetCode
/LeetCode/树(Binary Tree)/114. 二叉树展开为链表.py
1,503
4.15625
4
""" 给定一个二叉树,原地将它展开为一个单链表。   例如,给定二叉树 1 / \ 2 5 / \ \ 3 4 6 将其展开为: 1 \ 2 \ 3 \ 4 \ 5 \ 6 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/flatten-binary-tree-to-linked-list 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 """ # Definition for a binary ...
false
ca4e9d27433326261734046a3976e098e1704cba
yiming1012/MyLeetCode
/LeetCode/数学/面试题 16.11. 跳水板.py
1,571
4.1875
4
""" 你正在使用一堆木板建造跳水板。有两种类型的木板,其中长度较短的木板长度为shorter,长度较长的木板长度为longer。你必须正好使用k块木板。编写一个方法,生成跳水板所有可能的长度。 返回的长度需要从小到大排列。 示例: 输入: shorter = 1 longer = 2 k = 3 输出: {3,4,5,6} 提示: 0 < shorter <= longer 0 <= k <= 100000 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/diving-board-lcci 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 """...
false
cb3e2ddcbf9b58bd603b6ce23151e7df6b41cee0
yiming1012/MyLeetCode
/LeetCode/1184. Distance Between Bus Stops.py
2,425
4.34375
4
''' A bus has n stops numbered from 0 to n - 1 that form a circle. We know the distance between all pairs of neighboring stops where distance[i] is the distance between the stops number i and (i + 1) % n. The bus goes along both directions i.e. clockwise and counterclockwise. Return the shortest distance between the ...
true
67f7d37b82e337c1c94ffc26c02464236cf14e21
yiming1012/MyLeetCode
/LeetCode/回溯法/5635. 构建字典序最大的可行序列.py
2,763
4.125
4
""" 5635. 构建字典序最大的可行序列 给你一个整数 n ,请你找到满足下面条件的一个序列: 整数 1 在序列中只出现一次。 2 到 n 之间每个整数都恰好出现两次。 对于每个 2 到 n 之间的整数 i ,两个 i 之间出现的距离恰好为 i 。 序列里面两个数 a[i] 和 a[j] 之间的 距离 ,我们定义为它们下标绝对值之差 |j - i| 。 请你返回满足上述条件中 字典序最大 的序列。题目保证在给定限制条件下,一定存在解。 一个序列 a 被认为比序列 b (两者长度相同)字典序更大的条件是: a 和 b 中第一个不一样的数字处,a 序列的数字比 b 序列的数字大。比方说,[0,1,9,0] 比 [0,1,5,6...
false
92dc91b390fde40f52df760b6f242e120cd7ae1b
yiming1012/MyLeetCode
/LeetCode/位运算/461. 汉明距离.py
1,058
4.4375
4
""" 两个整数之间的汉明距离指的是这两个数字对应二进制位不同的位置的数目。 给出两个整数 x 和 y,计算它们之间的汉明距离。 注意: 0 ≤ x, y < 231. 示例: 输入: x = 1, y = 4 输出: 2 解释: 1 (0 0 0 1) 4 (0 1 0 0) ↑ ↑ 上面的箭头指出了对应二进制位不同的位置。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/hamming-distance 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 """ class Solution: def ...
false
bfbf594cc9c4e32065223bb06fee7b6f529cd945
yiming1012/MyLeetCode
/LeetCode/树(Binary Tree)/1367. 二叉树中的列表.py
2,164
4.125
4
""" 1367. 二叉树中的列表 给你一棵以 root 为根的二叉树和一个 head 为第一个节点的链表。 如果在二叉树中,存在一条一直向下的路径,且每个点的数值恰好一一对应以 head 为首的链表中每个节点的值,那么请你返回 True ,否则返回 False 。 一直向下的路径的意思是:从树中某个节点开始,一直连续向下的路径。 示例 1: 输入:head = [4,2,8], root = [1,4,4,null,2,2,null,1,null,6,8,null,null,null,null,1,3] 输出:true 解释:树中蓝色的节点构成了与链表对应的子路径。 示例 2: 输入:head = [1,4,...
false
47d8e7ca10710cc2e5f3124c9ce0397ee87dd9fd
yiming1012/MyLeetCode
/LeetCode/840. Magic Squares In Grid.py
1,990
4.28125
4
''' A 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 to 9 such that each row, column, and both diagonals all have the same sum. Given an grid of integers, how many 3 x 3 "magic square" subgrids are there?  (Each subgrid is contiguous).   Example 1: Input: [[4,3,8,4], [9,5,1,9], ...
true
b9446b52ab01cd26faaa1b6a36ec555800178aef
yiming1012/MyLeetCode
/LeetCode/树(Binary Tree)/889. 根据前序和后序遍历构造二叉树.py
1,727
4.125
4
""" 889. 根据前序和后序遍历构造二叉树 返回与给定的前序和后序遍历匹配的任何二叉树。  pre 和 post 遍历中的值是不同的正整数。   示例: 输入:pre = [1,2,4,5,3,6,7], post = [4,5,2,6,7,3,1] 输出:[1,2,3,4,5,6,7]   提示: 1 <= pre.length == post.length <= 30 pre[] 和 post[] 都是 1, 2, ..., pre.length 的排列 每个输入保证至少有一个答案。如果有多个答案,可以返回其中一个。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/prob...
false
3b89c920a23fe0a68e3743068091a6969eeb910c
yiming1012/MyLeetCode
/LeetCode/会员题/243. 最短单词距离.py
1,403
4.125
4
""" 243. 最短单词距离 给定一个单词列表和两个单词 word1 和 word2,返回列表中这两个单词之间的最短距离。 示例: 假设 words = ["practice", "makes", "perfect", "coding", "makes"] 输入: word1 = “coding”, word2 = “practice” 输出: 3 输入: word1 = "makes", word2 = "coding" 输出: 1 注意: 你可以假设 word1 不等于 word2, 并且 word1 和 word2 都在列表里。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/pr...
false
9e6dcce6dedd93812e378a54f53748beb5487972
yiming1012/MyLeetCode
/LeetCode/数组/1267. 统计参与通信的服务器.py
1,962
4.125
4
""" 1267. 统计参与通信的服务器 这里有一幅服务器分布图,服务器的位置标识在 m * n 的整数矩阵网格 grid 中,1 表示单元格上有服务器,0 表示没有。 如果两台服务器位于同一行或者同一列,我们就认为它们之间可以进行通信。 请你统计并返回能够与至少一台其他服务器进行通信的服务器的数量。   示例 1: 输入:grid = [[1,0],[0,1]] 输出:0 解释:没有一台服务器能与其他服务器进行通信。 示例 2: 输入:grid = [[1,0],[1,1]] 输出:3 解释:所有这些服务器都至少可以与一台别的服务器进行通信。 示例 3: 输入:grid = [[1,1,0,0],[0,0...
false
c2bc4d78568aadf371ab4830a2e9e08080135591
yiming1012/MyLeetCode
/LeetCode/并查集/547. 朋友圈.py
2,204
4.21875
4
""" 班上有 N 名学生。其中有些人是朋友,有些则不是。他们的友谊具有是传递性。如果已知 A 是 B 的朋友,B 是 C 的朋友,那么我们可以认为 A 也是 C 的朋友。所谓的朋友圈,是指所有朋友的集合。 给定一个 N * N 的矩阵 M,表示班级中学生之间的朋友关系。如果M[i][j] = 1,表示已知第 i 个和 j 个学生互为朋友关系,否则为不知道。你必须输出所有学生中的已知的朋友圈总数。 示例 1: 输入: [[1,1,0], [1,1,0], [0,0,1]] 输出: 2 说明:已知学生0和学生1互为朋友,他们在一个朋友圈。 第2个学生自己在一个朋友圈。所以返回2。 示例 2: 输入: [[1,1,0], ...
false
3d9a4fa16551d9863e59c4f1b1e980c4b2943ae9
yiming1012/MyLeetCode
/LeetCode/树(Binary Tree)/653. 两数之和 IV - 输入 BST.py
1,757
4.15625
4
""" 给定一个二叉搜索树和一个目标结果,如果 BST 中存在两个元素且它们的和等于给定的目标结果,则返回 true。 案例 1: 输入: 5 / \ 3 6 / \ \ 2 4 7 Target = 9 输出: True   案例 2: 输入: 5 / \ 3 6 / \ \ 2 4 7 Target = 28 输出: False 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/two-sum-iv-input-is-a-bst 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请...
false
313d594302ee78ed6154d46cc8fa80c25493c2c6
Kristianmartinw/8-30-reference
/number.py
695
4.25
4
# Integers, no decimal print(3) print(int()) print(int(3)) print(int(3.0)) # Type casted (conversion from one type to another) # Floating Point Number, has decimal print(4.0) print(float()) print(float(4.0)) print(float(4)) # Type casted (conversion from one type to another) # Type casting to string print(str(7.0) ...
true
27fcf9b9c7d1fc17e56c38c757362da24ffef957
shermanbell/CTI110
/M6HW2_Bell.py
2,373
4.21875
4
#Sherman_Bell #CTI_110 #M6HW2_Random Number Guessing Game #9_Nov_2017 # Write a program that does the following # Gernerate a random number in the range of 1 through 100. ( We'll call this "secret number") # Ask the user to guess what the secret number is # If the user's guess the higher thatn the secret numbe...
true
76fb1e4b9fdeccb59405863d1f8f3d7cc1cf0193
akudalek/short
/4/4.py
2,164
4.28125
4
""" Я предположил, что если задание из модуля “Цикл while”, то в коде напрашивается использование этого оператора. Как мне видится, для того чтобы выводить данные о кол-ве месяцев в бесконечном цикле. Если это так, напомнить ученику об этом и попросить дополнить код. В целом код рабочий, но можно в качестве предислов...
false
05543281d6fad233f401393a66d0c1dcd63eddb6
afl0w/pythonNotes
/Activity-E.py
319
4.40625
4
#user input for the lengths of three sides of a triangle. print("Enter the lengths of the three triangle sides: ") x = int(input("x: ")) y = int(input("y: ")) z = int(input("z: ")) #if else statement if x == y == z: print("This is a Equilateral triangle") else: print("This is not a Equilateral triangle")
true
a9212b9cb5d30f782628cb570ef646c199ddbbe9
JunctionChao/python_trick
/ContextManger/3_属性私有化.py
964
4.5
4
""" python 通过下划线的命名规范来控制属性的访问 _单下划线开头:弱“内部使用”标识,如:from M import *,将不导入所有以下划线开头的对象,包括包、模块、成员 __双下划线开头双下划线结尾__:指那些包含在用户无法控制的命名空间中的“魔术”对象或属性,如类成员的__name__ 、__doc__、__init__、__import__、__file__、等。推荐永远不要将这样的命名方式应用于自己的变量或函数 __双下划线开头:模块内的成员,表示私有成员,外部无法直接调用 单下划线结尾_:只是为了避免与python关键字的命名冲突 """ class A: def __init__(self, x)...
false
a2262ddc8021d0e5b0669bac14cd3385627b49a6
nikhilchowdarykanneganti/python_by_example_-NICHOLA-LACEY-
/the basics/c6.py
329
4.34375
4
#Challenge6 '''Ask how many slices of pizza the user started with and ask how many slices they have eaten. Work out how many slices they have left and display the answer in a user- friendly format.''' print('you are left with',int(input('How many slices of pizza have you ordered\n'))-int(input('How many slices u ate\n'...
true
76b7e9ec61e55aa043ca62db1871d7adb6e8534b
SuyogKhanal5/PythonNotes
/reg_expressions_three.py
945
4.40625
4
import re print(re.search(r'cat|dog','The cat is here')) # Use the pipe operator to see if you have cat or dog print(re.findall(r'.at', 'The cat in the hat sat')) # . is the wild card operator, so use it if you dont know one of the letters print(re.findall(r'...at', 'The cat in the hat went splat')) print(re...
true
048daa5772e37fb3b19814ef57797a323707cdc6
Simran-kshatriya/Basic
/PythonBasics2.py
534
4.15625
4
if 5 > 3: print(" 5 is grater than 3") num = 0 if num > 0: print("This is a positive number") elif num == 0: print("Number is zero") else: print("This is a negative number") num1 = [1, 2, 3, 4, 5] sum = 0 for val in num1: sum +=val print("Total is ", sum) languages = ["Python", "Java","Ruby","PHP...
true
56fd69c6c693926b9161939ac1e8b69a2cf85cc2
JaeGyu/PythonEx_1
/20161221_1.py
1,048
4.25
4
#_*_ coding: UTF-8 _*_ import csv def read_data(): file = open('data.csv') reader = csv.reader(file) rows = [row[1:] for row in reader][1:] file.close() print(rows) return [float(row[0]) for row in rows],[float(row[1]) for row in rows] def read_data2(): with open("data.csv") as file: ...
false
614c48c004a052e42dcdd0f9d35fb7a49842f37d
sarahcenteno/chatServer
/server.py
2,768
4.125
4
#!/usr/bin/env python import socket host = '' port = 5713 # Creates TCP socket serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) serverSocket.bind((host, port)) # server connects to given host and port serverSocket.listen(2) # server listens for incoming TCP requests print("Server started") print("Wa...
true
573535f4084cee4bed4787ccabf7a2d4de6d75e7
linshiu/python
/data_structures_algorithms/problem_solving_data_structures_algorithms/chap02_analysis/anagram.py
1,883
4.25
4
# -*- coding: utf-8 -*- """ Problem Solving with Data Structures and Algorithms, Brad Miller Chapter 2 - Analysis Anagram IDE: Spyder, Python 3 A good example problem for showing algorithms with different orders of magnitude is the classic anagram detection problem for strings. One string is an anagram of another if...
true
414e0568c3840e44c3b1b2fd7728c613f1a26c1d
linshiu/python
/data_structures_algorithms/problem_solving_data_structures_algorithms/chap04_recursion/reverseList.py
776
4.125
4
# -*- coding: utf-8 -*- """ Problem Solving with Algorithms and Data Structures, Brad Miller Chapter 4: Recursion IDE: Spyder, Python 3 Reverse a list """ #%% Function ################################################################# def reverseList(ls): """ Reverse a list base: Args: ...
true
39d9a59d7e31ec327248ca7d8675066ffbacb494
linshiu/python
/data_structures_algorithms/problem_solving_data_structures_algorithms/chap05_searching_sorting/bubbleSort.py
2,739
4.15625
4
# -*- coding: utf-8 -*- """ Problem Solving with Algorithms and Data Structures, Brad Miller Chapter 5: Searching and Sorting IDE: Spyder, Python 3 Bubble Sort """ import timeit import matplotlib.pyplot as plt import numpy.random as nprnd import numpy as np #%% Function ################################################...
true
fced4355855688f19276d43d5b11bbaca98ade02
linshiu/python
/think_python/10_03_cum_sum.py
456
4.25
4
def cum_sum(t): ''' Write a function that takes a list of numbers and returns the cumulative sum; that is, a new list where the ith element is the sum of the first i + 1 elements from the original list. For example, the cumulative sum of [1, 2, 3] is [1, 3, 6].''' total = 0 cum_list = []...
true
243b8db5be415551b8664270bfa8e96e124a4c2f
Seariell/basics-of-python
/hw4/task_1.py
1,170
4.28125
4
# homework lesson: 4, task: 1 """ Реализовать скрипт, в котором должна быть предусмотрена функция расчета заработной платы сотрудника. В расчете необходимо использовать формулу: (выработка в часах*ставка в час) + премия. Для выполнения расчета для конкретных значений необходимо запускать скрипт с параметрами. """ from ...
false
0e108d3f3cd9b3038653d6465363728ffc73f2ae
PrasamsaNeelam/CSPP1
/cspp1-practice/m9/Odd Tuples Exercise/odd_tuples.py
439
4.28125
4
#Exercise : Odd Tuples ''' Author: Prasamsa Date: 8 august 2018 ''' def odd_tuples(a_tup): ''' aTup: a tuple returns: tuple, every other element of aTup. ''' return a_tup[::2] def main(): '''input a tuple''' data = input() data = data.split() a_tup = () l_len = len(data) ...
false
a90a75e5f3b0efcf58f5c990ed4fd55f21849599
PrasamsaNeelam/CSPP1
/cspp1-practice/cspp1-assignments/m6/p2/special_char.py
399
4.15625
4
''' Author: Prasamsa Date: 4 august 2018 ''' def main(): ''' Read string from the input, store it in variable str_input. ''' str_input = input() char_input = '' for char_input in str_input: if char_input in('!', '@', '#', '$', '%', '^', '&', '*'): str_input = str_input.replac...
true
0c7c2f31713898a2ec1381e38c662fcb3ad74b34
davidgoldcode/cs-guided-project-problem-solving
/src/demonstration_09.py
1,071
4.25
4
""" Challenge #9: Given a string, write a function that returns the "middle" character of the word. If the word has an odd length, return the single middle character. If the word has an even length, return the middle two characters. Examples: - get_middle("test") -> "es" - get_middle("testing") -> "t" - get_middle("...
true
693558f4371fc3aa9d3deff7e0aa8aaefe389b24
natkam/adventofcode
/2017/aoc_05_jumps_1.py
2,014
4.46875
4
""" The message includes a list of the offsets for each jump. Jumps are relative: -1 moves to the previous instruction, and 2 skips the next one. Start at the first instruction in the list. The goal is to follow the jumps until one leads outside the list. In addition, these instructions are a little strange; after eac...
true
b9eb9cc86ccd65bba04bfce054c8238362992270
natkam/adventofcode
/2017/aoc_02_checksum1.py
1,908
4.3125
4
""" The spreadsheet consists of rows of apparently-random numbers. To make sure the recovery process is on the right track, they need you to calculate the spreadsheet's checksum. For each row, determine the difference between the largest value and the smallest value; the checksum is the sum of all of these differences....
true
ff451d9981296e73a3c71ed09a8605cb4b6dd9ed
fox-flex/lb7_2sem_op
/example/point_1.py
1,494
4.34375
4
from math import pi, sin, cos, radians class Point: 'Represents a point in two-dimensional geometric coordinates' def __init__(self, x=0, y=0): '''Initialize the position of a new point. The x and y coordinates can be specified. If they are not, the point defaults to the origin.''' ...
true
022aa7c9028a366b991567693d5be0c0ae2ed08d
DarinZhang/lpthw
/ex31/ex31.py
1,346
4.15625
4
# -*- coding: utf-8 -*- def break_words(sentence): words = sentence.split(' ') return words #sentence = "You are beautiful!" #print break_words(sentence) #print type(break_words(sentence)) print "You enter a dark room with two doors. Do you go through door #1 or door #2?" door = raw_input("> ") if door == "1": ...
true
acb041f6f6ef7016b60015882784cbb91bf4f5bf
sruthy-github/sruthy-python-files
/flow control/maximum 3 numbers.py
235
4.25
4
num1=int(input("Enter number1")) num2=int(input("Enter number2")) num3=int(input("Enter number3")) if(num1<num2,num3): print(num1,"is highest") elif(num2<num1,num3): print(num2,"is highest") else: print(num3,"is highest")
false
a458570e869d9d8d3205053ea2587d07089afaca
jddelia/think-python
/Section15/rect_in_circle.py
671
4.5
4
# This program creates a circle with OOP. from math import sqrt class Point: def __init__(self, x, y): self.x = x self.y = y class Circle: def __init__(self, center, radius): self.center = center self.radius = radius class Rectangle: def __init__(self, corner, height,...
true
fe9b543b362b50a9491d74451d7fae5b27939e92
seunjeong/pykds
/pykids/class_2.py
2,518
4.3125
4
################################################################################ # More on String ################################################################################ my_name = 'Seongeun' my_age = 46 # Two different ways of print things print ('My name is: ' + my_name) print ('My name is {}'.format (my_na...
true
cc1a90064133b00c617934fb421fa56f010b4b45
longroad41377/variables
/divmod.py
441
4.125
4
try: number1 = int(input("Enter number 1: ")) number2 = int(input("Enter number 2: ")) div = number1 // number2 mod = number1 % number2 print("The integer result of the division is {}".format(div)) print("The remainder of the division is {}".format(mod)) except ValueError: ...
true
3b4d595cb330cf983825957c1ac535cef82c7668
HakiimJ/python-bootcamp
/pre-session/basic_calculations.py
767
4.21875
4
pi = 3.14 # global constant #advanced way to set globals is given here: https://www.programiz.com/python-programming/variables-constants-literals def area_circle(radius): area = pi * radius * radius return area def volume_sphere(radius): return 0 def volume_cylinder(radius, height): area = area_circle (rad...
true
596c2e7245265d4977774f9e6b6c11c0b3736612
VLevski/Programming0-1
/week3/4-Problems-Construction/int_functions.py
1,310
4.1875
4
def reverse_int(n): reverse_numbers = [] reverse_number = 0 while n != 0: reverse_numbers += [n % 10] n //= 10 for number in reverse_numbers: reverse_number = reverse_number * 10 + number return reverse_number def sum_digits(n): numbers = [] sum_numbers = ...
false
023519deca4c47c8d426dc5cad7ebf464cc4a4de
VLevski/Programming0-1
/week1/3-And-Or-Not-In-Problems/simple_answers.py
1,215
4.125
4
say = input("Say what you have to say: ") answer = "@" if "hello" in say: answer = answer + "H" if "how are you?" in say: answer = answer + "h" if "feelings" in say: answer = answer + "F" if "age" in say: answer = answer + "A" H = "Hello there, good stranger! " h = "I am fine, thanks for asking! How are you? " F ...
false
93c6d65644d19659bb0b118235ab632eeb8d1d2b
salehsami/100-Days-of-Python
/Day 3 - Control Flow and Logical Operators/Roller_Coaster_Ticket.py
717
4.15625
4
# Roller coaster Ticket print("WWelcome to the RollerCoaster") height = int(input("Enter your height in cm: ")) bill = 0 if height >= 120: print("You can ride the Roller Coaster") age = int(input("What is your age: ")) if age < 12: print("Your Ticket will be $5") bill += 5 eli...
true
cd83e291a5f957ea7f201ae33d6f269f14644135
salehsami/100-Days-of-Python
/Day 10 - Beginner - Functions with Outputs/output_functions.py
254
4.21875
4
first_name = input("Enter your first name: ") last_name = input("Enter your last name: ") def format_name(f_name, l_name): first = f_name.title() last = l_name.title() return f"{first} {last}" print(format_name(first_name, last_name))
true
47759d97ecce73c812888b02765a374685273cb8
GauravPadawe/1-Player-Rock-Paper-Scissors
/Game.py
2,642
4.28125
4
import sys # Importing required packages import random import time def game(user, choice): # Defining a function which will accept 2 inputs from user as (user, choice) choice = str(input(user + ", What's your choice?: ")) ...
true
d449b9cc2aeedf6e3c4c05402012ac58bf68ef5a
sduffy826/FinchBot
/testMath.py
1,012
4.15625
4
import math def conversionTest(): degrees = input("Enter degrees: ") print("{degrees:d} converted to radians is {radians:.2f}".format(degrees=degrees,radians=math.radians(degrees))) radians = input("Enter radians: ") print("{radians:.2f} converted to degrees is: {degrees:.2f}".format(radians=radians,degrees=m...
true
f1d629382312813dde2c6855af4f63bf21c4dcb7
YesimOguz/calculate-bill-python
/calculateBill.py
687
4.15625
4
# this is a program to calculate the total amount to be paid by customer in a restourant # get the price of the meal # ask the user to chose the type of tip to give(18%,20%,25%) # base on the tip calculate the total bill meal_cost = int(input('please enter the price of the meal: ' )) percentage_of_tip = input("""what ...
true
34cb6e42eaf5504075f29b9e93eb09bdb89e9800
deShodhan/Algos
/w2pa5.py
868
4.3125
4
# Accept a string as input. Select a substring made up of three consecutive characters in the input string such that there are an equal number of characters to # the left and right of this substring. If the input string is of even length, make the string of odd length as below: • If the last character is a period ( . ...
true
d21eca2dcc25ea7d6fb521c53d3358ebef57e9c4
carlosgomes1/python-tests
/world-1/17-cateto-and-hypotenuse.py
391
4.46875
4
# Make a program that reads the length of the opposite cateto and the adjacent catheter of a # right triangle. Calculate and show the length of the hypotenuse. from math import hypot opposite = float(input('Length of opposite cateto: ')) adjacent = float(input('Length of adjacent cateto: ')) hypotenuse = hypot(oppos...
true
13e6bf1cafdc689897f61716751c132d5625cbe0
carlosgomes1/python-tests
/world-1/05-predecessor-and-successor.py
256
4.4375
4
# Make a program that receives an integer and shows on the screen its predecessor and successor. number = int(input('Enter an integer: ')) print( f'The number entered was {number}. The predecessor is {number - 1} and the successor is {number + 1}.')
true
9e71556d9191490662374993741a4b111715c9c9
carlosgomes1/python-tests
/world-1/19-sorting-item.py
494
4.1875
4
# A teacher wants to draw one of his four students to erase the board. # Make a program that helps him by reading the students' names and writing on the screen # the name of the chosen one. from random import choice student1 = input('First student: ') student2 = input('Second student: ') student3 = input('Third stud...
true
1634bb33fbde3d6e7186019a6a09ed7c8b3afcc5
monchhichizzq/Leetcode
/Reverse_Integer.py
1,516
4.25
4
''' Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−2^31, 2^31 − 1] ([−214783...
true
781b64fb1675bdb0a9455b12881ebd0e7445a33e
sgouda0412/regex_101
/example/012_matching_one_or_more_repetitions.py
373
4.21875
4
""" Task You have a test string S. Your task is to write a regex that will match S using the following conditions: S should begin with 1 or more digits. After that, S should have 1 or more uppercase letters. S should end with 1 or more lowercase letters. """ import re Regex_Pattern = r'^[\d]+[A-Z]+[a-z]+$' print(s...
true
6770521cbf59e985dc41341e5d05bd9760a66f82
sgouda0412/regex_101
/example/011_matching_zero_or_more_repetitions.py
375
4.1875
4
""" Task You have a test string S. Your task is to write a regex that will match S using the following conditions: S should begin with 2 or more digits. After that, S should have 0 or more lowercase letters. S should end with 0 or more uppercase letters """ import re Regex_Pattern = r'^[\d]{2,}[a-z]*[A-Z]*$' print...
true
e15dc6d20c691a643fb184992e45bb6d3f55aac1
dustyujanin/Python_course
/lesson6/lesson6_4.py
1,166
4.125
4
class car: def __init__(self, speed, color, name, is_police): self.name = name self.speed = speed self.color = color self.is_police = is_police print(f"New {self.color} {self.name} is born!") def go(self): print(f"{self.color} car {self.name} is going") def...
false
0f79fabfc085fe7aae85f66fb216ff8d8591c90a
nikhilrane1992/Python_Basic_Exercise
/angle_betn_clock_hands.py
844
4.3125
4
# Find the anfle between the two clock hands # First find the hour degree and minute degree for hour angle from 12 hour_degree = (360 / 12.0) hr_minutes_degree = (360 / 12 / 60.0) # hour degree = 30 and hr minutes degree 0.5. # Find minute angle from 12 minutes_degree = 360 / 60.0 # minute degree is 6 # Now find the...
true
5749e068940ab140b24525d99e32e927ff7476a0
nikhilrane1992/Python_Basic_Exercise
/conversion.py
585
4.59375
5
# Convert kilometers to mile # To take kilometers from the user km = input("Enter value in kilometers: ") # conversion factor for km to mile conv_fac = 0.621371 # calculate miles miles = km * conv_fac print '{:.3f} kilometers is equal to {:.3f} miles'.format(km, miles) # Python Program to convert temperature in cel...
true
f656676ddc417498eca99aa1b687bac6391fa630
shubhamyedage/pycharm-codebase
/Test/apps/test_date_time/test_date_2.py
611
4.25
4
""" This module converts string to given date format. Date-Time Formats http://strftime.org/ """ from datetime import datetime, date s1 = "2008-08" s2 = "2017-08" v1 = datetime.strptime(s1, "%Y-%m") # print(v1) # print(v1.year) v1_date = str(v1.date()) # print(datetime.strptime(v1_date, "%Y-%m-%d").date()) v2 = dat...
false
500fbe4ebe78bc2cd8cf8dc4b49639ba9bd746d3
Robzabel/AutomateTheBoringStuffScripts
/14.Data_Structures.py
1,324
4.46875
4
cats = { 'name': 'fenty', 'age': 6, 'colour': 'black'} # this creates a dictionary of information on the cat allCats = [] #this creates a blank dictionary that can hold all data about all cats in the variable called allCats allCats.append(cats) allCats.append({ 'name': 'Pooka', 'age': 3, 'colour': 'grey'})#Adding data ...
false
51010381f36511069c0e670f5d2a2a283ed40364
KOdunga/Python_Introduction
/PycharmProjects/untitled1/maxnumber.py
389
4.25
4
# Create a function that requests for three integers then get the maximum number def getnumbers(): list = [] x = 1 while x<4: num = input("Enter a number: ") list.append(num) x+=1 getmaxnum(list) def getmaxnum(list): print(max(list)) y=1 while y != 0: getnumbers() y...
true
b1b3198703fb3708a2fc277f0b9b4c99c68774b5
dave5801/data-structures
/sorting/sortings.py
2,316
4.21875
4
"""Class for sorting algorithms.""" ''' class Sortings(object): """A general class for sorting algorithms.""" def __init__(self, sort_list=None): """Take in empty list.""" if sort_list is None: self.sort_list = [] else: self.sort_list = sort_list def bub...
false
3fcfbb9610c0aa54f8d8290b35d587e731f111bc
kevinjdonohue/LearnPythonTheHardWay
/ex7.py
878
4.40625
4
"""Exercise 7.""" # prints out a string print("Mary had a little lamb.") # prints out a formatted string with a placeholder -- inside we call format # and pass in the value to be placed in the formatted string placeholder print("Its fleece was white as {}.".format('snow')) # prints out a string print("And everywhere...
true
a4f32612138904fc26b35cc88768253b840c10f6
cgsmendes/aulas
/exerc_M_ou_F.py
205
4.125
4
letra = str(input("Digite M ou F: ")) if letra is 'm' or letra is 'M': print(letra, "É Masculino") elif letra is 'f' or letra is 'F': print(letra, "É FEMININO") else: print("SEXO INVÁLIDO")
false
dbace8d9d68e4dcc983acac20ac2dfc3e2ae1fe0
kushalkarki1/pythonclass-march1
/firstclass.py
388
4.1875
4
# if <condition>: # code # if 7 > 10: # print("This is if statement") # else: # print("This is else statement") # num = int(input("Enter any number: ")) # if num > 0: # print("This is positive number.") # else: # print("This is negative number.") num = int(input("Enter any num: ")) rem = num % 2...
true