blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
7565a69d0c981b85dbd55b8f744c6e94e15c54b5
hajarNasr/Project-Euler
/Problem 20 (sum_factorial_digits)/twenty/__init__.py
393
4.1875
4
from functools import reduce def sum_factorial_digits(num): digits = list(str(factorial(num))) # compute factorial num and convert it to a string to list it into a list of digits return sum([int(i) for i in digits]) # convert items in digits into ints and add them. def factorial(num): return reduce(...
true
768b60609d8c6f86b6464e0ac1c0ebc76f47a32b
ashfaqdotes/python
/Decision Making.py
1,611
4.375
4
# if ,if else in Python:~ # if else statement in use for check conditions. # so First 'if' Statement: a = 5 if a == 5: # ':' colon is use print('Yes its Equal') # Now suppose the condition is false: if a == 6: print('yes its equals') # the Code is Not execute # There will nothing show if...
true
72accd0bb78f7267237ced06941ff9e297a26b54
kun1987/Python
/chapter10_EX7.py
430
4.34375
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- def check(s1, s2): """function to check if two strings are anagram or not it takes two strings and returns True if they are anagrams.""" if(sorted(s1)== sorted(s2)): return True else: return False if __name__ == "__...
true
bb3616abd6b96bbcc9e7510a8087473dae2adc05
kun1987/Python
/chapter6_EX8.py
397
4.125
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- def gcd(a,b): #this functon finds the greatest common divisor (GCD) of a and b. if a == 0 or b == 0: return 0 elif not isinstance(a, int) or not isinstance(b, int): print 'gcd is only defined for integers.' else: r = a % b ...
true
10d2a296cf60c61b5d233aebefdb5845641a1334
kun1987/Python
/chapter5_EX4.py
927
4.28125
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Fri Oct 11 15:10:49 2019 @author: Kun Wang """ def is_triangle(a, b, c): #this function is for check is it able to arrange a triangle with three given sticks #formula:If any of the three lengths is greater than the sum of the other two, #then y...
true
f207372328c9d2174fbfe47a29f79ac43dea4f37
kun1987/Python
/chapter11_EX4.py
624
4.3125
4
#!/usr/bin/env python2 def reverse_lookup_wrong(d, v): #this functionthat takes a value and returns the first key that maps to that value for k in d: if d[k] == v: return k raise ValueError def reverse_lookup_correct(d,v): #this function builds and returns a list of all keys that ma...
true
3bb39be81bb2e698fd2efc1574d71d4baeb3f9e7
paulhendricks/python-cookbook
/ch04/4.3.py
273
4.15625
4
#!/usr/bin/python3 """Creating New Iteration Patterns with Generators Complete! """ def frange(start, stop, increment): x = start while x < stop: yield x x += increment if __name__ == '__main__': for i in frange(0, 10, 3): print(i)
true
aa9707d6a18297f8a00d86dae58f784ddd0e452d
dec880126/NCHU-Evolutionary-Computation
/Homework/binary_tournament_skel.py
1,548
4.1875
4
# # Binary tournament selection experiment # from random import Random import matplotlib.pyplot as plt #A few useful constants # pop_size=20 generations=10 fit_range=40 #Init the random number generator # prng=Random() prng.seed(123) #Let's suppose we have an imaginary problem that generates #integer fitness value...
true
f96c220b481247292cc05d6100fd713238c6e2c4
drs021/codewars-solutions
/Find the odd integer in array of integers lvl 6.py
460
4.25
4
# -*- coding: utf-8 -*- """ Created on Wed Aug 4 15:52:14 2021 @author: David Stoneking """ """Find the odd int Given an array of integers, find the one that appears an odd number of times. There will always be only one integer that appears an odd number of times. """ def find_it(seq): for i in...
true
37cbed5eb1f8da55e1e578c513fc7449ce71ee22
stasi009/TestDrivenLearn
/Python/TestPython3/test_bool.py
946
4.25
4
import unittest ######################################################################## class BoolTest(unittest.TestCase): """test how boolean values are used in python""" def testConjunctionOperators(self): self.assertTrue( (2 < 4) and (5 > 1) ) self.assertTrue( 2 < 3 < 4 )# a simpl...
true
d3020d03c6292159bfab36cb713b98edf783a2a6
stasi009/TestDrivenLearn
/Python/TestPython2/demo_print_input.py
1,294
4.375
4
def demo_print_multiples(): a = 1 b = "stasi" c = 99.9 d = True # print multiple items on one line, seperated by whitespace print(a,b,c,d) def demo_howto_print_oneline(): ################### print in multiple lines for c in ["a","b","c"]: print(c) ################### print...
true
5b6c0699db8267cf287da676f95dd537dfe03e82
prowlett/date_coincidence_checker
/date_coincidence_checker.py
2,355
4.46875
4
""" digit sums for dates in a year Looks at all days over a year starting at start_date_str and sums the digits of the day, month and two-digit year. Reports: - the digit sum for each day in the year; - the number of days in the year matching each digit sum; - a bar chart of digit sums against number of days in the y...
true
2162a7df0998c0ae03efde8d444f6faaebb21d61
intentions/fizzbuzz
/fizzbuzz.py
450
4.34375
4
#python implementation of fizzbuzz #!/usr/local/bin/python def fizzbuzz(max = 100): """ takes in an integer value (default 100) and prints a list, if the number is evenly divisible by 3 then it prints Fizz, otherwise it prints Buzz """ for i in range(1,max): Final = str(i) + " " if i%3 == 0: Final += "Fizz" ...
true
79e8d452cd8683317b668d0419c9d428c10d287d
Balaji751/Must-Do-Coding
/gretgivle.py
228
4.125
4
def great(str,x): s=str.split(" ") for word in s: if len(word)>x: print(word) else: print("No words greater than given length") str=input() x=int(input("Enter the length of word:")) result=great(str,x)
true
a1cc08a7eb64d83c236667c08ec4881183b7d1a4
Balaji751/Must-Do-Coding
/Helloworld/cargame.py
930
4.375
4
# command=input("> ") # if command=="Help" or command=="help": # print("Start - to start the engine") # print("Stop - to stop the engine") # print("quit - to quit") # else: # print("I don't understand that ...") # entered=input() # if entered=="Start": # print("Engine started, Ready to go!") # elif ent...
true
5a958526f8d6a8c1a6a41d313b817ed5a001b4eb
sanketg10/leetcode
/Python/Udacity/Previous/factorial_recursive.py
608
4.34375
4
# Writing a function for the same thing in recursive way -- awesome! def factorial(number): if number <= 1: # always have a base case: thats where it stops return 1 else: return number * factorial(number - 1) number = input('Enter a positive number: ') print "Factorial is: ", factorial(number)...
true
475d6a1db55978a86c62cf7f00928808ec3212c7
LukeZSW/Data_structures_and_Algorithms_with_LeetCode
/math/Permutation_Sequence.py
1,100
4.28125
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- """ @File : Permutation_Sequence.py @Author : Siwen @Time : 2/10/2020 7:37 PM """ """ 60. Permutation Sequence The set [1,2,3,...,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, we get the following sequenc...
true
d62a7f96da67adf700707b229e651dd5de1fcc69
Alphonsbaby/PYTHON-CYCLE-1
/private.py
901
4.25
4
#Create a class Rectangle with private attributes length and width. Overload ‘<’ operator to #compare the area of 2 rectangles. class Rectangle(): def __init__(self, l, w): self.__length = l self.__width = w def area(self): return self.__length*self.__width def __lt__...
true
c950bedb85e14c348d73f0fdd33b79e5c7af2dcc
cmccahil/Classwork
/cs150/lab06/concordance.py
1,743
4.15625
4
#concordance.py #Asks the user for the name of one file. Program opens file and reads it one #line at a time, counting the line numbers. Each word in the line should be #stripped of punctuation, in lower-case, and added to concordance w/ line number #All words that are keys of concordance will be printed in alphabetica...
true
799625de9079961ee7f5f7d3e9185d0af16b0139
Wizdave97/Algorithms-and-Data-Structures
/linked_lists/loop_detection.py
1,412
4.21875
4
class Node: def __init__(self, value): self.value = value self.next = None class LinkedList: def __init__(self, init_list=None): self.head = None if init_list: for value in init_list: self.append(value) def append(self, value): if self.he...
true
3147022996f74dfb4cdd522fe8a400c7265d4ccf
Wizdave97/Algorithms-and-Data-Structures
/P0/Task2.py
1,252
4.15625
4
""" Read file into texts and calls. It's ok if you don't understand how to read files """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 2: Which telephone number spent the ...
true
8b908c8d604ca6426fed4a3728e259dbf167a393
Santhosh-23mj/Joy-Of-Computing-Using-Python
/WEEK 5/ASSIGNMENTS/SemiPrine.py
1,197
4.40625
4
#!/usr/bin/python3 """ A semiprime number is an integer which can be expressed as a product of two distinct primes. For example 15 = 3*5 is a semiprime number but 9 = 3*3 is not . Given an integer number N, find whether it can be expressed as a sum of two semi-primes or not (not necessarily distinct). Input Format: Th...
true
6f97c2f52fab4abc67effe8c5e44446994e63aab
Santhosh-23mj/Joy-Of-Computing-Using-Python
/WEEK 9/ASSIGNMENTS/MaxNumeric.py
502
4.25
4
""" Given an alphanumeric string S, extract maximum numeric value from that string. All the alphabets are in lower case. Take the maximum consecutive digits as a single number. Input Format: The first line contains the string S. Output Format: Print the maximum value Example: Input: 23dsa43dsa98 Output: 98 Explan...
true
431a8c2acf32a6c080dcc035288e31acc0e6bb34
akhileshcheguisthebestintheworld/pythonrooom
/homeworkproblem.py
296
4.25
4
#figure if a word is a palindrome or not word = input("Speak, human.") length = len(word) counter = 0 for i in range(0,(length/2)): if word[i] == word [-i-1]: counter = counter + 1 else: print "Not a palindrome" counter = counter - length break if counter > 0: print "palindrome"
true
b82759ed9bc9e1bbe722e4aa5715e77ec73786ac
Oyekunle-Mark/sherlock-codes
/hour_glass_sum2.py
1,484
4.3125
4
def calculate_hour_glass(arr, position): """Calculates the sum of the hour glass derivable by a position(second argument) from an array(first position) Arguments: arr {list} -- the 6 x 6 matrix position {list} -- the position of the starting point of the hour glass Returns: int -- ...
true
627e652c802ea2abfc7b2611eaeca4357d284b14
Sean81nLA/Projects-in-Python
/PythonForDataAnalysis_week_4_project.py
2,429
4.25
4
#!/usr/bin/env python # coding: utf-8 # # Assignment 4 # # You will need to change the variable `labor_data_path` rto the path of the LaborSheetData.csv on your computer if you want to run this notebook. # In[1]: import pandas as pd # In[4]: # you will need to change the path to a location on your computer if...
true
9b44a34e772eea26e6067696014380c3b4fbd490
ks-99/forsk2019
/week5/day1/iri_class.py
1,567
4.1875
4
""" Q2. This famous classification dataset first time used in Fisher’s classic 1936 paper, The Use of Multiple Measurements in Taxonomic Problems. Iris dataset is having 4 features of iris flower and one target class. The 4 features are SepalLengthCm SepalWidthCm PetalLengthCm PetalWidthCm The target class The flow...
true
d450d48afc464c4ded140f3fdd4ef508e39bd3ef
ks-99/forsk2019
/week 1/day4/imgprocess.py
1,804
4.5
4
""" Code Challenge Name: Image Processing using PIL Filename: imgprocess.py Problem Statement: Given an image, perform image processing operations. Keep only one output image i.e perform all tasks on the same image (override) and print only the name of your output image with extension nam...
true
1e9aa9cebc6ec4172132ccf6f1a4e7ef16d59a74
JujjuruSrikanth/DSA-Assignment
/2_build_binary_tree_from_traversal.py
1,257
4.125
4
class Node: left = right = None def __init__(self,data): self.data = data def build_tree(in_order, post_order): '''Build Unique Binary Tree from In-Order and Post-Order Traversal''' # In-Order is mandatory for building unique tree if in_order is None: return None # Defining sub...
true
18a0539584917bbed1c25a42c846e1a0c65c6a27
sdoering/til
/functions.py
801
4.25
4
def dict_factory(colnames, rows): """ Returns each row as a dict. [...] """ return [dict(zip(colnames, row)) for row in rows] def named_tuple_factory(colnames, rows): """ Returns each row as a namedtuple https://docs.python.org/2/library/collections.html#collections.namedtuple ...
true
1e630c83538adc25a9b48348dd578b874dfef6de
agvaibhav/linked-list
/compare_2-linked_lists.py
1,724
4.21875
4
# Node class class Node: def __init__(self, data): self.data = data self.next = None # Constructor to initialize the node object class LinkedList: # Function to initialize head def __init__(self): self.head = None # Method to print linked list def printList(self): ...
true
b6295e5dcb8a8d0d26b22e3aad54ae463aef01d4
agvaibhav/linked-list
/node-insertion-at-end.py
1,000
4.46875
4
# Node class class Node: # Function to initialize the node object def __init__(self, data): self.data = data # Assign data self.next = None # Initialize next as null # Linked List class class LinkedList: # Function to initialize the Linked List object def __init__(self): ...
true
04088074d50f4d54d9ec55c234cbbfbd8d7cc193
z0t0b/ISMN6656
/Homework/HW4/HW4Q2.py
1,747
4.15625
4
# R4.2a # default values x = 2 sumEven = 0 # stores each even number in x and total sum in SumEven; includes 2 & 100 while (x <= 100): sumEven += x x += 2 # print sum print("a. The sum of all even numbers between 2 and 100 (inclusive) is: " + str(sumEven)) #########################################...
true
78e8b48a6789f9960c71542e1b40649ec057a7a1
Grace-Joydhar/Python-Learning
/Study Mart/7. Operators.py
990
4.125
4
a = "Arithmetic Operator +, -, *, /, %, **, // " print(a) x = 10 y = 3 print(x+y) #addition print(x-y) #Substraction print(x*y) #Multiplication print(x/y) #Division print(x%y) #Modulus (Vagses) print(x**y) #Exponential print(x//y) #Floor Division (Remove Fractional Value b= "\nAssingment Operator: It means...
true
31a638786938447430fd6dc29833d76a6d2b4e8c
Grace-Joydhar/Python-Learning
/Study Mart/27. 1. Assert.py
380
4.21875
4
a = "Assert is mainly used for Eroor Handling as like Exception. But there is some different issues. For example, salary can not be less than 0. So if it is lower than 0, then a error will be occured\n" print(a) def MySalary(salary): '''assert condition, "Message"''' assert salary > 0, "Salary can not less th...
true
30192b29d85771a9fcda77d31dac091aa215770f
notesonartificialintelligence/07-01-20
/chapter_9/0904_number_served.py
1,259
4.3125
4
#Gabriel Abraham #notesonartificialintelligence #Python Crash Course - Chapter 9 #Start with the below class, and add a few changes. class Restaurant: """A Simple Restaurant class""" def __init__(self, restaurant_name, cusine_type): self.restaurant_name = restaurant_name self.cusine_type = cusine_type #Added a...
true
4f5c833be92f5979f65c21f5c827a9d4fca54da9
notesonartificialintelligence/07-01-20
/chapter_7/0704_pizza_topping.py
343
4.28125
4
#Gabriel Abraham #notesonartificialintelligence #Python Crash Course - Chapter 7 #Write a loop that promptsthe user to enter a series of pizza toppings until they enter #a 'quit' value. prompt = "Enter your pizza toppings." prompt += "\nPress 'quit' to exit." topping = "" while topping.lower() != "quit": print(to...
true
e7df7dffe30e305bce1d09b8604f1b148f9b3907
notesonartificialintelligence/07-01-20
/chapter_10/1010_common_words.py
660
4.40625
4
#Gabriel Abraham #notesonartificialintelligence #Python Crash Course - Chapter 10 #Visit project Gutenbery and find a few texts you'd like to analyse. #Download the file, then use the count methed to find out how many times a word or phrase #appears in a string. #The word will be 'the' fileName ='pride_and_prejudice....
true
2503bc5993913e3bbb592d2c813c5ebc0d600790
notesonartificialintelligence/07-01-20
/chapter_7/0703_multiples_of_ten.py
481
4.46875
4
#Gabriel Abraham #notesonartificialintelligence #Python Crash Course - Chapter 7 #Ask the user for a number, and then report whether the number is a multiple of 10 or not. #A prompt that will spread over 2 lines. prompt = "I can calculate multiples." prompt += "\nEnter a number, and I'll tell you if is a multiple of ...
true
f1e16d4e805ac23b10f00e07c64b47da40bbefa1
notesonartificialintelligence/07-01-20
/chapter_7/0702_restaurant_seating.py
391
4.375
4
#Gabriel Abraham #notesonartificialintelligence #Python Crash Course - Chapter 7 #A program that ask the user how many seats they will require. #If the value is over 8, tell them they'll have to wait for a seat. people = input("How many people are in the group? ") people = int(people) if people <= 8: print("We'll j...
true
8cccd85ff422bd6e5eabe5e41300e3ad0ba85723
notesonartificialintelligence/07-01-20
/chapter_7/rollercoaster.py
305
4.25
4
#Gabriel Abraham #notesonartificialintelligence #Python Crash Course - Chapter 7 #Using the int() function. casting. height = input("How tall are you, in inches? ") height = int(height) if height >= 48: print("\nYou're tall enough to ride!") else: print("\nYou'll be able to rise when you're a little older.")
true
0865eefa3ca9c2d905601cbabc59e0ab3b8dd413
notesonartificialintelligence/07-01-20
/chapter_2/full_name.py
726
4.28125
4
# Using variables in Strings. # F-strings. The F is for format, this is because python formats the string byy replacing the name of the variable with its value first_name = "ada" last_name = "lovelace" full_name = f"{first_name} {last_name}" #print(f"Hello, {full_name.title()}") #One can use the fstring to compost...
true
8cb1e91465a66e2e3b0c9d56611ac3e5ff83adef
notesonartificialintelligence/07-01-20
/chapter_10/1001_learning_Python.py
808
4.5
4
#Gabriel Abraham #notesonartificialintelligence #Python Crash Course - Chapter 10 #Write a program that reads the file and prints what has been written 3 times. #Print the list once by reading in the entire file. #Once by looping over the file object #Once by storing the lines in a list and then working with them outs...
true
451ace81051604ff44473c37f0538700ed21503d
rahulmainali/Projectlab
/pythonscripts.py
475
4.3125
4
"""Solve each of the following problems using Pyhton Scripts. Make sure you use appropriate variable if names and comments. When there is a final answer have python print on the same screen. A person's body mass index (BMI) is defined as: BMI=mass in kg / (height in m)/2""" mass = float(input("enter the mass of the pe...
true
10abd17b5762dff569bbbf24ebaf27475cfa3582
ellisandrews/practice-problems
/epi/05_arrays/05_09_enum_primes.py
727
4.28125
4
""" Write a program that takes an integer argument and returns all the primes between 1 and that integer. Example: Input: 18 Return: [2, 3, 5, 7, 11, 13, 17] Hint: Exclude the multiples of primes """ def is_prime(n): """Brute force check if a number `n` is prime.""" for i in range(2, n): if n % i == ...
true
da248e913ba7e251d95aed422566777dfda1ac9a
cjefferies84/python-exercises
/test_1/test_1.py
966
4.28125
4
from sys import exit num1_string = raw_input('Please enter the first integer: ') num2_string = raw_input('Please enter the second integer: ') # We will have a problem casting if either entry is not a number # We want to abort completely if there is something other than a number if num1_string.isalpha() or num2_string...
true
3f6dc59e3d0f7551997ef1837f7484d8a30c70a2
kspnec/RealPython
/format() & f-string/code_examples/string_formatting_starter_code/format_function.py
1,054
4.4375
4
# Basic usage demo_string = "This is a demonstration of the {} function".format("format") # Expected output: 'This is a demonstration of the format function' # print(demo_string) fruits = ["apples", "bananas", "oranges"] # You can use indices to access lists in format strings # The '0' below refers to the 0th argumen...
true
049621f2d8b2ffe7f53744751ff1bcecbe7612ab
kushwahash/Regression
/SimpleLinearRegression/SalaryPredictor/SalaryPredictor_SLR.py
1,768
4.34375
4
#Data preprocessing Start import numpy as np import matplotlib.pyplot as plt import pandas as pd #read the data file dataset = pd.read_csv("Salary_Data.csv") X = dataset.iloc[:, :-1].values y = dataset.iloc[:, 1].values #split the dataset into training set and test set from sklearn.model_selection import train_test_...
true
e5227144b4caf1bf3d1b71c0055fbf3982714ba9
kledole/PyCharmProjects
/codeLogicintro.py
2,095
4.3125
4
# File: codeLogicintro.py # # Basics to conditional logic. ## # Time: 4:10:28 # Review of conditionals: # == is equal to # != is not equal to # < is less than # < is greater than # >= is greater than or equal to # <= is less than or equal to # Tip review for PyCharm %/... comment blocks of code... # Note usage of...
true
c88c2b05a20ae49d6ea37ec7dec29221dcaa777c
KetanSingh11/Data-Structures-in-Python
/Linked_List.py
2,469
4.1875
4
#=================================================== """ Linked List Implementation in PYTHON """ #=================================================== class Node(object): def __init__(self, data=None, next=None): self.data = data # contains the data self.next = next # contains the reference ...
true
dac3bd874f86411b320b78e5274a01159348abbd
KylerVillarreal/learning1
/learning.py
1,559
4.1875
4
print("hello world") print("howdy, y'alL") print("I like typing this") # math skills demo print(" i will not count my chickens", 2) print("Hens: ", 25+30/6) print("Roosters: ", 100 - 25 * 3 % 4) print("Now I will count the eggs, 7") print(3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 +6) # more math problems print(5.0 + 4.0 + 1.0 ...
true
82e416d296020aaf7c5dee9009f3874f55c5d578
jeantardelli/math-with-python
/trees-and-networks/getting-the-basic-characteristics-of-networks.py
1,260
4.1875
4
""" Networks have various basic characteristics beyond the number of nodes and edges that are useful for analyzing a graph. For example, the degree of a node is the number of edges that start (or end) at that node. A higher degree indicates that the node is better connected to the rest of the network. This module illu...
true
b437cddd400059d1d559ca2284141eabdc8d7813
jeantardelli/math-with-python
/finding-optimal-solutions/using-least-squares-to-fit-a-curve-to-data.py
1,555
4.375
4
""" Least squares is a powerful technique for finding a function from a relatively small family of potential functions that best describe a particular set of data. This technique is especially common in statistics. For example, least squares is used in linear regression problems – here, the family of potential function...
true
9852e50e4bbced76a32fa02ab2187cefadcc253b
jeantardelli/math-with-python
/mathematical-plotting-matplotlib/basic-plotting-with-matplotlib.py
341
4.3125
4
""" This module illustrates how to create a basic plot using matplotlib library. """ import numpy as np import matplotlib.pyplot as plt def f(x): return x*(x-2)*np.exp(3-x) x = np.linspace(-0.5, 3.0, 100) # 100 values between -0.5 and 3.0 y = f(x) ax = plt.plot(x, y) plt.show() lines = plt.plot(x, f(x), x, x**2...
true
3a7883fa0d08669ce8100a65a8fd8fac3a5d423d
sherifzakaria/grokking-algorithms
/selectionSort.py
684
4.125
4
def findSamllest(arr): """ return index of smallest element in an array """ smallest = arr[0] smallest_index = 0 for i in range(1, len(arr)): if arr[i] < smallest: smallest = arr[i] smallest_index = i return smallest_index def selectionSort(arr): """ ...
true
6c8384564c26e00489775c3d59740ace7d05cdb7
VIC21BC/comp110-21f-workspace
/exercises/ex05/utils_test.py
1,756
4.25
4
"""Unit tests for list utility functions.""" __author__ = "730449914" from exercises.ex05.utils import only_evens from exercises.ex05.utils import sub from exercises.ex05.utils import concat def test_only_evens_empty() -> None: """Test if an empty list results in an empty the list.""" a: list[int] = [] ...
true
cbfad7eda454a186d4bdcf7a4411b842f037e62c
DincerDogan/Hackerrank-Codes
/Algorithms/Sansa_And_XOR.py
2,133
4.125
4
# Title: Sansa and XOR # Difficulty: Medium # Points: 30 # Sansa has an array. She wants to find the value obtained by XOR-ing the contiguous subarrays, followed by XOR-ing the values thus obtained. Determine this value. # For example, if arr = [3, 4, 5]: # Subarray Operation Result # 3 None 3 # 4 None 4 # 5 No...
true
17b21333bdfd088358f245c141b969422090b862
TheBeardNerd/cs50
/pset6/caesar/caesar.py
1,213
4.28125
4
import sys def caesar(): # checks for correct argument while True: if len(sys.argv) != 2: print("Usage:", sys.argv[0], "integer") exit(1) else: break # converts user key from char input to integer key = int(sys.argv[1]) # prompts user for plai...
true
2f260a317cc8cdb7583ba9811d9404d220315c92
LostInFandom/PythonCrashCourse
/name_cases.py
702
4.21875
4
first_name = "Kaila" print("Hello, " + first_name + ", would you like to learn some Python today?") print("Isaac Newton said, \"If I have seen further than others, it is by standing on the shoulders of giants.\"") famous_person = "Isaac Newton" message = "said, \"If I have seen further than others, it is by standing ...
true
e85cf1c1c5a38c6be44f09e60b8fd11f6a0ff293
cozek/code-practice
/linkedlist/remove_duplicates.py
2,040
4.125
4
#!/usr/bin/env python3 from linkedlist import LinkedList """ This scripts implements code to remove duplicates from sorted and unsorted linked list """ class LinkedListSorted(LinkedList): def __init__(self, data: list): super().__init__(data) def __str__(self): return super().__str__() ...
true
b620b7a528d20ca5d8bad8f89fb6d8baebccedf4
Chantal13/P4E-Python
/Week 3/ex3_1_error_checking.py
1,128
4.28125
4
# Exercise 3_1 with error checking # Write a program to prompt the user for hours and rate per hour using raw_input to compute gross pay. Pay # the hourly rate for the hours up to 40 and 1.5 times the hourly rate for all hours worked above 40 hours. # Use 45 hours and a rate of 10.50 per hour to test the program (the ...
true
36fafa5a10b5f411e9e74b9e2338e42f10d6ea45
melissaehong/AllProjects
/Python/PythonFundamentals/typelist.py
1,547
4.34375
4
'''Assignment: Type List Write a program that takes a list and prints a message for each element in the list, based on that element's data type. Your program input will always be a list. For each item in the list, test its data type. If the item is a string, concatenate it onto a new string. If it is a number, add it ...
true
87d90c51f581967ad5e958c26209539a898bd862
melissaehong/AllProjects
/Python/PythonFundamentals/pythonturtle.py
986
4.75
5
Optional Assignment: Python Turtle Try drawing a simple picture using the Python module Turtle. Turtle is a Python drawing module for kids. It uses Python's built-in ability to test GUI apps as you write the code. Even though it's for kids, you can do some complex drawing with it. Learning new technologies, languages,...
true
6e2bf28519f53773e4326ab5c899d5b584b8c662
mbotha13/mbotha_python
/submission_001-hangman/hangman.py
1,060
4.21875
4
#TIP: use random.randint to get a random word from the list import random def read_file(file_name): """ TODO: Step 1 - open file and read lines as words """ words = open(file_name, "r").readlines() return (words) def select_random_word(words): """ TODO: Step 2 - select random word from l...
true
da445073b91bcc2cfcff95290a50062bcf63d21c
SI-Squad/si-material
/CS1/Stacks-And-Queues/drivethru_stu.py
1,941
4.25
4
""" SI exercise to simulate a drivethru using a queue file: driveway.py Created by Yancarlos Diaz, yxd3549, for the Academic Success Center Supplemental Instruction Program. """ from queue import * def queue_up(drivethru, car): """ Add a car to the end of the drivethru """ # TODO: Add the car to the e...
true
f812907b760a958414b530a75ce1eae35d2d5140
SI-Squad/si-material
/CS1/Stacks-And-Queues/drivethru_sol.py
1,977
4.3125
4
""" SI exercise to simulate a drivethru using a queue file: driveway.py Created by Yancarlos Diaz, yxd3549, for the Academic Success Center Supplemental Instruction Program. """ from queue import * def queue_up(drivethru, car): """ Add a car to the end of the drivethru """ enqueue(drivethru, car) de...
true
479df5c7bae9d9ae79c81073181278f3d42221ba
Alex-Philp/CP1404_pracs
/practical_04/repeat_strings.py
371
4.125
4
strings = [] repeated_strings = [] string = input("Please enter some strings, finish by hitting the enter key with no input\n>>> ") while not string == "": if string not in repeated_strings: if string in strings: repeated_strings.append(string) strings.append(string) string = input("...
true
a3269b0ead1856eec9caef418ba32ba974501ba3
Yuchen112211/Leetcode
/problem945.py
1,989
4.25
4
''' 945. Minimum Increment to Make Array Unique Medium Given an array of integers A, a move consists of choosing any A[i], and incrementing it by 1. Return the least number of moves to make every value in A unique. Example 1: Input: [1,2,2] Output: 1 Explanation: After 1 move, the array could be [1, 2, 3]. Ex...
true
5819f4116e4a26cdc37334bbccb01d77f12228e0
Yuchen112211/Leetcode
/problem905.py
1,002
4.15625
4
''' 905. Sort Array By Parity Easy Given an array A of non-negative integers, return an array consisting of all the even elements of A, followed by all the odd elements of A. You may return any answer array that satisfies this condition. Example 1: Input: [3,1,2,4] Output: [2,4,3,1] The outputs [4,2,3,1], [2,4,...
true
c2d7b811ca74bb5b222662f6bbd9d1d67a2cb9d4
tusharkawsar/test_repo
/function.py
1,524
4.8125
5
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ PASSING VARIABLE NUMBER OF ARGUMENTS """ # Positional Arguments def func_with_var_pos_arg(*args): # Can use other names instead of ARGS print(args) # No asterisk necessary when dealing with ARGS func_with_var_pos_arg(1,2) func_with_var_pos_arg(1,2,3,"string") def ...
true
943eb806cb61a842430ea4de53c0bdec479fcfc3
Darthpbal/helperToolsAndFiles
/languages/python/codecademy/advanced topics/iteratorsForDictionaries.py
1,486
4.65625
5
my_dict = { "name": "Wakawaka", "age": 26, "major": "Astrophysics", "eyeColor": "brown", "hairColor": "brown", "song": {"title": "Madness", "artist": "Muse"} "" } print my_dict.items() print my_dict.keys() print my_dict.values() for key in my_dict: print key, my_dict[key] #### Advanced l...
true
3d535cf4be88bb880c416b1394365491385bb889
rdrapeau/Euler_2013
/16-30/20_Factorial_Digit_Sum.py
563
4.125
4
''' Created on Mar 7, 2013 @author: RDrapeau n! means n x (n - 1) ... 3 x 2 x 1 For example, 10! = 10 x 9 ... 3 x 2 x 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. Find the sum of the digits in the number 100! ''' # Returns the sum of the digits in n def sum_digits...
true
5c3edef62da7695669f1caed3a226f880ef63cfa
Lashirova/DoubleCheck
/main.py
1,849
4.40625
4
doubleWords=['homework', 'assignment', 'quiz', 'discussion', 'quiz', 'program'] doubleWords1=[]; for i in doubleWords: if i not in doubleWords1: doubleWords1.append(i) else: print(i,end=' ') # Explanation # The list (l) with duplicate elements is taken to find the duplicates. # An empt...
true
fc331cb48077735d8afcb136a929f4361834d631
saikatdas0790/introduction-to-computer-science-and-programming-using-python
/week-2-simple-programs/3-simple-programs/1-exercise-guess-my-number.py
720
4.1875
4
print("Please think of a number between 0 and 100!") start = 0 end = 100 middle = int((start + end) / 2) while True: print("Is your secret number " + str(middle) + "?") enteredLetter = input( "Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicat...
true
61cd329f36f3ff7f62a9928d3aec361e3f5691bc
komali2/pygame_learning
/prime_checker.py
619
4.125
4
# Check if something is prime def prime_checker(n): if n < 1: return False elif n<= 3: return True elif n % 3 == 0 or n % 2 == 0: return False i = 5 while i * i < n: # There's somet fancy thing you can add here to do like # 6k+3 but I don't understand it yet ...
true
4225258165d15b491f30a9d890bfccdab9d3ea30
BhagyaRana/SVNIT_Study_Material_First_Year
/Semester_2_First_Year/6-Web_Programming[Branch Specific Course-II]/5.) Python/Python/Most_Imp_Practice_Question/count.py
583
4.28125
4
#Write a program to compute the number of characters, words and lines in string. def count(name): numwords = 0 numchars = 0 numlines = 0 split_string = name.split() print(split_string) numwords = len(split_string) for word in split_string: numchars += len(word) print(nam...
true
221e6bd75ed13cd40662edd2bcf3f11aa8655e9d
BhagyaRana/SVNIT_Study_Material_First_Year
/Semester_2_First_Year/6-Web_Programming[Branch Specific Course-II]/5.) Python/Python/Most_Imp_Practice_Question/reverse-list.py
597
4.65625
5
#Write a function reverse to reverse a list. Without using the reverse function. #Create a slice that starts at the end of the string, # and moves backwards. #In this particular example, the slice statement [::-1] means # start at the end of the string and end at position 0, #move with the step -1, negative one, whi...
true
f1ac08798f1e7969a4a00ee5968398b44b1857e3
BhagyaRana/SVNIT_Study_Material_First_Year
/Semester_2_First_Year/6-Web_Programming[Branch Specific Course-II]/6.) Python/Python/Examples/import/example/Practical3.py
653
4.34375
4
''' Python Program to Convert given Kilometer into Miles 1 km = 0.621371 miles Meter 1 km = 1000 meter Centimeter 1 m = 100 centimeter Feet 1 m = 3.28084 foot Inch 1 foot = 12 Inch ''' kilometers = 5.5 # To take kilometers from the user, uncomment the code below # kilometers = float(input("Enter value in kilometers")...
true
ba282c44ee0fd9cdb01e59f0a6ab10763203155f
BhagyaRana/SVNIT_Study_Material_First_Year
/Semester_2_First_Year/6-Web_Programming[Branch Specific Course-II]/5.) Python/Assignment_1/Q6.py
748
4.375
4
# Write a python program to insert a word at a specific position in string. # Prompt the user for : # (i) input string, # (ii) word which is to be inserted, # (iii) position where it is to be inserted. # python program to insert a word at given position in string string = input("Enter input string : ") word = inpu...
true
6c42586e1a03b87c93b759b7d224af9164314054
BhagyaRana/SVNIT_Study_Material_First_Year
/Semester_2_First_Year/6-Web_Programming[Branch Specific Course-II]/5.) Python/Python/Most_Imp_Practice_Question/string-count-dict.py
780
4.3125
4
# 1. Write a program to store input string & count of each character of that input string into different dictionary respectively. # 2. write a program which takes input from the user for specific number of times and each time, that input and that input's length(or character count) should be stored in dictioanry ''' s...
true
0537d21a348e17f767daba248912bf5e76d3f05a
BhagyaRana/SVNIT_Study_Material_First_Year
/Semester_2_First_Year/6-Web_Programming[Branch Specific Course-II]/5.) Python/Python/Most_Imp_Practice_Question/dup_del.py
964
4.46875
4
# removing duplicated from list using set() ''' #test_list = [1, 5, 3, 6, 3, 5, 6, 1] test_list = ['hello', 'hi', 'Hello', 'hello', 'abc'] print ("The original list is : " , test_list) # using set() to remove duplicated from list test_list = list(set(test_list)) # printing list after removal print ("The list af...
true
280b6e9cadd677ad69ae9aa8e71204ea209bdc4f
BhagyaRana/SVNIT_Study_Material_First_Year
/Semester_2_First_Year/6-Web_Programming[Branch Specific Course-II]/6.) Python/Python/Examples/lambda/lambda1.py
278
4.46875
4
# Program to show the use of lambda functions #Create a lambda function that takes one parameter (a) and returns it. x = lambda a : a double = lambda x: x * 2 print(double(5)) adder = lambda x, y: x + y print (adder (1, 2)) f = lambda x,y : x**2 + y**2 print(f(2,3))
true
ea73f1695590ed3c7faa4d675754581cf18410dc
BhagyaRana/SVNIT_Study_Material_First_Year
/Semester_2_First_Year/6-Web_Programming[Branch Specific Course-II]/5.) Python/Python/Most_Imp_Practice_Question/triangle-area.py
545
4.21875
4
#area of triangle base = float(input("Input the base : ")) height = float(input("Input the height : ")) area = (base * height)/2 print("The Area of a Triangle using", base, "and", height, " = ", area) ''' def area_of_triangle(base, height): return (base * height) / 2 base = float(input('Please Enter the Base...
true
721f6cda908fabb83a920707bae7ff1242561be6
ruoilegends/NGUYENTANLOC_43807_CA18A1A
/NguyenTanLoc_43807_CH01/project/page33_project_05.py
497
4.4375
4
""" Author: Nguyen Tan Loc Date: 25/08/2021 Problem: Modify the program of Project 4 to compute the area of a triangle. Issue the appropriate prompts for the triangle’s base and height, and change the names of the variables appropriately. Then, use the formula .5 * base * height to compute the area. Test the progr...
true
260a896b6978b5843348528cad16c0e7393a055e
ruoilegends/NGUYENTANLOC_43807_CA18A1A
/NguyenTanLoc_43807_CH05/project/5.3/Page_165_Project_03.py
1,601
4.40625
4
""" Author: Nguyen Tan Loc Date: 7/10/2021 Problem:Modify the sentence-generator program of Case Study 5.3 so that it inputs its vocabulary from a set of text files at startup. The filenames are nouns.txt, verbs. txt, articles.txt, and prepositions.txt. (Hint: Define a single new function, getWords. This function...
true
0f5a705beaf0c3af77e203b90f87138376772aec
ruoilegends/NGUYENTANLOC_43807_CA18A1A
/NguyenTanLoc_43807_CH02/exercise/page54_exercise_03.py
451
4.15625
4
""" Author: Nguyen Tan Loc Date: 1/09/2021 Problem: How does a Python programmer round a float value to the nearest int value? Solution: • To round a float value to the nearest int value, round() function is used which gives the rounded off value of float value. • If the value after decimal point is greater than 0...
true
2dd86e09873a003019ae53fb4f7c51b2bc71aba3
ruoilegends/NGUYENTANLOC_43807_CA18A1A
/NguyenTanLoc_43807_CH07/Project/7.8/Page_241_Project_08.py
829
4.21875
4
""" Author: Nguyen Tan Loc Date: 9/10/2021 Problem: Old-fashioned photographs from the nineteenth century are not quite black and white and not quite color, but seem to have shades of gray, brown, and blue. This effect is known as sepia, as shown in Figure 7-17. Write and test a function named sepia that convert...
true
d43ede5c07154e5c677b58323b4f8e051e665b01
ruoilegends/NGUYENTANLOC_43807_CA18A1A
/NguyenTanLoc_43807_CH04/project/Page_133_Project_06.py
866
4.40625
4
""" Author: Nguyen Tan Loc Date:24/09/2021 Problem: Use the strategy of the decimal to binary conversion and the bit shift left operation defined in Project 5 to code a new encryption algorithm. The algorithm should add 1 to each character’s numeric ASCII value, convert it to a bit string, and shift the bits of ...
true
372c4f134a45002e6e720eb0ae58a791109a4fa1
ruoilegends/NGUYENTANLOC_43807_CA18A1A
/NguyenTanLoc_43807_CH07/Exercises/Page218_Exercise_05.py
1,328
4.53125
5
""" Author: Nguyen Tan Loc Date: 15/10/2021 Problem: Turtle graphics windows do not automatically expand in size. What do you suppose happens when a Turtle object attempts to move beyond a window boundary? Solution: About Turtle Graphics • A turtle graphics toolkit provides a simple and enjoyable way to draw...
true
1fb21cd46b268afd40ae1004c3cbc87d52c960c0
ruoilegends/NGUYENTANLOC_43807_CA18A1A
/NguyenTanLoc_43807_CH04/exercise/Page106_Exercise_02.py
489
4.125
4
""" Author: Nguyen Tan Loc Date: 24/09/2021 Problem: Assume that the variable data refers to the string "myprogram.exe". Write the expressions that perform the following tasks: a. Extract the substring "gram" from data. b. Truncate the extension ".exe" from data. c. Extract the character at the middle positi...
true
2a6a3e5f1f7784746accf69c017f253ec1c9f1df
ruoilegends/NGUYENTANLOC_43807_CA18A1A
/NguyenTanLoc_43807_CH01/exercise/page29_exercise_02.py
288
4.25
4
""" Author: Nguyen Tan Loc Date: 25/08/2021 Problem: Write a line of code that prompts the user for his or her name and saves the user’s input in a variable called name. Solution: >>> name = input("Enter your name: ") Enter your name: LOC >>> name 'LOC' >>> print(name) LOC >>> """
true
1d01471ad3715a6c271f273d6ef62c68e373365a
ruoilegends/NGUYENTANLOC_43807_CA18A1A
/NguyenTanLoc_43807_CH07/Project/7.12/Page_241_Project_12.py
1,173
4.15625
4
""" Author: Nguyen Tan Loc Date: 16/10/2021 Problem: Each image-processing function that modifies its image argument has the same loop pattern for traversing the image. The only thing that varies is the code used to change each pixel within the loop. Section 6.6 of this book, on higher-order functions, suggests ...
true
f30c7666f9c4db3f03aa8155412b91adb25b69f5
a29585817/turtle_draw
/day19.py
990
4.21875
4
from turtle import Turtle, Screen import random is_goal = False screen = Screen() screen.setup(width=500, height=400) user_bet = screen.textinput(title="Make your bet", prompt="Which turtle will win the race? Enter color") colors = ["red", "orange", "blue", "purple", "yellow", "green"] turtle_name = [] for x in range...
true
84fb5e08392e6612dfd83946def8719c59f1d3b6
stemmler/sandbox
/string_compression.py
1,082
4.125
4
import sys ''' String compression problem: Compress a string, but only return its compressed from if it is shorter than the original string. Examples: input: aaaabbbbbbbcccdde output: a4b7c3d2e input: abcdd output: abcdd ''' def compress_char_string(char, count): if count == 1: return char else: ...
true
b2125d5d7526a10efbacac037479a6154b486364
iashraful/text-mining
/text_processor.py
1,083
4.125
4
import re def get_paragraph_from_file(file_path=None): """ params: file_path(string) A valid location of file return: The whole file in string format """ if not file_path: file_path = 'paragraph.txt' paragraph = '' # Opeing paragraph.txt file and read the whole file with open(f...
true
05c303c531d86410da65d382877887bad96ac332
WhosKhoaHoang/leetcode_fun
/1185. Day of the Week.py
792
4.21875
4
import datetime # ===== Problem Statement ===== # Given a date, return the corresponding day of the week for that date. # The input is given as three integers representing the day, month and # year respectively. # Return the answer as one of the following values # {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday...
true
61c4f44f6d285a210900a200f3e921406d3367fd
Enid-Sky/codeacademy-python-fundamentals
/inventory_project.py
1,128
4.5
4
inventory = ["twin bed", "twin bed", "headboard", "queen bed", "king bed", "dresser", "dresser", "table", "table", "nightstand", "nightstand", "king bed", "king bed", "twin bed", "twin bed", "sheets", "sheets", "pillow", "pillow"] # Find out how many items in the inventory inventory_len = len(inventory) print(f"There ...
true
0bfd7ee04126b8dd4afdee7503389cefadddb716
bchewy/Calculator-Python
/Python 3/methods/eval.py
606
4.625
5
number_1 = input("Number 1:") print("Select an operator") operator = (input("Operator:")) number_2 = input("Number 2:") print(eval(number_1 + operator + number_2)) #What eval does is that it runs the given arguments as one line in python # EG: # # # Number 1:5 # Select an operator # Operator:* # Number 2:5 # ...
true
f17161c0fd1e4df119a24b9af6cd524ca3254e51
Allanxyz/The-Eye-of-Khemet
/kemet.py
2,649
4.125
4
input("\nWelcome to Karnak. Beware of the Eye. [Press 'Enter' to continue]") print('-' * 30) print( """INSTRUCTIONS: Type in your choice as given in the choices provided. Press 'Enter' when prompted '>'""") print('-' * 30) yes_no = input("Do you wish to continue? Y/N : ") print('-' * 30) if(yes_no == 'Y...
true
c42d6f517856a36d5bf876681092678f67241e7e
greall2/-Python-Fundamentals-Problem-Sheet
/Problem6.py
578
4.28125
4
#Emerging Technologies #Python Fundatmentals Problem Sheet #Ríona Greally - G00325504 #6. Write a function that returns the largest and smallest elements in a list. #creating a list list =[] #assigning the userinput to length length = int(input("How long do you want the list?")) count = 0 while count < length: us...
true