blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
e6ad416dcbc20283cd2ed283872f6362118c1efc
skybohannon/python
/w3resource/string/26.py
461
4.34375
4
# 26. Write a Python program to display formatted text (width=50) as output. import textwrap text_block = "Python is a widely used high-level, general-purpose, interpreted, dynamic programming language. " \ "Its design philosophy emphasizes code readability, and its syntax allows programmers to express c...
true
6e63b95872bcfa0c0c2e5d81568a398c146cd393
skybohannon/python
/w3resource/string/38.py
366
4.25
4
# 38. Write a Python program to count occurrences of a substring in a string. str1 = "FYI man, alright. You could sit at home, and do like absolutely nothing, and your name goes through like 17 computers a day. 1984? Yeah right, man. That's a typo. Orwell is here now. He's livin' large. We have no names, man. No names...
true
c6a50a2cc4250618428fe74a9b35b215db56f07f
skybohannon/python
/w3resource/string/7.py
540
4.15625
4
# 7. Write a Python program to find the first appearance of the substring 'not' and 'poor' from a given string, # if 'bad' follows the 'poor', replace the whole 'not'...'poor' substring with 'good'. Return the resulting string. # Sample String : 'The lyrics is not that poor!' # Expected Result : 'The lyrics is good!' ...
true
e00cb16e158ea45b54c71ddfb6d8f2ece9db06b0
Dragnes/Automate-the-Boring-Stuff-with-Python
/Lesson 15 pg 89-92.py
1,211
4.375
4
#Lesson 15 pages 89-92 'Method is similar to function, except it is "called on" a value.' # Finding a Value in a List with the index() Method spam = ['hello', 'hi', 'howdy', 'heyas'] spam.index('hello') spam.index('heyas') # Adding Values to a List using append() and insert() Methods spam = ['cat', 'dog', ...
true
09afad6687e6dffbda763514f059c9c44b35f69a
byugandhara1/assessment
/polygon.py
432
4.21875
4
''' Program 1 : Check if the given point lies inside or outside a polygon? ''' from shapely.geometry import Point, Polygon def check_point_position(polygon_coords, point_coords): polygon = Polygon(polygon_coords) point = Point(point_coords) print(point.within(polygon)) polygon_coords = input('Enter polygon coord...
true
bf66df0a04e52ab210db84b47f24a3e575dfe0c4
Yozi47/Data-Structure-and-Algorithms-Class
/Homework 5/C 5.26.py
1,070
4.1875
4
B = [1, 2, 3, 3, 3, 3, 3, 4, 5] # considering B as an array of size n >= 6 containing integer from 1 to n-5 get_num = 0 for i in range(len(B)): # looping the number of elements check = 0 for j in range(len(B)): # looping the number of elements if B[i] == B[j]: # checking for common number ...
true
2b2765e7e51b754bdc6f580789c525dec86766a7
Shivanisarikonda/assgn1
/newfile.py
294
4.1875
4
import string def pangram(string): alphabet="abcdefghijklmnopqrstuvwxyz" for char in alphabet: if char not in string: return False return True string="five boxing wizards jump quickly" if(pangram(string)==True): print("given string is pangram") else: print("string is not a pangram")
true
9ae7ed690d2b3c60271b9ae0eb094e77bfde4797
heloise-steam/My-Python-Projects
/Turtle Time Trials
1,384
4.15625
4
#!/bin/python3 from turtle import* from random import randint print('Pick a turtle either green yellow blue red and chose a stage that the turtle you picked will get up. To make sure you bet with each other') print('Ok now let the time trials begin') speed(10) penup() goto(-140, 140) for step in range(15): write(s...
true
adc2e276f9795092034d9cb1942446a30c6a3755
eric-elem/prime-generator
/primegenerator.py
1,411
4.15625
4
import math import numbers import decimal def get_prime_numbers(n): # check if input is a number if isinstance(n,numbers.Number): # check if input is positive if n>0: # check if input is decimal if isinstance(n, decimal.Decimal): return 'Undefined' ...
true
2e6f198de36b43c6455ee8c11e425729d37cd8db
mjcastro1984/LearnPythonTheHardWay-Exercises
/Ex3.py
714
4.34375
4
print "I will now count my chickens:" # the following lines count the number of chickens print "Hens", 25.0 + 30.0 / 6.0 print "Roosters", 100.0 - 25.0 * 3.0 % 4.0 print "Now I will count the eggs:" # this line counts the number of eggs print 3.0 + 2.0 + 1.0 - 5.0 + 4.0 % 2.0 - 1.0 / 4.0 + 6.0 print "Is it true tha...
true
252ba707cb39ef0c0f3100c1586a94d34060ddd0
hmtareque/play-with-python
/numbers.py
1,975
4.1875
4
""" Number data types store numeric values. Number objects are created when you assign a value to them. """ num = 1076 print(num) """ Python supports four different numerical types: - int (signed integers) They are often called just integers or ints. They are positive or negative whole num...
true
9785f3ad0bbf239885768d4a4c046ad81c6c8930
holmanapril/01_lucky_unicorn
/01_test.py
2,028
4.25
4
#name = input("Hello, what is your name?") #fruit = input("Pick a fruit") #food = input("What is your favourite food?") #animal = input("Pick an animal") #animal_name = input("Give it a name") #print("Hi {} guess what? {} the {} is eating some {} and your {}".format(name, animal_name, animal, fruit, food)) #Setting s...
true
c82a9e44ac4a78a843bb598c1cba56f8c6ffd773
lahwahleh/python-jupyter
/Errors and Exception Handling/Unit Testing/cap.py
259
4.15625
4
""" A script to captilize texts """ def cap_text(text): """ function takes text and capitalizes it """ # words = text.split() # for word in words: # print(word.capitalize()) return text.title() cap_text("hello world today")
true
83727ced73caf7c95dfbbf9cc1a2087099123377
vikasmunshi/euler
/projecteuler/041_pandigital_prime.py
1,083
4.15625
4
#!/usr/bin/env python3.8 # -*- coding: utf-8 -*- """ https://projecteuler.net/problem=41 We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime. What is the largest n-digit pandigital prime that exists? Answer...
true
e25cf5ed10c5692653bfca95afe045a347f34219
Surbhi-Golwalkar/Python-programming
/programs.py/p4.py
348
4.25
4
# '''The int() function converts the specified value into an integer number. # We are using the same int() method to convert the given input. # int() accepts two arguments, number and base. # Base is optional and the default value is 10. # In the following program we are converting to base 17''' num = str(input("ENTER...
true
a3b1f0ccf64324a1a493c96b651fa127a64760da
Surbhi-Golwalkar/Python-programming
/loop/prime.py
280
4.1875
4
num = int(input("enter number:")) prime = True for i in range(2,num): if(num%i == 0): prime = False break if (num==0 or num==1): print("This is not a prime number") elif prime: print("This number is Prime") else: print("This number is not prime")
true
a318db450ffc3dc94bc00b0a413446a7e5e4723b
Surbhi-Golwalkar/Python-programming
/programs.py/washing-machine.py
1,547
4.5625
5
# A Washing Machine works on the principle of a Fuzzy system, # the weight of clothes put inside it for wash is uncertain. # But based on weight measured by sensors, it decides time and water # levels which can be changed by menus given on the machine control # area. For low Water level, time estimate is 25 minut...
true
773ce4110c657204df88c1653f277c8790b9e2af
CalebCov/Caleb-Repository-CIS2348
/Homework1/2.19.py
1,410
4.1875
4
#Caleb Covington lemon_juice_cups = float(input('Enter amount of lemon juice (in cups):\n')) water_in_cups = float(input('Enter amount of water (in cups):\n')) agave_in_cups = float(input('Enter amount of agave nectar (in cups):\n')) servings = float(input('How many servings does this make?\n')) print('\nLemonade ing...
true
04ed8d95e2d03a0b9c1aedbcaa1dcbd4a9121a21
PEGGY-CAO/ai_python
/exam1/question3.py
526
4.1875
4
# Given the following array: # array([[ 1, 2, 3, 4, 5], # [ 6, 7, 8, 9, 10], # [11, 12, 13, 14, 15]]) # write statements to perform the following tasks: # # a. Select the second row. # # b. Select the first and third rows. # # c. Select the middle three columns. import numpy as np array = np.array...
true
890ed31dfd858591a2850c17bf516d05eed46cf2
PEGGY-CAO/ai_python
/wk2/calCoins.py
607
4.21875
4
# This program is used to ask the user to enter a number of quarters, dimes, nickels and pennies # Then outputs the monetary value def askFor(coinUnit): coinCounts = int(input("How many " + coinUnit + " do you have?")) if coinUnit == "quarters": return 25 * coinCounts elif coinUnit == "dimes": ...
true
8f4d286e3c9cbdd2736972bbea43113805060cc0
manu-s-s/Challenges
/challenge2.py
412
4.15625
4
# Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. # The string will only contain lowercase characters a-z import sys text=input('enter text: ') if text==text[::-1]: print('palindrome') sys.exit(0) for i in range(len(text)): k=text[0:i]+text[i+1:]...
true
d921eab7839c522018051a8ae3fb5d95d47fdbfa
Darkbladecr/ClinDev-algorithms
/06 queue/queue.py
1,206
4.15625
4
"""Queue implementation. A queue is an abstract data type that serves as a collection of elements, with two principal operations: enqueue, which adds an element to the collection, and dequeue, which removes the earliest added element. The order in which elements are dequeued is `First In First Out` aka. `FIFO`. The te...
true
f374e213211ff8a50aa6f9b0880ef0da146efe1f
MariaNazari/Introduction-to-Python-Class
/cs131ahw5Final.py
555
4.78125
5
""" The purpose of this program is to print out its own command line arguments in reverse order from last to first. Directions: enter file name following by inputs Example: filename.py Input1 Input2 ... Input n """ import sys # Get argument list: args = list(sys.argv) #Remove file name args.pop(...
true
2fe67867fe4bcd18aeda6179b6b1992873cda22a
polina-pavlova/epam_python_feb21
/homework7/tasks/hw1.py
819
4.15625
4
""" Given a dictionary (tree), that can contains multiple nested structures. Write a function, that takes element and finds the number of occurrences of this element in the tree. Tree can only contains basic structures like: str, list, tuple, dict, set, int, bool """ from typing import Any def find_occurrences(t...
true
920506e62c69aa9c45b6a658b351bf904623fd9f
jurayev/algorithms-datastructures-udacity
/project2/trees/path_from_root_to_node.py
757
4.15625
4
def path_from_root_to_node(root, data): """ :param: root - root of binary tree :param: data - value (representing a node) TODO: complete this method and return a list containing values of each node in the path from root to the data node """ def return_path(node): # 2 if not node: ...
true
926627cd357722cf552dadc7b0986c2420671b14
jurayev/algorithms-datastructures-udacity
/project2/recursion/palindrome.py
384
4.25
4
def is_palindrome(input): """ Return True if input is palindrome, False otherwise. Args: input(str): input to be checked if it is palindrome """ if len(input) < 2: return True first_char = input[0] last_char = input[-1] return first_char == last_char and is_palindrome(inp...
true
ab0129a56445630cccee1c997ed5994217d4ed17
jurayev/algorithms-datastructures-udacity
/project2/recursion/return_codes.py
1,400
4.3125
4
def get_alphabet(number): """ Helper function to figure out alphabet of a particular number Remember: * ASCII for lower case 'a' = 97 * chr(num) returns ASCII character for a number e.g. chr(65) ==> 'A' """ return chr(number + 96) def all_codes(number): # 23 """ :param: nu...
true
77b666b096790694700a2d2e725015d9c2b1fc2c
jurayev/algorithms-datastructures-udacity
/project2/recursion/key_combinations.py
1,827
4.15625
4
""" Keypad Combinations A keypad on a cellphone has alphabets for all numbers between 2 and 9. You can make different combinations of alphabets by pressing the numbers. For example, if you press 23, the following combinations are possible: ad, ae, af, bd, be, bf, cd, ce, cf Note that because 2 is pressed before 3, ...
true
bf3f684516a9a2cb16697ea3d129e6754a2d3af7
jurayev/algorithms-datastructures-udacity
/project2/recursion/staircase.py
1,310
4.28125
4
""" Problem Statement Suppose there is a staircase that you can climb in either 1 step, 2 steps, or 3 steps. In how many possible ways can you climb the staircase if the staircase has n steps? Write a recursive function to solve the problem-2. """ def staircase(n): """ :param: n - number of steps in the stairc...
true
7c6e3af24a972f2a23dc50669bc589e47e325cd5
rtduffy827/github-upload
/python_tutorial_the_basics/example_10_sets.py
1,466
4.5625
5
example = set() print(dir(example), "\n") print(help(example.add)) example.add(42) example.add(False) example.add(3.14159) example.add("Thorium") print(example) # Notice that data of different types can be added to the set # Items inside the set are called elements # Elements of a set could appear in a different ord...
true
2bc88f03339962830e865e32bcb8927bd5be1bab
sanjay2610/InnovationPython_Sanjay
/Python Assignments/Task4/Ques4.py
421
4.21875
4
# Write a program that accepts a hyphen-separated sequence of words as input and # prints the words in a hyphen-separated sequence after sorting them alphabetically. sample = 'Run-through-the-jungle' buffer_zone = sample.split("-") buffer_zone.sort(key=str.casefold) result='' for word in buffer_zone: if word==...
true
5ad636481a085eac73c53d1e4552488c5d8ee518
sanjay2610/InnovationPython_Sanjay
/Python Assignments/Task3/ques3and4.py
377
4.28125
4
#Write a program to get the sum and multiply of all the items in a given list. list1= [1,4,7,2] sum_total = 0 mul = 1 for num in list1: sum_total +=num mul *=num print("Sum Total of all elements: ", sum_total) print("Product of all the elements in the list", mul) print("Largest number in the list: ", max(l...
true
48eb98880e53c60893014a48660a8b3f80939240
trriplejay/CodeEval
/python3/rollercoaster.py
1,269
4.3125
4
import sys if __name__ == '__main__': if sys.argv[1]: try: file = open(sys.argv[1]) except IOError: print('cannot open', sys.argv[1]) else: """ loop through the file, read one line at a time, turn it into a python list, then call...
true
dc787b60b21add5ec63daed3e9d36b2a08248d3c
trriplejay/CodeEval
/python3/simplesorting.py
1,149
4.125
4
import sys if __name__ == '__main__': """ given a list of float values, sort them and print them in sorted order """ if sys.argv[1]: try: file = open(sys.argv[1]) except IOError: print('cannot open', sys.argv[1]) else: """ loop t...
true
354467448ca6536c7e875bdd4447d807cbf04258
go4Mor4/My_CodeWars_Solutions
/7_kyu_String_ends_with?.py
493
4.1875
4
''' Instructions Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string). Examples: solution('abc', 'bc') # returns true solution('abc', 'd') # returns false ''' #CODE def solution(frase, final): final = final[::-1] frase = frase[::-1]...
true
8ed5b0e9361b907f3d90601bcd216e2e795f6ee1
morbidlust/pythonCrashCourse
/ch2/math.py
880
4.6875
5
#Adding print(2+3) #Subtracting print(2/3) #Multiplication print(2*4) #Division print(2/4) #Exponent print(3**3) #3 to the power of 3, aka 27 #Don't forget the order of operations matter! print(2+3*4) # 3*4 =12 + 2 = 14 #Use parenthesis if needed to set the order as intended) print((2...
true
4d30cb1c0922cc09aa18f76f70393bdb624e4f65
kkeefe/py_Basic
/hello_py_stuff/self_test.py
1,085
4.34375
4
<<<<<<< HEAD # stuff to write as a silly test bench of py code to place in other note sections.. # use of a map function as applied to a lambda function # make some function you want my_func = lambda x: x ** x # lets make a map for this function sequence = [1, 2, 3] my_map = list(map(my_func, sequence)) print(my_map...
true
1819a769a857c24fa11e9af79f503f160ed0e61d
isheebo/ShoppingLister
/shoppinglister/models/user.py
2,089
4.125
4
from datetime import datetime class User: """ A user represents a person using the Application""" def __init__(self, name, email, password): self.name = name self.email = email self.password = password # a mapping of ShoppingList IDs to ShoppingList names self.shopping...
true
3b2b3340575fde0709fe7b8632c0f48d202ff814
MokahalA/ITI1120
/Lab 8 Work/magic.py
2,219
4.25
4
def is_square(m): '''2d-list => bool Return True if m is a square matrix, otherwise return False (Matrix is square if it has the same number of rows and columns''' for i in range(len(m)): if len(m[i]) != len(m): return False return True def magic(m): '...
true
bfd26facfdcd3a54f02140cca999585e22eff7da
MokahalA/ITI1120
/Lab 11 Work/Lab11Ex4.py
1,044
4.3125
4
def is_palindrome_v2(s): """(str) -> bool Return whether or not a string is a palindrome. While ignoring letters not of the english alphabet """ #Just 1 letter so its a palindrome if len(s) <= 1: return True #First letter is not in the alphabet if not s[0].isalpha(): ...
true
5fc4e6f7732929cb1442da206a315a974555f5cf
Mamuntheprogrammer/Notes
/Pyhton_snippet/HackerRankString.py
2,110
4.3125
4
# Python_365 # Day-26 # Python3_Basics # Python Data Types : String # Solving String related problems: (src : hackerrank) # Problem title : sWAP cASE """ Problem description : You are given a string and your task is to swap cases. In other words, convert all lowercase letters to uppercase letters and vice versa. ...
true
972eea4d5a9c74cd3a9aae9e35c3037ce8d68a46
Sukhrobjon/Hackerrank-Challanges
/interview_kit/Sorting/bubble_sort.py
660
4.28125
4
def count_swaps(arr): """ Sorts the array with bubble sort algorithm and returns number of swaps made to sort the array """ count = 0 swapped = False while swapped is not True: swapped = True for j in range(len(arr)-1): if arr[j] > arr[j + 1]: ...
true
c77f6ee57e3500c56f4c64d920b343b600b9d1ea
Sukhrobjon/Hackerrank-Challanges
/ProblemSolving/plus_minus.py
718
4.15625
4
def plus_minus(arr): ''' print out the ratio of positive, negative and zero items in the array, each on a separate line rounded to six decimals. ''' # number of all positive numbers in arr positive = len([x for x in arr if x > 0]) # number of all negative numbers in arr negative = len(...
true
7b905d6a127cd3076cba642a7b40eb5fd3503288
blu3h0rn/AI4I_DataCamp
/07_Cleaning_Data/reg_ex.py
626
4.125
4
import re # Write the first pattern # A telephone number of the format xxx-xxx-xxxx. You already did this in a previous exercise. pattern1 = bool(re.match(pattern='\d{3}-\d{3}-\d{4}', string='123-456-7890')) print(pattern1) # Write the second pattern # A string of the format: A dollar sign, an arbitrary number of dig...
true
aff8db65519cf6c95930facf7e4a9f5794c261cc
0neMiss/cs-sprint-challenge-hash-tables
/hashtables/ex4/ex4.py
598
4.21875
4
def has_negatives(list): """ YOUR CODE HERE """ dict = {} result = [] #for each number for num in list: # if the number is positive if num > 0: #set the value of the dictionary at the key of the number equal to the number dict[num] = num #itera...
true
5ecf9ec9ff9ec7eafcda9f8c61fdb6493c338743
Andytrento/zipf
/bin/my_ls.py
606
4.1875
4
""" List the files in a given directory with a given suffix""" import argparse import glob def main(args): """Run the program""" dir = args.dir if args.dir[-1] == "/" else args.dir + "/" glob_input = dir + "*." + args.suffix glob_output = sorted(glob.glob(glob_input)) for item in glob_output: ...
true
2ab455fa9d6bbba20a4c15c1e178ae6193255d43
Pavithjanum/PythonModule1
/Module1-Q2.py
490
4.40625
4
# 2 # Write a code which accepts a sequence of words as input and prints the words in a sequence after sorting them alphabetically. # Hint: In case of input data being supplied to the question, it should be assumed to be a console input. import sys inputs = sys.argv print('Raw inputs from user',inputs[1:]) String_...
true
2ed66b56971d82556312f1a1ab8139cb62d5378c
nkat66/python-1-work
/noble_kaleb_tipcalculatorapp.py
996
4.34375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Feb 25 19:00:12 2019 Kaleb Noble 2/27/2019 Python 1 - DAT-119 - Spring 2019 Tip Calculator Assignment This program takes an input of a meal bill, then calculates and presents the user with the 10%, 15%, and 20% tip values. @author: katnob8 """ ...
true
7b9f94392c28ae061f682df6ae65e2d4d3bbfcec
gwccu/day2-rachelferrer
/day3.py
283
4.21875
4
# my code prints my name, then stores it as a variable which I can then add things to such as my last name and repeating it multiple times print("Rachel") myName = "Rachel" print(myName) print(myName + "Ferrer") print(myName*78) print("What comes first the 'chicken' or the 'egg'?")
true
fa61cb6964caf46d16e3c390a51921bd0371d2f2
mRse7enNIT/Guess_The_Number_Python
/main.py
1,975
4.21875
4
# input will come from buttons and an input field # all output for the game will be printed in the console import simplegui import math import random range = 100 no_of_guess = 0 secret_number = 0 # helper function to start and restart the game def new_game(): # initialize global variables used in your code here ...
true
08f8c4c315469294ebfedf93a8338cd3c6c368e5
qdaniel4/project3Finished
/validation.py
1,223
4.28125
4
def topic_validation(user_input): while user_input.isnumeric() is False or int(user_input) <= 0 or int(user_input) > 3: print('Please enter a whole number between 1 & 3:') user_input = input() user_input = int(user_input) if user_input == 1: topic = 'Sports' return topic ...
true
db0e1096127e695e22eb59543b0329f8bbdad662
isi-frischmann/python
/exercise.py
1,611
4.28125
4
# 1. # SET greeting AS 'hello' # SET name AS 'dojo' # LOG name + greeting greeting = 'hello' name = 'dojo' print greeting +" "+ name # 2. # Given an array of words: ['Wish', 'Mop', 'Bleet', 'March', 'Jerk'] # Loop through the array # Print each word to consol array = ['Wish', 'Mop', 'Bleet', 'March', 'Jerk'] for i...
true
6b7d0b73e2881d111d33dd98118593847032d83f
isi-frischmann/python
/multiplication_table.py
579
4.125
4
''' pseudocode: -create two lists from 0 - 12 (listHorizontal and listVertical) - create a for loop which goes through each index of listVertical -create a for loop in the for loop which goes through each index in listHorizontal -and multiplies it with index 0 from listVertical ''' #first row (horizontal) is wrong...
true
aa1bdb2b6f2dfc31f467de5d05807bbd3a3ac8c9
sirinsu/GlobalAIHubPythonHomework
/project.py
2,657
4.1875
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: """Student Management System""" def calculateFinalGrade(grades):#takes a dictionary including midterm, final and project grades then returns the final grade after some calculations. midterm = int(grades.get('midterm')) final = int(grades.get('final')) proje...
true
8ba1f5a63053442a3d804fff31c0af7554fb8d1d
GuillemGodayol/Ironhack_Data_Labs
/Week_3/lab-code-simplicity-efficiency/your-code/challenge-3.py
1,120
4.625
5
""" You are presented with an integer number larger than 5. Your goal is to identify the longest side possible in a right triangle whose sides are not longer than the number you are given. For example, if you are given the number 15, there are 3 possibilities to compose right triangles: 1. [3, 4, 5] 2. [6, 8, 10] 3. ...
true
7dcb240d949c5299263b562fbb1bb3a76943e44b
Matt-GitHub/Sprint-Challenge--Data-Structures-Python
/reverse/reverse.py
2,019
4.21875
4
class Node: def __init__(self, value=None, next_node=None): self.value = value self.next_node = next_node def get_value(self): return self.value def get_next(self): return self.next_node def set_next(self, new_next): self.next_node = new_next class LinkedList...
true
919fc9a46afa10b97448ff531296f4d33966717e
raresteak/py
/collatz.py
1,203
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # def collatz(checkNum): if checkNum % 2 == 0: newNum = checkNum // 2 #print('Entered EVEN branch, value is now: ' + str(newNum) ) return newNum else: newNum = 3 * checkNum +1 #print('Entered ODD branch, value is now: ' + str(newNum) ) return newNu...
true
8f0b416ef147905aa8de95a096079e793270370f
ssciere/100-days-of-python
/days_ago.py
530
4.25
4
"""promblem solved for the Talk Python course https://github.com/talkpython/100daysofcode-with-python-course""" import datetime from datetime import date, timedelta print("This program allows you to enter a date to find out how many days ago it occurred") day = int(input("Enter the day: ")) month = int(input("Enter ...
true
e59230a3886cb74b298041992eabf99d2247bd94
gaylonalfano/blockchain-cryptocurrency
/loops_conditionals_assignment.py
1,003
4.34375
4
# My attempt: # 1) Create a list of names and use a for loop to output the length of each name (len() ). names = ['Robert', 'Archie', 'Rudolph', 'Cloud', 'Raistlin', 'Miller', 'Fitz', 'Falco', 'Jon'] # for name in names: # print(len(name)) # 2) Add an if check inside the loop to only output names longer ...
true
00fe8b198e8cf153a2ada8b8236033e9f801856b
mradoychovski/Python
/PAYING OFF CREDIT CARD DEBT/bisection_search.py
863
4.25
4
# Uses bisection search to find the fixed minimum monthly payment needed # to finish paying off credit card debt within a year balance = float(raw_input("Enter the outstanding balance on your credit card: ")) annualInterestRate = float(raw_input("Enter the annual credit card interest rate as a decimal: ")) monthlyInt...
true
52a2b99fac1e18fd1579af864e8443a001bae6de
kgashok/algorithms
/leetcode/algorithms/spiral-matrix/solution.py
1,391
4.21875
4
#!/usr/bin/env python class Solution(object): def spiralOrder(self, matrix): """ Returns the clockwise spiral order traversal of the matrix starting at (0, 0). Modifies the matrix to contain all None values. :type matrix: List[List[int]] :rtype: List[int] """ ...
true
53a441d1adf62e68789c06718842ae64aae974a7
Kha-Lik/Olimp-Informatics-I_10-11_2021
/calculate_function.py
308
4.125
4
from math import sqrt, sin, cos def calculate(x, y): first_part = (x**3)/(3*y) third_part = 3*sin(y)/cos(x/y) num = x**3-8*x if num < 0: print("Error: cannot get sqrt of negative number") return second_part = sqrt(num) return first_part + second_part + third_part
true
482b59bb08c334c1c689197ea222fe4d6e68a19d
finjo13/assignment_II
/FinjoAss2/Qno8.py
234
4.1875
4
''' 8. Write a Python program to remove duplicates from a list. ''' someList=[23,43,33,23,12,13,13,13,67,89,89] newList=[] for item in someList: if item not in newList: newList.append(item) print(newList)
true
e57364064fc0ffd7f176bea85eded3e22fc2cb37
Levintsky/topcoder
/python/leetcode/math/970_powerful_int.py
1,278
4.1875
4
""" 970. Powerful Integers (Easy) Given two positive integers x and y, an integer is powerful if it is equal to x^i + y^j for some integers i >= 0 and j >= 0. Return a list of all powerful integers that have value less than or equal to bound. You may return the answer in any order. In your answer, each value should...
true
2ebfad24c9d71a8889f98b6f2f668e3e6d8cce56
Levintsky/topcoder
/python/leetcode/array/subarray_cont/992_subarray_K_diff_int.py
2,475
4.3125
4
""" 992. Subarrays with K Different Integers (Hard) Given an array A of positive integers, call a (contiguous, not necessarily distinct) subarray of A good if the number of different integers in that subarray is exactly K. (For example, [1,2,3,1,2] has 3 different integers: 1, 2, and 3.) Return the number of good ...
true
b3a226938dbe7c5b8ed39e06d8486edcec65fec0
Levintsky/topcoder
/python/leetcode/numerical/1073_add_negbin.py
2,526
4.25
4
""" 1073. Adding Two Negabinary Numbers (Medium) Given two numbers arr1 and arr2 in base -2, return the result of adding them together. Each number is given in array format: as an array of 0s and 1s, from most significant bit to least significant bit. For example, arr = [1,1,0,1] represents the number (-2)^3 + (-2)...
true
69c850829a9c6a9bded7752eb4f485eaccc8e8e1
NenadPantelic/GeeksforGeeks-Must-Do-Interview-preparation
/Queues/StackUsingTwoQueues.py
888
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Feb 21 20:11:12 2020 @author: nenad """ ''' :param x: value to be inserted :return: None queue_1 = [] # first queue queue_2 = [] # second queue ''' queue_1, queue_2 = [],[] def push_in_stack(x): # global declaration g...
true
c8ab858fae3988afeca03d06a5eb669bbc614be9
Connor-Cahill/call-routing-project
/project/trie.py
2,423
4.28125
4
#!python class TrieNode: """ TrieNode is the node for our Trie Class """ def __init__(self): """ Initializes new TrieNode """ self.children = [None]*10 self.cost = None def __repr__(self): return f"NODE({self.children})" class Trie: def ...
true
c92eb2d64a506f56af0ce03156176b1766f67d22
gdesjonqueres/py-complete-course
/generators/map.py
842
4.15625
4
friends = ['Rolf', 'Jose', 'Randy', 'Anna', 'Mary'] friends_lower = map(lambda x: x.lower(), friends) print(next(friends_lower)) # this is equivalent to: friends_lower = [f.lower() for f in friends] friends_lower = (f.lower() for f in friends) # prefer generator comprehension over the other two class User: def _...
true
65163e63c3495fa837d8d3ae7cb0f3a320b63bed
djpaguia/SeleniumPythonProject1
/Demo/PythonDictionary.py
1,360
4.34375
4
# There are 4 Collection data types in Python # List | Tuple | Set | Dictionary # List - [] - ordered | indexed | changeable | duplicates # Tuple - () - ordered | indexed | unchangeable | duplicates # Set - {} - unordered | unindexed | no duplicates # Dictionary - {K:V}...
true
7bb8a309c528e4d676b9cd88a38a02a44dd171b1
djpaguia/SeleniumPythonProject1
/Demo/PythonSet.py
2,007
4.5
4
# There are 4 Collection data types in Python # List | Tuple | Set | Dictionary # List - [] - ordered | indexed | changeable | duplicates # Tuple - () - ordered | indexed | unchangeable | duplicates # Set - {} - unordered | unindexed | no duplicates # Dictionary - {K:V}...
true
335c2bdee5d841a95132706f8a5a3924c3ab05f0
Esther-Wanene/training101
/lists.py
1,181
4.46875
4
empty_string = "" my_first_number = 0 empty_list = [] noise_makers= ["Brian", "Mike", 9, True] days_of_the_week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] print(days_of_the_week) number_of_days_in_a_week = len(days_of_the_week) print(number_of_days_in_a_week) # list indexing to ret...
true
90aa42e73081e6f1177ccb48753d847c18243855
Esther-Wanene/training101
/Trainee_task3.py
569
4.40625
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. For practice, #write this code inside a function # define the list you want to use as input a = [7,5, 10, 15, 20, 25] # function to slice the list with para...
true
5c33fea35ba7602309c76f301a95950656aedffe
CellEight/Interest-Rate-Prediction
/interestRatePrediction.py
240
4.3125
4
def stringTo3TupleList(string): """Takes as input a string and returns a list of all possible 3-tuples of ajacent words""" output = [] string = string.split() for i in range(len(string-2)): output.append(string[i:i+3]) return ouput
true
d33c6ade75a190274d1b81d472fe55b2b3702ebf
laurmertea/simple-chatty-bot-python-developer
/scripts/simple_counting_interaction.py
1,788
4.53125
5
# Description # Now you will teach your bot to count. It's going to become an expert in numbers! # Objective # At this stage, you will program the bot to count from 0 to any positive number users enter. # Example # The greater-than symbol followed by space (> ) represents the user input. Notice that it's not the part...
true
a0ae3540f2e8420fb821634146e3cf63b8363221
quanganh1996111/30days-python
/day-09-conditionals/exercise-3.py
363
4.28125
4
# Get two numbers from the user using input prompt. If a is greater than b return a is greater than b, if a is less b return a is smaller than b, else a is equal to b. Output: a=float(input('Nhap a bang: ')) b=float(input('Nhap b bang: ')) if a>b: print('a is greater than b') elif a<b: print('a is smaller than ...
true
b8c68289d8c60b9311eb440f5ba84cd28ce0f94e
jeremysong/rl-book-exercises
/chap_4/jacks_car_rental/jacks_car_rental.py
2,317
4.25
4
"""Jack manages two locations for a nationwide car rental company. Each day, some number of customers arrive at each location to rent cars. If Jack has a car available, he rents it out and is credited $10 by the national company. If he is out of cars at that location, then the business is lost. Cars become available fo...
true
b3cd1a9c0b97e05dc5c1de8eeafbaf665e8e0227
cwdbutler/python-practice
/Algorithms/binary search.py
680
4.15625
4
def binary_search(array, element): # return the index of the element left = 0 right = len(array) while left < right: # this should always be true so it makes the if statements loop mid = (left + right) // 2 if array[mid] == element: # if mid = element we are looking for just ret...
true
99a13ff2ab97c4222f0a82d951b9d843a40fe9c5
adisonlampert/include-projects
/Advanced-Concepts/starter-code/rock-paper-scissors/rockpaperscissors.py
1,365
4.5
4
import random import tkinter #NOTE: A function that determines whether the user wins or not # Passes the user's choice (based on what button they click)to the parameter def get_winner(call): # Access variables declared after the function so that the variables can be changed inside of the function global ...
true
a6659ece35f1f6c0f03446c1a11278f7c25d7288
lin0110/Data-Science---Unit-1-Python
/PythonBreak.py
1,145
4.53125
5
#Scenario #The break statement is used to exit/terminate a loop #Design a program that uses a while loop and continuously asks the user to enter a word unless the user enters “Chupacabra” as the secret exit word. In which case, the message “You’ve successfully left the loop.” should be printed to the screen, and the l...
true
c46c747b079d3422b9646de1390a8670e29257b9
ghostklart/python_work
/08.03.py
277
4.15625
4
def make_shirt(size, text): rmsg = f"You have ordered a {size} size shirt with '{text}' print!" print(rmsg) prompt_0 = "What size are you: " prompt_1 = "What text would you like to have printed on: " size = input(prompt_0) text = input(prompt_1) make_shirt(size, text)
true
1892d459ba8f4a64d381fe10cee41fd6270bf173
ninux1/Python
/decorators/simple_deco1.py
936
4.28125
4
#!/usr/bin/env python """ Plz refer to simple_deco.py for some reference on decorators. This syntax may not be exactly like the decorator but its the same for exact syntax plz refer to actual_deco.py at same location. """ def called(func): # This is a function to receive the function to be modified/decorated. i.e de...
true
2653c8b66067aa50c5701f2bec1c69e468c6b664
rajsingh7/Cracking-The-Machine-Learning-Interview
/Supervised Learning/Regression/question13.py
942
4.3125
4
# When would you use k-Nearest Neighbors for regression? from sklearn import neighbors import numpy as np import matplotlib.pyplot as plt # Let's create a small random dataset np.random.seed(0) X = 15 * np.random.rand(50, 1) y = 5 * np.random.rand(50, 1) X_test = [[1], [3], [5], [7], [9], [11], [13]] # We will use k...
true
d2dbe7bb9c6eee567fb4ad09a449e2ac2a0ac31c
EmirVelazquez/thisIsTheWay
/lists.py
1,716
4.28125
4
# Working with lists basics (similar to an array from JS) random_numbers = [44, 4, 5, 24, 42, 10] office_char = ["Michael", "Jim", "Dwight", "Pam", "Karen", "Toby", "Dwight", "Dwight"] print(office_char) # Return element index 4 print(office_char[4]) # Return element from index 2 and forward print(office_char[2:]) # R...
true
4fd7fe64bf80f30b56911568b72a5cfa2371bb60
Vinodkannojiya/PythonStarter1
/8_Swapping_numbers.py
318
4.125
4
#method 1 Swapping with temp/extra variable a,b=5,2 print("a before is ",a," and b before is ",b) temp=a a=b b=temp print("a after is ",a," and b after is ",b) #Method swapping wothout extra variable c,d=5,2 print("c before is ",c," and d before is ",d) d=c+d c=d-c d=d-c print("c after is ",c," and d after is ",d)
true
db4b0b8eb0c68c5275b092287821c4a45deb47f1
SenpaiPotato/gwc
/chatbot.py
2,169
4.1875
4
import random # --- Define your functions below! --- def introduction(): acceptable_answers = ["hey", "hello", "hi", "holla", "what's up"] answer = input("Hello? ") if answer in acceptable_answers: print("I am nani nice to meet you ") else: print("That's cool!") def rock_paper_s...
true
80531e604b5a016e89fc250874f79126dffb3a76
mikej803/digitalcrafts-2021
/python/homework/shortS.py
265
4.15625
4
strings = ['work', 'bills', 'family', 'vacation', 'money'] def shortest(strings): shortest = strings[0] for i in strings: if i <= shortest: shortest = i print('This is the shortest string:', shortest ) shortest(strings)
true
c5ef5a96108672e690cbe1c15b2e0a47660fadbe
SaranyaEnesh/luminarpython
/luminarpython1/regularexpression/quantifiers.py
392
4.25
4
from re import * #pattern="a+"#it check only the position of more than a #pattern="a*"#it check all positions #pattern="a?"#it check all position individually #pattern="a{2}"#chk 2 num of a pattern="a{2,3}"#mini 2 and max 3 num of a matcher=finditer(pattern,"aabaaaabbabbaaaa") count=0 for match in matcher: print(ma...
true
a024de3e492cbcfe653c2b6e7a08a9c58c313e98
Mahalakshmi7619523920/Mahalakshmi.N
/maxofthreenumbers.py
218
4.15625
4
def max (a,b,c): if a>b and b>c: l=a elif b>a and a>c: l=b else: l=c return l print("enter three values") a=input() b=input() c=input() l=max(a,b,c) print("largest is",l)
true
b9adbdd32cf3825be8c02145d9c8db7d11deeee0
afarica/Task2.16
/p26.py
426
4.15625
4
# If you were on the moon now, your weight will be 16,5% of your earth weight. # To calculate it you have to multiple to 0,165. If next 15 years your weight will # increase 1 kg each year. What will be your weight each year on the moon next # 15 years? your_weight=float(input("Enter your weight:")) years=int(input("How...
true
c972456c92ebe364ca07cec941b0de83d664e4bd
INOS-soft/Python-LS-LOCKING-Retunning-access
/3.3 Weighted Independent Set.py
2,175
4.15625
4
""" 3.Question 3 In this programming problem you'll code up the dynamic programming algorithm for computing a maximum-weight independent set of a path graph. This file (mwis.txt) describes the weights of the vertices in a path graph (with the weights listed in the order in which vertices appear in the path). It ha...
true
121db2d5907a4251729c7ecf67ebe77673f90bc4
trainingpurpose/python_exercises
/src/py_exercises/lists.py
339
4.21875
4
# -*- coding: utf-8 -*- from py_exercises.recursion import * def my_last(arr): """Find the last element of a list""" return arr[-1] def my_last_recursive(arr): return head(arr) if not tail(arr) else my_last_recursive(tail(arr)) def my_but_last(arr): """Find the last but one element of a list""" ...
true
691e45c3e27dd22286408a645c9b3de691002632
theamurtagh/exercises
/fibo.py
1,486
4.34375
4
# Ian McLoughlin # A program that displays Fibonacci numbers. def fib(n): """This function returns the nth Fibonacci number.""" i = 0 j = 1 n = n - 1 while n >= 0: i, j = j, i + j n = n - 1 return i # Test the function with the following value. x = 21 ans = fib(x) print("Fibonacci number", x,...
true
315c8e3a35b4cfb73c61ac77cafd96d11d22e9e3
zardra/Book_Catalog
/books.py
2,144
4.5
4
class Book(object): """Class for creating individual book objects. The defaults for bookcase and shelf are empty strings because a book can be created without placing it on a bookcase shelf. The default for the has_read setting is False because it is assumed that books are being cataloged ...
true
2d9092c4d466439da70443d490dbb13fd5fbe574
edimaudo/Python-projects
/daily_coding/coding_bat/Warmup-1/front3.py
315
4.21875
4
#Given a string, we'll say that the front is the first 3 chars of the string. If the string length is less than 3, the front is whatever is there. Return a new string which is 3 copies of the front. def front3(str): if len(str) >= 3: return 3*(str[0]+str[1]+str[2]) else: return 3*str
true
235a331f4571490ddcafe04dddabe5662af7eb0c
edimaudo/Python-projects
/daily_coding/coding_bat/List-2/centered_average.py
1,151
4.1875
4
##Return the "centered" average of an array of ints, which we'll say is the mean average of the values, except ignoring the largest and smallest values in the array. If there are multiple copies of the smallest value, ignore just one copy, and likewise for the largest value. Use int division to produce the final aver...
true
bab6f2a3306cbc34bc355d2b07b1e97238668921
marangoni/nanodegree
/Rascunhos/Lição 12 - Resolução problemas/aniversario.py
1,476
4.1875
4
# Given your birthday and the current date, calculate your age # in days. Compensate for leap days. Assume that the birthday # and current date are correct dates (and no time travel). # Simply put, if you were born 1 Jan 2012 and todays date is # 2 Jan 2012 you are 1 day old. # IMPORTANT: You don't need to solve the p...
true
22b165f8dcee9d2c1caad06e83e45085952cade8
Wanna101/CSC119-Python
/accountBalance.py
863
4.125
4
""" David Young CSC119-479 6/14/2020 Julie Schneider """ def main(): # initial balance is $1000 # 5% interest per year # find balance after first, second, and third year # expected answers: # year 0 = 1000 # year 1 = 1050 # year 2 = 1102.5 # year 3 = 1157....
true
b9d441dfd55730285e13e86e7a476f6ee62c0e7b
dugiwarc/Python
/old/find_factors.py
288
4.1875
4
def find_factors(num): """ parameters: a number returns: a list of all of the numbers which are divisible by starting from 1 and going up the number """ factors = [] i = 1 while i <= num: if num % i == 0: factors.append(i) i += 1 return factors print(find_factors(100))
true
ff90e6c18e4b2de09c1ff1e8c240b87b9e3a7211
kerslaketschool/Selection
/if_improvement_excercise.py
905
4.21875
4
#Toby Kerslake #25-09-14 #selection improvement exercise month = int(input("Please enter a month as a number between 1-12: ")) if month == 1: print("The first month is January") elif month == 2: print("The second month is February") elif month == 3: print("The third month is March") elif month...
true