blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
2aa078dc068d59306dd016ccd5f61591fc6c1214
aselvais/PythonOOPexample
/libs/animals/AnimalArmy.py
1,246
4.1875
4
""" Class for creating an army of animal """ from libs.animals.Dog import Dog from libs.animals.Duck import Duck class AnimalArmy: """Generates an army of animals Args: animal_type (str, optional): duck or dog. Defaults to 'duck'. army_size (int, optional): Number of animal in the army. Defau...
true
c3102ca81f107494c8479b0ecf60af4889522c7c
emws0415/program_basics_python
/Chapter 1/20174067, 강범수, 1장 과제, 2번.py
2,039
4.1875
4
#컴퓨터공학과, 20174067, 강범수 print("컴퓨터공학과, 20174067, 강범수") from random import randint while True: print("ㅡㅡㅡㅡㅡMENUㅡㅡㅡㅡㅡ") print("1. UP & DOWN") print("2. Bulls and Cows") print("3. Exit") choose = int(input("> ")) # UP & DOWN if choose == 1 : print("\nㅡㅡㅡUP & DOWN!ㅡㅡㅡ")...
false
3807e45d09f23244239ad8db2bdd786c0badc56e
Kota-N/python-exercises
/ex6StringLists.py
350
4.125
4
# An exercise from http://www.practicepython.org/ #6 String Lists import math word = input("Enter a word: ") middleIndex = math.floor(len(word)/2) firstHalf = word[0:middleIndex] lastHalf = word[middleIndex+1:] if firstHalf[::-1] == lastHalf: print(word, ": Your word is palindrome!") else: print(word, ": Y...
true
d71db487817a2fec22a537d41cae952aed2351be
elunacado/FISICA_FUERZA
/F/main.py
1,381
4.21875
4
def calculo(): ul = ["a = asceleracion", "m = masa", "f = fuerza"] print(ul) peticion=input("que quieres calcular?") def fuerza(): m = float(input("dime el valor de la m ")) a = float(input("dime el valor de la a ")) result=m * a print(result) aga...
false
906289d11e5d2e0cb23ed09ed268916674ae689f
SmileShmily/LaunchCode-summerofcode-Unit1
/ClassExercise & studio/Hacker Chapter--Files/ex.04.py
2,959
4.25
4
'''Here is a file called labdata.txt that contains some sample data from a lab experiment. 44 71 79 37 78 24 41 76 19 12 19 32 28 36 22 58 89 92 91 6 53 7 27 80 14 34 8 81 80 19 46 72 83 96 88 18 96 48 77 67 Interpret the data file labdata.txt such that each line contains a an x,y coordinate pair. Write a function c...
true
eaedab6cec968ff2daf1313210d0713a8a397653
SmileShmily/LaunchCode-summerofcode-Unit1
/ClassExercise & studio/chapter 3/ex.04.py
1,137
4.375
4
'''Football Scores Suppose you’ve written the program below. The given program asks the user to input the number of touchdowns and field goals scored by a (American) football team, and prints out the team’s score. (We assume that for each touchdown, the team always makes the extra point.) The European Union has decid...
true
8751ce643df7e321eaf0f354e4e2d03641f56778
SmileShmily/LaunchCode-summerofcode-Unit1
/ClassExercise & studio/chapter 2/ex.08.py
326
4.28125
4
'''Write a program that will compute the area of a rectangle. Prompt the user to enter the width and height of the rectangle. Print a nice message with the answer. ''' ## question 9 solution width = int(input("Width? ")) height = int(input("Height? ")) area = width * height print("The area of the rectangle is", ...
true
cd9e9cf99f39ffab5a59d013375ebe2016503dae
SmileShmily/LaunchCode-summerofcode-Unit1
/ClassExercise & studio/chapter 11/Problem Set--Crypto/commandline.py
1,150
4.53125
5
''' commandline.py Jeff Ondich, 21 April 2009 This program gives a brief illustration of the use of command-line arguments in Python. The program accepts a file name from the command line, opens the file, and counts the lines in the file. ''' import sys # If the user types too few or too ma...
true
f81af3b3ee07daecb713502882d235f0b62e0fca
SmileShmily/LaunchCode-summerofcode-Unit1
/ClassExercise & studio/chapter 11/List Comprehensions.py
628
4.5
4
'''The previous example creates a list from a sequence of values based on some selection criteria. An easy way to do this type of processing in Python is to use a list comprehension. List comprehensions are concise ways to create lists. The general syntax is: [<expression> for <item> in <sequence> if <condition>] wh...
true
b1b9abda174eecee080e0bc8b1fa8b424104ea3e
SmileShmily/LaunchCode-summerofcode-Unit1
/ClassExercise & studio/chapter 11/Problem Set--Crypto/strings2.py
442
4.15625
4
'''strings2.py Jeff Ondich, 2 April 2009 This sample program will introduce you to "iteration" or "looping" over the characters in a string. ''' s = 'two kudus and a newt' # What happens here? print('The first loop') for ch in s: print (ch) print() # And here? print( 'The second loop') k = 0 while k ...
true
6b49356fb32eee0f79ad56e806a41b549b7fc847
SmileShmily/LaunchCode-summerofcode-Unit1
/ClassExercise & studio/chapter 6/ex.08.py
337
4.28125
4
'''Now write the function is_odd(n) that returns True when n is odd and False otherwise. ''' from test import testEqual def is_odd(n): # your code here if n % 2 == 0: return False else: return True testEqual(is_odd(10), False) testEqual(is_odd(5), True) testEqual(is_odd(1), True) testEqual(...
true
1122da139c723e93234aba0ae35e3ec62f7504b6
SmileShmily/LaunchCode-summerofcode-Unit1
/ClassExercise & studio/chapter 11/Nested Lists.py
776
4.53125
5
'''A nested list is a list that appears as an element in another list. In this list, the element with index 3 is a nested list. If we print(nested[3]), we get [10, 20]. To extract an element from the nested list, we can proceed in two steps. First, extract the nested list, then extract the item of interest. It is ...
true
cbb24873533a63b0842920b265efe25987dca3f3
SmileShmily/LaunchCode-summerofcode-Unit1
/ClassExercise & studio/chapter 14/ex.06.py
1,691
4.125
4
''') (GRADED) Write a new method in the Rectangle class to test if a Point falls within the rectangle. For this exercise, assume that a rectangle at (0,0) with width 10 and height 5 has open upper bounds on the width and height, i.e. it stretches in the x direction from [0 to 10), where 0 is included but 10 is exclude...
true
bd7d3da5c3917644520e2fd9528bee66e85ade32
SmileShmily/LaunchCode-summerofcode-Unit1
/ClassExercise & studio/chapter 4/ex.02.py
884
4.4375
4
'''Turtle objects have methods and attributes. For example, a turtle has a position and when you move the turtle forward, the position changes. Think about the other methods shown in the summary above. Which attibutes, if any, does each method relate to? Does the method change the attribute? ''' '''Write a program tha...
true
d15fa577adbdc9cf9ac0c3ad0652ad2430eb8bca
SmileShmily/LaunchCode-summerofcode-Unit1
/ClassExercise & studio/chapter 12/Crypto/Caesar Cipher/caesar01/caesar 02.py
1,272
4.375
4
def caesarCipher(t, s): """ caesarCipher(t, s) Returns the cipher text in a given plain text or vice versa. Variables: t - text (input), nt - new text (output) lc - lowercase, uc - uppercase pt[c] - nth character of the plain text (also used to get the ...
true
7f7f4cd5a877fb9a457cd662ec1cbe4f47cba6cb
CriticalD20/String-Jumble
/stringjumble.py
1,567
4.3125
4
""" stringjumble.py Author: James Napier Credit: http://stackoverflow.com/questions/12794141/reverse-input-in-python, http://stackoverflow.com/questions/25375794/how-to-reverse-the-order-of-letters-in-a-string-in-python, http://stackoverflow.com/questions/25375794/how-to-reverse-the-order-of-letters-in-a-string-in-...
true
c5bf60c3b48425c93a6c39a20b01d10a3fe36bc2
narenaruiz/Python
/P6/P6E5.py
894
4.28125
4
"""5.-Escribe un programa que te pida números cada vez más grandes y que se guarden en una lista. Para acabar de escribir los números, escribe un número que no sea mayor que el anterior. El programa termina escribiendo la lista de números: Escribe un número: 6 Escribe un número mayor que 6: 10 Escribe un número mayor ...
false
7156e4a491a294fce7e93b898bbe0a83eaf89bb8
narenaruiz/Python
/P6/P6E3.py
639
4.1875
4
"""3.-Escribe un programa que pida notas y los guarde en una lista. Para terminar de introducir notas, escribe una nota que no esté entre 0 y 10. El programa termina escribiendo la lista de notas. Escribe una nota: 7.5 Escribe una nota: 0 Escribe una nota: 10 Escribe una nota: -1 Las notas que has Escrito son [7.5, 0.0...
false
03478dde7f02433ae2c351c181cefc942e0c75be
parthpanchal0794/pythontraining
/NumericType.py
1,634
4.25
4
""" Numeric types classes 1. Integer e.g 10 2. Float e.g 10.0 3. Complex e.g 3 + 5j 4. Binary type (Class Int) 5. Hexadecimal (Class Int) 6. Octa decimal (Class Int) """ # Integer Values a = 13 b = 100 c = -66 print(a, b, c) print(type(a)) # Floating values x = 33.44 y = -8.78 z = 56.0 # with...
true
523474ff795187ae2740e98b9a2c2f393e6f71d7
HyeongSeoku/Programmers_CodingTest
/python/datastructure/descendingSort.py
1,130
4.1875
4
''' 1. maxMachine 클래스를 완성하세요. 2. sorting 함수를 완성하세요. ''' class maxMachine : ''' 이곳에 '최댓값 기계' 문제에서 작성했던 클래스를 붙여넣으세요 ''' def __init__(self) : self.numbers = []; def addNumber(self, n) : self.numbers.append(n); def removeNumber(self, n) : self.numbers.remove(n); def g...
false
a862febaed4059785ab37c810b54b6a1034c6901
Mohibtech/Mohib-Python
/UrduPythonCourse/List Comprehension.py
2,248
4.75
5
''' List comprehensions provide a concise way to create lists. It consists of brackets containing an expression followed by a for clause, then optional if clauses. The expressions can be anything, meaning you can put in all kinds of objects in lists. The list comprehension always returns a result list. ''' # List co...
true
5a51b340ba8d0d8c4ec9548812a0b3dd7152c64c
alex88yushkov/les_4.2_salary_echo
/salary_echo.py
1,459
4.25
4
# Exercise #1 def show_employee(name = "Trus", sal = 5000): name = "Name: " + name sal = "Salary: " + str(sal) print(name, sal, sep=", ") show_employee() show_employee(name = 'Balbes') show_employee(name = 'Bivaliy', sal = 4000) # Exercise #2 # VARIANT 1: #Define shout_echo def shout_echo(word1 = "Hey ",...
false
3cf56345025b2e3d5581c689813defd14a38feb7
malhar-pr/side-projects
/pythagorean.py
2,783
4.375
4
import time pyth_list=[] #Creates an empty list that will hold the tuples containing Pythagorean/Fermat triplets power_list=[] #Creates an empty list that will cache the value of each index raised to the specified exponent in the given range print("------------------------------------------------------------------...
true
0e7c83d4d2c446c084206623cfc460d5d9e0eb58
SvetlanaTsim/python_basics_ai
/lesson_8/task_8_7.py
1,851
4.46875
4
""" Реализовать проект «Операции с комплексными числами». Создать класс «Комплексное число». Реализовать перегрузку методов сложения и умножения комплексных чисел. Проверить работу проекта. Для этого создать экземпляры класса (комплексные числа), выполнить сложение и умножение созданных экземпляров. Проверить корректно...
false
7efb1395d46e4478a38a1e87632274ca4cf07cc4
SvetlanaTsim/python_basics_ai
/lesson_3_ht/task_3_6.py
1,111
4.1875
4
""" 6. Реализовать функцию int_func(), принимающую слово из маленьких латинских букв и возвращающую его же, но с прописной первой буквой. Например, print(int_func(‘text’)) -> Text. Продолжить работу над заданием. В программу должна попадать строка из слов, разделенных пробелом. Каждое слово состоит из латинских букв в...
false
e884acf79724ce595323ca07bf8e9783a2698f2e
shubham-bhoite164/DSA-with-Python-
/Reversing the Integer.py
685
4.21875
4
# Our task is to design an efficient algorithm to reverse the integer # ex :- i/p =1234 , o/p =4321 # we are after the last digit in every iteration # we can get it with modulo operator: the last digit is the remainder when dividing by 10 # we have to make sure that we remove that digit from the original number # so w...
true
1c7a92b66d1999fc6158a0422558668498f5aa0f
hdjsjyl/LeetcodeFB
/23.py
2,577
4.21875
4
""" 23. Merge k Sorted Lists Share Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Example: Input: [ 1->4->5, 1->3->4, 2->6 ] Output: 1->1->2->3->4->4->5->6 """ ## solution1: similar to merge sort algorithm, the time complexity is O(nklogn) # n is the length ...
true
aa866eb07967f983e83b81db0dd63ca2237c8935
marwane8/algorithms-data-structures
/Sorting.py
2,174
4.25
4
import heapq ''' SORTING ALGORITHMS -Sorting Algorithms are a common class of problems with many implementation -This class highlights some of the foundational implmentations of sorting -SORT FUNCTIONS- selectionSort: finds the minimum number and pops it into the result array mergeSort: u...
true
87784d6b0b95fb4c9b84b0a25d1b9c3423a7a52c
linhdvu14/leetcode-solutions
/code/874_walking-robot-simulation.py
2,149
4.5
4
# A robot on an infinite grid starts at point (0, 0) and faces north. The robot can # receive one of three possible types of commands: # -2: turn left 90 degrees # -1: turn right 90 degrees # 1 <= x <= 9: move forward x units # Some of the grid squares are obstacles. # The i-th obstacle is at grid poin...
true
7908915172b367d592be102e890a18001709d6e2
linhdvu14/leetcode-solutions
/code/231_power-of-two.py
639
4.375
4
# Given an integer, write a function to determine if it is a power of two. # Example 1: # Input: 1 # Output: true # Explanation: 20 = 1 # Example 2: # Input: 16 # Output: true # Explanation: 24 = 16 # Example 3: # Input: 218 # Output: false # ---------------------------------------------- # Ideas: power of two iff...
true
ded0c70db2cdd448b7041f41266219fe933f1aa7
linhdvu14/leetcode-solutions
/code/589_n-ary-tree-preorder-traversal.py
918
4.125
4
# Given an n-ary tree, return the preorder traversal of its nodes' values. # For example, given a 3-ary tree: # 1 # / | \ # 3 2 4 # / \ # 5 6 # Return its preorder traversal as: [1,3,5,6,2,4]. # Note: Recursive solution is trivial, could you do it iteratively? # --------------------------------------...
true
41be3c636e2d3cda64f2b4db81121a7b47ead5f5
alexresiga/courses
/first semester/fp/assignment1/SetBP10.py
660
4.375
4
# Consider a given natural number n. Determine the product p of all the proper factors of n. def productOfProperFactors(n): """ This function returns the product of all proper factor of a given natural number n. input: n natural number. output: a string with the proper factors and the reuslt...
true
a4e6c461cea4d86d34094af65ca4ee743b7be922
oneandzeroteam/python
/dev.garam.seo/factorial.py
227
4.25
4
#factorial.py factorial = 1 number = int (input ("input the number wanted to factorial: ")) print (number) if (number == 1): factorial = 1 else : for i in range (1, number+1): factorial = factorial * i print (factorial)
true
98b8353fedd8c1efa32ef163d62ba63c9cf169c2
WhySongtao/Leetcode-Explained
/python/240_Search_a_2D_Matrix_II.py
1,350
4.125
4
''' Thought: When I saw something like sorted, I will always check if binary search can be used to shrink the range. Here is the same. [ [1, 4, 7, 11, 15], [2, 5, 8, 12, 19], [3, 6, 9, 16, 22], [10, 13, 14, 17, 24], [18, 21, 23, 26, 30] ] Take this as an example. First let's go to the middle of the f...
true
b928b09a4b3e417316274d2bd19ddccf31198aff
LeftySolara/Projects
/Classic Algorithms/Collatz_Conjecture/collatz.py
606
4.1875
4
""" Collatz Conjecture: Start with a number n > 1. Find the number of steps it takes to reach one using the following process: If n is even, divide it by 2. If n is odd, multiply it by 3 and add 1 """ try: n = int(input("Enter a number greater than one: ")) if n <= 1: print("Invalid input")...
true
80f8377d734ff1a9f51ea52956ddbdb172456b78
lachlankerr/AdventOfCode2020
/AdventOfCode2020/day09.py
1,883
4.15625
4
''' Day 09: https://adventofcode.com/2020/day/9 ''' def read_input(): ''' Reads the input file and returns a list of all the lines ''' lines = [] with open('day09input.txt') as f: lines = f.read().splitlines() lines = list(map(int, lines)) # convert list to ints return li...
true
90251aa6711f4db8af28ce75d89e4de26552f4a6
danielmaddern/DailyProgrammer
/easy_challenge_1/challange.py
611
4.25
4
""" create a program that will ask the users name, age, and reddit username. have it tell them the information back, in the format: your name is (blank), you are (blank) years old, and your username is (blank) for extra credit, have the program log this information in a file to be accessed later. """ name = raw_input(...
true
5bc53494fea4b54fcde00ef55f03d3be4a93a2a8
WenboWong/Python-Geography-spatial-analysis
/Python Geography spatial analysis/chapter5 Python与地理信息系统/Pythagoras.py
347
4.15625
4
#Pythagoras .py #投影坐标计算距离 import math '''x1=456456.23 y1=1279721.064 x2=576628.34 y2=1071740.33 x_dist=x1-x2 y_dist=y1-y2 dist_sq=x_dist**2+y_dist**2 distance=math.sqrt(dist_sq) print("距离为:{0}".format(distance)) ''' #十进制计算度数进行距离量算 x1=-90.21 y1=32.31 x2=-88.95 y2=30.43 x_dist=math.radians(x1-x2)
false
35cf1ad32b02ae5e60a20e0511e5b0e92e835b76
MichaelDc86/Algorythms
/lesson_02/task_5.py
797
4.3125
4
# Вывести наэкран коды и символы таблицы ASCII, начиная с символа под номером 32 и заканчивая 127 - м включительно. # Вывод выполнить в табличной форме: по десять пар "код-символ" в каждой строке.. def print_symbol(symbol_code): if (symbol_code - 2) % 10 == 0: print() print(f'{symbol_code}-{chr(symbol...
false
cc68d3d33daad46d3395e152c04d2ca0786fdb99
yathie/machine-learning
/ex8-basico-python.py
520
4.1875
4
'''faça um programa que leia um valor e apresente o número de Fibinacci correspondente a este valor lido. Lembre que os primeiros elementos sa série de Fibonacci são 0 e 1 e cada próximo termo é a soma dos 2 anteriores a ele. 0 1 1 2 3 5... ''' posicao = int(input("Digite uma posição: ")) def fib(x): seq = [0, 1, 1] ...
false
5368c1c72141f2c65dc28018a9007b8465b308a4
neha52/Algorithms-and-Data-Structure
/Project1/algo2.py
2,928
4.21875
4
# -*- coding: utf-8 -*- array = [] #create an array. x = float (input ("Enter the value of X: ")) n = int(input("Enter the number of elements you want:")) if(n<2): #check if array more than two elements. print ("Enter valid number of elements!") else: print ('Enter numbers in array: ') #take i...
true
679425af21b2ce17248f38b842ab6717df10d1a9
Langutang/Spark_Basics
/spark_basics_.py
2,906
4.1875
4
''' Spark is a platform for cluster computing. Spark lets you spread data and computations over clusters with multiple nodes (think of each node as a separate computer). Splitting up your data makes it easier to work with very large datasets because each node only works with a small amount of data. As each node works...
true
d07674970d95b0ab207982ccf70f771840a8486d
Liam1809/Classes
/Polymorphism.py
798
4.28125
4
a_list = [1, 18, 32, 12] a_dict = {'value': True} a_string = "Polymorphism is cool!" print(len(a_list)) print(len(a_dict)) print(len(a_string)) # The len() function will attempt to call a method named __len__() on your class. # This is one of the special methods known as a “dunder method” (for double underscore) w...
true
2ab337712c44f9dd7fffb98548c8e3a7d0cea93f
tillyoswellwheeler/python-learning
/multi-question_app/app.py
929
4.15625
4
#-------------------------------------------- # Python Learning -- Multi-Question Class App #-------------------------------------------- from Question import Question #------------------------------------- # Creating Question Object and App question_prompts = [ "What colour are apples?\n(a) Red/Green\n(b) Purple...
true
0443bd0c80489e9a063851c62583a9fb7956bc4a
tillyoswellwheeler/python-learning
/2d-lists_&_nested-loops.py
625
4.40625
4
#----------------------------------------- # Python Learning -- 2D & Nested Loops #----------------------------------------- #----------------------------------------- # Creating a 2D array number_grid = [ [1, 3, 4], [3, 4, 5], [3, 6, 7], [2] ] #----------------------------------------- # Accessing r...
true
69e4a76a2265aa14a5efaaef542c8335fdd2a3e1
tillyoswellwheeler/python-learning
/inheritance.py
607
4.4375
4
#------------------------------------- # Python Learning -- Inheritance #------------------------------------- #------------------------------------- # class Chef: def make_chicken(self): print("Chef makes chicken") def make_ham(self): print("Chef makes ham") def make_special_dish(self)...
true
d16589bfe23eaa72097e6fd6ea740bc4008a9415
tillyoswellwheeler/python-learning
/LPTHW/Ex15.py
1,123
4.40625
4
# ------------------------------------ # LPTHW -- Ex15. Reading Files # ------------------------------------ from sys import argv # this means when you run the python, you need to run it with the name of the python command # and the file you want to read in script, filename = argv # This opens the file and assigns ...
true
0bc1e75b9b72d3dc658993e020e7067a3ad5e468
sriram161/Data-structures
/PriorityQueue/priorityqueue.py
1,580
4.21875
4
""" Priotity Queue is an abstract data structure. Logic: ------- Priority queue expects some sort of order in the data that is feed to it. """ import random class PriorityQueue(object): def __init__(self, capacity): self.capacity = capacity self.pq = [] def push(self, value...
true
98082b9e10c1250be6b115aa7278315a0a4b9cdc
griffs37/CA_318
/python/8311.sol.py
1,013
4.15625
4
def make_sum(total, coins): # Total is the sum that you have to make and the coins list contains the values of the coins. # The coins will be sorted in descending order. # Place your code here greedy_coin_list = [0] * len(coins) # We create a list of zeros the same length as the coins list we read in i = 0...
true
2f69b2620798d10de0b6eb730ee28e82cb032a67
vikky1993/Mytest
/test3.py
1,997
4.34375
4
# Difference between regular methods, class methods and static methods # regular methods in a class automatically takes in instance as the first argument and by convention we wer # calling this self # So how can we make it to take class as the first argument, to do that we gonna use class methods #just add a decor...
true
3d891ab050621beb39df665cf7e7845f16b6d9af
shoumu/HuntingJobPractice
/leetcode/62_unique_paths.py
1,151
4.125
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- # Author: shoumuzyq@gmail.com # https://shoumu.github.io # Created on 2015/12/16 15:39 def unique_paths(m, n): """ according to the Combinatorics, the result is C(m - 1)(m + n -2) :param m: :param n: :return: """ a = m + n - 2 b =...
false
6b66cbbdb06804c86c757ca97397895a314ecfeb
RamaryUp/hackerrank
/Python/sets/symmetric_difference.py
1,060
4.28125
4
''' HackerRank Challenge Name : Symmetric Difference Category : Sets Difficulty : easy URL : https://www.hackerrank.com/challenges/symmetric-difference/problem Given sets of integers, and , print their symmetric difference in ascending order. The term symmetric difference indicates those values that exist in either ...
true
ef64e4a52c2f1f0d14755358ba29b6f945a86336
SinghTejveer/stepic_python_in_action_eng
/solutions/s217.py
713
4.25
4
"""Given a real positive number a and an integer number n. Find a**n. You need to write the whole program with a recursive function power(a, n). Sample Input 1: 2 1 Sample Output 1: 2 Sample Input 2: 2 2 Sample Output 2: 4 """ def solve(num: float, exp: int) -> float: """Calculate num*...
true
99f3382c8b97ce2f4195f6ac93d9712d662cace5
SinghTejveer/stepic_python_in_action_eng
/solutions/s005.py
1,065
4.15625
4
# pylint: disable=invalid-name """Difference of times Given the values of the two moments in time in the same day: hours, minutes and seconds for each of the time moments. It is known that the second moment in time happened not earlier than the first one. Find how many seconds passed between these two moments of time...
true
85288d85c45185c3505ac16f9fc76d02459e83a3
SinghTejveer/stepic_python_in_action_eng
/solutions/s080.py
423
4.1875
4
""" Write a program, which reads the line from a standard input, using the input() function, and outputs the same line to the standard output, using the print() function. Please pay attention that you need to use the input function without any parameters, and that you need to output only that, what was transferred to ...
true
8c3ed77439371b18c45e60d0c1623efa5e2570c7
bthuynh/python-challenge
/PyPoll/main.py
2,879
4.125
4
# You will be give a set of poll data called election_data.csv. # The dataset is composed of three columns: Voter ID, County, and Candidate. # Your task is to create a Python script that analyzes the votes and calculates each of the following: # The total number of votes cast # A complete list of candidates who receive...
true
8a4876cd4aae26f15d9673aac9fdf90aa58b573c
peltierchip/the_python_workbook_exercises
/chapter_1/exercise_17.py
787
4.1875
4
## #Compute the amount of energy to achieve the desired temperature change H_C_WATER=4.186 J_TO_KWH=2.777e-7 C_PER_KWH=8.9 #Read the volume of the water and the temperature change from the user volume=float(input("Enter the amount of water in milliliters:\n")) temp_change=float(input("Enter the value of the temperature...
true
1e0ed285d5f8797eab8da2e8bd076f1c7078185a
peltierchip/the_python_workbook_exercises
/chapter_2/exercise_49.py
894
4.40625
4
## #Determine the animal associated with the inserted year #Read the year from the user year=int(input("Enter the year:\n")) #Check if the year is valid if year>=0: #Determine the corresponding animal and display the result if year%12==8: animal="Dragon" elif year%12==9: animal="Sn...
true
4878ceeb7108bd2885a2fccdce8abb5312be586d
peltierchip/the_python_workbook_exercises
/chapter_8/exercise_184.py
1,378
4.59375
5
## # Perform the flattening of a list, which is convert # a list that contains multiple layers of nested lists into a list that contains all the same elements without any nesting ## Flatten the list # @param data the list to flatten # @return the flattened list def flattenList(data): if not(data): return d...
true
5d8a7606ac90a78fb1303d7f7e93c1be4e9aa563
peltierchip/the_python_workbook_exercises
/chapter_5/exercise_115.py
995
4.5
4
## #Determine the list of proper divisors of a positive integer entered from the user ##Create the list of proper divisors # @param n the positive integer # @return the list of proper divisors def properDivisors(n): p_d=[] i=1 #Keep looping while i is less or equal than about half of n while i<=(n//2): ...
true
b3f81cd9792372a13ee9a09e03775b4c95aeacaf
peltierchip/the_python_workbook_exercises
/chapter_5/exercise_130.py
1,143
4.34375
4
## #Identify unary + and - operators in a list of tokens and replace them with u+ and #u- respectively from exercise_129 import tokenizing ##Replace unary + and - operators respectively with u+ and u- # @param ts the list of tokens # @return the list of tokens where the unary + and - operators have been substituted def...
false
f08114b5f25112a2f4b604ed1df58218901bdfeb
peltierchip/the_python_workbook_exercises
/chapter_4/exercise_109.py
943
4.15625
4
## #Display all the magic dates of the 20th century from exercise_106 import daysMonth #Store the first year and the last year as constants FIRST_YEAR=1901 LAST_YEAR=2000 ##Determine if the date is a magic date # @param y the year # @param m the month # @param d the day # @return True if the date is magic. False other...
false
8312a957ec2cc7de0eacaa4fda57e20f04689b70
peltierchip/the_python_workbook_exercises
/chapter_5/exercise_120.py
785
4.1875
4
## #Display a list of items formatted ##Formatting items in a list # @param l the list # @return a string containing the formatted elements def formattingList(l): i=0 n_l=l if len(l)==0: return "No items have been entered." if len(l)==1: return str(l[i]) delimeter=" " n_s="" ...
true
d58c3325359ae564c265e490b0dbf0240d51a137
peltierchip/the_python_workbook_exercises
/chapter_2/exercise_47.py
1,246
4.4375
4
## #Determine the season from the day of the year entered #Read the day of the year fom the user month=input("Enter the month:\n") day=int(input("Enter the day:\n")) season=" " #Determine the season if (month=="January") and (1<=day<=31): season=="Winter" elif (month=="February") and (1<=day<=28): sea...
false
1d460dae11b9cf1493fa428c3d32e07fcf3910d8
peltierchip/the_python_workbook_exercises
/chapter_4/exercise_95.py
1,319
4.3125
4
## #Capitalize a string entered from the user ##Capitalize the string # @param string the string to capitalize # @return the string for which the capitalization has been realized def capitalize_it(string): c_string=string i=0 while i<len(string) and c_string[i]==" ": i=i+1 if i<len(string): ...
true
029562d3c3a05977df813e73fbda14bf86927683
peltierchip/the_python_workbook_exercises
/chapter_8/exercise_181.py
1,233
4.125
4
## # Determine whether it is possible to form the dollar amount entered by # the user with a precise number of coins, always entered by the user from itertools import combinations_with_replacement ## Determine whether or not it is possible to construct a particular total using a # specific number of coins # @param d_...
true
ab065da1c97d276ae71cff4985aa8b33314cf6ee
peltierchip/the_python_workbook_exercises
/chapter_1/exercise_7.py
247
4.1875
4
## #Calculation of the sum of the first n positive integers #Read positive integer n=int(input("Enter a positive integer\n")) #Calculation of the sum s=(n)*(n+1)/2 #Display the sum print("The sum of the first %d positive integers is: %d" %(n,s))
true
b6f80becd1d1f37802a427950c059b41788d2b0d
peltierchip/the_python_workbook_exercises
/chapter_6/exercise_136.py
921
4.71875
5
## # Perform a reverse lookup on a dictionary, finding keys that # map to a specific value ## Find keys that map to the value # @param d the dictionary # @param v the value # @return the list of keys that map to the value def reverseLookup(d,v): # Create a list to store the keys that map to v k_a_v=[] # Check ...
true
c22deedf7d33043df0d14f90d3068ea1776b5f54
peltierchip/the_python_workbook_exercises
/chapter_7/exercise_172.py
1,981
4.15625
4
## # Search a file containing a list of words and display all of the words that # contain each of the vowels A, E, I, O, U and Y exactly once and in order # Create a list to store vowels vowels_list = ["a", "e", "i", "o", "u", "y"] # Read the name of the file to read from the user f_n_r = input("Enter the name of the ...
true
b9a6cb431b02ff057c8ce4aff5a20ae724f78b30
peltierchip/the_python_workbook_exercises
/chapter_5/exercise_111.py
718
4.4375
4
## #Display in reverse order the integers entered from the user, after being stored in a list #Read the first integer from the user n=int(input("Enter the first integer:\n")) #Initialize integers to an empty list integers=[] #Keep looping while n is different from zero while n!=0: #Add n to integers integers.ap...
true
84e1d58ad16f91825fcfb06eac1c1226b61f5e6a
Lycurgus1/python
/day_1/Dictionaries.py
1,220
4.53125
5
# Dictionary student_records = { "Name": "Sam" # Name is key, sam is value , "Stream": "DevOps" , "Topics_covered": 5 , "Completed_lessons": ["Tuples", "Lists", "Variables"] } # Can have a list in a tuple student_records["Name"] = "Jeff" print(student_records["Completed_lessons"][2]) # fetching ind...
true
1467bd581d54b3244d0ed003f2e5a47d0d6e77a7
Lycurgus1/python
/day_1/String slicing.py
567
4.21875
4
# String slicing greeting_welcome = "Cheese world" # H is the 0th character. Indexing starts at 0. print(greeting_welcome[3]) # Gets 4th character from string print(greeting_welcome[-1]) # Gets last character from string print(greeting_welcome[-5:]) # Gets 1st character to last x = greeting_welcome[-5:] print(x) # St...
true
2ecaa40da83339322abdb4f2377cbe44fad0b3b6
Lycurgus1/python
/OOP/Object Orientated Python.py
1,496
4.25
4
# Object orientated python # Inheritance, polymorhpism, encapsulation, abstraction class Dog: amimal_kind = "Canine" # Class variable # Init intalizes class # Give/find name and color for dog def __init__(self, name, color): self.name = name self.color = color def bark(self): ...
true
d9df4158b15accfba5c36e113f383140409ab02a
Lycurgus1/python
/More_exercises/More_Methods.py
2,013
4.21875
4
# From the Calculator file importing everything from Calculator import * # Inheriting the python calculator from the previous page class More_Methods(Python_Calculator): # As per first command self not needed def remainder_test(): # Input commands get the numbers to be used, and they are converted to ...
true
d445e006605290b0c4511c1272f6ff07ed306ca0
renatojobal/fp-utpl-18-evaluaciones
/eval-parcial-primer-bimestre/Ejercicio8.py
1,333
4.15625
4
''' Ejercicio 8.- Ingresar por teclado tres variables, dichas variables siempre tendrán como valores letras mayúsculas de abecedario. Sabiendo que por ejemplo la letra “E” es menor que la letra “P”; establezca una solución que permita determinar ¿Cuál de las tres letras ingresadas, aparece primero en el abecedario ? E...
false
e03113509c9c78385a00ba2253044ab698d974a6
xtiancc/Andalucia-Python
/listaintstr.py
561
4.15625
4
def mostrarNombres(nombres): print("\nListado:") for name in nombres: print(name) print("LISTA NUMEROS Y NOMBRES") print("-----------------------") numeros = [20, 14, 55, 99, 77] print(numeros[0]) numeros.sort() print("Los numeros ahora están ordenados") for num in numeros: print(num) nombres...
false
80a11ffa961d83208461d324062f37d9f7b1d830
yesusmigag/Python-Projects
/Functions/two_numberInput_store.py
444
4.46875
4
#This program multiplies two numbers and stores them into a variable named product. #Complete the missing code to display the expected output. # multiply two integers and display the result in a function def main(): val_1 = int(input('Enter an integer: ')) val_2 = int(input('Enter another integer: ')) mul...
true
a5643896a36f24aab394372e73d18e052deb624c
yesusmigag/Python-Projects
/List and Tuples/10 find_list_example.py
710
4.34375
4
"""This program aks the user to enter a grocery item and checks it against a grocery code list. Fill in the missing if statement to display the expected output. Expected Output Enter an item: ice cream The item ice cream was not found in the list.""" def main(): # Create a list of grocery items. grocery_list ...
true
8c4a55fa444dc233b0f11291147c224b0ed1bdb5
yesusmigag/Python-Projects
/List and Tuples/18 Min_and_Max_functions.py
500
4.40625
4
"""Python has two built-in functions named min and max that work with sequences. The min function accepts a sequence, such as a list, as an argument and returns the item that has the lowest value in the sequence.""" # MIN Item my_list = [5, 4, 3, 2, 50, 40, 30] print('The lowest value is', min(my_list)) #display Th...
true
73037324693d0170667f036a2e61fcd1e586895f
yesusmigag/Python-Projects
/File and Files/Chapter6_Project3.py
639
4.125
4
'''Write a program that reads the records from the golf.txt file written in the previous exercise and prints them in the following format: Name: Emily Score: 30 Name: Mike Score: 20 Name: Jonathan Score: 23''' #Solution 1 file = open("golf.txt", "r") name = True for line in file: if name: print("Nam...
true
f735a64f0aa2132efd6a12b57cc812bc87a29444
JaimeFanjul/Algorithms-for-data-problems
/Sorting_Algorithms/ascii_encrypter.py
1,301
4.40625
4
# ASCII Text Encrypter. #-------- # Given a text with several words, encrypt the message in the following way: # The first letter of each word must be replaced by its ASCII code. # The second letter and the last letter of each word must be interchanged. #-------- # Author: Jaime Fanjul García # Date: 16/10/2020 ...
true
bc0c2d7871b4263c62e43cd04d7370fc4657468e
gitsana/Python_Tutorial
/M5-Collections/words.py
1,607
4.5
4
#!/usr/bin/env python3 #shebang # indent with 4 spaces # save with UTF-8 encoding """ Retrieve and print words from a URL. Usage: python3 words.py <URL> """ from urllib.request import urlopen def fetch_words(): """Fetch a list of words from a URL. Args: url: The URL of a UTF-8 text document Returns: A list o...
true
a90012c851cad115f6f75549b331cfa959de532b
JasleenUT/Python
/ShapeAndReshape.py
587
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jan 3 22:47:26 2019 @author: jasleenarora """ #You are given a space separated list of nine integers. #Your task is to convert this list into a 3X3 NumPy array. #Input Format #A single line of input containing space separated integers. #Output For...
true
5c8061c586c1ca3f86bb662601a812e3cf46fdec
ashish-bisht/ds_algo_handbook
/top_k_elements/frequency_sort.py
613
4.375
4
import collections import heapq def sort_character_by_frequency(str): str_dict = collections.Counter(str) heap = [] for key, val in str_dict.items(): heapq.heappush(heap, (-val, key)) final_string = '' while heap: val, char = heapq.heappop(heap) final_string = final_stri...
false
8d5312a4489988236f75acb7025db9c86dd4d58a
Krishesh/AngelAssignment
/q1.py
864
4.1875
4
class Person: firstlen = 0 middlelen = 0 lastlen = 0 def __init__(self, first_name, middle_name, last_name): self.first_name = first_name self.middle_name = middle_name self.last_name = last_name def first_name_length(self): for _ in self.first_name: Per...
false
a685dfed0946a9c01454d98f65abab97d25f6ce2
StarPony3/403IT-CW2
/Rabbits and recurrence.py
645
4.3125
4
# program to calculate total number of rabbit pairs present after n months, # if each generation, every pair of reproduction-age rabbits produces k rabbit pairs, instead of only one. # variation of fibonacci sequence # n = number of months # k = number of rabbit pairs # recursive function for calculating grow...
true
9e10db07bd159f36235ff5b58654eba48d66a6f3
manisha-jaiswal/iterator-and-generator-in-python
/OOPS18_iterator_genrator.py
763
4.28125
4
""" Iterable - __iter__() or __getitem__() Iterator - __next__() Iteration - """ def gen(n): for i in range(n): # return i - it returns the value true or false yield i #yeh i ko yield krega , # yeild ek generator h jo on the fly value ko geneerate krega g = gen(3) print(g) ...
false
21fbc706321e771b06be18dd923943321d229bf0
yinjiwenhou/python-notes
/generator/test.py
1,062
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ 通过列表生成式,我们可以直接创建一个列表。但是,受到内存限制,列表容量肯定是有限的。 在Python中,这种一边循环一边计算的机制,称为生成器:generator。 第一种方法很简单,只要把一个列表生成式的[]改成(),就创建了一个generator 定义generator的另一种方法。如果一个函数定义中包含yield关键字,那么这个函数就不再是一个普通函数,而是一个generator: """ g = (x*x for x in range(1, 11)) print type(g) for n in g: print n ...
false
c781d941c5b21e8476a0a3a22c58fca13c835d3f
supremepoison/python
/Day16/Code/test_yield.py
931
4.21875
4
# 写一个生成器函数 myeven(start, stop) 用来生成从 start 开始到stop 结束区间内的一些列偶数(不包含stop) # 如: # def myeven(start, stop): # ... # evens = list(myeven(10,20)) # print(evens) [10,12,14,16,18] # for x in myeven(5,10): # ...
false
d9f32b00f9bcaec443b3fc22b1f239333bfb26a3
peterpfand/aufschrieb
/higher lower.py
413
4.65625
5
string_name.lower() #to lower a string .higher() #to higher a string #example: email = input("What is your email address?") print(email) final_email = email.lower() print(final_email) string_name.isLower() #to check if a string id written in lowercase letters .ishigher() #to check...
true
ad26db5b5d0e3e5b8c73c190b88db85b16c8fa3c
sawaseemgit/AppsUsingDictionaries
/PollingApp.py
1,596
4.21875
4
print('Welcome to Yes/No polling App') poll = { 'passwd': 'acc', } yes = 0 no = 0 issue = input('What is the Yes/No issue you will be voting on today: ').strip() no_voters = int(input('What is number of voters you want to allow: ')) repeat = True while repeat: for i in range(no_voters): fname = input(...
true
99a2a83c7059b61e14c054e650e4bb1c221047cd
iroro1/PRACTICAL-PYTHON
/PRACTICAL-PYTHON/09 Guessing Game One.py
699
4.25
4
# Generate a random number between 1 and 9 (including 1 and 9). Ask the user to guess the number, then tell them whether they guessed too low, too high, or exactly right. import random numGuess= 0 a = random.randint(1,9) end= 1 while (end != 0) or (end != 0): guess = input('Guess a number : ') guess = int(gues...
true
f033cc8e82f2692f55b1531159229168fdb638b9
iroro1/PRACTICAL-PYTHON
/PRACTICAL-PYTHON/12 List Ends.py
293
4.125
4
# Write a program that takes a list of numbers (for example, a = [5, 10, 15, 20, 25]) and makes a new list of only the first and last elements of the given list. def rand(): import random return random.sample(range(5, 25), 5) a= rand() print(a) newList = [a[0],a[-1]] print(newList)
true
63f22070edd727c7652ae1c6c930a3443d95710b
lynn-study/python
/seq_op.py
1,249
4.125
4
#!/usr/bin/python x = [1, 2, 3] print x print x[1] = 4 print x print del x[1] print x print name = list('perl') print name name[2:] = list('ar') print name name_1 = list('perl') print name_1 name_1[1:] = list('ython') print name_1 print numbers = [1, 5] print numbers numbers[1:1] = [2, 3, 4] print number...
false
6ad663e24007cbf743411b9389d75205cc201152
mattdelblanc/Mypythonscripts
/iflelse.py
278
4.21875
4
number = 15 if number % 2 == 0: print ('Number is divisible by 2') elif number % 3 == 0: print('Number is divisible by 3') elif number % 4 == 0: print('Number is divisible by 4') elif number % 5 == 0: print('Number is divisible by 5')
false
1972fc4c6f7e307acfa496ab9cde6a56410a10c7
mattdelblanc/Mypythonscripts
/nestedloops.py
359
4.4375
4
number = 45 if number % 2 == 0: print('Number is even number') if number % 3 == 0: print('number is also divisible by 3') else: print('number is not divisible by 3') else: print('Number is odd number') if number % 5 == 0: print('number is divisible by 5') else: print('number ...
false
a25fba2603e9632a90dc18a1a01f772bce2cace2
Yuhta28/TestPJ
/Sets_in_Python.py
653
4.25
4
# Set example x = set(["Posted", "Radio", "Telegram", "Radio"]) # A set may not contain the same element multiple times. print(x) # Set Method # Clear elements y = set(["Posted", "Rao", "Teram", "Rdio"]) y.clear() print(y) # Add elements z = set(["Posted", "Rao", "Teram", "Rdio"]) z.add("AAQWER") print(z) # Remove el...
false
a186fe5f3f8b658705509fbf443dc7fcb7605db5
Ghoochannej/Python-Projects
/calculadora/calc.py
550
4.125
4
from funcoes import soma, subtracao, divisao, multiplicacao if __name__ == '__main__': valor01 = float(input('Digite o primeiro valor ')) valor02 = float(input('Digite o segundo valor ')) operacao = input('Digite a operação ') if operacao == '+': resultado = soma(valor01, valor02) elif operacao == '-': res...
false
cfa6497baa42d0662b46188a4460d47c28e878aa
LemonTre/python_work
/Chap09/eat_numbers.py
1,166
4.15625
4
class Restaurant(): def __init__(self,restaurant_name,cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type self.number_served = 0 def describe_restaurant(self): print("The name of restaurant is: " + self.restaurant_name.title() + ".") print("The type of restaurant is " + s...
true
a787c4e2a01b88818289586d13c7332a12d8868f
omkar1117/pythonpractice
/file_write.py
993
4.3125
4
fname = input("Enter your First name:") lname = input("Enter your Last name:") email = input("Enter your Email:") if not fname and not lname and not email: print("Please enter all the details:") elif fname and lname and not email: print("Please enter a valid email") elif email and fname and not lname: pr...
true