blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
6a6a06d047a95ed76a60ed9f2392016f6d379ccf
motleytech/crackCoding
/arraysAndStrings/urlify.py
1,506
4.34375
4
''' Replace all spaces in a string with '%20' We can do this easily in python with the string method 'replace', for example to urlify the string myurl, its enough to call myurl.replace(' ', '%20') Its that simple. To make the task a little more difficult (to be more in line with what the question expects), we will c...
true
edf168e27bffaa08a8f44733f3b55a524ff3052f
ZswiftyZ/Nested_Control_Structures
/Nested Control Structures.py
1,064
4.25
4
""" Programmer: Trenton Weller Date: 10.15.19 Program: This program will nest a for loop inside of another for loop """ for i in range(3): print("Outer for loop: " + str(i)) for l in range(2): print(" innner for loop: " +str(l)) """ Programmer: Trenton Weller Date: 10.22.19 Program: Aver...
true
fe6259b11728d674f4e31caef1a1d284bc2b225a
Harshhg/python_data_structures
/Arrays/alternating_characters.py
634
4.125
4
''' You are given a string containing characters A and B only. Your task is to change it into a string such that there are no matching adjacent characters. To do this, you are allowed to delete zero or more characters in the string. Your task is to find the minimum number of required deletions. For example, given the ...
true
368a07b7981351a62e8090e04924e62e0a03bafa
Harshhg/python_data_structures
/Graph/py code/implementing_graph.py
1,481
4.28125
4
#!/usr/bin/env python # coding: utf-8 # In[1]: # Implementing Graph using Adjacency List from IPython.display import Image Image("graph.png") # In[6]: # Initializing a class that will create a Adjacency Node. class AdjNode: def __init__(self,data): self.vertex = data self.next = None # In[1...
true
6d9e626308c9d866e15c071a6b0e74a3f38eeda5
NiklasAlexsander/IN3110
/assignment3/wc.py
2,168
4.40625
4
#!/usr/bin/env python import sys def main(): """Main function to count number of lines, words, and characters, for all the given arguments 'filenames' given. A for-loop goes through the array of arguments given to wc.py when run from from the terminal. Inside the loop each argument will be 'open' for...
true
5d86b8b02a006566aefd819c9249151916514c82
TECHNOCRATSROBOTICS/ROBOCON_2018
/Computer Science/Mayankita Sisodia/ll.py
1,564
4.53125
5
# TO INSERT A NEW NODE AT THE BEGINNING OF A LINKED LIST class Node: # Function to initialize the node object def __init__(self, data): self.data = data # Assign data to the node. self.next = None # In...
true
dca26a9e0cc1952bd168baae5621036c8ac19e8d
TECHNOCRATSROBOTICS/ROBOCON_2018
/Computer Science/Mayankita Sisodia/tree.py
1,955
4.28125
4
class Node: def __init__(self, val): #constructor called when an object of class Node is created self.left = None #initialising the left and right child node as null self.right = None self.data = val ...
true
818f452713e6fce3908f59df610f6a9e4dd073b9
mo2274/CS50
/pset7/houses/import.py
1,508
4.375
4
from sys import argv, exit import cs50 import csv # check if the number of arguments is correct if len(argv) != 2: print("wrong argument number") exit(1) # create database db = cs50.SQL("sqlite:///students.db") # open the input file with open(argv[1], "r") as characters: # Create Reader reader_csv ...
true
d56d83109a66b60b73160c4a45d770d01ef76274
Stuff7/stuff7
/stuff7/utils/collections/collections.py
1,021
4.1875
4
class SafeDict(dict): """ For any missing key it will return {key} Useful for the str.format_map function when working with arbitrary string and you don't know if all the values will be present. """ def __missing__(self, key): return f"{{{key}}}" class PluralDict(dict): """ Parses keys with the form "k...
true
68b0ed0774592899b32fc7838d54d9d361a05ff8
gevuong/Developer-Projects
/python/number_game.py
1,407
4.21875
4
import random def game(): # generate a random number between 1 and 10 secret_num = random.randint(1, 10) # includes 1 and 10 as possibilities guess_count = 3 while guess_count > 0: resp = input('Guess a number between 1 and 10: ') try: # have player guess a number ...
true
8f8cb15ef494edb05050d9eb8e82047c89dd1ad1
chandrikakurla/inorder-traversal-using-stack-in-python
/bt_inorder traversal using stack.py
1,018
4.28125
4
#class to create nodes of a tree class Node: def __init__(self,data): self.left=None self.data=data self.right=None #function to inorder traversal of a tree def print_Inorder(root): #initialising stack stack=[] currentnode=root while True: #reach leftmost...
true
1398699207d99c1fd94e7ed1e72fc3ec0cb661de
cvk1988/biosystems-analytics-2020
/assignments/01_strings/vpos.py
1,425
4.375
4
#!/usr/bin/env python3 """ Author : cory Date : 2020-02-03 Purpose: Find the vowel in a string """ import argparse import os import sys # -------------------------------------------------- def get_args(): """Get command-line arguments""" parser = argparse.ArgumentParser( description='Rock the Casb...
true
d5ff9d18c1fdf3e489080b6925293d5626adae93
sideroff/python-exercises
/01_basic/exercise_024.py
363
4.25
4
def is_vowel(char: str): vowels = ('a', 'e', 'i', 'o', 'u') if len(string_input) > 1: print("More than 1 character received. Choosing the first char as default.") char = string_input[:1] print("Your char is a vowel" if char in vowels else "Your char is not a vowel") string_input = input(...
true
58a9abb0dae2450fd180b6e00ae41748647b9176
sideroff/python-exercises
/various/class_properties.py
634
4.15625
4
# using property decorator is a different way to say the same thing # as the property function class Person: def __init__(self, name: str): self.__name = name def setname(self, name): self.__name = name def getname(self): return self.__name name = property(getname, setname) ...
true
bd11a5ebbf2cdb102526ec1f39866c801e04ff54
ladamsperez/python_excercises
/Py_Gitbook.py
2,123
4.75
5
# # Integer refers to an integer number.For example: # # my_inte= 3 # # Float refers to a decimal number, such as: # # my_flo= 3.2 # # You can use the commands float()and int() to change from onte type to another: # float(8) # int(9.5) # fifth_letter = "MONTY" [4] # print (fifth_letter) # #This code breaks because Py...
true
8c650f2e69061c4d164e8028b41009512e47d715
ladamsperez/python_excercises
/task6_9.py
636
4.125
4
# Write a python function that takes a list of names and returns a new list # with all the names that start with "Z" removed. # test your function on this list: # test_list = ['Zans', 'Dan', 'Grace', 'Zelda', 'L.E.', 'Zeke', 'Mara'] test_list = ['Zans', 'Dan', 'Grace', 'Zelda', 'L.E.', 'Zeke', 'Mara'] def noznames...
true
b3facc57e8f25fe47cbd1b12d94d98403d490c9a
GabrielCernei/codewars
/kyu6/Duplicate_Encoder.py
596
4.15625
4
# https://www.codewars.com/kata/duplicate-encoder/train/python ''' The goal of this exercise is to convert a string to a new string where each character in the new string is "(" if that character appears only once in the original string, or ")" if that character appears more than once in the original string. Ignore ...
true
2811c2f7ad8732f43ab8498fb10ba05d8e6ad1e6
GabrielCernei/codewars
/kyu6/Opposite_Array.py
342
4.15625
4
# https://www.codewars.com/kata/opposite-array/train/python ''' Given an array of numbers, create a function called oppositeArray that returns an array of numbers that are the additive inverse (opposite or negative) of the original. If the original array is empty, return it. ''' def opposite_list(numbers): return...
true
61e909280a67b37ae7f53ace4915e2ef3b51ba67
GabrielCernei/codewars
/kyu6/To_Weird_Case.py
859
4.5625
5
# https://www.codewars.com/kata/weird-string-case/train/python ''' Note: The instructions are not very clear on this one, and I wasted a lot of time just trying to figure out what was expected. The goal is to alternate the case on *EACH WORD* of the string, with the first letter being uppercase. You will not pass al...
true
0e26c6bb0da2b0e5546e86aa6b2cb6ba09b27ccf
enajeeb/python3-practice
/PythonClass/answer_files/exercises/sorting.py
711
4.1875
4
# coding: utf-8 ''' TODO: 1. Create a function called sort_by_filename() that takes a path and returns the filename. - Hint: You can use the string's split() function to split the path on the '/' character. 2. Use sorted() to print a sorted copy of the list, using sort_by_filename as the sorting function. ''' p...
true
c09cdf2e94f9060f285d01e110dc2fc48f2db496
enajeeb/python3-practice
/PythonClass/class_files/exercises/lists.py
688
4.34375
4
# coding: utf-8 ''' Lists Lists have an order to their items, and are changeable (mutable). Documentation: https://docs.python.org/2/tutorial/introduction.html#lists ''' # Square brackets create an empty list. animals = [] # The append() function adds an item to the end of the list. animals.append('cat') animals...
true
cffa20e72d74c07324bac4fdd490bac5218dae9a
enajeeb/python3-practice
/PythonClass/class_files/exercises/functions.py
552
4.40625
4
# coding: utf-8 ''' Useful functions for the Python classs. ''' ''' TODO: 1. Create a function called words(). 2. The function should take a text argument, and use the string's split() function to return a list of the words found in the text. The syntax for defining a function is: def func_name(arg...
true
dd18b7dbf8cf814f889a497c4565dcb3b1d12719
drnodev/CSEPC110
/meal_price_calculator.py
1,349
4.15625
4
""" File:meal_price_calculator.py Author: NO Purspose: Compute the price of a meal as follows by asking for the price of child and adult meals, the number of each, and then the sales tax rate. Use these values to determine the total price of the meal. Then, ask for the payment amount and compute the amount of chan...
true
844344450154b2caacee4af1a0530e14781b9ace
sayan19967/Python_workspace
/Python Application programming practice/Context Managers.py
2,410
4.59375
5
#A Context Manager allows a programmer to perform required activities, #automatically, while entering or exiting a Context. #For example, opening a file, doing few file operations, #and closing the file is manged using Context Manager as shown below. ##with open('a.txt', 'r') as fp: ## ## content = fp.read...
true
81eccca3e13efaf255a41a92b5f7ee203a6aca41
Elzwawi/Core_Concepts
/Objects.py
2,689
4.4375
4
# A class to order custom made jeans # Programming with objects enables attributes and methods to be implemented # automatically. The user only needs to know that methods exist to use them # User can focus on completing tasks rather than operation details # Difference between functions and objects: Objects contain stat...
true
af30645406d953795958b806cf529f1ce97150c2
ZSerhii/Beetroot.Academy
/Homeworks/HW6.py
2,918
4.1875
4
print('Task 1.\n') print('''Make a program that generates a list that has all squared values of integers from 1 to 100, i.e., like this: [1, 4, 9, 16, 25, 36, ..., 10000] ''') print('Result 1:\n') vResultList = [] for i in range(1, 101): vResultList.append(i * i) print('Squared values list of integers from 1 to...
true
4cc9d559c7a44cd2f500a60548fc6b98294828f0
erictseng89/CS50_2021
/week6/scores.py
769
4.125
4
scores = [72, 73, 33] """ print("Average: " + (sum(scores) / len(scores))) """ # The "len" will return the number of values in a given list. # The above will return the error: # TypeError: can only concatenate str (not "float") to str # This is because python does not like to concatenate a float value to a string. ...
true
72548593092cdbc2ddb64d76951d71d4a89b93e3
mzdesa/me100
/hw1/guessNum.py
599
4.21875
4
#write a python program that asks a user to guess an integer between 1 and 15! import random random_num = random.randint(1,15) #generates a random int between 0 and 15 guess = None #generate an empty variable count = 0 while guess != random_num: count+=1 guess = int(input('Take a guess: ')) if guess == rand...
true
e7011a00db9e29abb6e8ad19259dfcacc1423525
abrolon87/Python-Crash-Course
/useInput.py
1,219
4.28125
4
message = input("Tell me something, and I will repeat it back to you: ") print (message) name = input("Please enter your name: ") print(f"\nHello, {name}!") prompt = "If you tell us who you are, we can personalize the messages you see." prompt += "\nWhat is your first name? " #prompt += "\nWhat is your age? " this do...
true
1957711865e1570ed423c327f288ce8a12d2fe50
jacquelinefedyk/team3
/examples_unittest/area_square.py
284
4.21875
4
def area_squa(l): """Calculates the area of a square with given side length l. :Input: Side length of the square l (float, >=0) :Returns: Area of the square A (float).""" if l < 0: raise ValueError("The side length must be >= 0.") A = l**2 return A
true
a957e7f81f52bc56d9af1cd63a284f2e597c6f9d
JohnAsare/functionHomework
/upLow.py
766
4.15625
4
# John Asare # Jun 19 2020 """ Write a Python function that accepts a string and calculates the number of upper case letters and lower case letters. Sample String : 'Hello Mr. Rogers, how are you this fine Tuesday?' Expected Output : No. of Upper case characters : 4 No. of Lower case Characters : 33 """ def up_low(...
true
f5306409b6be76bdc3ce5789daafcca973fdb971
kelvinng213/PythonDailyChallenge
/Day09Challenge.py
311
4.1875
4
#Given a string, add or subtract numbers and return the answer. #Example: #Input: 1plus2plus3minus4 #Output: 2 #Input: 2minus6plus4plus7 #Output: 7 def evaltoexpression(s): s = s.replace('plus','+') s = s.replace('minus','-') return eval(s) print(evaltoexpression('1plus2plus3minus4'))
true
e082eb4ff18f0f3a19576a5e3e346227ba98ebf8
kelvinng213/PythonDailyChallenge
/Day02Challenge.py
894
4.53125
5
# Create a function that estimates the weight loss of a person using a certain weight loss program # with their gender, current weight and how many weeks they plan to do the program as input. # If the person follows the weight loss program, men can lose 1.5% of their body weight per week while # women can lose 1.2% o...
true
45f5407c770e494c7d9be2fbcbf1802e56c74e21
rohan-krishna/dsapractice
/arrays/array_rotate.py
533
4.125
4
# for the sake of simplicity, we'll use python list # this is also known as Left Shifting of Arrays def rotateArray(arr, d): # arr = the input array # d = number of rotations shift_elements = arr[0:d] arr[:d] = [] arr.extend(shift_elements) return arr if __name__ == "__main__": print("How m...
true
bba98a339cc3fe159b5db7a6979f37a1e6467eee
shridharkute/sk_learn_practice
/recursion.py
668
4.375
4
#!/usr/bin/python3 ''' This is recursion example. recursion is method to call itself while running. Below is the example which will create addition till we get 1. Eg. If we below funcation as "tri_resolution(6)" the result will be Rcursion example result 1 1 2 3 3 6 4 10 5 15 6 21 But in the background it will execu...
true
600409d5897e5a6a2a8fa5900a8ca197abf294f7
DAVIDCRUZ0202/cs-module-project-recursive-sorting
/src/searching/searching.py
798
4.34375
4
# TO-DO: Implement a recursive implementation of binary search def binary_search(arr, target, start, end): if len(arr) == 0: return -1 low = start high = end middle = (low+high)//2 if arr[middle] == target: return middle if arr[middle] > target: return binary_search(ar...
true
1e4ecc5c66f4f79c0f912313acd769edb3a92008
harshal-jain/Python_Core
/22-Lists.py
1,980
4.375
4
list1 = ['physics', 'chemistry', 1997, 2000] list2 = [1, 2, 3, 4, 5, 6, 7 ] """ print ("list1[0]: ", list1[0]) #Offsets start at zero print ("list2[1:5]: ", list2[1:5]) #Slicing fetches sections print ("list1[-2]: ", list1[-2]) #Negative: count from the right print ("Value available at index 2 : ", list1[2]) list1[...
true
b253f828fc56c2f9e7148e13ae2a910c542f1249
cosmos512/PyDevoir
/StartingOutWithPy/Chapter 05/ProgrammingExercises/03_budget_analysis.py
1,540
4.40625
4
# Write a program that asks the user to enter the amount that they have # budgeted for a month. A loop should then prompt the user to enter each of # their expenses for the month, and keep a running total. When the loop # finishes, the program should display the amount that the user is over # or under budget. def budg...
true
88cfb1d6b2746e689d6a661caa34e5545f044670
cosmos512/PyDevoir
/StartingOutWithPy/Chapter 04/ProgrammingExercises/09_shipping_charges.py
1,098
4.4375
4
# The Fast Freight Shipping Company charges the following rates: # # Weight of Package Rate per Pound # 2 pounds or less $1.10 # Over 2 pounds but not more than 6 pounds $2.20 # Over 6 pounds but not more than 10 pounds $3.70 #...
true
4d24d83ec69531dd864ef55ed900a6d154589fd8
cosmos512/PyDevoir
/StartingOutWithPy/Chapter 03/ProgrammingExercise/04_automobile_costs.py
1,248
4.34375
4
# Write a program that asks the user to enter the monthly costs for the # following expenses incurred from operating his or her automobile: loan # payment, insurance, gas, oil, tires, and maintenance. The program should # then display the total monthly cost of these expenses, and the total # annual cost of these expens...
true
36e179b5db4afaf4b7bc2b6a51f0a81735ac2002
cosmos512/PyDevoir
/StartingOutWithPy/Chapter 06/ProgrammingExercises/01_feet_to_inches.py
521
4.40625
4
# One foot equals 12 inches. Write a function named feet_to_inches that # accepts a number of feet as an argument, and returns the number of inches # in that many feet. Use the function in a program that prompts the user # to enter a number of feet and then displays the number of inches in that # many feet. def main()...
true
a8bf3cc39005180b6d3b2d18a751c43f3665ec23
cosmos512/PyDevoir
/StartingOutWithPy/Chapter 07/ProgrammingExercises/09_exception_handling.py
348
4.125
4
# Modify the program that you wrote for Exercise 6 so it handles the following # exceptions: # • It should handle any IOError exceptions that are raised when the file is # opened and data is read from it. # • It should handle any ValueError exceptions that are raised when the items # that are read from the file are...
true
3d4cba89be0858b757da7c59a4845ab4360d28d3
cosmos512/PyDevoir
/StartingOutWithPy/Chapter 06/ProgrammingExercises/05_kinetic_energy.py
1,110
4.40625
4
# In physics, an object that is in motion is said to have kinetic energy (KE). # The following formula can be used to determine a moving object’s kinetic # energy: # # KE = (1/2) * m * v^2 # # The variables in the formula are as follows: KE is the kinetic energy in # joules, m is the object’s mass in kilogr...
true
8cccedbab97b4439c53bbec5f443011066947897
kescalante01/learning-python
/Address.py
867
4.28125
4
#Use raw_input() to allow a user to type an address #If that address contains a quadrant (NW, NE, SE, SW), then add it to that quadrant's list. #Allow user to enter 3 addresses; after three, print the length and contents of each list. ne_adds = [] nw_adds = [] se_adds = [] sw_adds = [] address1 = raw_input("Whats y...
true
6d72e4e2ce4447de1dfee99def28204c089f7faf
riteshsingh1/learn-python
/string_function.py
406
4.34375
4
string="Why This Kolaveri DI" # 1 # len(string) # This function returns length of string print(len(string)) # 2 # In Python Every String is Array string = "Hello There" print(string[6]) # 3 # index() # Returns index of specific character / Word - First Occurance string="Python is better than PHP." print(string.inde...
true
6b8442b9cd22aa2eeb37966d42ca6511f3ba6c17
antoninabondarchuk/algorithms_and_data_structures
/sorting/merge_sort.py
797
4.125
4
def merge_sort(array): if len(array) < 2: return array sorted_array = [] middle = int(len(array) / 2) left = merge_sort(array[:middle]) right = merge_sort(array[middle:]) left_i = 0 right_i = 0 while left_i < len(left) and right_i < len(right): if left[left_i] > right[rig...
true
12ee12d7d101ed158bae6079f14e8a6360c424f6
elicecheng/Python-Practice-Code
/Exercise1.py
359
4.15625
4
#Exercise 1 #Asks the user to enter their name and age. #Print out a message addressed to them that #tells them the year that they will turn 100 years old. import datetime name = input("What is your name?") age = int(input("How old are you?")) now = datetime.datetime.now() year = (now.year - age) + 100 print(name, ...
true
cb04890ea51898c5c225686f982e77da4dc71535
playwithbear/Casino-Games
/Roulette Basic.py
1,488
4.28125
4
# Basic Roulette Mechanics # # Key attributes: # 1. Provide a player with a balance # 2. Take a player bet # 3. 'Spin' Roulette wheel # 4. Return result to player and update balance if necessary with winnings # # NB. This roulette generator only assumes a bet on one of the evens i.e. red of black to test a gam...
true
c413add161722e8efad1b4319463ede4f5a3aff8
ramsundaravel/PythonBeyondBasics
/999_Misc/004_generators.py
1,140
4.375
4
# Generators - # Regular function returns all the values at a time and goes off # but generator provides one value at a time and waits for next value to get off. function will remain live # it basically yields or stops for next call # basically not returning all values together. returning one value at a time def gene...
true
d70c7e14cb9974a1320850eb1e70fa2fb1e14dd7
AhmedElatreby/python_basic
/while_loop.py
2,392
4.4375
4
""" # While Loop A while loop allows code to be repeated an unknown number of times as long as a condition is being met. ======================================================================================================= # For Loop A for loop allows code to be repeated known number of loops/ iterations """ # impo...
true
4280063ba51d897bdb1049d6a1a84c6625ed0a39
igor-kurchatov/python-tasks
/Warmup1/pos_neg/pos_neg_run.py
355
4.1875
4
################################# # Task 8 - implementation # Desription: Given 2 int values, return True if one is negative and one is positive. # Except if the parameter "negative" is True, then return True only if both are negative. # Author : Igor Kurchatov 5/12/2016 ################################# from ...
true
0fe469e04d72b5e225fdc4279f6f4c9542031644
AmeyMankar/PracticePython
/Exercise2.py
462
4.28125
4
# Let us find the sum of several numbers (more than two). It will be useful to do this in a loop. #http://www.codeabbey.com/index/task_view/sum-in-loop user_input = [] sum_of_numbers = 0 choice=1 while choice != 2: user_input.append(int(input("Please enter your number: \t"))) choice = int(input("Do you want to add...
true
edbc80e91c8a9ad244bee62bcfe3809a3dce876a
ethanpierce/DrZhao
/LinkedList/unitTestLinkedList.py
644
4.15625
4
from linkedlist import LinkedList def main(): #Create list of names listOfNames = { "Tom", "Harry","Susan","Ethan","Willy","Shaina"} #Create linkedlist object testinglist = LinkedList() #Test insertion method for name in listOfNames: testinglist.insert(name) #Test size of list ...
true
97fc123c1a6beb45aa2893c0c4a8d21bfc41b174
dvcolin/Sprint-Challenge--Data-Structures-Python
/reverse/reverse.py
2,387
4.1875
4
class Node: def __init__(self, value=None, next_node=None): # the value at this linked list node self.value = value # reference to the next node in the list self.next_node = next_node def get_value(self): return self.value def get_next(self): return self.nex...
true
1041fe53fa1dbc0a91f0602f20530a4608656069
tadeograch/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/0-add_integer.py
483
4.3125
4
#!/usr/bin/python3 """ 0. Integers addition A function that adds 2 integers add_integer(a, b) """ def add_integer(a, b=98): """ Function that add two integers """ if not type(a) is int and not type(a) is float: raise TypeError("a must be an integer") if not type(b) is int and not type(b) ...
true
0725747b9015941bac5f87ff3c5a9372ab9fd5cc
uoshvis/py-data-structures-and-algorithms
/sorting_and_selection/selection.py
1,527
4.15625
4
# An example of prune-and-search design pattern import random def binary_search(data, target, low, high): """Return True if target is found in indicated portion of a Python list. The search only considers the portion from data[low] to data[high] inclusive. """ if low > high: return False ...
true
0ae6074efd9a9b393439a72b9f596d4baf09f7c8
v13aer14ls/exercism
/salao_de_beleza.py
1,538
4.21875
4
#!/bin/python2/env #Guilherme Amaral #Mais um exercicio daqueles hairstyles = ["bouffant", "pixie", "dreadlocks", "crew", "bowl", "bob", "mohawk", "flattop"] prices = [30, 25, 40, 20, 20, 35, 50, 35] last_week = [2, 3, 5, 8, 4, 4, 6, 2, 1] #1. Create a variable total_price, and set it to 0. total_price = 0 #2. I...
true
ff01b081c831b0593ebb3722ee47ca04b2406991
Praneeth313/Python
/Loops.py
1,363
4.25
4
# -*- coding: utf-8 -*- """ Created on Thu May 6 23:02:40 2021 @author: Lenovo Assignment 5: Basic Loop Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of ...
true
9018be0092cebcda903279b87fcdb9e78a8c79fb
akshat12000/Python-Run-And-Learn-Series
/Codes/98) list_comprehension_in_nested_list.py
389
4.53125
5
# List comprehension in nested list # We want the list --> [[1,2,3], [1,2,3], [1,2,3]] # Method 1)--> without list comprehension l=[] for i in range(3): p=[] for j in range(1,4): p.append(j) l.append(p) print(l) # Method 2)--> with list comprehension l1=[[i for i in range(1,4)] for _ in...
true
8f9ef1a6b1b42b511331646021caa6a7e9b298eb
akshat12000/Python-Run-And-Learn-Series
/Codes/104) args_as_argument.py
296
4.28125
4
def multiply(*args): mul=1 print(f"Elements in args are {args}") for i in args: mul*=i return mul l=[1,2,3] t=(1,2,3) print(multiply(l)) # OUTPUT: [1,2,3] print(multiply(*l)) # OUTPUT: 6 , here all the elements of the list will get unpacked print(multiply(*t))
true
4cd283528b382fab7369630629c6f46d0993590c
akshat12000/Python-Run-And-Learn-Series
/Codes/134) generators_intro.py
569
4.65625
5
# generators are iterators # iterators vs iterables l=[1,2,3,4] # iterable l1=map(lambda a:a**2,l) # iterator # We can use loops to iterate through both iterables and iterators!! li=[1,2,3,4,5] # memory --- [1,2,3,4,5], list, it will store as a chunk of memory!! # memory --- (1)->(2)->(3)->(4)->(5), genera...
true
82703ca80bd6745995fd86e4de8a7ae6e978efc5
akshat12000/Python-Run-And-Learn-Series
/Codes/137) generators_comprehension.py
444
4.21875
4
# Genrators comprehension square=[i**2 for i in range(1,11)] # list comprehension print(square) square1=(i**2 for i in range(1,11)) # generator comprehension print(square1) for i in square1: print(i) for i in square1: print(i) # Notice that it will print only once!! square2=(i**2 for i in r...
true
5e5bcdee2c5fd58e9532872a8c4403e8cf47d49f
akshat12000/Python-Run-And-Learn-Series
/Codes/22) string_methods2.py
298
4.25
4
string="He is good in sport and he is also good in programming" # 1. replace() method print(string.replace(" ","_")) print(string.replace("is","was",1)) print(string.replace("is","was",2)) # 2. find() method print(string.find("is")) print(string.find("also")) print(string.find("is",5))
true
7613ae3e2b62c471be17440d5ce22679b7d61d0d
akshat12000/Python-Run-And-Learn-Series
/Codes/119) any_all_practice.py
421
4.1875
4
# Write a funtion which contains many values as arguments and return sum of of them only if all of them are either int or float def my_sum(*args): if all([type(i)== int or type(i)== float for i in args]): total=0 for i in args: total+=i return total else: r...
true
ea0f61c783a093d998866e3b7843daa2cbd01e4a
akshat12000/Python-Run-And-Learn-Series
/Codes/126) closure_practice.py
399
4.125
4
# Function returning function (closure or first class functions) practice def to_power(x): def calc_power(n): return n**x return calc_power cube=to_power(3) # cube will be the calc_power function with x=3 square=to_power(2) # square will be the calc_power function with x=2 print(cube(int(input...
true
7232967214c29480b14d437eba3a42e5a2b23a5f
akshat12000/Python-Run-And-Learn-Series
/Codes/52) greatest_among_three.py
365
4.125
4
# Write a function which takes three numbers as an argument and returns the greatest among them def great3(a,b,c): if a>b: if a>c: return a return c else: if b>c: return b return c x,y,z=input("Enter any three numbers: ").split() print(f"Greates...
true
ba1551611784af483ea8341a3fdbccc5a5d8b235
akshat12000/Python-Run-And-Learn-Series
/Codes/135) first_generator.py
932
4.5625
5
# Create your first generator with generator function # Method 1) --> generator function # Method 2) --> generator comprehension # Write a function which takes an integer as an argument and prints all the numbers from 1 to n def nums(n): for i in range(1,n+1): print(i) nums(5) def nums1(n): ...
true
fd70a0a0c399b7ea099ad0df2069b1b861f7ac6d
akshat12000/Python-Run-And-Learn-Series
/Codes/58) intro_to_lists.py
702
4.3125
4
# A list is a collection of data numbers=[1,2,3,4,5] # list declaration syntax and it is list of integers print(numbers) words=["word1",'word2',"word3"] # list of strings as you can see we can use both '' and "" print(words) mixed=[1,2,3,4,"Five",'Six',7.0,None] # Here the list contains integers, strings, float...
true
f803ca25ed0928e6c2786d99f26a2f69b5c69dd2
indradevg/mypython
/cbt_practice/for1.py
609
4.34375
4
#!/usr/bin/python3.4 i=10 print("i value before : the loop: ", i) for i in range(5): print(i) ''' The for loops work in such a way that leave's behind the i value to the end of the loop and re-assigns the value to i which was initializd as 10 in our case ''' print("i value after the loop: ", i) ''' The below line ...
true
0c28d1d950dbbdf74ec827583dd7c46c331bc4b0
thanasissot/myPyFuncs
/fibonacci.py
481
4.1875
4
# cached fibonacci cache = dict() def memFib(n): """Stores result in cache dictionary to be used at function definition time, making it faster than first caching then using it again for faster results """ if n in cache: return cache[n] else: if n == 0: return 0 ...
true
e58f837ab1a161e23b8af68e15cb9095961ab52c
Moglten/Nanodegree-Data-structure-and-Algorithm-Udacity
/Data Structure/queue/reverse_queue.py
329
4.21875
4
def reverse_queue(queue): """ Given a Queue to reverse its elements Args: queue : queue gonna reversed Returns: queue : Reversed Queue """ stack = Stack() while not queue.is_empty(): stack.push(queue.dequeue()) while not stack.is_empty(): queue.enqueue(stac...
true
38b7b5030e6d39b2adaabe73e14b40e637a14e3b
feleck/edX6001x
/lec6_problem2.py
623
4.1875
4
test = ('I', 'am', 'a', 'test', 'tuple') def oddTuples(aTup): ''' aTup: a tuple returns: tuple, every other element of aTup. ''' result = () i = 0 while i < len(aTup): if i % 2 == 0: result += (aTup[i:i+1]) i+= 1 #print result return result # ...
true
8781f9f96a111b4edb2772afc5bee20e7861a881
deadsquirrel/courseralessons
/test14.1mod.py
1,059
4.15625
4
''' Extracting Data from JSON In this assignment you will write a Python program somewhat similar to http://www.pythonlearn.com/code/json2.py. The program will prompt for a URL, read the JSON data from that URL using urllib and then parse and extract the comment counts from the JSON data, compute the sum of the number...
true
97caae6c7fcaed2f8c0442dec8166a3c26b7caf5
pduncan08/Python_Class
/Wk3_Sec4_Ex3a.py
704
4.28125
4
# Lists - Exercise 3 # Python indexing starts at 0. This will come up whenever you # have items in a list format, so always remember to ask for # 1 less than whatt you want! John_Skills=["Python", "Communicateon", "Low Salary Request", 1000] print(John_Skills) Applicants=[["John", "Python"],["Geoff", "Doesn't Know P...
true
5394d2d8237802a930e1c43b1fffc5fb1f2a1090
non26/testing_buitIn_module
/superMethod/test1_superMethod.py
603
4.53125
5
""" this super method example here takes the argument of two, first is the subClass and the second is the instance of that subClass so that the the subClass' instance can use the superClass' attributes STRUCTURE: super(subclass, instance) """ class Rectangle(object): def __init__(self, width...
true
f31816fec154d08f18eaa849cbd8d8ca3920bb2e
SoyUnaFuente/c3e3
/main.py
571
4.21875
4
score = int(input("Enter your score: ")) # if score in range(1, 51): # print (f"There is no prize for {score}") if 1 <= score <=50: print (f"There is no prize for {score}") elif 51 <= score <=150: medal = "Bronze" print(f"Congratulations, you won the {medal} medal for having {score} points ") elif 1...
true
5c133a38fdca5f32432dbe164820ed62e249615c
cosmos-sajal/python_design_patterns
/creational/factory_pattern.py
1,035
4.21875
4
# https://dzone.com/articles/strategy-vs-factory-design-pattern-in-java # https://stackoverflow.com/questions/616796/what-is-the-difference-between-factory-and-strategy-patterns # https://stackoverflow.com/questions/2386125/real-world-examples-of-factory-method-pattern from abc import ABCMeta, abstractmethod class D...
true
92d46625f1bb1bfe6e6a2a359af18f50770d540b
potnik/sea_code_club
/code/python/rock-paper-scissors/rock-paper-scissors-commented.py
2,585
4.5
4
#!/bin/python3 # The previous line looks like a comment, but is known as a shebang # it must be the first line of the file. It tells the computer that # this is a python script and to use python3 found in the /bin folder from random import randint # From the python module called random, import the function randint #...
true
af908716f27a9ff46e623c883300cdcd7464d994
pranaychandekar/dsa
/src/basic_maths/prime_or_no_prime.py
1,199
4.3125
4
import time class PrimeOrNot: """ This class is a python implementation of the problem discussed in this video by mycodeschool - https://www.youtube.com/watch?v=7VPA-HjjUmU :Authors: pranaychandekar """ @staticmethod def is_prime(number: int): """ This method tells whethe...
true
db56d84911eac1cae9be782fd2ebb047c625fce2
pranaychandekar/dsa
/src/sorting/bubble_sort.py
1,488
4.46875
4
import time class BubbleSort: """ This class is a python implementation of the problem discussed in this video by mycodeschool - https://www.youtube.com/watch?v=Jdtq5uKz-w4 :Authors: pranaychandekar """ @staticmethod def bubble_sort(unsorted_list: list): """ This method s...
true
7e2f82c44c8df1de42f1026dcc52ecef804d9506
pranaychandekar/dsa
/src/basic_maths/prime_factors.py
1,324
4.25
4
import time class PrimeFactors: """ This class is a python implementation of the problem discussed in this video by mycodeschool - https://www.youtube.com/watch?v=6PDtgHhpCHo :Authors: pranaychandekar """ @staticmethod def get_all_prime_factors(number: int): """ This meth...
true
2910d6bc150cfb5cfc60e5b31f9910d546027eda
karthikwebdev/oops-infytq-prep
/2-feb.py
1,943
4.375
4
#strings # str = "karthi" # print(str[0]) # print(str[-1]) # print(str[-2:-5:-1]) # print(str[-2:-5:-1]+str[1:4]) #str[2] = "p" -- we cannot update string it gives error #del str[2] -- this also gives error we cannot delete string #print("i'm \"karthik\"") --escape sequencing # print("C:\\Python\\Geeks\\") # print(r"I...
true
29be4af3d652948430278ffe545f81c011643a1e
ronaka0411/Google-Python-Exercise
/sortedMethod.py
222
4.125
4
# use of sorted method for sorting elements of a list strs = ['axa','byb','cdc','xyz'] def myFn(s): return s[-1] #this will creat proxy values for sorting algorithm print(strs) print(sorted(strs,key=myFn))
true
d53ea1900d1bfc9ab6295430ac272616293cb09d
talebilling/hackerrank
/python/nested_list.py
1,480
4.3125
4
''' Nested Lists Given the names and grades for each student in a Physics class of students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade. Note: If there are multiple students with the same grade, order their names alphabetically and print each name on a new line...
true
cc2355c574130c4b5244b930cb6c5c3160af40e3
KarimBertacche/Intro-Python-I
/src/14_cal.py
2,289
4.65625
5
""" The Python standard library's 'calendar' module allows you to render a calendar to your terminal. https://docs.python.org/3.6/library/calendar.html Write a program that accepts user input of the form `14_cal.py [month] [year]` and does the following: - If the user doesn't specify any input, your program should ...
true
1387e63d50e7170a0733e43c95da207acf0f5925
kagekyaa/HackerRank
/Python/005-for_while_loop_in_range.py
488
4.28125
4
'''https://www.hackerrank.com/challenges/python-loops Read an integer N. For all non-negative integers i<N, print i^2. See the sample for details. Sample Input 5 Sample Output 0 1 4 9 16 ''' if __name__ == '__main__': n = int(raw_input()) for i in range(0, n): print i * i ''' A for loop: for i in ran...
true
261a252acbfe4691fbee8166a699e3789f467e8b
franciscoguemes/python3_examples
/basic/64_exceptions_04.py
1,328
4.28125
4
#!/usr/bin/python3 # This example shows how to create your own user-defined exception hierarchy. Like any other class in Python, # exceptions can inherit from other exceptions. import math class NumberException(Exception): """Base class for other exceptions""" pass class EvenNumberException(NumberExce...
true
73cccc2cd1bbcea2da0015abc9ea0157be449844
franciscoguemes/python3_examples
/projects/calculator/calculator.py
1,434
4.3125
4
#!/usr/bin/python3 # This example is the typical calculator application # This is the calculator to build: # ####### # 7 8 9 / # 4 5 6 * # 1 2 3 - # 0 . + = # Example inspired from: https://www.youtube.com/watch?v=VMP1oQOxfM0&t=1176s import tkinter window = tkinter.Tk() #window.geometry("312x324") window.resizable...
true
7244b8b9da478b14c71c81b2ff299da0e4b18877
franciscoguemes/python3_examples
/basic/06_division.py
697
4.4375
4
#!/usr/bin/python3 # Floor division // --> returns 3 because the operators are 2 integers # and it rounds down the result to the closest integer integer_result = 7//2 print(f"{integer_result}") # Floor division // --> returns 3.0 because the first number is a float # , so it rounds down to the closest integer and ret...
true
e83ee865e27bc54b1c58fb9c220ef757d2df4de3
franciscoguemes/python3_examples
/advanced/tkinter/03_click_me.py
557
4.125
4
#!/usr/bin/python3 # This example shows how to handle a basic event in a button. # This basic example uses the command parameter to handle the click event # with a function that do not have any parameters. # Example inspired from: https://www.youtube.com/watch?v=VMP1oQOxfM0&t=1176s import tkinter window = tkinter....
true
776a51053306a024ab824003e63255c89cdbb6d4
franciscoguemes/python3_examples
/basic/09_formatting_strings.py
673
4.625
5
#!/usr/bin/python3 # TODO: Continue the example from: https://pyformat.info/ # There are two ways of formatting strings in Python: # With the "str.format()" function # Using the Old Python way through the "%" operator # Formatting strings that contain strings old_str = "%s %s" % ("Hello", "World") new_str = "{}...
true
b315f178386a8072670a9087e791c0f978cd2212
stianbm/tdt4113
/03_crypto/ciphers/cipher.py
1,223
4.28125
4
"""The file contains the parent class for different ciphers""" from abc import abstractmethod class Cipher: """The parent class for the different ciphers holding common attributes and abstract methods""" _alphabet_size = 95 _alphabet_start = 32 _type = '' @abstractmethod def encode(self, te...
true
9c20ceec0fdccd3bc2bb92815e56b7a99855058a
cindy859/COSC2658
/W2 - 1.py
721
4.15625
4
def prime_checker(number): assert number > 1, 'number needs to be greater than 1' number_of_operations = 0 for i in range(2, number): number_of_operations += 3 #increase of i, number mod i, comparision if (number % i) == 0: return False, number_of_operations # returning multip...
true
bdc290072854219917fe8a24ef512b26d38e93f9
TecProg-20181/02--matheusherique
/main.py
1,779
4.25
4
from classes.hangman import Hangman from classes.word import Word def main(): guesses = 8 hangman, word = Hangman(guesses), Word(guesses) secret_word, letters_guessed = hangman.secret_word, hangman.letters_guessed print'Welcome to the game, Hangman!' print'I am thinking of a word that is', len(s...
true
327d89760aca774d4cf1019eda5c88cadc469502
arossbrian/my_short_scripts
/multiplier.py
405
4.15625
4
##This is a multiply function #takes two figures as inputs and multiples them together def multiply(num1, num2): multiplier = num1 * num2 return multiplier input_num1 = input("Please enter the first value: ") input_num2 = input("Enter the Second Value: ") ##input_num1 = int(input_num1) ##input_num2 = ...
true
f8b914676da0c034a908c3e440313e6633264068
arossbrian/my_short_scripts
/shoppingbasketDICTIONARIES.py
492
4.15625
4
print (""" Shopping Basket OPtions --------------------------- 1: Add item 2: Remove item 3: View basket 0: Exit Program """) shopping_basket = {} option = int(input("Enter an Option: ")) while option != 0: if option == 1: item = input("Add an Item :") qnty = int(input("Enter the quan...
true
36ec1104b30f90707920614405bc83cd5a2f7e40
yeonsu100/PracFolder
/NewPackage01/LambdaExample.py
601
4.5
4
# Python program to test map, filter and lambda # Function to test map def cube(x): return x ** 2 # Driver to test above function # Program for working of map print "MAP EXAMPLES" cubes = map(cube, range(10)) print cubes print "LAMBDA EXAMPLES" # first parentheses contains a lambda form, that is # a squaring ...
true
c30cd41b41234884aea693d3d0893f2889bd5f1d
deeptivenugopal/Python_Projects
/edabit/simple_oop_calculator.py
605
4.125
4
''' Simple OOP Calculator Create methods for the Calculator class that can do the following: Add two numbers. Subtract two numbers. Multiply two numbers. Divide two numbers. https://edabit.com/challenge/ta8GBizBNbRGo5iC6 ''' class Calculator: def add(self,a,b): return a + b def subtract(sel...
true
6598f0f714711ea063ef0f160e65847cc9dfa295
fiberBadger/portfolio
/python/collatzSequence.py
564
4.15625
4
def collatz(number): if number % 2 == 0: print(number // 2) return number // 2 else: print(3 * number + 1) return 3 * number + 1 def app(): inputNumber = 0 print('Enter a number for the collatz functon!') try: inputNumber = int(input()) except (Val...
true
f416c4993cfc11e8ca6105d48168d42952f55aa3
fiberBadger/portfolio
/python/stringStuff.py
813
4.125
4
message = 'This is a very long message' greeting = 'Hello' print(message); print('This is the same message missing every other word!'); print(message[0:5] + message[8:9] + ' ' + message[15:19]); print('The length of this string is: ' + str(len(message)) + 'chars long'); print('This is the message in all lower case ' ...
true