blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
4cc251643d5402e0efcf329d49cae419353e212a
AntnvSergey/EpamPython2019
/13-design-patterns/hw/4-chain_of_responsibility/chain_of_responsibility.py
2,995
4.34375
4
""" С помощью паттерна "Цепочка обязанностей" составьте список покупок для выпечки блинов. Необходимо осмотреть холодильник и поочередно проверить, есть ли у нас необходимые ингридиенты: 2 яйца 300 грамм муки 0.5 л молока 100 грамм сахара 10 мл подсолнечного масла 120 грамм сливочного масла В и...
false
18ef3a0b8d402ad9d8d8990d4e659716b1ef9e2f
deepakgit2/Python-Basic-and-Advance-Programs
/polynomial_multiplication_using_cauchy_prod.py
639
4.1875
4
# This function multiply two polynomials using cauchy product formula # Input : a polynomial can be represent by a list where elements # of list are the coefficients of polynomial # Output : This program return multiplication of two polynomails in list form # a = 1 + 2x can be wriiten as following a = [1, 2,...
true
27729bbd7bd225d94e31b088294d9eb1a4334f8d
Shressaajan/AssignmentsCA2020Soln
/FunctionsTask/T5Q11.py
425
4.1875
4
# 11. Write a program which can map() and filter() to make a list whose elements are square of even number in # [1,2,3,4,5,6,7,8,9,10] # Hints: Use map() to generate a list. # Use filter() to filter elements of a list # Use lambda to define anonymous functions sqr_list = list(range(1, 11)) even_...
true
d0fa5db62fd6550b002462d65aa9ccda064500eb
Shressaajan/AssignmentsCA2020Soln
/FunctionsTask/T5Q4.py
293
4.40625
4
# 4. Write a program that accepts a hyphen-separated sequence of words as input and prints the words in a # hyphen-separated sequence after sorting them alphabetically. def sorted_output(x): y = x.split('-') return print('-'.join(sorted(y))) sorted_output("a-z-s-x-d-c-f-v-g-b-h-n")
true
a5fb5007a15661cffee7e630118336a2ec14b11f
Shressaajan/AssignmentsCA2020Soln
/DataStructureTask/T4Q6.py
259
4.15625
4
# 6. Write a program in Python to iterate through the list of numbers in the range of 1,100 and print the number # which is divisible by 3 and a multiple of 2. x = [] for i in list(range(1100)): if i % 3 == 0 and i % 2 == 0: x.append(i) print(x)
true
aedcdfa645bf5411601773c9cd4606de4d88e3fd
Shressaajan/AssignmentsCA2020Soln
/FunctionsTask/T5Q8.py
273
4.28125
4
# 8. Define a function which can generate and print a tuple where the value are square of numbers between 1 and 20. def sqr_tuple(): x = list(range(1,21)) y = [] for i in x: i *= i y.append(i) z = tuple(y) return z print(sqrt_tuple())
true
b083122b51b9cf91469312cb9cd4adc4f559c985
Shressaajan/AssignmentsCA2020Soln
/DataStructureTask/T4Q8.py
238
4.40625
4
# 8. Write a program in Python to iterate through the string “hello my name is abcde” and print the string which # has even length of word. x = 'Hello my name is abcde' for i in x.split(' '): if len(i) % 2 == 0: print(i)
true
8d9109e2ab0b4f15c17b47fa202cc9420003d130
gxmls/Python_Leetcode
/28.py
1,188
4.125
4
''' 实现 strStr() 函数。 给你两个字符串 haystack 和 needle ,请你在 haystack 字符串中找出 needle 字符串出现的第一个位置(下标从 0 开始)。如果不存在,则返回  -1 。 说明: 当 needle 是空字符串时,我们应当返回什么值呢?这是一个在面试中很好的问题。 对于本题而言,当 needle 是空字符串时我们应当返回 0 。这与 C 语言的 strstr() 以及 Java 的 indexOf() 定义相符。 示例 1: 输入:haystack = "hello", needle = "ll" 输出:2 示例 2: 输入:haystack = "aaaaa",...
false
8d5f5109d6f35772e5b4f564d34c2a6a0262c983
sudarshan-suresh/python
/core/CalculateGrossPay.py
276
4.3125
4
#!/usr/bin/python # Problem Statement:- # user will input number of hours and rate the program has to calculate wage. input1 = input("Enter Number of hours: ") hours = int(input1) input2 = input("Enter the rate perhour: ") rate = float(input2) wage = rate * hours print(wage)
true
e8bd0e48bc136bb3fc5af6c340c0d76aa4e7c2ef
muhdibee/holberton-School-higher_level_programming
/0x0B-python-input_output/3-write_file.py
535
4.125
4
#!/usr/bin/python3 def write_file(filename="", text=""): """Write string to file Args: filename (str): string of path to file text (str): string to write to file Returns: number of characters written """ chars_written = 0 with open(filename, 'w', encoding='utf-8') as f...
true
abb48f87c3e2e1592bbd9a91ee142a05305bf162
muhdibee/holberton-School-higher_level_programming
/0x07-python-test_driven_development/tests/6-max_integer_test.py
1,210
4.25
4
#!/usr/bin/python3 """Unittest for max_integer([..]) """ import unittest #max_integer = __import__('6-max_integer').max_integer def max_integer(list=[]): """Function to find and return the max integer in a list of integers If the list is empty, the function returns None """ if len(list) == 0: ...
true
184d8c046ba1e9f415737544602e7f5369aa3c66
aldo2811/cz1003_project
/module/check.py
1,845
4.375
4
def user_input_index(min_index, max_index): """Asks user for input and checks if it matches a number in the specified range. Args: min_index (int): Minimum number of user input. max_index (int): Maximum number of user input. Returns: int: An integer that the user inputs if it satis...
true
a49d33bb74d81fb96198b1353be7a9c06a2eeb7a
RatnamDubey/DataStructures
/LeetCode/7. Reverse Integer.py
1,314
4.125
4
""" 7. Reverse Integer Easy Add to List Share Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -ç 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 in...
true
a301e55ed8c88d1cb3a54af1e6e45b581dd00dc5
jbailey430/The-Tech-Academy-Python-Projects
/POLYMORPHISM.py
1,028
4.1875
4
#Parent Class User class User: name = "Steve" email = "Steve@gmail.com" password = "12345678" def getLogin(self): entry_name =("Enter your name: ") entry_email = input("Enter your email: ") entry_password = input("Enter your password: ") if (entry_email == self.email and entry_password ==...
true
2431c4b7da841c2fbce9387e4b4a633eb1316eaa
42madrid/remote-challs
/chall04/vde-dios.py
1,971
4.28125
4
#!/usr/bin/env python3 import sys import re def error(e , i): file_name = "stdin" if i == 0 else sys.argv[i] if (e == 1): print("%s: %s: Bad format" %(sys.argv[0], file_name)) elif (e == 2): print("%s: %s: Can't read file" %(sys.argv[0], file_name)) elif (e == 3): print("%s: ...
true
dd869008cb29eb27f7e2840ce0cc014c326091e3
TheArchit/equiduct-test
/exercise2.py
582
4.34375
4
#!/usr/local/bin/python -S from sys import argv """ Write a function that takes a list of integers (as arguments) and returns a response with the average (mean), total/sum of integers, the maximum and minimum values. Print the average to two decimal places. To make this a little more straightforward assume that input...
true
3367d1e03ca47c3aeea059a3b760a8b4d39ab5b6
petervalberg/Python3-math-projects
/Binomialtest.py
2,061
4.375
4
""" Binomial Distribution Calculator. --------------------------------- n is the number of times the experiment is performed. p is the probability of success in decimal. k is the target number of successes. """ from math import factorial combinations = 0 def binomial_coefficient(n, k): globals()['co...
true
ba2a94081ff03d9e2718a9345ccfb6f2f7a703d7
novdulawan/python-function
/function_stdoutput.py
390
4.15625
4
#!/usr/bin/env python #Author: Novelyn G. Dulawan #Date: March 16, 2016 #Purpose: Python Script for displaying output in three ways def MyFunc(name, age): print "Hi! My name is ", name + "and my age is", age print "Hi! My name is %s and my age is %d" %(name, age) print "Hi! My name is {} ...
true
eb3c96a2dc281331533d6f20f75c6a7e8f4a6ad4
SaidRem/just_for_fun
/ints_come_in_all_sizes.py
361
4.125
4
# Integers in Python cab be as big as the bytes in a machine's # memory. There is no limits in size as there is: # 2^31 - 1 or 2^63 - 1 # Input # integers a, b, c, d are given on four separate lines. # Output # Print the result of a^b + c^d a = int(input()) b = int(input()) c = int(input()) d = int(input(...
true
b478fd8893a353ee3ec536d5083d6faf8fafc372
LGonzales930/My-Project
/FinalProjectPart2/FinalProjectinput.py
1,476
4.15625
4
# Lorenzo Gonzales # ID: 1934789 # Final Project part 2 # The Following program outputs information about an Electronics stores inventory import csv # The Dictionary ID is created to connect the other values together as a key, Everything else acts as a value # Everything is connected using ID = {} with open("Manufactu...
true
d6e0f39b05b2fc88e1d6b55943d81f4a9ac031b5
MarkisDev/python-fun
/Competitive Programming/fibonacci.py
733
4.28125
4
""" Fibonacci Series This script prints Fibonacci series for n value of numbers using variable swap to implement recursion. @author : MarkisDev @copyright : https://markis.dev @source : https://www.geeksforgeeks.org/program-for-nth-fibonacci-number/ """ number = int(input('Enter the maximum numbers to be dis...
true
92216f65be78b9d4951c2a2e8d9be9333da312a1
Grizz5678/Apprendre-Python
/Pythagore.py
1,529
4.15625
4
import turtle import time from math import * tortue1 = turtle.Turtle() tortue1.color("green") tortue1.shape("turtle") tortue1.pensize(6) for i in range(4): tortue1.showturtle() time.sleep(.5) tortue1.hideturtle() time.sleep(.5) tortue1.showturtle() a = input("Quelle est la longueur du pre...
false
ec2e930df7110bcb1ea94d80d6ace008e8e8447b
onlyrobot/DiscreteMathematicsProgram
/code/greatest_common_factor.py
391
4.15625
4
# greatest common factor a = int(input('input a non-negative number: ')) b = int(input('input another no-negative number: ')) if a < b: a, b = b, a if b == 0: print('the greatest common factor is ', a) if a == 0: print('no greatest common factor') else: r = a % b while r != 0: a, b =...
false
bd484643860671de6ee0259cf719d67c10fc4efd
sakurashima/my-python-exercises-100
/programming-exercises/34-打印字典从1到20.py
493
4.1875
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @文件 :34.py @说明 :Define a function which can print a dictionary where the keys are numbers between 1 and 20 (both included) and the values are square of keys. @时间 :2020/09/02 16:03:17 @作者 :martin-ghs @版本 :1.0 ''' def print_dict(): my_dict ...
true
136df51b61bfd054a757839411aae2c8db8c1b49
sakurashima/my-python-exercises-100
/programming-exercises/58-59-re在放送一遍成功过.py
800
4.4375
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @文件 :58.py @说明 :Assuming that we have some email addresses in the "username@companyname.com" format, please write program to print the user name of a given email address. Both user names and company names are composed of letters only. @时间 :2...
true
c5c9391a9220edf57014300e0c71292377f1cab7
sakurashima/my-python-exercises-100
/programming-exercises/21-坐标轴自己选取数据结构.py
1,311
4.53125
5
""" Question A robot moves in a plane starting from the original point (0,0). The robot can move toward UP, DOWN, LEFT and RIGHT with a given steps. The trace of robot movement is shown as the following: UP 5 DOWN 3 LEFT 3 RIGHT 2 ¡­ The numbers after the direction are steps. Please write a program to compute the di...
true
bf8e6248c0d6df71d96446e0e6fa2e0f1c699720
sakurashima/my-python-exercises-100
/programming-exercises/91.py
495
4.125
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @文件 :91.py @说明 :By using list comprehension, please write a program to print the list after removing the 0th, 4th,5th numbers in [12,24,35,70,88,120,155]. @时间 :2020/09/11 16:34:42 @作者 :martin-ghs @版本 :1.0 ''' def main(): li = [12, 24, 35,...
true
476ac61e9f8b8a4b5f20b2ddaaf9c36818e094af
sakurashima/my-python-exercises-100
/programming-exercises/02-求n!.py
524
4.15625
4
# Question: Write a program which can compute the factorial of a given numbers. # The results should be printed in a comma-separated sequence on a single line. # Suppose the following input is supplied to the program: 8 Then, the output should be: 40320 def main(): given_num = input("enter the num: ") sum = 1...
true
8c4b74f17278c12cb587509679b1c1f7fec6548a
sakurashima/my-python-exercises-100
/programming-exercises/40-还是列表索引.py
600
4.3125
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @文件 :40.py @说明 :Define a function which can generate a list where the values are square of numbers between 1 and 20 (both included). Then the function needs to print all values except the first 5 elements in the list. @时间 :2020/09/02 16:22:1...
true
68dd0bda0d33c5ac3ce00bf9c7d5eab867627220
deepabalan/python-practice-book
/2_working_with_data/38.py
269
4.34375
4
# Write a function invertdict to interchange keys and values in a # dictionary. For simplicity, assume that all values are unique. def invertdict(d): res = {} for i, v in d.items(): res[v] = i return res print invertdict({'x': 1, 'y': 2, 'z': 3})
true
1138dd8c34c4dbb343e3089ba6caf3a28c1c213b
deepabalan/python-practice-book
/2_working_with_data/6.py
396
4.5
4
# Write a function reverse to reverse a list. Can you do this without # using list slicing? # reverse([1, 2, 3, 4]) gives [4, 3, 2, 1] # reverse(reverse([1, 2, 3, 4])) gives [1, 2, 3, 4] def reverse_list(l): rev = [] i = len(l) - 1 while i >= 0: rev.append(l[i]) i -= 1 return rev prin...
true
2cb6675cf76f8de1f9d3545b206c4441b843203c
njuliacsouza/_udemy_Python
/secao_13/2_leitura_arquivos.py
1,106
4.28125
4
""" Leitura de Arquivos Para ler o conteúdo de um arquivo em Python, usamos a função integrada open(). open() -> Na forma mais simples de utilização, nós passamos apenas um parâmetro de entrada, que neste caso é o nome do arquivo a ser lido. Essa função retorna um _io_TextIOWrapper e é com ele que travalhamos então. ...
false
5709fd8aa94eeb63606d9d1e3d9ee21e7d606e3f
njuliacsouza/_udemy_Python
/secao_10/zip.py
1,103
4.34375
4
""" Zip zip() -> Cria um interavel (zp object) que agrega elemento de cada um dos iteraveis de entrada. # Exemplo lista1 = [1, 2, 3, 10] lista2 = [4, 5, 6] zip1 = zip(lista1, lista2) # cria tuplas com os elementos, o valor 10 será ignorado print(zip1) print(type(zip1)) print(list(zip1)) # pode ser set, tupla e d...
false
b216f080be17474d02d8e5ccf461cd24c7b31710
njuliacsouza/_udemy_Python
/secao_12/modulo_random.py
1,437
4.125
4
""" Módulo Random e o que são módulos? - Em Python, módulos nada mais são do que outros arquivos Python. Módulo Random -> Possui várias funções para geração de números pseudo-aleatório. # OBS: Existem duas formas de se utilizar um módulo ou função deste # Forma 1 - importando todo o módulo import random # Ao real...
false
6ef1c3547acf3b758f8854ad6d978afd92ec8e48
njuliacsouza/_udemy_Python
/secao_10/any_all.py
832
4.28125
4
""" Any e All All: retorna True se todos os elementos do iteravel são verdadeiros ou se o iteravel está vazio # Exemplo all() print(all([0, 1, 2, 3, 4])) # Todos são True? Não, o zero é falso print(all([1, 2, 3, 4])) # True print(all([])) # True OBS: não apenas listas, mas sets, tuplas também. nomes = ['Carla', ...
false
414430518b37f4ec2ad0e62ec7d63c3953bf6315
njuliacsouza/_udemy_Python
/secao_13/5_escrever_em_arquivos.py
1,382
4.71875
5
""" Escrevendo em arquivos Vamos utilizar outro modo de abertura da função open(), antes utilizamvamos o modo 'r', que era somente para leitura, não podendo realizar escrita nele. Agora, podemos utilizar o modo para escrita, não podendo lê-lo. # Modo de leitura with open('novo.txt', 'w', encoding='utf-8') as arquivo...
false
1d11cc72412b349f9fa4cba5db5f5b7ae209e3f1
njuliacsouza/_udemy_Python
/secao_19/2_manipulando_data_hora.py
1,322
4.34375
4
""" Manipulando Data e Hora Python tem um módulo buit-in (integrado) para se trabalhar com data e hora chamado datetime import datetime # print(dir(datetime)) print(datetime.MAXYEAR) print(datetime.MINYEAR) # Dentro da classe datetime print(datetime.datetime.now()) # 2021-07-30 20:08:48.108489 print(repr(datetime...
false
770782703584c23ed76a71ece31eaf997c6f0427
carlhinderer/python-algorithms
/classic_cs_problems/code/ch01/fibonacci.py
1,449
4.15625
4
# Different approaches for generating Fibonacci numbers # # First attempt just shows what happens if you forget a base case # # Naive attempt with base case def fib2(n): if n < 2: return n return fib2(n-1) + fib2(n-2) # Use memoization MEMO = {0: 0, 1: 1} def fib3(n): if n not in MEMO: ...
true
674ee54534ab25221bd886eef60b512aa9edf7d4
msaldeveloper/python
/pythonKodemia/clase3_listas.py
2,034
4.40625
4
##listas en python(arreglos) miPrimerLista =[1,3.1416,"hola mundo"] ### x=[1,2]#se crea la variable x que contiene una lista con valores 1,2 y=x x[0]=0 print(y) ##append miListaUno=[ 1, 2, 3] miListaDos=[ 1, 3] miListaUno.append(miListaDos) ##añade el arreglo de miListDos a un espacio nuevo del arreglo miListaUno #res...
false
961f9d2658e2fbf0e1642457c0b552117d72fefc
saurabh0307meher/Python-Programs
/basic programs/3nos.py
232
4.15625
4
#largest of two numbers a=int(input("Enter 1st nos")) b=int(input("Enter 2nd nos")) c=int(input("Enter 3rd nos")) if (a>b and a>c): print(a,"is greatest") elif (b>c): print(b,"is greatest") else: print(c,"is greatest")
true
8b660b989bb61fd07afd32bf8b18253e705c3fa4
ruchikpatel/abbdemo
/sort/insertion/reverseOrder_IS.py
679
4.46875
4
''' Author: Ruchik Patel Date: 09/16/2017 File: randromNumbers_IS.py Description: Insertion sort algorithm that sorts reverse orderintegers. ''' import sys #import system library/package n = int(sys.argv[1]) #System argument # For reverse: nums = list(range(n, 0, -1)) print("Unsorted array: \n ", nums)#Pr...
true
5c42eb4b6ae9288a1675c24a6491bbf82941714d
ruchikpatel/abbdemo
/sort/selectionSort/selectionSort_reverse.py
718
4.34375
4
''' Author: Ruchik Patel Date: 09/16/2017 File: selectionSort_reverse.py Description: Selection sort algorithm that sorts reverse orderintegers. ''' import sys #import system library/package n = int(sys.argv[1]) #System argument # For reverse: nums = list(range(n, 0, -1)) print("Unsorted array: \n ", nums...
true
0941cffce853d5953f81e0d19afd1cc4ea21e435
greyreality/python_tasks
/Codility/StrSymmetryPoint_my.py
1,530
4.3125
4
# Write a function: def solution(S) # that, given a string S, returns the index (counting from 0) of a character such that the part of the string to the left of that character # is a reversal of the part of the string to its right. The function should return −1 if no such index exists. # Note: reversing an empty str...
true
b1729397c045e0a3b0bd4486e74cf1374a29b880
greyreality/python_tasks
/Other_tasks/triangle_validity.py
613
4.46875
4
# Python3 program to check if three # sides form a triangle or not # У треугольника сумма любых двух сторон должна быть больше третьей. def checkValidity(a, b, c): if (a + b <= c) or (a + c <= b) or (b + c <= a): return False else: return True # Operator Meaning Example # and True if both the o...
true
d5808e4eadd351292439c619cd5b73a1d35ede29
Ankur-v-2004/Python-ch-6-data-structures
/prog_q1.py
597
4.28125
4
#Inserting element in a queue Queue = [] rear = 0 def Insertion_Queue(Queue, rear): ch = 'Y' while ch == 'y' or ch=='Y': element = input("Enter the element to be added to the Queue :") rear = rear + 1 #rear is incremented by 1 and then insertion takes place Queue.append(eleme...
true
e6c9c2f68f9d968db92000de5c820ac809fc533a
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH06/EX6.46.py
862
4.21875
4
# 6.46 (Turtle: connect all points in a hexagon) Write a program that displays a hexagon # with all the points connected, as shown in Figure 6.12b. import math import turtle # Draw a line from (x1, y1) to (x2, y2) def drawLine(x1, y1, x2, y2): turtle.penup() turtle.goto(x1, y1) turtle.pendown() turtle...
false
a2c893a42650af0f31d847df25921cf0c11e7545
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH03/EX3.15.py
784
4.4375
4
# (Turtle: paint a smiley face) Write a program that paints a smiley face, as shown in # Figure 3.6a. import turtle turtle.circle(100) # face # smile turtle.penup() turtle.left(90) turtle.forward(30) turtle.right(60) turtle.pendown() turtle.forward(80) turtle.backward(80) turtle.left(120) turtle.forward(80) turtle.b...
false
218ea769330f80223324f5dda2c9749953d34b26
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH06/EX6.26.py
483
4.25
4
# 6.26 (Mersenne prime) A prime number is called a Mersenne prime if it can be written # in the form for some positive integer p. Write a program that finds all # Mersenne primes with and displays the output as follows: # p 2^p - 1 # 2 3 # 3 7 # 5 31 # ... from CH6Module import MyFunctions print("P", " ", "2^p - 1")...
true
6f40c592f87d09d6a2d046b25fabd3e80395a695
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH11/EX11.38.py
1,372
4.59375
5
# 11.38 (Turtle: draw a polygon/polyline) Write the following functions that draw a # polygon/polyline to connect all points in the list. Each element in the list is a list of # two coordinates. # # Draw a polyline to connect all the points in the list # def drawPolyline(points): # # Draw a polygon to connect all the p...
true
9e08660316315554e6272d205261e69d86626036
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH10/EX10.28.py
1,735
4.34375
4
# 10.28 (Partition of a list) Write the following function that partitions the list using the # first element, called a pivot: # def partition(lst): # After the partition, the elements in the list are rearranged so that all the elements # before the pivot are less than or equal to the pivot and the element after # the ...
true
45f193d1594484a857709fae36c7d96fd39a9a4c
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH04/EX4.11.py
1,227
4.40625
4
# (Find the number of days in a month) Write a program that prompts the user to # enter the month and year and displays the number of days in the month. For example, # if the user entered month 2 and year 2000, the program should display that # February 2000 has 29 days. If the user entered month 3 and year 2005, the p...
true
60621aebebf46e1bab7bdf1bf90f28e68e9d18b7
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH06/EX6.12.py
545
4.53125
5
# 6.12 (Display characters) Write a function that prints characters using the following # header: # def printChars(ch1, ch2, numberPerLine): # This function prints the characters between ch1 and ch2 with the specified # numbers per line. Write a test program that prints ten characters per line from 1 # to Z. def print...
true
0d4bfdb03fa72aad73ca5a0f74298eb85078720b
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH11/EX11.4.py
832
4.1875
4
# 11.4 (Compute the weekly hours for each employee) Suppose the weekly hours for all # employees are stored in a table. Each row records an employee’s seven-day work # hours with seven columns. For example, the following table stores the work hours # for eight employees. Write a program that displays employees and thei...
true
7e1bb35e01e8e7fbf698a954f8627d381029cb24
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH05/EX5.19.py
465
4.21875
4
# 5.19 (Display a pyramid) Write a program that prompts the user to enter an integer # from 1 to 15 and displays a pyramid, as shown in the following sample run: n = int(input("Enter number of lines: ")) x = n * 2 for i in range(1, n + 1): s = n + x sp = str(s) + "s" print(format(" ", sp), end='') for ...
true
3f49290f5bdfe6b67bdabef777e17c8051905f1b
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH08/EX8.5.py
855
4.34375
4
# 8.5 (Occurrences of a specified string) Write a function that counts the occurrences of a # specified non-overlapping string s2 in another string s1 using the following header: # def count(s1, s2): # For example, count("system error, syntax error", "error") returns # 2. Write a test program that prompts the user to e...
true
5f3c2905fc6851de987bad08f1a0ff2c9d0ec4c5
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH13/EX13.9.py
582
4.40625
4
# 13.9 (Decrypt files) Suppose a file is encrypted using the scheme in Exercise 13.8. # Write a program to decode an encrypted file. Your program should prompt the # user to enter an input filename and an output filename and should save the unencrypted # version of the input file to the output file. infile = input("En...
true
11d4ed6ac8734971cdf7cf91f29e57747b72df47
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH05/EX5.44.py
323
4.25
4
# 5.44 (Decimal to binary) Write a program that prompts the user to enter a decimal integer # and displays its corresponding binary value. d = int(input("Enter an integer: ")) bin = "" value = d while value != 0: bin = str(value % 2) + bin value = value // 2 print("The binary representation of", d, "is", bi...
true
40dba80ab9881ee0d5f18a1ef881c6202c707b20
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH08/EX8.8.py
654
4.34375
4
# 8.8 (Binary to decimal) Write a function that parses a binary number as a string into a # decimal integer. Use the function header: # def binaryToDecimal(binaryString): # For example, binary string 10001 is 17 # So, binaryToDecimal("10001") returns 17. # Write a test program that prompts the user to enter a binary st...
true
dac980495e1d018450893bb6247da7049abe78db
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH07/EX7.1.py
1,244
4.875
5
# 7.1 (The Rectangle class) Following the example of the Circle class in Section # 7.2, design a class named Rectangle to represent a rectangle. The class # contains: # ■ Two data fields named width and height. # ■ A constructor that creates a rectangle with the specified width and height. # The default values are 1 an...
true
0a9788e3aca817a8e3c9bfdd55cc60dddfa710ba
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH05/EX5.43.py
341
4.125
4
# 5.43 (Math: combinations) Write a program that displays all possible combinations for # picking two numbers from integers 1 to 7. Also display the total number of combinations. count = 0 for i in range(1, 8): for j in range(i+1, 8): print(i, " ", j) count += 1 print("The total number of all comb...
true
c27897d3dd75790a1778be71ae337c7483f29183
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH15/EX15.11.py
512
4.40625
4
# 15.11 (Print the characters in a string reversely) Rewrite Exercise 15.9 using a helper # function to pass the substring for the high index to the function. The helper # function header is: # def reverseDisplayHelper(s, high): def reverseDisplay(value): reverseDisplayHelper(value, len(value) - 1) def reverseDi...
true
e9ce060de5debd11b74c64e81cbcdb2149776bea
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH15/EX15.34.py
1,848
4.40625
4
# 15.34 (Turtle: Hilbert curve) Rewrite the Hilbert curve in Exercise 15.33 using Turtle, # as shown in Figure 15.20. Your program should prompt the user to enter the # order and display the corresponding fractal for the order. import turtle def upperU(order): if order > 0: leftU(order - 1) turtle...
true
a97533ceba4eff0dfc8f651a353d21c931c380e4
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH03/EX3.5.py
632
4.15625
4
# (Geometry: area of a regular polygon) A regular polygon is an n-sided polygon in # which all sides are of the same length and all angles have the same degree (i.e., the # polygon is both equilateral and equiangular). The formula for computing the area # of a regular polygon is # Here, s is the length of a side. Write...
true
050e743c103dbe2f59ddb3451709031d30ca5b1f
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH13/EX13.2.py
554
4.21875
4
# 13.2 (Count characters, words, and lines in a file) Write a program that will count the # number of characters, words, and lines in a file. Words are separated by a whitespace # character. Your program should prompt the user to enter a filename. filename = input("Enter a filename: ").strip() file = open(filename, 'r...
true
ccea56d0aaed3b2e976259cc6decbd3516bde27c
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH15/EX15.01.py
493
4.3125
4
# 15.1 (Sum the digits in an integer using recursion) Write a recursive function that computes # the sum of the digits in an integer. Use the following function header: # def sumDigits(n): # For example, sumDigits(234) returns Write a test program # that prompts the user to enter an integer and displays its sum. def ...
true
7ad21495c9581d74dc9b9f02930fbfe7dd7c3f12
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH06/EX6.7.py
1,140
4.3125
4
# 6.7 (Financial application: compute the future investment value) Write a function that # computes a future investment value at a given interest rate for a specified number of # years. The future investment is determined using the formula in Exercise 2.19. # Use the following function header: # def futureInvestmentVal...
true
cfa8e99d7f24ebcbb5c4237e74f1f475ba1e5704
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH06/EX6.38.py
557
4.3125
4
# 6.38 (Turtle: draw a line) Write the following function that draws a line from point # (x1, y1) to (x2, y2) with color (default to black) and line size (default to 1). # def drawLine(x1, y1, x2, y2, color = "black", size = 1): import turtle def drawLine(x1, y1, x2, y2, color="black", size=1): turtle.color(color...
true
02b3e59d523a56be6ae7df5c11687f7a168db030
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH10/EX10.5.py
540
4.28125
4
# 10.5 (Print distinct numbers) Write a program that reads in numbers separated by a # space in one line and displays distinct numbers (i.e., if a number appears multiple # times, it is displayed only once). (Hint: Read all the numbers and store # them in list1. Create a new list list2. Add a number in list1 to list2. ...
true
808f4c21115654ed8553ba1e529b933b1e258b79
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH03/EX3.11.py
344
4.25
4
# (Reverse number) Write a program that prompts the user to enter a four-digit integer # and displays the number in reverse order. num = eval(input("Enter an integer: ")) n1 = num % 10 num = num // 10 n2 = num % 10 num = num // 10 n3 = num % 10 num = num // 10 n4 = num print(n1, end='') print(n2, end='') print(n3, end...
true
9ef95ef743118f21adfb7b048d4744122da08dc5
6igsm0ke/Introduction-to-Programming-Using-Python-Liang-1st-edtion
/CH05/EX5.40.py
429
4.15625
4
# 5.40 (Simulation: heads or tails) Write a program that simulates flipping a coin one # million times and displays the number of heads and tails. import random print("Simulating flipping a coin 1000000 times") head = 0 tail = 0 print("Wait....") for i in range(0, 1000000): if random.randint(0, 1) == 0: ...
true
a6da77075a5d612fdd68de486f11f3bb5c7cee12
jameszhan/leetcode
/algorithms/095-unique-binary-search-trees-ii.py
1,417
4.125
4
""" 不同的二叉搜索树 II 给定一个整数 n,生成所有由 1 ... n 为节点所组成的 二叉搜索树 。 示例: 输入:3 输出: [   [1,null,3,2],   [3,2,null,1],   [3,1,null,null,2],   [2,1,3],   [1,null,2,null,3] ] 解释: 以上的输出对应以下 5 种不同结构的二叉搜索树: 1 3 3 2 1 \ / / / \ \ 3 2 1 1 3 2 / / \ ...
false
07bd7f173af81adfc21fb4cc4bf67e2220ce7236
jameszhan/leetcode
/algorithms/035-search-insert-position.py
1,277
4.1875
4
""" 给定一个排序数组和一个目标值,在数组中找到目标值,并返回其索引。如果目标值不存在于数组中,返回它将会被按顺序插入的位置。 你可以假设数组中无重复元素。 示例 1: 输入: [1,3,5,6], 5 输出: 2 示例 2: 输入: [1,3,5,6], 2 输出: 1 示例 3: 输入: [1,3,5,6], 7 输出: 4 示例 4: 输入: [1,3,5,6], 0 输出: 0 """ def search_insert(nums, target) -> int: nums_len = len(nums) if nums_len < 1: return 0 ...
false
159c18a4adce4d20d774ab866e3198b710b00376
jcontreras12/Moduel-6
/factorial.py
336
4.3125
4
# problem 6 use a for statement to calculate the factorial of a users input value import math x = int(input("Enter a number:")) number = 1 for i in range(1, x+1): number = number * i print("Factorial of {} using for Loop {}".format(x, number)) print(" Factorial of {} using inbuilt function: {}".format(x, mat...
true
5e84a356985f8bc40ccb7758b6ea9acc233626fa
kutay/workshop-intro
/python-sqlite3/main.py
1,339
4.3125
4
import sqlite3 from sqlite3 import Error # https://www.sqlitetutorial.net/sqlite-python/ def create_connection(db_file): """ create a database connection to the SQLite database specified by the db_file :param db_file: database file :return: Connection object or None """ conn = None tr...
true
3fd5c20428b51725c133e7702fed0de0412d05b1
inaram/workshops
/python3/fitnessChallenge.py
899
4.21875
4
def fitnessChallenge(): challengeLength = int(input("How many days do you want your fitness challenge to last? ")) totalMinutes = 0 totalDays = 0 for day in range(1, challengeLength + 1): answer = input("Have you exercised today? (y/n): ") if answer == "y" or answer == "yes" or answer ...
true
a6e07131d153747bbeeb90472617f2fe6322aef9
grahamrichard/COMP-123-fall-16
/PycharmProjects/Oct03/whileloops.py
2,820
4.46875
4
""" ================================================== File: whileloops.py Author: Susan Fox Date: Spring 2013 This file contains examples of while and for loops for the Iteration activity. """ # ==================================================== # Simple while loop examples # loop 1 def printEveryFifth(x): ...
true
0b141796ccdf60dd04b46e419ee0254db7e79d18
grahamrichard/COMP-123-fall-16
/PycharmProjects/FINAL/Q1.py
2,130
4.65625
5
# In this question you are provided a function to determine # if a string is a palindrome. This function is recursive # you have several tasks # 1. Using comments, label each line of code as either # part of a base case or a recursive case. If there are # more than one base case or recursive case number the # cases (I...
true
94262de064f2348068e6650a9e69c1b227d4bf93
grahamrichard/COMP-123-fall-16
/PycharmProjects/Oct10/InClass.py
1,685
4.28125
4
import turtle wind = turtle.Screen() turt1 = turtle.Turtle() turt1.up() turt1.goto(100,100) turt1.down() turt2 = turtle.Turtle() turt2.up() turt2.goto(-100, -100) turt2.down() turt3 = turt1 # gives us another name to refer to turt1/creates an Alias # this line of code creates a new turtle that is a 'copy' of ...
false
cbbe95857a99d7b349eff3d726b944f5dbf48a20
grahamrichard/COMP-123-fall-16
/PycharmProjects/FINAL/Q2.py
589
4.4375
4
# This question has you write a function named greater. # The Greater function takes a dictionary whose keys are # numbers and whose values are numbers. The function # returns a list of all keys that are larger than their # values. The original dictionary should not be modified. # See the included example for more info...
true
cfcac0732131c1af470b48fee911605cd4b45d07
cabudies/Python-Batch-3-July-2018
/5-July.py
539
4.28125
4
# use input() function to take input from user # use int() function to convert string to int number = int(input('Enter the number of rows for star pattern: ')) for i in range(0, number): for j in range(0, i): print("*", end=" ") print() # use def to create a function def printUserDetails(): ...
true
f5d5c595241d3b20830f30c314114a2e00cb7379
Grinch101/data_structure
/algorithms/sorting_algorithms/merge_sort.py
2,196
4.1875
4
# merge sort: # The divide-and-conquer paradigm involves three steps at each level of the recursion: # Divide the problem into a number of subproblems that are smaller instances of the # same problem. # Conquer the subproblems by solving them recursively. If the subproblem sizes are # small enough, however, just solve...
true
86d2fb4f5f5739055fb0dfbffa1250b7d0ea6840
roctubre/compmath
/serie6/6_3_lists.py
2,262
4.1875
4
from itertools import permutations # a) def has_duplicates(n): """ Check if the given list has unique elements Uses the property of sets: If converted into a set it is guaranteed to have unique elements. -> Compare number of elements to determine if the list contains duplicates """ ...
true
c441f91a6bf19db24c245518efaebc4306217d64
WomenWhoCode/WWCodePune
/Python/running_with_python/exercise.py
1,164
4.15625
4
""" 1). Create function without/ with none/default arguments. 2). Try passing args and kwargs 3). Call a lambda function inside a function. 4). Try r,r+,w,w+,a modes with file handling 5). Import modules from different and same directories 6). Create a class and try using __init__ method 7). Try calling a funct...
true
987052f4c5e9bf33254a569ecf1a14b7b1fc814f
beatwad/algorithm
/find_max_subarray_recursive.py
1,541
4.125
4
import math def find_max_sublist(_list, low, high): """ Recursively find max sublist of list. Difficulty is O(n*lg(n)) """ if low == high: return low, high, _list[low] else: mid = divmod(low + high, 2)[0] left_low, left_high, left_sum = find_max_sublist(_list, low, mid) rig...
true
e58ba82afdc2622c981e0211369580ba6dbc6549
devjinius/algorithm
/Hackerrank/Left_Rotation.py
941
4.1875
4
''' HackerRank Left Rotation 문제 https://www.hackerrank.com/challenges/array-left-rotation/problem 문제 A left rotation operation on an array of size n shifts each of the array's elements 1 unit to the left. For example, if 2 left rotations are performed on array [1,2,3,4,5], then the array would become [3,4,5,1,2]. 입...
true
4742a4c9509853579379e3dfd120c48786e4b659
jalongod/LeetCode
/69.py
933
4.21875
4
''' 69. x 的平方根 实现 int sqrt(int x) 函数。 计算并返回 x 的平方根,其中 x 是非负整数。 由于返回类型是整数,结果只保留整数的部分,小数部分将被舍去。 示例 1: 输入: 4 输出: 2 示例 2: 输入: 8 输出: 2 说明: 8 的平方根是 2.82842...,   由于返回类型是整数,小数部分将被舍去。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/sqrtx 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 ''' class Solution: def mySqrt(self...
false
56875cbaf2634b7524737c4d8e063a631811d4ce
MichelPinho/exerc-cios
/Par_ou_Impar.py
277
4.125
4
# CRIE UM PROGRAMA QUE RECEBE UM NÚMERO, E DIGA SE ELE É PAR OU ÍMPAR num = int(input('Informe o número que deseje saber se é par ou ímpar: ')) if num % 2 == 0: print('O número {} é par'.format(num)) else: print('O número {} é ímprar'.format(num))
false
fe5c51d3953c808574151cb872901c2cc00d3850
MichelPinho/exerc-cios
/Desafio_75_AnáliseDados_Tuplas.py
858
4.125
4
# Desenvolva um programa que leia 4 números pelo teclado, e guarde-os em uma tupla, no final disso, mostre : # Quantas vezes apareceu o número 9 ? # Em que posição foi digitado o primeiro número 3 ? # Quais são os números pares ? n = (int(input('Digite um número: ')), int(input('Digite o segundo número: ')), int(input(...
false
02cbcf7ee03758c630aa0ffccf4943cd23591960
NathanSouza27/Python
/ING/005 - Predecessor and successor.py
231
4.125
4
#Make a program that reads an integer and shows your successor and predecessor on the screen. n = int(input('Type it a value:')) a = n - 1 s = n + 1 print('The predecessor de {} is {} and successor is {}'.format(n, a, s))
true
0ccadc8754ff399cbb3f4e544e68fd33ed2dbc04
NathanSouza27/Python
/ING/010 - Currency converter.py
294
4.15625
4
#Create a program that reads how much money a person has in their wallet and shows how many dollars they can buy. # Consider 1U$ = R$ 3,27. mon = float(input('How much money do you have in your wallet? U$ ')) con = mon * 3.27 print('With U$ {} you can buy R$ {:.2f}'.format(mon, con))
true
8f7ccc28ea13ded236db2056040a22bf6fa5209f
audy018/tech-cookbook
/python/python-package-example/module_package/techcookbook/caseconvert.py
299
4.34375
4
""" module to convert the strings to either lowercase or uppercase """ def to_lowercase(given_strings): """"convert given strings to lower case""" return given_strings.lower() def to_uppercase(given_strings): """"convert given strings to upper case""" return given_strings.upper()
true
0169985953a5b02442e7169e2068ebf8b1e0ec44
pehuverma/Python-code.py
/function.py
2,232
4.125
4
'''function -> hum is fucntion k through code ko again nd again use kr skte h apne program m function jo h vo code ko divide kr dete h taki code ko easy to understand kr ske programmer function are basically 2 tpyes: 1. User defined : means user apne according function ko built krta h def functionname(): 2. Buil...
false
aaed8f499f38230ddbfad6373945a2146898cf58
tinali0923/orie5270-ml2549
/hw2/optimize.py
1,121
4.15625
4
import numpy as np from scipy import optimize def Rosenbrock(x): """ This is the function for Rosenbrock with n=3 :param x: a list representing the input vector [x1,x2,x3] :return: a number which is the Rosenbrock value """ return 100 * (x[2] - x[1] ** 2) ** 2 + (1 - x[1]) ** 2 + 100 * (x[1] -...
true
b8f77afc83bca627d39c2e2373f89a0568e09fd7
PeterMurphy98/comp_sci
/sem_1/programming_1/prac9/p17p1.py
500
4.3125
4
# Define a function to return a list of all the factors of a number x. def divisor(x): """Finds the divisors of a.""" # Initialise the list of divisors with 1 and x divisors = (1,x) # Check if i divides x, from i = 1 up to i = x/2. # If it does, add i to the divisors list. for i in range(2, int(...
true
7f267e86ab6e1a5132f8a794bc4e1b8a9501a9dd
PeterMurphy98/comp_sci
/sem_1/programming_1/prac10/p19p1.py
463
4.125
4
def new_base(x, b): """Takes a number, x, in base 10 and converts to base b.""" # Initialise the new number as a string new = '' # While the division result is not equal to 0 while x != 0: # add the remainder to the string remainder = x % b new += str(remainder) x =...
true
4c3d05ee24ea643e24813638c1c5592db7776d95
PeterMurphy98/comp_sci
/sem_1/programming_1/test2/exam-q1.py
675
4.375
4
def isPal(text): # Initialise new string new = "" # Add all letters, numbers and spaces from input string to new string for i in range (len(text)): if text[i].isalnum() or text[i] == " ": new += text[i] # Check if new string is the same when reversed if new == new[::-1]: ...
true
365a0eef3630dd6ae3e85e1527154ef3b154af26
coder91x/Linked_Lists
/linked_list_swap.py
1,410
4.125
4
class Node(object): def __init__(self, data): self.data = data self.next = None class LinkedList(object): def __init__(self): self.head = None def push(self, new_data): new_node = Node(new_data) new_node.next = self.head self.head = new_node ...
true
be81b120372bcdf5fe1428bbd767d8cc40ae225a
titouanfreville/-3AIT-_Labs_Correction
/TP_NOTE/Python/tri.py
2,440
4.25
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # LIST FUNCTIONS ---------------------------------------------------------------------- # FUNCTION ON LISTS WITHOUT DELETE Lsp Likes # @car # @PARAM list # @RETURN first element def car (l): return l[0] # @cdr # @PARAM list # @RETURN list without head def cdr (l): ret...
false
a0f0acdef772a13a5c7c3666b9e3c0755a1de519
kevna/python-exercises
/src/sorting/stupid_sort.py
956
4.28125
4
from sorting.sorter import Sorter, SortList class StupidSort(Sorter): # pylint: disable=too-few-public-methods """Implementation of stupid sort, also known as gnome sort. If the current pair are out of order swap them and move back one otherwise step forward. """ def sort(self, items: SortList, ...
true
178c20e7b4a535c3ab70fe6b851dfd90587938cc
KelvienLee/Python-learnning
/chapter_5/creat_str.py
2,124
4.53125
5
# 单引号创建字符串 # name = 'hello' # hobby = "creating" # # zen = ''' # 给注释赋值,适合长文字的输出。 # 这是很长的一段注释 # this is a long paragraph. # 这里面的格式 会被保留。 # ''' # print(name, hobby) # print(zen) # 转义字符的使用 # 这是一种错误的 is 使用方法,单引号会被识别为字符串标识符 # print('kelvien's hobby is creating things.') # 正确的 is 使用方法是使用转义符号 \ 反斜杠 ,...
false