blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
7a26e4bc77d34fd19cf4350c78f4764492d32064
venkatadri123/Python_Programs
/core_python_programs/prog83.py
250
4.25
4
# Retrive only the first letter of each word in a list. words=['hyder','secunder','pune','goa','vellore','jammu'] lst=[] for ch in words: lst.append(ch[0]) print(lst) # To convert into List Comprehension. lst=[ch[0] for ch in words] print(lst)
true
b1c41d7bfbc80bdd15642bcb0f02291c7867779e
ProgrammingForDiscreteMath/20170830-bodhayan
/code.py
700
4.15625
4
# 1 # Replace if-else with try-except in the the example below: def element_of_list(L,i): """ Return the 4th element of ``L`` if it exists, ``None`` otherwise. """ try: return L[i] except IndexError: return None # 2 # Modify to use try-except to return the sum of all numbers in L, ...
true
b6834d2bf0af216c26a7a2b92880ab566685caea
planetblix/learnpythonthehardway
/ex16.py
1,436
4.40625
4
#/bin/python from sys import argv script, filename = argv print "We're going to erase %r." % filename print "If you don't want that, hit CTRL-C (^C)." print "If you do want that, hit RETURN." raw_input("?") print "Open the file..." #rw doesn't mean read and write, it just means read! #You could open the file twice...
true
9522b6a465c1644ff8399a838eb3a7fb3b9cbcec
seriouspig/homework_week_01_day_01
/precourse_recap.py
566
4.15625
4
print("Guess the number I'm thinking from 1 to 10, What do you think it is?") guessing = True number_list = [1,2,3,4,5,6,7,8,9,10] import random selected_number = random.choice(number_list) while guessing == True: answer = int(input('Pick a number from 1 to 10: ')) if answer == selected_number: prin...
true
961b6639cb292351bff3d4ded8c366ab0d860ed8
IshaqNiloy/Any-or-All
/main (1).py
980
4.25
4
def is_palindromic_integer(my_list): #Checking if all the integers are positive or not and initializing the variable is_all_positive = all(item >= 0 for item in my_list) #Initializing the variable is_palindrome = False if is_all_positive == True: for item in my_list: #Converting...
true
de3f02e8416760c40ab208ff7ee372313040fcd1
bishal-ghosh900/Python-Practice
/Practice 1/main30.py
992
4.1875
4
# Sieve of Eratosthenes import math; n = int(input()) def findPrimes(n): arr = [1 for i in range(n+1)] arr[0] = 0 arr[1] = 0 for i in range(2, int(math.sqrt(n)) + 1, 1): if arr[i] == 1: j = 2 while j * i <= n: arr[j*i] = 0 j += 1 for i...
true
eaadca4eda12fc7af10c3a6f70437a760c14358f
bishal-ghosh900/Python-Practice
/Practice 1/main9.py
595
4.6875
5
# Logical operator true = True false = False if true and true: print("It is true") # and -> && else: print("It is false") # and -> && # Output --> It is true if true or false: print("It is true") # and -> || else: print("It is false") # and -> || # Output --> It is true if true and not true: ...
true
460ea4d25a2f8d69e8e009b70cdec588b8ca7b20
bishal-ghosh900/Python-Practice
/Practice 1/main42.py
782
4.28125
4
# set nums = [1, 2, 3, 4, 5] num_set1 = set(nums) print(num_set1) num_set2 = {4, 5, 6, 7, 8} # in set there is not any indexing , so we can't use expression like num_set1[0]. # # Basically set is used to do mathematics set operations #union print(num_set1 | num_set2) # {1, 2, 3, 4, 5, 6, 7, 8} # intersection pr...
true
789e675cb561a9c730b86b944a0a80d6c423f475
bishal-ghosh900/Python-Practice
/Practice 1/main50.py
804
4.75
5
# private members # In python there we can prefix any data member with __ (dunder sign) , then it will be private. In reality it don't get private, if we declare any data member with __ , that data member actually get a differet name from python , which is like => _classname__fieldname. So in the below implementation...
true
c35759cf6ddf382cd6ec14e90bd013707af13fd6
learninfo/pythonAnswers
/Task 5 - boolean.py
236
4.375
4
import turtle sides = int(input("number of sides")) while (sides < 3) or (sides > 8) or (sides == 7): sides = input("number of sides") for count in range(1, sides+1): turtle.forward(100) turtle.right(360/sides)
true
a8a5edf3c6cf3f5a6470016eb6c5802e18df4338
bharath-acchu/python
/calci.py
899
4.1875
4
def add(a,b): #function to add return (a+b) def sub(a,b): return (a-b) def mul(a,b): return (a*b) def divide(a,b): if(b==0): print("divide by zero is not allowed") return 0 else: return (a/b) print('\n\t\t\t SIMPLE...
true
49629b071964130f6fb9034e96480f7b5a179e51
aakhriModak/assignment-1-aakhriModak
/01_is_triangle.py
2,117
4.59375
5
""" Given three sides of a triangle, return True if it a triangle can be formed else return False. Example 1 Input side_1 = 1, side_2 = 2, side_3 = 3 Output False Example 2 Input side_1 = 3, side_2 = 4, side_3 = 5 Output True Hint - Accordingly to Triangle inequality theorem, the sum of any two sides of a triangl...
true
5097aa5c089e31d239b06bbd76e99942694cbdd7
CBehan121/Todo-list
/Python_imperative/todo.py
2,572
4.1875
4
Input = "start" wordString = "" #intializing my list while(Input != "end"): # Start a while loop that ends when a certain inout is given Input = input("\nChoose between [add], [delete], [show list], [end] or [show top]\n\n") if Input == "add": # Check if the user wishes to add a new event/task to the list check...
true
813e9e90d06cb05c93b27a825ac14e5e96abcc9b
bparker12/code_wars_practice
/squre_every_digit.py
520
4.3125
4
# Welcome. In this kata, you are asked to square every digit of a number. # For example, if we run 9119 through the function, 811181 will come out, because 92 is 81 and 12 is 1. # Note: The function accepts an integer and returns an integer def square_digits(num): dig = [int(x) **2 for x in str(num)] dig...
true
f9b9cc936f7d1596a666d0b0586e05972e94cefa
jamiekiim/ICS4U1c-2018-19
/Working/practice_point.py
831
4.375
4
class Point(): def __init__(self, px, py): """ Create an instance of a Point :param px: x coordinate value :param py: y coordinate value """ self.x = px self.y = py def get_distance(self, other_point): """ Compute the distance between the...
true
318a80ce77b542abc821fa8ff2983b0760da2838
aaronstaclara/testcodes
/palindrome checker.py
538
4.25
4
#this code will check if the input code is a palindrome print('This is a palindrome checker!') print('') txt=input('Input word to check: ') def palindrome_check(txt): i=0 j=len(txt)-1 counter=0 n=int(len(txt)/2) for iter in range(1,n+1): if txt[i]==txt[j]: counte...
true
f0754dfa5777cd2e69afa26e2b73b216d0ff5313
sb1994/python_basics
/vanilla_python/lists.py
346
4.375
4
#creating lists #string list friends = ["John","Paul","Mick","Dylan","Jim","Sara"] print(friends) #accessing the index print(friends[2]) #will take the selected element and everyhing after that print(friends[2:]) #can select a range for the index print(friends[2:4]) #can change the value at specified index friends[...
true
1deb78c1b1af35d46bf3fef07643a25ba7a1c5f1
naveen882/mysample-programs
/classandstaticmethod.py
2,569
4.75
5
""" Suppose we have a class called Math then nobody will want to create object of class Math and then invoke methods like ceil and floor and fabs on it.( >> Math.floor(3.14)) So we make them static. One would use @classmethod when he/she would want to change the behaviour of the method based on which subclass is call...
true
fc8bde15b9c00120cb4d5b19920a58e288100686
CHemaxi/python
/003-python-modules/008-python-regexp.py
2,984
4.34375
4
""" MARKDOWN --- Title: python iterators and generators MetaDescription: python regular, expressions, code, tutorials Author: Hemaxi ContentName: python-regular-expressions --- MARKDOWN """ """ MARKDOWN # PYTHON REGULAR EXPRESSIONS BASICS * Regular Expressions are string patterns to search in other strings * PYTHON Re...
true
bcd7c3ee14dd3af063a6fea74089b02bade44a1c
hussein343455/Code-wars
/kyu 6/Uncollapse Digits.py
729
4.125
4
# ask # You will be given a string of English digits "stuck" together, like this: # "zeronineoneoneeighttwoseventhreesixfourtwofive" # Your task is to split the string into separate digits: # "zero nine one one eight two seven three six four two five" # Examples # "three" --> "three" # "eightsix" ...
true
64e73cb395d25b53a166a6e491e70a7834c96aee
sajjadm624/Bongo_Python_Code_Test_Solutions
/Bongo_Python_Code_Test_Q_3.py
2,330
4.1875
4
# Data structure to store a Binary Tree node class Node: def __init__(self, data, left=None, right=None): self.data = data self.left = left self.right = right # Function to check if given node is present in binary tree or not def isNodePresent(root, node): # base case 1 ...
true
92156b23818ebacfa3138e3e451e0ed11c0dd343
brianspiering/project-euler
/python/problem_025.py
1,139
4.375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Solution to "1000-digit Fibonacci number", Problem 25 http://projecteuler.net/problem=25 The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 F6...
true
5448d28db97a609cafd01e68c875affe1f97723c
brianspiering/project-euler
/python/problem_004.py
992
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Solution to "Largest palindrome product", aka Problem 4 http://projecteuler.net/problem=4 A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the...
true
bd009da4e937a9cfc1c5f2e7940ca056c1969ae5
brianspiering/project-euler
/python/problem_024.py
1,489
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Solution to "Lexicographic permutations", Problem 24 http://projecteuler.net/problem=24 A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or...
true
5e2ae02f6553cbe7c31995ba76abf564c596d346
serenechen/Py103
/ex6.py
767
4.28125
4
# Assign a string to x x = "There are %d types of people." % 10 # Assign a string to binary binary = "binary" # Assign a string to do_not do_not = "don't" # Assign a string to y y = "Those who knows %s and those who %s." % (binary, do_not) # Print x print x # Print y print y # Print a string + value of x print "I sai...
true
dc66d84ad39fb2fe87895ca376652e9d95781326
amshapriyaramadass/learnings
/Hackerrank/Interviewkit/counting_valley.py
789
4.25
4
#!/bin/python3 import math import os import random import re import sys # # Complete the 'countingValleys' function below. # # The function is expected to return an INTEGER. # The function accepts following parameters: # 1. INTEGER steps # 2. STRING path #Sample Input # #8 #UDDDUDUU #Sample Output #1 # def cou...
true
35775689bab1469a42bae842e38963842bf54016
scottherold/python_refresher_8
/ExceptionHandling/examples.py
731
4.21875
4
# practice with exceptions # user input for testing num = int(input("Please enter a number ")) # example of recursion error def factorial(n): # n! can also be defined as n * (n-1)! """ Calculates n! recursively """ if n <= 1: return 1 else: return n * factorial(n-1) # try/except (if ...
true
8923477b47a2c2d283c5c4aba9ac797c589fbf7e
nobin50/Corey-Schafer
/video_6.py
1,548
4.15625
4
if True: print('Condition is true') if False: print('Condition is False') language = 'Python' if language == 'Python': print('It is true') language = 'Java' if language == 'Python': print('It is true') else: print('No Match') language = 'Java' if language == 'Python': print('It is Python') ...
true
e8893f7e629dede4302b21efee92ff9030fe7db2
Piper-Rains/cp1404practicals
/prac_05/word_occurrences.py
468
4.25
4
word_to_frequency = {} text = input("Text: ") words = text.split() for word in words: frequency = word_to_frequency.get(word, 0) word_to_frequency[word] = frequency + 1 # for word, count in frequency_of_word.items(): # print("{0} : {1}".format(word, count)) words = list(word_to_frequency.keys()) words.s...
true
6abf00b079ceab321244dbe606f05bac9a347be0
siva237/python_classes
/Decorators/func_without_args.py
1,331
4.28125
4
# Decorators: # ---------- # * Functions are first class objects in python. # * Decorators are Higher order Functions in python # * The function which accepts 'function' as an arguments and return a function itslef is called Decorator. # * Functions and classes are callables as the can be called explicitly. # def hel...
true
39a9ed0ca6f8ce9095194deb21f2c685cfcb079c
mantrarush/InterviewPrep
/InterviewQuestions/SortingSearching/IntersectionArray.py
1,037
4.21875
4
""" Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. Note: Each element in the result should appear as many times as it shows in both arrays. The result can be in any order. Follow up: What if the given array is already sorted? How w...
true
66da83e7687f9d598add37baee9aecf6ff44c10a
shfhm/Practice-Python
/Check Power of 2.py
226
4.40625
4
#function that can determine if an input number is a power of 2 import math def sqrtt(x): i=math.sqrt(x) if i**2==x: print('the input is power 2 of %s' %(i) ) else: print('it\'s not the power 2')
true
2e70910939fedcde1d3c98da05618a8ff871abd0
diego-ponce/code_snippets
/code_challenges/sort_stack.py
1,380
4.15625
4
def pop_until(fromstack, tostack, val): ''' pops from fromstack onto tostack until val is greater than the last value popped. Returns the count of items popped. ''' count = 0 while fromstack: if fromstack[-1] < val: return count pop_val = fromstack.pop() tosta...
true
a54f2d23123a452a9a4b4ed7be2e1ea6cebf4b5b
emmadeeks/CMEECourseWork
/Week2/Code/lc1.py
2,225
4.65625
5
#!/usr/bin/env python3 #Author: Emma Deeks ead19@imperial.ac.uk #Script: lc1.py #Desc: List comprehensions compared to for loops #Arguments: No input #Outputs: Three lists containing latin names, common names and mean body masses for each species of birds in a given list of birds #Date: Oct 2019 # Creates a list o...
true
3e953d2ae7128c97dcdad05b1f4dd97cbd58f77d
emmadeeks/CMEECourseWork
/Week2/Sandbox/comprehension_test.py
1,903
4.46875
4
## Finds list those taxa that are oak trees from a list of species #There is a range of 10 and i will run throough the range and print the numbers- remember it starts from 0 x = [i for i in range(10)] print(x) #Makes an empty vector (not vector LIST) called x and fils it by running through the range 10 and appendin...
true
0cca2868af0d5c598552626a20bdd749e57e2364
emmadeeks/CMEECourseWork
/Week2/Code/oaks.py
1,565
4.59375
5
#!/usr/bin/env python3 #Author: Emma Deeks ead19@imperial.ac.uk #Script: oaks.py #Desc: Uses for loops and list comprehensions to find taxa that are oak trees from a list of species. #Arguments: No input #Outputs: Oak species from list #Date: Oct 2019 """ Uses for loops and list comprehensions to find taxa that are ...
true
d3ec3a217a17c9ab7963663f0db285dfd80945e7
carinasauter/D04
/D04_ex00.py
2,018
4.25
4
#!/usr/bin/env python # D04_ex00 # Create a program that does the following: # - creates a random integer from 1 - 25 # - asks the user to guess what the number is # - validates input is a number # - tells the user if they guess correctly # - if not: tells them too high/low # - only lets th...
true
098556b0003a35c50a5631496c5d24c38a7c3e12
CODEvelopPSU/Lesson-4
/pythonTurtleGame.py
1,176
4.5
4
from turtle import * import random def main(): numSides = int(input("Enter the number of sides you want your shape to have, type a number less than 3 to exit: ")) while numSides >= 3: polygon(numSides) numSides = int(input("Enter the number of sides you want your shape to have, type a ...
true
d62805b6544a217f531eaf387853a7120c479d3f
ArturAssisComp/ITA
/ces22(POO)/Lista1/Question_7.py
1,115
4.125
4
''' Author: Artur Assis Alves Date : 07/04/2020 Title : Question 7 ''' import sys #Functions: def sum_of_squares (xs): ''' Returns the sum of the squares of the numbers in the list 'xs'. Input : xs -> list (list of integers) Output: result -> integer ''' ...
true
590591e904740eb57a29c07ba3cf812ac9d5e921
ArturAssisComp/ITA
/ces22(POO)/Lista1/Question_4.py
1,580
4.15625
4
''' Author: Artur Assis Alves Date : 07/04/2020 Title : Question 4 ''' import sys #Functions: def sum_up2even (List): ''' Sum all the elements in the list 'List' up to but not including the first even number (Is does not support float numbers). Input : List -> list (list of...
true
b74253bc3566b35a29767cc23ceb5254cb303441
MailyRa/calculator_2
/calculator.py
1,093
4.125
4
"""CLI application for a prefix-notation calculator.""" from arithmetic import (add, subtract, multiply, divide, square, cube, power, mod, ) print("Welcome to Calculator") #ask the user about the equation def calculator_2(): user_input = (input(" Type your equation ")) num = use...
true
6a9febac0dcf6886c3337991eb7c5dde84ee281b
pdhawal22443/GeeksForGeeks
/GreaterNumberWithSameSetsOFDigit.py
2,055
4.15625
4
'''Find next greater number with same set of digits Given a number n, find the smallest number that has same set of digits as n and is greater than n. If n is the greatest possible number with its set of digits, then print “not possible”. Examples: For simplicity of implementation, we have considered input number as a ...
true
52fc107624d46f57e2b99394196053e444eb7136
PawelKapusta/Python-University_Classes
/Lab8/task4.py
387
4.15625
4
import math def area(a, b, c): if not a + b >= c and a + c >= b and b + c >= a: raise ValueError('Not valid triangle check lengths of the sides') d = (a + b + c) / 2 return math.sqrt(d * (d - a) * (d - b) * (d - c)) print("Area of triangle with a = 3, b = 4, c = 5 equals = ", area(3, 4, 5)) print("Area o...
true
849402be8f503d46883dc5e8238821566b33598b
Rajatku301999mar/Rock_Paper_Scissor_Game-Python
/Rock_paper_scissor.py
2,350
4.21875
4
import random comp_wins=0 player_wins=0 def Choose_Option(): playerinput = input("What will you choose Rock, Paper or Scissor: ") if playerinput in ["Rock","rock", "r","R","ROCK"]: playerinput="r" elif playerinput in ["Paper","paper", "p","P","PAPER"]: playerinput="p" elif playerinput i...
true
866df365ca6ec790f67224b2208e90eca5eeb811
vaamarnath/amarnath.github.io
/content/2011/10/multiple.py
665
4.125
4
#!/usr/bin/python import sys def checkMultiple(number) : digits = {"0":0, "1":0, "2":0, "3":0, "4":0, "5":0, "6":0, "7":0, "8":0, "9":0} while number != 0 : digit = number % 10 number = number / 10 digits[str(digit)] += 1 distinct = 0 for i in range(0, 10) : if digi...
true
7cee4713aa67c45851d8ac66e6900c25c95ccef1
UCMHSProgramming16-17/final-project-shefalidahiya
/day05/ifstatement2.py
366
4.375
4
# Create a program that prints whether a name # is long name = "Shefali" # See if the length of the name counts as long if len(name) > 8: # If the name is long, say so print("That's a long name") # If the name is moderate elif len(name) < 8: print("That's a moderate name") # If the name is short else l...
true
1a9dea57415668bf56fd5e0b0193952a1af49e27
freaking2012/coding_recipes
/Python/LearnBasics/HashPattern2.py
365
4.3125
4
''' This program takes input a even number n. Then it prints n line in the following pattern For n = 8 ## #### ###### ######## ######## ###### #### ## ''' n=input("Enter number of lines in patter (should be even): ") for i in range(1,n/2+1): print (' ' * (n/2-i)) + ('##' * i) for i in range(1,n/2+1): ...
true
4ca634a62c46930073c67fbb01bea13796de8edb
leoP0/OS1
/Small Python/mypython.py
1,376
4.1875
4
#Python Exploration #CS344 #Edgar Perez #TO RUN IT JUST DO: 'python mypython.py' (whitout the ' ') #Modules import random import string import os import io #function that generates random lowercase leters given a range def random_char(y): return ''.join(random.choice(string.ascii_lowercase) for x in range(y)) #cre...
true
b6f5c5dc5b1c4703650b0e12ba82517d237c92ea
SanjayMarreddi/Open-CV
/Object_Detection/1.Simple_Thresholding.py
2,452
4.375
4
# Now we are focused on extracting features and objects from images. An object is the focus of our processing. It's the thing that we actually want to get, to do further work. In order to get the object out of an image, we need to go through a process called segmentation. # Segmentation can be done through a variety ...
true
dddf7daa3fd9569dbeb61fdba7f39f070aa4be39
Ironkey/ex-python-automatic
/Chapter 01-02/Hello World.py
597
4.21875
4
# This program says hello and asks for my name. print('Hello wolrd!') print ('What is your name?') # ask for their name myName = input() print('It is good to meet you, ' + myName) print('The Length of your name is:') print(len(myName)) print('What is your age?') # ask for their age myAge = input() print('You will be...
true
4c69bf913b87c5c3373368d83464ecd9e49e9184
mennonite/Python-Automation
/Chapter 8 -- Reading and Writing Files/Practice Projects/madlibs_Regex.py
920
4.25
4
#! python3 # madlibs_Regex.py - opens and reads a text file and lets the user input their own words (solved using REGEX) import re # open text file madlibFile = open('.\\Chapter 8 -- Reading and Writing Files\\Practice Projects\\test.txt') # save the content of the file into a variable content = madlibFile.read() m...
true
cb5a0fa4c5e15ece58b25f8a0fedb9fb56f26c5f
rohitprofessional/test
/f_string.py
386
4.4375
4
letter = "Hey my name is {1} and I am from {0}" country = "India" name = "Rohit" print(letter.format(country, name)) print(f"Hey my name is {name} and I am from {country}") print(f"We use f-strings like this: Hey my name is {{name}} and I am from {{country}}") price = 49.09999 txt = f"For only {price:.2f} doll...
true
f9d5c0e1ab4ec959bb7988e185c83b2ba49a23a5
rohitprofessional/test
/PRACTICE/stop_watch.py
534
4.125
4
#---------------STOP WATCH-------- import time time_limit = int(input("Enter the stopwatch time.: ")) # hours = int(time_limit/3600) # minutes = int(time_limit/60) % 60 # seconds = (time_limit) % 60 # print(hours,minutes,seconds) for x in range(time_limit,0,-1): seconds = (x) % 60 minutes = i...
true
608257fd5528026be5797f7ca712d9328ca7382b
rohitprofessional/test
/CHAPTER 01/localVSglobal_variable.py
1,353
4.5
4
# It is not advisable to update or change the global variable value within in a local block of code. As it can lead to complexity # in the program. But python provides a global keyword to do so if you want to. # Although it is also not advisable to use global variable into a local function. It is a maintainable progr...
true
e49eb95627c1f9262aad83447236cc085a6f5afd
rohitprofessional/test
/CHAPTER 07/intro to for loops.py
1,151
4.375
4
# -------------------- FOR LOOP UNDERSTANDING ------------------------------- '''So here we range is a function w/c helps compiler to run the for loop. Return an object that produces a sequence of integers from start (inclusive) to stop (exclusive) by step. range(i, j) produces i, i+1, i+2, ..., j-1. start defa...
true
37940d1160cc5a78595a58676589eca91d3d7fdc
AlanaMina/CodeInPlace2020
/Assignment1/TripleKarel.py
1,268
4.28125
4
from karel.stanfordkarel import * """ File: TripleKarel.py -------------------- When you finish writing this file, TripleKarel should be able to paint the exterior of three buildings in a given world, as described in the Assignment 1 handout. You should make sure that your program works for all of the Triple sample w...
true
3da0242e36ee059b8471559ae4491a435b90e234
AlanaMina/CodeInPlace2020
/Assignment5/word_guess.py
2,881
4.1875
4
""" File: word_guess.py ------------------- Fill in this comment. """ import random LEXICON_FILE = "Lexicon.txt" # File to read word list from INITIAL_GUESSES = 8 # Initial number of guesses player starts with def play_game(secret_word): """ Add your code (remember to delete the "pass" below) """ ...
true
4f06365db3bb2fdfa5e6c62e722e03f1ca916a7b
twillis209/algorithmsAndDataStructures
/arraySearchAndSort/insertionSort/insertionSort.py
422
4.125
4
def insertionSort(lst): """ Executes insertion sort on input. Parameters ---------- lst : list List to sort. Returns ------- List. """ if not lst: return lst sortedLst = lst[:] i = 1 while i < len(sortedLst): j = i - 1 while j >= 0 and sortedLst[j] > sortedLst[j+1]: temp = sortedLst[...
true
18290f2b984ca71bdbc4c147ec052ba17e246ad0
twillis209/algorithmsAndDataStructures
/arraySearchAndSort/timsort/timsort.py
1,029
4.25
4
import pythonCode.algorithmsAndDataStructures.arraySearchAndSort.insertionSort as insertionSort def timsort(): pass def reverseDescendingRuns(lst): """ Reverses order of descending runs in list. Modifies list in place. Parameters --------- lst : list List to sort. Returns ------- List. """ runStack...
true
df296049dd2cd2d136f15afdf3d8f1ebec49871d
wulianer/LeetCode_Solution
/062_Unique_Paths.py
902
4.25
4
""" A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). How many possible unique paths are there? Ab...
true
fb10a2f3e98da33e6f5cbbe1f1d08f41dc452855
vincenttchang90/think-python
/chapter_1/chapter_1_exercises.py
1,190
4.375
4
#chapter 1 exercises #1-1 # In a print statement, what happens if you leave out one of the parentheses, or both? ## print 'hello') or print('hello' return errors # If you are trying to print a string, what happens if you leave out one of the quotation marks, or both? ## print('hello) or print(hello') return errors wh...
true
526886cff12e987b705d2443cd0bc1741a552f36
bharatanand/B.Tech-CSE-Y2
/applied-statistics/lab/experiment-3/version1.py
955
4.28125
4
# Code by Desh Iyer # TODO # [X] - Generate a random sample with mean = 5, std. dev. = 2. # [X] - Plot the distribution. # [X] - Give the summary statistics import numpy as np import matplotlib.pyplot as plt import random # Input number of samples numberSamples = int(input("Enter number of samples in the sample lis...
true
c5d76587c717609f3a2f3da3a9136f92b3fee367
bmgarness/school_projects
/lab2_bmg74.py
755
4.125
4
seconds = int(input('Enter number of seconds to convert: ')) output = '{} day(s), {} hour(s), {} minute(s), and {} second(s).' secs_in_min = 60 secs_in_hour = secs_in_min * 60 # 60 minutes per hour secs_in_day = secs_in_hour * 24 # 24 hours per day days = 0 hours = 0 minutes = 0 if seconds >= secs_in_day: days ...
true
ec32d18f39290dc135c190a49764ae585be27ccd
ayeshaghoshal/learn-python-the-hard-way
/ex14.py
1,252
4.5
4
# -*- coding: utf-8 -*- print "EXERCISE 14 - Prompting and Passing" # Using the 'argv' and 'raw_input' commands together to ask the user something specific # 'sys' module to import the argument from from sys import argv # define the number of arguments that need to be defined on the command line script, ...
true
8c787b221b005f2f997f7d927a008d3ff9fa1514
ayeshaghoshal/learn-python-the-hard-way
/ex19.py
2,520
4.40625
4
# -*- coding: utf-8 -*- print "EXERCISE 19 - Functions and Variables" # defining the function that commands the following strings to be printed out # there are 2 parameters that have to be defined in brackets def cheese_and_crackers(cheese_count, boxes_of_crackers): # use of the parameters is the same method ...
true
cce19d5079460040e6174142d487e9fac7a22adf
jamesfeng1994/ORIE5270
/HW2/tree/tree_print.py
2,454
4.15625
4
class Tree(object): def __init__(self, root): self.root = root def get_depth(self, current, n): """ This function is to get the depth of the tree using recursion parameters: current: current tree node n: current level of the tree return: the dept...
true
180595fd0f78376e8b9d3da6af980876a743fcda
Vandeilsonln/Python_Automate_Boring_Stuff_Exercises
/Chapter-9_Organizing-Files/selective_copy.py
1,268
4.125
4
#! python3 # selective_copy.py - Once given a folder path, the program will walk through the folder tree # and will copy a specific type of file (e.g. .txt or .pdf). They will be copied to a new folder. import os, shutil def copy_files(folderPath, destinyPath, extension): """ Copy files from 'folderPath' to ...
true
26d42973cb952c3c2af0cddba3d4772c34b2d788
Liam-Hearty/ICS3U-Unit2-03-Python
/circumference_finder.py
493
4.625
5
#!/usr/bin/env python3 # Created by: Liam Hearty # Created on: September 2019 # This program will calculate the circumference of a determined circle radius. import constants def main(): # this function will calculate the circumference # input radius = int(input("Enter the radius of circle (mm): ")) ...
true
94a97edaa66c9527fc133ec3c33386a5410968ba
biradarshiv/Python
/CorePython/24_String_Formatting.py
1,464
4.46875
4
""" The format() method allows you to format selected parts of a string. Sometimes there are parts of a text that you do not control, maybe they come from a database, or user input? To control such values, add placeholders (curly brackets {}) in the text, and run the values through the format() method: """ print("# Fi...
true
a36c60c380517b1e6b6d146669e9b93cf797fbcd
biradarshiv/Python
/CorePython/13_ClassObject.py
2,393
4.25
4
""" Python is an object oriented programming language. Almost everything in Python is an object, with its properties and methods. A Class is like an object constructor, or a "blueprint" for creating objects. """ print("# Create a class and access a property in it") class MyClass: x = 5 print(MyClass) p1 = MyClass() p...
true
47846eb1a2b8b5db15f5f7262ae51e15973eb75b
oxfordni/python-for-everyone
/examples/lesson2/4_exercise_1.py
372
4.21875
4
# Determine the smallest number in an unordered list unordered_list = [1000, 393, 304, 40594, 235, 239, 2, 4, 5, 23095, 9235, 31] # We start by ordering the list ordered_list = sorted(unordered_list) # Then we retrieve the first element of the ordered list smallest_number = ordered_list[0] # And we print the result ...
true
18ca47e10a0af9166e4366ca61b3a726bbc74454
callmefarad/Python_For_Newbies
/sesions/stringslice.py
756
4.53125
5
# slicing simply means returning a range of character # this is done by using indexing pattern # note when dealing with range the last number is exclusive. # i.e if we are to get the last letter of digit 10, we would have a # range of number tending to 11 where the 11th index is exclusive # declaring my variable my_s...
true
f8ccced9d2f8bf8df346c5f5ff77a1fbc8d32954
callmefarad/Python_For_Newbies
/sesions/rangetype.py
367
4.125
4
# showing range type representation # declaring a variable name range_of_numbers range_of_numbers = range(40) # displaying the range of numbers print("Below shows the range of numbers") print(range_of_numbers) # displaying python representation of the output value print("Below show the python data type representation...
true
b59e530c1b2e7d8275003cde9e1b8bce78d9b43f
callmefarad/Python_For_Newbies
/sesions/membershipin.py
536
4.3125
4
# a membership operator checks if sequence is present in an object # "in" is on of the membership operator # creating a variable named " my_list = ['orange', 'bean', 'banana', 'corn'] print("List of items: ", my_list) # creating a check variable check = "banana" # prints the result print(check in my_list) """" # c...
true
fd0795fd1e3b86ce259b392b644d5ade274655f0
callmefarad/Python_For_Newbies
/sesions/func.py
1,652
4.15625
4
# # declaring a function # def dummy(): # print("this is a dummy print.") # # # callin the function # dummy() # # def add(): # user1 = float(input('Enter your firstnumber: ')) # user2 = float(input('Enter your secondnumber: ')) # sum = user1 + user2 # return sum # # # call the function # add() # x ...
true
05700d145da30b014ab880e5af9be1a13d3a0a98
callmefarad/Python_For_Newbies
/sesions/passwordChecker.py
1,122
4.125
4
# a program that checks if a password is too weak, weak and very strong # defining the function def copywrite(): print("Copywrite: Ubani U. Friday") # main function special_characters = ['!', '^', '@', '#', '$', '%', '&', '*', '(', ')', '_', '+'] special_numbers = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']...
true
67c8770308f34f234d91c330da73e5aefee2a58c
Ilis/dawson
/useless_trivia.py
585
4.125
4
# Useless trivia name = input("Hi! What's your name? ") age = input("How old are you? ") age = int(age) weight = int(input("What is your weight? ")) print() print("If Cammings write you a letter, he write", name.lower()) print("If mad Cammings write you a letter, he write", name.upper()) called = name * 5 print("Kid...
true
d05ab90c27a5d8821c19b17cb48a2dafc78f35bc
GaboUCR/Mit-Introduction-to-python
/ps1/Ps1B.py
848
4.28125
4
total_cost = float(input("Enter the cost of your dream house ")) annual_salary = float(input("enter your annual salary ")) portion_saved= float(input("enter the percentage to be saved ")) semi_annual_raise = float(input("Enter the percentage of your raise")) current_savings = 0 annual_return = 0.04 total_months = 0 por...
true
8111dfc4110b25b75a6d8f4e3e583aa583a54d31
DoughyJoeyD/WorkLog2
/task.py
1,889
4.125
4
from datetime import datetime import os import time #handy script to clean the screen/make the program look nice def clearscreen(): os.system('cls' if os.name == 'nt' else 'clear') #how each task is constructed #name #date of task #time taken #extra notes class Task(): def __init__(self): ...
true
ae9a97b3fb40b8285182bb65d435f836de70ada6
SuryaNMenon/Python
/Functions/timeAndCalendar.py
543
4.21875
4
import calendar,time def localTime(): localtime = time.asctime(time.localtime(time.time())) print(f"Current local time is {localtime}") def displayCalendar(): c = calendar.month(int(input("Enter year: ")),int(input("Enter month: "))) print("The calendar is:\n",c) while(1): choice = int(input("Menu\...
true
8c2bbc0c0175bc8883d9fe65cbca3511dbefd81e
SuryaNMenon/Python
/Other Programs/leapYear.py
217
4.3125
4
#Program if user input year is leap year or not year = int(input('Enter the year')) if(year%4==0 or year%100==0 or year%400==0): print('Given year is a leap year') else: print('Given year is not a leap year')
true
5493d5308b986e4efd6bfed3687712872d76bc35
hyjae/udemy-data-wrangling
/DataCleaning/audit.py
2,698
4.21875
4
""" Observation of types - NoneType if the value is a string "NULL" or an empty string "" - list, if the value starts with "{" - int, if the value can be cast to int - float, if the value can be cast to float, but CANNOT be cast to int. For example, '3.23e+07' should be considered a float because it can be cast ...
true
1df3bc87016ad046ffc4c7a27108e943ae84da27
kalyanrohan/ASSIGNMENTS
/level2excercise.py
1,187
4.6875
5
#LEVEL 2 """ 1.Using range(1,101), make a list containing only prime numbers. """ prime=[x for x in range(2,101) if x%2!=0 and x%3!=0 and x%5!=0 and x%7!=0] print(prime) """ 2.Initialize a 2D list of 3*3 matrix. E.g.- 1 2 3 4 5 6 7 8 9 Check if the matrix is symmetric or not. """ """ 3. Sorting refers to arranging da...
true
1ff75c4685f869eece4ada6af2fb00769e251097
JudgeVector/Projects
/SOLUTIONS/Text/CountVowels.py
636
4.1875
4
""" Count Vowels - Enter a string and the program counts the number of vowels in the text. For added complexity have it report a sum of each vowel found. """ vowels = ['a','e','i','o','u'] vowel_count = [0,0,0,0,0] def count_vowels(s): for i in range(0, len(s)): if s[i] in vowels: for j in range(0, len(vowels))...
true
53cf3eed32f2c405ee56e4b433e3180bc1aa1d77
kju2/euler
/problem033.py
1,362
4.15625
4
""" The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that 49/98 = 4/8, which is correct, is obtained by cancelling the 9s. We shall consider fractions like, 30/50 = 3/5, to be trivial examples. There are exactly four non-trivial examples ...
true
a3940af34ce7d808facbdb0ac67cdbbd17d50a23
xxrom/617_merge_two_binary_trees
/main.py
2,534
4.125
4
# Definition for a binary tree node. class Node: def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right = right def __str__(self): return str(self.__dict__) class Solution: # print all values def printAll(self, root): if root...
true
2d425e371bd59c5a0ad3e6807a239378c5e44a12
jiaoqiyuan/Tests
/Python/python-practice/chapter5-if/toppints.py
1,428
4.25
4
requested_topping = 'mushrooms' if requested_topping != 'anchovies': print("Hold the anchovies!") answer = 17 if answer != 42: print("That is not the correct answer. Please try again!") requested_toppings = ['mushrooms', 'extra cheese'] if 'mushrooms' in requested_toppings: print("Adding mushrooms.") if 'pepperon...
true
9fac6a0305889d4cdbe3bfa868aea21272314850
mmaoga/bootcamp
/helloworld.py
711
4.21875
4
print ("hello, world") print ("hi my name is Dennis Manyara") print("This is my first code") for _ in range(10): print("Hello, World") text = "Hello my world" print(text) text = "My name is Dennis Maoga Manyara" print(text) print("hello\n"*3) name = "Dennis M." print("Hello, World, This is your one and only",n...
true
303fbdd2815a32d580ccd80192cd28da946a2865
Tej-Singh-Rana/Code-War
/code3.py
263
4.15625
4
#!/bin/python3 #reverse !! name=input("Enter the word you want to reverse : ") print(name[::-1],end='') #to reverse infinite not adding value in parameters. print('\n') #print(name[4::-1],end='') #to reverse in max 4 index values. #print('\n')
true
8057729bfad807fc5b23ed68b71e5746af7b26ee
yuuuhui/Basic-python-answers
/梁勇版_4.28rpy.py
949
4.21875
4
x1,y1,w1,h1 = eval(input("Enter r1's x-,y- coordinates,width,and height:")) x2,y2,w2,h2 = eval(input("Enter r2's x-,y- coordinates,width,and height:")) hd12 = abs(x2 - x1) vd12 = abs(y2 - y1) if 0 <= hd12 <= w1 /2 and 0 <= vd12 <= h1 / 2: print("The coordinate of center of the 2nd rect is withi...
true
e174013d66f9135fd27ed24b666eff412b3f49c3
Sarumathikitty/guvi
/codekata/Absolute_Beginner/check_odd_even.py
264
4.5
4
#program to check number whether its odd or even. number=float(input()) num=round(number) #check number whether it is zero if(num==0): print("Zero") #whether the number is not zero check its odd or even elif(num%2==0): print("Even") else: print("Odd")
true
a34a5cf032f82720848d4adaef67d135ad941e4c
pradyotpsahoo/P342_A1
/A1_Q2.py
500
4.46875
4
# find the factorial of a number provided by the user. # taking the input from the user. num = int(input("Enter the number : ")) factorial = 1 # check if the number is negative, positive or zero if num < 0: print("Factorial does not exist for negative numbers. Enter the positive number.") elif num == 0: ...
true
aa9b82d2376bccc0c2ee86a4458901fd1bb42707
SireeshaPandala/Python
/Python_Lesson5/Python_Lesson5/LinReg.py
936
4.15625
4
import numpy as np import matplotlib.pyplot as plt #for plotting the given points x=np.array([2.9,6.7,4.9,7.9,9.8,6.9,6.1,6.2,6,5.1,4.7,4.4,5.8]) #converts the given list into array y=np.array([4,7.4,5,7.2,7.9,6.1,6,5.8,5.2,4.2,4,4.4,5.2]) meanx=np.mean(x) #the meanvalue of x will ...
true
7cb0fe658d8359c299ca1cca662c19c015d7441a
pvaliani/codeclan_karaoke
/tests/song_test.py
714
4.21875
4
import unittest from classes.song import Song class TestSong(unittest.TestCase): def setUp(self): self.song = Song("Beautiful Day", "U2") # - This test determines that a song exists by comparing the object self.song with attribute "name" to the value of "Beautiful Day by U2" # - self.song.name re...
true
f25ecf69bcb1c5f168f74fd923d72b9a53248763
MomSchool2020/show-me-your-cool-stuff-LisaManisa
/Lesson3.py
583
4.15625
4
print("Hello World!") # if you have a line of text that you want to remove, #"comment it out" by adding in a hashtag. # print("Hello World!") # text in Python is always in quotation marks print("Lisa") print("Hello World. Lisa is cool") print("Lisa said, 'I love you'") print('Lisa said, "I love you"') # if you put anyt...
true
821f16b00b90c79867dfbfbf7f93d92d9ce3a23b
agray998/qa-python-assessment-example
/exampleAssessment/Code/example.py
503
4.5625
5
# <QUESTION 1> # Given a string, return the boolean True if it ends in "py", and False if not. Ignore Case. # <EXAMPLES> # endsDev("ilovepy") → True # endsDev("welovepy") → True # endsDev("welovepyforreal") → False # endsDev("pyiscool") → False # <HINT> # What was the name of the function we have seen which change...
true
231b812ebd89cf804f350a03e3ca5d0b11023cb8
TonaGonzalez/CSE111
/02TA_Discount.py
1,162
4.15625
4
# Import the datatime module so that # it can be used in this program. from datetime import datetime # Call the now() method to get the current date and # time as a datetime object from the computer's clock. current = datetime.now() # Call the isoweekday() method to get the day # of the week from the current...
true
fb0055af02a4823c00e6baeaa1c44c3089dacd4a
hovell722/eng-54-python-practice-exercises
/exercise_102.py
610
4.3125
4
# # Create a little program that ask the user for the following details: # - Name # - height # - favourite color # - a secrete number # Capture these inputs # Print a tailored welcome message to the user # print other details gathered, except the secret of course # hint, think about casting your data type. name ...
true
d2d41bc519f79737818c852306c97b988e89ace7
hovell722/eng-54-python-practice-exercises
/exercise_107.py
1,370
4.46875
4
# SIMPLEST - Restaurant Waiter Helper # User Stories #1 # AS a User I want to be able to see the menu in a formated way, so that I can order my meal. #2 # AS a User I want to be able to order 3 times, and have my responses added to a list so they aren't forgotten #3 # As a user, I want to have my order read back to ...
true
12bfab7e083f2b0326e72ec60cd53c42be2dd280
monicajoa/holbertonschool-higher_level_programming
/0x0B-python-input_output/6-from_json_string.py
425
4.15625
4
#!/usr/bin/python3 """This module holds a function From JSON string to Object """ import json def from_json_string(my_str): """function that returns an object (Python data structure) represented by a JSON string Arguments: my_str {[str]} -- string to convert to object Returns: ...
true