blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
e7f984891192ed29be9c414d5d58f57e3529e23d
mbadheka/python_practice_code
/20.py
215
4.125
4
# list intro # works the same way string slicing num = [1,2,3,4] print(num) words = ["apple", "banana", "orange"] print(words) mixed = [1,"orange", 2.345, "five", None] print(mixed) print(len(mixed))
true
a5b9d69923aa98c719df46f6c57149a1104e51b3
mbadheka/python_practice_code
/26.py
314
4.21875
4
# Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old. name,age= input("enter your name and age ").split(",") age= int(age) year = 2020 - age + 100 print(f"you will turn 100 year old on {year}")
true
be23529c73cbbcbba6c5c414caa5d9d37b682731
dare1302/Pyhton-Code-
/prime.py
218
4.125
4
i,temp=0,0 n = int(input("please give a number : ")) for i in range(2,n//2): if n%i == 0: temp=1 break if temp == 1: print("given number is not prime") else: print("given number is prime")
true
cda459916f43f9ec8b58563d81f0bb5a40b520a4
Pizzu/my-codewars-katas
/Python/sum_of_digits.py
655
4.15625
4
# In this kata, you must create a digital root function. # A digital root is the recursive sum of all the digits in a number. Given n, take the sum of the digits of n. If that value has more than one digit, continue reducing in this way until a single-digit number is produced. This is only applicable to the natural nu...
true
d9f20f95bb6830254ca690626b7dc3a9aaf17894
daver787/ArcPy
/GEO6533Final/EspinolaFinal/EspinolaScripts/UserString.py
866
4.5625
5
#Question 4.1-Write a code for the simple program "UserString.py" which will read a string from the keyboard and print it out on the screen, #you should test that the user input is only Alphabetical. The code should be a complete program that can run;that is #if the user uses numbers and/or other characters non alphabe...
true
13de180d454f12a89007350295fdb25142ec18fb
daver787/ArcPy
/Python_Lab_Exercises/Data/Exercise04/Results/challenge1.py
468
4.21875
4
# Name: David Espinola #Date: February, 13, 2109 #Description: This script looks for occurence of letter in string and prints a messge to console depending on whether letter is in string or not #Declare a string letter= "Georaphic Information Systems" #Use if statement to print two messages depending on if letter "z...
true
6cf0dbb7e9d353f6c58d0cf2717a70cf07854b05
daver787/ArcPy
/GEO6533Final/EspinolaFinal/EspinolaScripts/ConvertGrade.py
1,317
4.25
4
#Question 4.2- Write a section of code to define a function 'Student',where each student should have two data instances(arguments),one for the student's name, #and one for the student numerical final grade. The Student function,should have the method 'ConvertGrade', which should return the letter grade for the student ...
true
ad4b8a665fd36c42b45bdbcebbfa448869e2726b
carriegrossman/week_one
/condition.py
332
4.125
4
name = "Carrie" message = """ What is your name? """ name = input(message) if(name == "Carrie"): print("You may enter.") else: print("Get out!") print("Please Enter Your Age:") older_than_twentyone = 21 age_of_use = int(input()) if age_of_use >= older_than_twentyone: print("Welcome!") else: print...
true
0a452a704cc91bf7f5c317e892a74b2c92a90837
pradeep122/LearnPython
/sandeep/Tutorial-2-Examples/number-to-word.py
297
4.1875
4
# Write a program to ask for phone number in digits and returns it in words phone = input("Phone: ") numbers = { "1": "one", "2": "two", "3": "three", "4": "four", "5": "five" } print(numbers["1"]) result = "" for ch in phone: result += numbers.get(ch) + "-" print(result)
true
eafa72d64c84d8d589fddfc8534b7d403e4b9e6a
pradeep122/LearnPython
/swetha/Tutorial_2/Keyword_Arguments/app.py
1,109
4.3125
4
# Keyword Argument is combination of having the parameter name # followed by its value is a key word argument # With Keyword argument the position doesn't really matter. def greet_user(first_name, last_name): print(f"Hi {first_name} {last_name}!") print("Welcome aboard") print("Start..") # For most part us...
true
ddc0594ad6ac808170d6ee7594f9f8c52f464f99
pradeep122/LearnPython
/pradeep/tutorial1/Exercises/7.py
594
4.125
4
# Write a function that prints all the prime numbers between 0 # and limit where limit is a parameter. def print_primes(limit): for number in range(0, limit + 1): if is_prime(number): print(number) def is_prime(prime): for number in range(2, prime // 2 + 1): if prime % number == ...
true
5fe9c2b8ea253b99c439ea829e9f800ad7d5e697
pradeep122/LearnPython
/swetha/Tutorial_1/Debugging/app.py
330
4.1875
4
def multiply(*numbers): total = 1 for number in numbers: total *= number return total print("Start") print(multiply(1, 2, 3)) def multiply_even(*numbers): total = 1 for number in numbers: if number % 2 == 0: total *= number return total print(multiply_even(1, -...
true
545b877bbf43806b07a7234e1646b3fa6b558abe
pradeep122/LearnPython
/sandeep/Tutorial-2-Examples/list-methods.py
736
4.28125
4
numbers = [3, 7, 5, 4, 8] # creates a copy of numbers and any changes made in numbers will not get changed in numbers2 numbers2 = numbers.copy() numbers.append(13) # will add 13 to the list print(numbers) numbers.insert(1, 10) # will insert the number in the list where we wanted print(numbers) numbers.remove(4) # ...
true
d40cefa3ad3771d8a11c557cf1d46541cd420c97
pradeep122/LearnPython
/pradeep/tutorial1/Exercises/3.py
1,337
4.25
4
# Write a function for checking the speed of drivers. This function should # have one parameter: speed. # # 1. If speed is less than 70, it should print “Ok”. # 2. Otherwise, for every 5km above the speed limit (70), it should give # the driver one demerit point and print the total number of demerit points. # For e...
true
3b96b80a375dc226cea66a3d5ab7bd22837917e8
jzuern/project-euler
/7/10001.py
722
4.1875
4
def isprime(n): '''check if integer n is a prime''' # make sure n is a positive integer n = abs(int(n)) # 0 and 1 are not primes if n < 2: return False # 2 is the only even prime number if n == 2: return True # all other even numbers are not primes if not n &...
true
31df3eac8d344069cb2611a1c70dae5caa857044
thathwam/Algos
/Stack/TimeConversion.py
823
4.3125
4
""" Given a time in AM/PM format, convert it to military (2424-hour) time. Note: Midnight is 12:00:00AM12:00:00AM on a 1212-hour clock, and 00:00:0000:00:00 on a 2424-hour clock. Noon is 12:00:00PM12:00:00PM on a 1212-hour clock, and 12:00:0012:00:00 on a 2424-hour clock. Input Format A single string containing a ti...
true
7aca852109f68397e9b36511db8a26b2fe0ff8bc
axelFrias1998/Using-Python-with-Linux
/Third_week/Capturing_groups/capturingGroups.py
551
4.25
4
#! /usr/bin/env python3 import re #Capturing groups are portions of the pattern that are enclosed in parentheses result = re.search(r"^(\w*), (\w*)$", "Lovelace, Ada") print(result) print(result.groups()) print(result[0]) print(result[1]) lastName, firstName = result.groups() print("{}, {}".format(lastName, firstNam...
true
7fe0bac312a90d33e5b78b406e0f535481198c34
dlfosterii/python103-small
/print_a_square2.py
303
4.1875
4
#PPrint a NxN square of * characters. Prompt the user for N #setup side = int(input('Enter a number to print a square of that size: ')) y = 0 #Code to make it work while(y < side): x = 0 while(x < side): x = x + 1 print('*', end = ' ') y = y + 1 print('') #end
true
9edb1e248cb2c29b003f788e81a4678ab49d09b6
abhinna1/SoftwaricaLab
/Python Sum/question 7.py
989
4.28125
4
'''You live 4 miles from university. The bus drives at 25mph but spends 2 minutes at each of the 10 stops on the way. How long will the bus journey take? Alternatively, you could run to university. You jog the first mile at 7mph; then run the next two at 15mph; before jogging the last at 7mph again. Will this be quic...
true
7dc3f644f4e539a42dbff60e60bf9764cd56ac4b
abhinna1/SoftwaricaLab
/Python Sum/question 6.py
574
4.5
4
'''Solve each of the following problems using python scripts. Make sure you use appropriate variable names and comments, When there is a final answer have python print it to the screen. A person;s body mass index (BMI) is defined as: BMI - mass in kg / (height in m)^2 ''' bodyMass=float(input('enter your body mass in ...
true
87523ca4659f83eb106fd1f40ae4b2bc4f75f74b
Goto15/HackerRankCode
/division.py
397
4.3125
4
""" Read two integers and print two lines. The first line should contain integer division, a//b . The second line should contain float division, a/b. You don't need to perform any rounding or formatting operations. """ def int_division(a, b): return a//b def float_division(a, b): return a/b def divisio...
true
33cba740854e4847cb42701472b204ac22457fc0
rdevgupta/258219
/Hackerrank_codes/python_mutations.py
590
4.5
4
#question is about how we can change or update a string as they are immutable means they can not be changed # there are two ways by slicing the string and join back # second is convert the string into list as lists are mutable ''' this is the second method of list string = input() print("before change string: "+stri...
true
8c3ccbac41de3d50071eaa95d1e6a10620db5338
rdevgupta/258219
/Python_Prog_Submissions/Dictionary/list_to_nested_dict.py
297
4.46875
4
# Write a Python program to convert a list into a nested dictionary of keys List = [1, 2, 3, 4, 5, 6] Final_Dict = Temp_Dict = {} for i in List: #creates empty dict for each list item Temp_Dict[i] = {} #make that dict a key to final dict Temp_Dict = Temp_Dict[i] print(Final_Dict)
true
8af31a91385f24c37ffd0ad3868fda3602e27afb
Arihantawasthi/fibo_Memoization
/file.py
457
4.15625
4
fibo_cache = {} def fibonacci(n): #Check if there is any cache and return it. if n in fibo_cache: return fibo_cache[n] #Compute fibonacci number. if n == 1: value = 1 if n == 2: value = 1 if n > 2: value = fibonacci(n-1) + fibonacci(n-2) #Store the val...
true
1be91ff0cfb9e3f28457e34708edbe2c567c5fd1
sbburton/cs50
/old-files/LC101/ch9Notes.py
2,940
4.15625
4
# Strings Continued # 9.1 # Traversal and the for loop, by item for aName in ['Joe', 'Amy', 'Brad', 'etc']: print('Hi ' + aName + '. Please come to my party Sat!') # the loop variable takes on each value in the sequence. for aValue in range(10): # same is true with range print(aValue) # This will traverse a s...
true
808ce79687d26ec149ff8be44045b0580744a5b8
jeremyCtown/data-structures-and-algorithms
/data_structures/linked_lists/linked_list/linked_list.py
1,351
4.25
4
from node import Node as Node class LinkedList: """ This class is used to assign nodes in a linked list """ def __init__(self, iter=[]): """ this initializes the linked list and creates global variables """ self._current = None self.head = None self._si...
true
648683755f9db4700859e49456cc5d1cfe481734
timbradley/mypython
/ex15.py
478
4.3125
4
from sys import argv script, filename = argv #open the file and assign to variable txt = open(filename) #print the file name print "Here is your file %r:" % filename #print the file contents print txt.read() #ask the user to input the file name again print "Type the filename again:" #assign the user's input to a ...
true
ca41c448af5cfcb2733b6e1dfaa8682449b8ea2e
DeviGopinath/Tarento_batch20-21
/stringsearch.py
784
4.1875
4
#- Accept a String input #- Accept a search String to search in the above input #- Verify if the search String is present in the input string and the position and number of occurrences def findall(s,ss): #funtion for finding position a=[] l = len(s) index = 0 while index < l: ...
true
c9584fde51ae0b0cd8f8eaa25386b3200f368334
baralganesh/Python-Simple-Programs
/12_GuessTheNumber.py
684
4.125
4
# This is a guess number game using random function from random import * print ('Hello, what is your name?') name = input() secNo = randint(1,20) print('Okay, '+name+', I have number in my head from 1 to 20') count = 1 for yourTurn in range(1,7): print('Take a guess.') count +=1 guess = int(...
true
de0e672d5411c4cac670e5b247232c9a27a54951
Sarah-sudo/Python-
/Python-hard_way(e24).py
1,049
4.21875
4
print("Let' review everything.") #\ print('you should know about \\ and how it works: ') print("you should know that \\n is newline and \\t is a tab ") print("--------------") print(""" \t Hi I'm Annie, hi I'm Annie. \n\t Hi i'm Ted, hi I'm Ted. \n\t How are you today Ted? \n\t Fine thank you Annie. \n\t How are y...
true
731f1828b269417d9affaefc60475f4240586f64
qdriven/designpattern-sanity
/hedwig-pdesignpattern/structural/decorator/decorator.py
1,675
4.28125
4
from functools import wraps __author__ = 'patrick' """https://docs.python.org/2/library/functools.html#functools.wraps""" """https://stackoverflow.com/questions/739654/how-can-i-make-a-chain-of-function-decorators-in-python/739665#739665""" """ *What is this pattern about? The Decorator pattern is used to dynamically...
true
b5bb696c6cb52471d740dd8251ced28f596a0f36
andersonmalloryk/python-challenge
/PyPoll/main.py
1,764
4.15625
4
#import os module to create a file path and to read a CSV file import os import csv #import the counter from collections import Counter #establish path to file election_data = os.path.join('Resources', 'election_data.csv') #open file to read number of votes with open(election_data) as csvfile: votes_reader...
true
45c0159a35f30f2a80b7967c355434b1ae889fa3
dimitriacosta/python-examples
/intermediate/events.py
388
4.21875
4
""" Events example """ import threading event = threading.Event() def myfunction(): """This function will wait for event to get triggered""" print("Waiting for event to trigger...") event.wait() print("Performing action xyz now...") t1 = threading.Thread(target=myfunction) t1.start() x = input("Do y...
true
70c9645a47a0e6cbdfc9bc63e73ec3cd5f0a1b7c
Phyks/Blueprinting
/tools.py
588
4.1875
4
#!/usr/bin/env python3 import os def list_directory(path, filter=lambda x: True): """ List all files in path directory. Works recursively Filter is an optional callback. If set, the found items will be appended to the returned list only if filter evaluated on them is True. Return a list of files...
true
4546adb4033168c8e2f7b9da5979a33b28db72f1
liliumcs/DEV274X-Introduction-to-Python
/Module 2/ Required_Code_MOD2_IntroPy.py
807
4.21875
4
#!/usr/bin/env python # coding: utf-8 # In[1]: #Program: list-o-matic def list_o_matic(string, list_items): if string=="": last_item=list_items.pop() return last_item+ " popped from list\n" elif string in list_items: list_items.remove(string) return string+" removed from list...
true
70a5e545cbce694fbe918328e495b61120e853d5
clayhindman01/EstimatePi
/estimate_pi.py
1,288
4.5
4
#Program that uses random points between 0-1 to estimate pi import random import math #Places n number of points into the square def place_points(n): #Initialize local variables for how many points are in the circle and in the square points_in_circle = 0 counter = 0 #Add n number of points to the sq...
true
51f2521ee1bca47412895ef70ab6ab6b3ada0d71
venelrene/pythonIntellipaat
/assignThree.py
755
4.4375
4
#1. Write a sample Python code to assign values to an instance using dot notation? class Dog: dogCount = 1 def __init__(self, name, color): self.name = name self.color = color Dog.dogCount += 1 def displayDogCount(self): print "Dog Count %d" % Dog.dogCount def displayD...
true
4c91a54f15c06b6e5569f01dcbdab5dfadd6bb67
lafber/realpython
/1introduction/5.3_review_exercice.py
935
4.34375
4
''' Real Python 5.3 review exercices 1 to 3   ''' ''' Exercice 1 : Write a for loop that prints out the integers 2 through 10, each on a new line, by using the range() function  for i in range(2, 11): print(i) ''' ''' Exercice 2 : Use a while loop that prints out the integers 2 through 10 (Hint: you'll ne...
true
ea5122cd94f63d9da4aceb77c79d79f40c2d72e4
lafber/realpython
/1introduction/5.3_function_cube.py
446
4.1875
4
''' Real Python     Functions Summary 5.3     Write a cube() function that takes a number and multiplies that number by itself twice over, returning the new value; test the function by displaying the result of calling your cube() function on a few different numbers     ''' def cube(input_number): return input_nu...
true
8af927a23e4d16931e9509e233c7a8a38881359e
jrbella/computer_science_icstars
/basic_functions/larger_list.py
447
4.125
4
#Write your function here def larger_list(lst1, lst2): if len(lst1) > len(lst2): return lst1[-1] elif len(lst2) > len(lst1): return lst2[-1] else: return lst1[-1] #Uncomment the line below when your function is done #should return 5 print(larger_list([4, 10, 2, 5], [-10, 2, 5, 10])) #shou...
true
2716ed1368e7d448520825d0ebab2512052172f5
thenamk20/Python_stuff
/Collection/dictionary.py
654
4.25
4
# A dicntionary: a changeable, unorder collection of unique key:value pair # they fast cause they use hasing capitals = {'Vietnam':'Hanoi', "Japan":"Tokyo", 'England':"London"} print(capitals['Japan']) # print value print(capitals.get("Vietnam")) # print value safer capital...
true
c5463741917a5bc26e220826f657688d8e7a09ab
mgermaine93/python-playground
/adventure-game.py
1,801
4.375
4
# Welcome message print("Choose your own adventure! ") # User adds their name name = input("What is your name? ") # User adds their age age = int(input("What is your age? ")) # Health health = 10 print("Hello", name, "you are", age, "years old.") # Program checks the age of the player if age >= 18: print("You ...
true
4825c4f5706bbe99661a1598d1261d3c151bcae2
mgermaine93/python-playground
/modern-python-3-bootcamp/deck_of_cards.py
2,106
4.125
4
# Import statements from random import shuffle # Defines the Card class class Card: def __init__(self, value, suit): self.value = value self.suit = suit def __repr__(self): return f"{self.value} of {self.suit}" # Define the Deck class class Deck: # Initializes the deck def __i...
true
0f4c14e63f49d010bfd6cfa56302816dd271facd
BTomlinson/PFB_problemsets
/python_probset4.py
818
4.4375
4
#! /usr/bin/env python import sys #simply making a list of animals animals = ['horse', 'cow', 'moose', 'hound','mouse'] #using print to print out the middle element 'moose' print(animals[2]) #replace moose with dog and print the list animals.remove('moose') animals.insert(2,'dog') print(animals) #add a new element...
true
2db89f6d29727b8ab10040a8a158da1a677245fc
GuilhermeCarvalho1144/Data_Analysis_Udacity_Intro
/Lesson_2/Twenty_Second _quiz.py
1,425
4.25
4
#============================================================================== # THIS CODE IMPLEMENTS THE TWENTY SECOND QUIZ FROM INDTRODUCTION TO DATA ANALYSIS COURSE # AUTHOR : GUILHERME CARVALHO PEREIRA # SOURCE: INDTRODUCTION TO DATA ANALYSIS COURSE...UDACITY COURSE #===============================================...
true
7310e6d772a7c4f8a7404ecb1509d61aee6d2327
sm2774us/2021_Interview_Prep
/003_Algorithms/breadth-first-search/breadth_first_search.py
1,200
4.15625
4
from collections import deque #Creating the graph manually #The graph is the same used in Chapter 4.1 (page 533) of the book "Algorithm II" vertex_list = [[2,1,5], [0,2], [0,1,3,4], [2,5,4], [2,3], [3,0]] #List used to mark visited vertex marked_list = [False, False, False, False, False, False] #List used to sign from...
true
e67bd345fef272c3be17de7c710effc3b6041d2f
Carolinacapote/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/0-add_integer.py
760
4.28125
4
#!/usr/bin/python3 """This module contains a function called add_integer(). The function adds 2 integers. Return the result of the addition. """ def add_integer(a, b=98): """ Args: a (int or float): First number to be added. b (int or float): Second number to be added. Returns: in...
true
ef1284a4a3929e2810271244ee796bdd27b2c8ed
Carolinacapote/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/5-text_indentation.py
881
4.3125
4
#!/usr/bin/python3 """This module contains a function called text_indentation(), that prints a text with 2 lines after each of these characters: '.', '?' and ':' The function returns nothing. """ def text_indentation(text): """ Args: text (str): Text to be printed. Raises: TypeError: text...
true
fce71193fef5171aa1b5c9f35593b39a50aa57d2
larsyencken/simplestats
/simplestats/basic.py
1,930
4.125
4
# -*- coding: utf-8 -*- # # stats.py # simplestats # """ General combinatoric methods, in particular determining possible combinations of input. """ from math import sqrt, isnan from errors import InsufficientData def mean(values): """ Returns the mean of a sequence of values. If the sequence is empty, r...
true
293d478f060d6e0ca2236942a1df9b509f9fd95f
mosimi20/RandomPasswordGenerator
/RandomPasswordGenerator - Simple.py
431
4.15625
4
11#This is a simple program that will generate passwords with lengths of your choice. import random print('Hi, please enter the length of the expected password: ') passLength = int(input()) characterUniverse = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~!@#$%^&*()_+-=:|' generatedPassword = ''.j...
true
938c9e49f911f297032abd3b2ef0452c2146f25f
IndhujaRavi/PreCourse_1
/Exercise_3.py
2,482
4.4375
4
""" The append function handles two cases: 1. The linkedlist is empty. 2. The linkedlist is not empty. The need for two cases is because the head is initialized to None and if the linkedlist is empty then head needs to be initialized to a node with the given value as data. If the linkedlist exists with other nodes then...
true
2c17e2011c2834b3c495ae671d2126f7fc95b78f
kayes-shawon/Test
/problem1.py
494
4.375
4
# Program to find the depth of nested dictionary def print_depth(data, level=1): """ Function to print all keys with their depth """ # Iterarating through all dictionary items for key, value in data.items(): if isinstance(value, dict): print("{0} : {1}".format(key, level)) ...
true
b7d29841c876ee0a1120a5687753d8303b1a197c
TemitopeOladokun/My-Python-Notebook
/Strings.py
1,114
4.3125
4
message = 'Hello Temi, How are you ?' print(message) message2 = "Hello Helena, check this article for Jess's line of thought" print(message2) message3 = ''' Hello Uncle, How are you doing ? I am really excited about our upcoming project. Hurray!!! Yours Sincerely, Temitope. ''' print(mess...
true
6b1ac7f1a975b256a83758ce066a19c2e9b2116f
cc0a/python_collection
/dictionary/dictionary.py
1,717
4.5625
5
# dictionaries are accessed via key fruit = {"orange": "a sweet, orange, citrus fruit", "lemon": "a sour, yellow, citrus fruit", "grape": "a small, sweet fruit, growing in bunches", "lime": "a sour, green, citrus fruit", "apple": "round and crunchy"} print(fruit) # print(fruit["le...
true
5bf985541d376547c1fed7f20078cc6d903e650c
Manevle16/PythonUTDDataScienceWorkshop
/October27/DSPython/13_MatPlotLibOO.py
880
4.125
4
# Plotting Library for Python # Similar feel to MatLab's graphical Plotting # Conda Install matplotlib # Visit matplotlib.org # important link is gallery import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 5, 11) y = x ** 2 # Object Oriented method #fig = plt.figure() # empty canvas #axes = fig.add_...
true
f913cb12ed970bd1e31eef03c1278deda61d54b4
weimerben/Python-Equation-Calculators
/Pythagorean_Theorem_Calculator.py
302
4.375
4
import math print("Given the length of two sides I can calculate the length of the third") A = eval(raw_input("What is the length of the first side?")) B = eval(raw_input("What is the length of the second side?")) C = math.sqrt( (A ** 2) + (B ** 2)) print('The Length of the third side is...') print C
true
badb4a8a82cce0e1cd5958e71d2250c7400fa7ff
alexshaoo/Visualizations
/Point.py
2,440
4.40625
4
import math import pygame from Angle import Angle from Circle import Circle from Data import Data class Point(Circle): """A class which represents a point. It inherits from the Circle class, as a point is a circle :cvar rad: The radii of all points are 10 """ rad = 10 def __init__...
true
856b305f62a47b3d3867e0fb4d70212371edc9d5
ThulasiKandhati/DailyTasks
/Decorators.py
1,203
4.78125
5
#@Decorators In python ''' A decorator takes a function, Adds some functionality and returns it. This is also called metaprogramming as a part of the program tries to modify another program at the compile time.''' def smart_divide(func): def inner(a,b): print("i am going to divide",a,"and ",b) if b...
true
877e7ed616b14669245b3e58a8ce3930aeeb1be8
HaykAvetisyan1979/intro-to-python
/Project/Loops.py
843
4.15625
4
def check_balance(brackets): # The argument is a string if brackets == "": return True brackets = list(brackets) count1 = brackets.count("[") count2 = brackets.count("]") if brackets[0] == "]" or count1 != count2: return False for i in range(len(brackets)): if brack...
true
20f6d172326b4672109558c4c5658437216f1d4e
naughtyDog7/wiut-tasks
/lecture2/example5.py
521
4.3125
4
some_variable = 1 # This function has local variable with the same name as outer 'some_variable' # Local variable has no connection with outer variable with same name, they are 2 different variables # Changing one of them doesn't affect other one # Local variable shadows outer variable, and each statement inside of f...
true
291b042be6c8a8036e72c701e302f6794d82e5b4
PankajMehar/automateBoringstuffPython
/misc/error/Chap8PracMadLibs.py
916
4.1875
4
#! \usr\bin\env python3 # Chapter 8 Practice Mad Libs # Replaces all ADJECTIVE, NOUN, ADVERB, VERB keywords with user input in text. import re import os madLibFile = open('madlibs.txt') madLibContents = madLibFile.read() # TODO: Find and replace ADJECTIVE, NOUN, ADVERB, VERB with user substitutes. adj...
true
52da454525b2ff158d59b76a0fd726a3e40ba4a7
njncalub/dcp
/002/solution.py
2,529
4.125
4
from typing import List def solve(N: List[int]) -> List[int]: """Returns a list of products, excluding the element at position i. Args: N: a list of integers Returns: A list where each element at index i is the product of all the numbers in the original list, except the one at i....
true
a9b932aa7cba655c7b43006ced219f55bee8bc32
lupeluna/python-exercises
/warmup.py
1,261
4.71875
5
# 1. Write the code to take a string and produce a dictionary out of that # string such that the output looks like the following: Some thoughts: truck = "toyota tacoma" truck.split() make = truck.split() model = truck.split()[1] truck = { "make": "toyota" "model": "tacoma" } print(truck) # 2. Write the...
true
6983986e9e48cbd773859e4b8b405e85ef5d65a6
johntharian/learn-python
/11.prime number.py
285
4.15625
4
def prime(): x=int(input("Enter number to be checked")) for i in range(2,int(x/2)): if x % i ==0: c=1 else: c=0 if c==0: print("{} is a prime number".format(x)) else : print(f"{x} is not a prime number ") prime()
true
72ea90ed3663e5635714e8ee5fc3b3ac13dffea0
Lucythefirst/Procedural-Programming
/HighestEvenNumberFunction.py
575
4.3125
4
# Coding a function that prints the highest even number from a list #Two Ways: #1 list1= [10,2,4,6,7,8,9,3,11] def highest_even(list): even_li=[] for num in list: if num % 2 == 0: even_li.append(num) li = sorted(even_li) return li[-1] print(highest_even(list1)) #Or can use the 'max' function ins...
true
c14d90bbd5c3bc88d0fc8160242d9e50db4bcd26
ankitbarak/algoexpert
/Extremely Hard/squareOfZeroes.py
2,175
4.125
4
# Write a function that takes in a sequare-shaped n by n two dimensional array of only 1s # and 0s and returns a boolean representing whether the input matrix contains a square whose boarders are # made up of only 0s. # Note that a 1x1 square doesn't count as a valid square for the purpose of this question. In other w...
true
5df5e27d6c98be90911a48ae79a5ab1cf4904b08
ankitbarak/algoexpert
/Medium/moveElementToEnd.py
908
4.125
4
# You are given an array of integers and an integer. Write a # function that moves all instances of that integer in the array # to the end of the array and returns the array # The function should perform this in place (i.e. it should mutate the input array) # and doesn't need to maintain the order of the other integer...
true
258b9100a7cc3b325b57c240cace80772131cf76
GhazanfarShahbaz/interviewPrep
/array_and_string/one_six.py
1,610
4.1875
4
"""Challenge : 1.6 String Compression implement a method to perform a basic string compression using the counts of repeated characters for example the string aabcccccaa would become a2b1c5a3. If the compressed string would not become smaller than the original string your method should return the original string. You ca...
true
660f49ff2f7871ff2a8b9f7629e53bbd492c4509
keshav1999/Python-Programming
/Assignments/Assignment-8.py
2,057
4.15625
4
# 1. Take as input str, a number in form of a string. Write a recursive function to find the sum of digits in the string. Print the value returned. # S=input() # l=len(S) # def sumdigits(s,n,i): # if i==n: # return 0 # return int(s[i])+sumdigits(s,n,i+1) # print(sumdigits(S,l,0)) # 2 Take as i...
true
d84f4da6b69c7c1b83ab9be2bdc6d504cd5d9fcd
idimitrov07/udacity-cs101-solutions
/lesson3optional/lesson3_optional.py
1,278
4.40625
4
# A list is symmetric if the first row is the same as the first column, # the second row is the same as the second column and so on. Write a # procedure, symmetric, which takes a list as input, and returns the # boolean True if the list is symmetric and False if it is not. def symmetric(ls): # Your code here if...
true
bc69f873743f1de51c1af41d55263ba4bfae66f1
miguelfajardoc/holbertonschool-machine_learning
/supervised_learning/0x00-binary_classification/16-deep_neural_network.py
1,783
4.125
4
#!/usr/bin/env python3 """ Module that defines a deep neural network """ import numpy as np class DeepNeuralNetwork: """ DeepNeuralNetwork that defines a deep neural network with one hidden layer performing binary classification Public instance attributes W1: The weights vector for the hidden...
true
10f3ce44e970c1c3ee8ceaa8de9b40e8e071c9f3
NidhiSharma28/Beginners_level2
/hangman/main.py
913
4.125
4
import random import hangman_words import hangman_art lives = 6 stages = hangman_art.stages print(hangman_art.logo) word_list = hangman_words.word_list chosen_word = random.choice(word_list) count = len(chosen_word) print(f"The chosen word is :{chosen_word}") display = [] end_of_game = False for i in chosen_word: di...
true
c56f638a434d9663f2b9f549823883a812a251f3
rogerhendricks/python
/basics/get_dict.py
886
4.34375
4
# The get() method on dicts # and its "default" argument # created a dictionary with {} brackets, inside is key:"value", name_for_userid = { 382: "Alice", 590: "Bob", 951: "Dilbert", } def greeting(userid): return "Hi %s!" % name_for_userid.get(userid, "there") print(greeting(382)) # print the keys /...
true
11b9042ffc8195121f8d1aef0b300e360f1dd258
raunakrastogi/pirple-python
/HW1_variables.py
2,127
4.53125
5
# Homework Assignment 1. """ What's your favorite song? Think of all the attributes that you could use to describe that song. That is: all of it's details or "meta-data". These are attributes like "Artist", "Year Released", "Genre", "Duration", etc. Think of as many different characteristics as you can. In your...
true
30ae2a72baa89e0a0c8056072cfbe824b0dd5422
nicksuch/todo_list
/app.py
2,598
4.15625
4
# Upper-Polo To Do List App from item import Item from item_list import ItemList def main(): my_list = ItemList() print(ItemList) # TODO: Remove this print while True: # Display menu show_menu() # Get user input user_in = int(input()) # Add item ...
true
b28067c6197abbc9a0c10e3afb73a528e1e741c8
ejrach/course-python-mega
/for_loops.py
545
4.34375
4
# Lists a = [1, 2, 3] for item in a: print(item) print("") # Strings a = "Hello" for item in a: print(item) # Dictionaries pins = {"Mike":1234, "Joe":1111, "Jack":2222} for item in pins: # print("Key: ", pins.keys(), "Value: ", pins.value()) # prints the key print(item) for item in pins.keys(): ...
true
54ae9eb843d7641a92ed4bfa0774c7bae076e05f
saumya470/python_assignments
/.vscode/ExceptionHandling/exceptionAssignment.py
553
4.125
4
# Ask the user to enter a password. Create a custom exception - InvalidPasswordException which is invoked if the password is less than 8 # characters, raise and and handle it class InvalidPasswordException(Exception): pass try: f = open('PswdFile','w') pswd = str(input('Enter the password- ')) if len...
true
664e18c873bab48df3493127fb9863038c6281cc
andruraj/PythonTuts
/tuts/dict.py
1,433
4.25
4
#Dict are like Maps in java #Dictionary is a collection which is unordered, changeable and indexed. No duplicate members. #Creating dict phonebook = {} phonebook["John"] = 938477566 phonebook["Jack"] = 938377264 phonebook["Jill"] = 947662781 print(phonebook) #or thisdict = { "brand": "Ford", #key:value "model"...
true
2c2f530c6b153fab07c61998abade0c9f50bfe13
andruraj/PythonTuts
/tuts/generators.py
1,255
4.53125
5
''' Generators are very easy to implement, but a bit difficult to understand. Generators are used to create iterators, but with a different approach. Generators are simple functions which return an iterable set of items, one at a time, in a special way. When an iteration over a set of item starts using the for stateme...
true
21f62576d9f193a53f7b068ce9dfbe9a5e54275e
wesleyjr01/rest_api_flask
/2_python_refresher/40-class_composition.py
525
4.34375
4
""" Composition is not Inheritance, you will be using a lot more Composition than Inheritance in Python. """ class BookShelf: def __init__(self, *books): self.books = books def __str__(self): return f"BookShelf with {len(self.books)} books." class Book: def __init__(self, na...
true
d18bbb31b4be12b310d4b33635f4d94958d81166
wesleyjr01/rest_api_flask
/5_StoringInSQL/86-LoggingIn_RetrvUsrFromDB/test.py
1,059
4.5625
5
import sqlite3 """ The cursor is reponsable for actually executing the queries, and also storing the result. So the cursor is going to run a query and then store the result, so we can acess the result. """ # URI - Unifier Resource Identifier connection = sqlite3.connect("data.db") cursor = connection.cur...
true
b0ed6e309079e17013b8a977093bcc5ffdeb3dd1
wesleyjr01/rest_api_flask
/2_python_refresher/29-lambda_functions.py
351
4.125
4
""" The lambda function is a different type of function, which doesnt have a name, and is only used to return values. Lambda functions are exclusively used to operate on inputs and return outputs. """ def double(x): return x * 2 sequence = [1, 3, 5, 9] doubled = list(map(lambda x: x ...
true
7647842c945b02e8a067fbc9752eb7d09176e3c1
KanvaBhatia/Data-Science-Projects
/Practice Code/Python Programming Notes/3_writing_simple_programs/1_compound_interest.py
571
4.15625
4
# compound_interest.py # this program calculates the future value of an investment # user provides principal, interest rate and duration of investment. print("This program calculates the future value on an investment") # Requests inputs from user. principal = eval(input("Enter initial amount invested: ")) interes...
true
b6969399cc50e1c5d9a72bbfd9b882f387e177a7
KanvaBhatia/Data-Science-Projects
/Practice Code/Python Programming Notes/5_strings_lists_files/1_generate_username.py
601
4.40625
4
""" # 1_generate_username.py # This program creates a username from the initials (firstname) and first 7 letters (of last name) # a user provides Created by: temikelani on: 1/27/20 """ def username(): print("This program generates a username! \n") # collect user's first and last name first...
true
6660d6dc14cae42ba6f29072b7f90abc01d82704
KanvaBhatia/Data-Science-Projects
/Practice Code/Python Programming Notes/7_decision_structures/6_day_of_year.py
1,864
4.4375
4
""" # 6_day_of_year.py # Program determine if a date is valid and then tells what day on the year it is from (1 - 365/366) Created by: temikelani on: 2/3/20 """ # program check if month(1-12) and date(1-29/30/31) entered are valid. and returns valid month and date def valid_date(month, day, year): if ...
true
9eb8986305971a1e0d53bdfe7c9901b12c2027bb
akashwendole/python
/practice programs/calculator.py
871
4.125
4
def calculator(choice): num1 = int(input("Enter the first number")) num2 = int(input("Enter the second number")) if choice == 1: result = num1 + num2 print("Addition of the two numbers is:- " + str(result)) elif choice == 2: result = num1 - num2 print("Substraction of the...
true
c42faee4eb3002ecd197158c93c3b3945f06f501
hamza777star/calculat
/calculator.py
2,579
4.28125
4
#Created by Hamza Khan. while True: from math import sin,cos,tan,sqrt print("[-]∆/\/\Z∆") print("options") print("Enter 'add' to add") print("Enter 'subtract' to subtract") print("Enter 'multiply' to multiply") print("Enter 'divide' to divide") print("Enter 'percent' to take percentage") print("Enter ...
true
2972a0b88cb8cfd804735b01323fbe51f0fa6254
karthi12503/assignment-5
/odd_even.py
502
4.125
4
def CountingEvenOdd(arr, arr_size): even_count = 0 odd_count = 0 for i in range(arr_size): if (arr[i] & 1 == 1): odd_count += 1 else: even_count += 1 print("Number of even elements = ", even_count) print("Number of odd elements = ", odd...
true
0a1b3579c344c7aec3886bab3b5e662f174c0918
CraigMorris1986/cp1404_practicals
/prac_01/Electricity bill estimator.py
1,437
4.28125
4
# This is an electricity bill calculator which multiplies kWh price to daily use in kWh # over a period of time. TARIFF_11 = 0.244618 TARIFF_31 = 0.136928 def main(): print("Electricity bill estimator") kwh_cost = float(input("Please enter the cost of electricity per kWh : ")) kwh_daily_use = float(input(...
true
ffefbccdc031b31ee38162a8afe135339be32fbf
ash/amazing_python3
/124-init-del.py
282
4.15625
4
# Creating custom constructor # and desctructor for a class class C: def __init__(self): print('Constructor') def __del__(self): print('Destructor') o = C() # constructor called print('Hello, World!') # destructor will be called # at the end of the program
true
92c0c42c12a5ef2d58e0dbd90ce6ae6337e21d4e
ash/amazing_python3
/031-split-string.py
217
4.59375
5
# How to split a string to # characters str = 'Hello, World!' # First, print a character print(str[3]) # Now, make a list out of a string # Just convert a type: chars = list(str) print(type(chars)) print(chars[3])
true
a6fa0863a42fc1d0d670fed913622a78bda56fe9
ash/amazing_python3
/011-multiline.py
222
4.21875
4
str = '''This is a multi-line string. That you can continue on another line pressing the Enter key''' print(str) str2 = '''Notice the spaces on the left. Will they appear in the output? ''' print(str2)
true
09d0655c631e75617a2418458d1c84f2be202e1e
naveencloud/python-basic
/dec182017/ps_io.py
962
4.125
4
#demo of IO name = input('enter your name:') city = input('which area:') #zip_code = (input('enter the postal code:')) zip_code = int(input('enter the postal code:')) #int need to add to tell the input value is integer and if value is AlphaNumeric it will be an error print('name:', name) print('city:', city) print(z...
true
a18db8fe8601d539646d8ef5c5e03401bfa76055
naveencloud/python-basic
/dec182017/19dec2017/ps_tuple.py
424
4.15625
4
# Once it defined cannot be modified # () paranthesis is not important #items = ('2.2', 2.2, 2, 'eva', 'tim', 'tom', 'jeo') items = '2.2', 2.2, 2, 'eva', 'tim', 'tom', 'jeo' n = (1000,) # Sigle Element represent in Tuple eg: n = 1000, print(type(n)) print(n) print() print(items) print(type(items)) # Items[-3] = ...
true
707f2b86005dd29621ab5f87691c57e3fb5ff456
naveencloud/python-basic
/dec182017/ps_stringfmt2.py
986
4.375
4
"""demo for string formatting is for printing the rows and column {:fmt-str}""" name, age, gender = 'sarah', 3, 'female' # Variable Parallel assignment print("|{}|{}|{}|".format(name, age, gender)) # It will print output as directly print("|{:>22}|{:>9}|{:>20}|".format(name, age, gender)) # It will have the Column ...
true
b950b2d4c14115781863956f2503565eb4535b96
dhanrajsr/own-practice-exercise
/class_student_database.py
1,848
4.125
4
class Student: def __init__(self, name, marks): self.name = name self.marks = marks class Database: """ Objective is to create a database to record students and marks of a particular subject. The database can add new students, update records, delete records and search for a particu...
true
f6b5c2bfcdb2adb9e0088a8fec0c944bc08ac43c
tvaidotas/python_syntax
/syntax/variables_and_types.py
815
4.125
4
# completely object oriented # do not need to declare variables before using them, or declare their type # every variable in Python is an object # supports two types of numbers - integers and floating point numbers # printing an integer myint = 7 print(myint) # printing a float can be done in two ways myfloat = 7.0 ...
true
3c135e7ab94fe30a0b73e38aa0a41087af7378bc
shaundavin13/euler
/1_10/1.py
498
4.46875
4
""" If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. """ def is_multiple(num, *args): results = [num % arg == 0 for arg in args] return True in results def find_multiples...
true
2fb680a2aef9b85af47f1e1ec000fe0c8a817a87
sksanthosh/pythononselenium
/pythonworkspace/example5.py
810
4.375
4
#Program to learn on the if, if else, if elif and else. customData=int(input("Enter the room temperature: "))# Performing type conversion at the time of input receving from user if ((customData > 25) and (customData <=28)): print("The temperature is at room temperature") print("Performing only IF statement") ...
true
15536376c18752d91d7819f9a2061174331d9d99
luigisiops/DC-PythonLearning
/isprime.py
285
4.21875
4
num = int(input("pick a number to check if prime: ")) def isprime (num): ##case if 1 if num <= 1: return False for i in range (2, num-1): if (num%i) == 0: print('False') return False return print("True") isprime(num)
true