blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
78881030afd3c76d3e4bab9a4d69e72767ef4cf5
deltonmyalil/PythonInit
/classDemo.py
1,038
4.40625
4
class Students: def __init__(self,name,contact): #to define attribs of the class use def __init__(self,<attribute1>,<attribute2>,...) self.name = name self.contact = contact #name and contact are attribs and they are to be defined like this #once attribs are defined, you have to define the meth...
true
9ba11952aebc8ecf80527af333763082d15ff2f5
deltonmyalil/PythonInit
/numericFunctions.py
389
4.34375
4
#minimum function print(min(2,3,1,4,5)) numbers = [x for x in range(10)] #list generation print(numbers) print("the minimum is {0}".format(min(numbers))) #prints the minimum in numbers using format function print("The minimum is",(min(numbers)),"thank you") #max function print("The maximum value is {0}".format(max(nu...
true
f5d0698a74866606d1010c83ad6b335415995b94
nmoya/coding-practice
/Algorithms/queue.py
1,044
4.1875
4
#!/usr/bin/python import random import linkedlist class Queue(): def __init__(self): ''' A queue holds a pointer to a list. The elements are inserted at the end and removed from the front. (FIFO). ''' self.start = linkedlist.List() self.size = 0 def __repr__(self): _l...
true
9ecad439ee39051487c0aa70e3a014f2b684389a
gkerkar/Python
/code/ada_lovelace_day.py
977
4.25
4
#!/bin/python3 import math import os import random import re import sys # # The function is expected to return an INTEGER. # The function accepts INTEGER year as parameter. # import calendar def ada(year): # Get October week days. oct_weeks = calendar.monthcalendar(year, 10) ada_first_week = oct_w...
true
098a0d9ea413dfcef9301f73650acb2142cd0935
HissingPython/sandwich_loopy_functions
/Sandwich 8.py
2,386
4.46875
4
#Do you want a sandwich or not? def yes_no_maybe (answer): while True: if answer.upper() == 'Y' or answer =='N': break else: print ("Please enter 'Y' or 'N'.") answer = input ("Do you want to order a sandwich? (Press 'Y' for Yes and 'N' for No): ")...
true
b480d970bf562a300ef1c05db6b06c15c0b580d7
adclleva/Python-Learning-Material
/automate_the_boring_stuff_material/06_Lists/list_methods.py
1,349
4.53125
5
# Methods # A method is the same thing as a function, except it is “called on” a value. # For example, if a list value were stored in spam, you would call the index() list method (which I’ll explain next) on that list like so: spam.index('hello'). # The method part comes after the value, separated by a period. # index...
true
d2f5afeaf363d8566d343a7be28a469d3990f198
adclleva/Python-Learning-Material
/automate_the_boring_stuff_material/07_Dictionaries/dictionary_data_type.py
2,480
4.53125
5
# The Dictionary Data Type # Like a list, a dictionary is a collection of many values. # But unlike indexes for lists, indexes for dictionaries can use many different data types, # not just integers. Indexes for dictionaries are called keys, # and a key with its associated value is called a key-value pair. # Diction...
true
a7d36e5aeefa0964601ae213b2029c5c6bcdedbe
bashbash96/InterviewPreparation
/LeetCode/Facebook/Medium/49. Group Anagrams.py
1,483
4.125
4
""" Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. Example 1: Input: strs = ["eat","tea","tan","ate","nat","ba...
true
0ab6cb2ca6a679b9692f841f095074e3d0e0bf4b
bashbash96/InterviewPreparation
/LeetCode/Facebook/Medium/1762. Buildings With an Ocean View.py
1,552
4.53125
5
""" There are n buildings in a line. You are given an integer array heights of size n that represents the heights of the buildings in the line. The ocean is to the right of the buildings. A building has an ocean view if the building can see the ocean without obstructions. Formally, a building has an ocean view if all ...
true
bca11339ec5f1b4604f5d2aba56878720c3ac9da
bashbash96/InterviewPreparation
/LeetCode/Facebook/Easy/21. Merge Two Sorted Lists.py
1,227
4.1875
4
""" Merge two sorted linked lists and return it as a sorted list. The list should be made by splicing together the nodes of the first two lists. Example 1: Input: l1 = [1,2,4], l2 = [1,3,4] Output: [1,1,2,3,4,4] Example 2: Input: l1 = [], l2 = [] Output: [] Example 3: Input: l1 = [], l2 = [0] Output: [0] Const...
true
9dc4874947764da50df7f064e85a48f8da0e1427
allisongorman/LearnPython
/ex6.py
975
4.46875
4
# The variable x is a string with a number x = "There are %d types of people." % 10 # The variable is a string binary = "binary" # The variable is a string do_not = "don't" # The variable is a string that contains to string variables (1) y = "Those who know %s and those who %s." % (binary, do_not) # Display e...
true
864ca61914c5ed4fc07f60ac7809d780d0d1ead9
prkuna/Python
/24_Slicing_ListComprehension_Multi_Input.py
704
4.15625
4
# Let us first create a list to demonstrate slicing # lst contains all number from 1 to 10 lst = list(range(1,11)) print(lst) # below list has number from 2 to 5 lst1_5 = lst[1:5] print(lst1_5) # below list has numbers from 6 to 8 lst5_8 = lst[5:8] print (lst5_8) # below list has numbers from 2 to 10 l...
true
15b3aa68352d4d0e61561fba36d67a3313b73d10
prkuna/Python
/33_Operator_All.py
710
4.40625
4
# Here all the iterables are True so all # will return True and the same will be printed print (all([True, True, True, True])) # Here the method will short-circuit at the # first item (False) and will return False. print (all([False, True, True, False])) # This statement will return False, as no # True ...
true
f3677abd9e2f6cfd571168968da284db06a3264e
dmonisankar/pythonworks
/DataScienceWithPython/sample_python_code/iteration/iteration2.py
949
4.75
5
# Create an iterator for range(3): small_value small_value = iter(range(3)) # Print the values in small_value print(next(small_value)) print(next(small_value)) print(next(small_value)) # Loop over range(3) and print the values for i in range(3): print(i) # Create an iterator for range(10 ** 100): googol googol ...
true
4dbdc22f0297113db71b3be921e829e7a0af9cfc
naaeef/signalflowgrapher
/src/signalflowgrapher/common/geometry.py
1,897
4.1875
4
import math # taken from: # https://stackoverflow.com/questions/34372480/rotate-point-about-another-point-in-degrees-python def rotate(origin, point, angle): """ Rotate a point counterclockwise by a given angle around a given origin. The angle should be given in radians. """ ox = origin[0] oy...
true
6571604b6d7c0da12ec7ca49c79f22e25f58031e
michaelnakai/PythonProject
/print.py
1,327
4.375
4
# Demonstration of the print statement # Other information # print("Hello World") # print('Hello World') # print("I can't do it") # print('Michael sure "tries"') # # Escape Characters # print('This is the first line \nThis is the second line') # # print integer and an integer string # print(35) # print('35') # # Co...
true
387646766e4bfb174e1007b4586aa5a178149a50
laraib-sidd/Data-Structures-And-Algortihms
/Data Structures/Array/String reverse.py
505
4.34375
4
''' Function to reverse a string. Driver Code: Input : "Hi how are you?" Output : "?uoy era woh iH" ''' def reverse(string): """ Function to reverse string """ try: if string or len(string) > 2: string = list(string) string = string[::-1] string = "".join(st...
true
c982cc2c3ae1d0c70ed0ba17f0535bc9f0b349d6
onkar444/Tkinter-simple-projects
/Rock_Paper_Scissors_Game.py
2,363
4.3125
4
#importing the required libraries import random import tkinter as tk #create a window for our game window=tk.Tk() window.title("Rock Paper Scissors") window.geometry("400x300") #now define the global variables that we are going to #use in our program USER_SCORE=0 COMP_SCORE=0 USER_CHOICE="" COMP_CHOICE="" ...
true
95171efb5910f91d9862c370014134e18dffbadc
ucsd-cse8a-w20/ucsd-cse8a-w20.github.io
/lectures/CSE8AW20-01-09-Lec2-Functions/functions.py
351
4.15625
4
# takes two numbers and returns the sum # of their squares def sum_of_squares(x, y): return x * x + y * y test1 = sum_of_squares(4, 5) test2 = sum_of_squares(-2, 3) # NOTE -- try moving test1/test2 above function definition? # takes two strings and produces the sum # of their lengths def sum_of_lengths(s1, s2):...
true
ebfa533261b02fe4b7799167b266d177eb1ba818
luismmontielg/project-euler
/euler001.py
737
4.1875
4
print """ Multiples of 3 and 5 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. ------------------------------------------------------------------------------ 1 + 2 + 3 + 4 + ... +...
true
60d6ca3d2a88bd66ab05ed6a179a52c5256a71ec
shen-huang/selfteaching-python-camp
/exercises/1901100258/1001S02E03_calculator.py
480
4.1875
4
operator = input('Please enter an operator (+, -, *, /) : ') first_number = input('Please enter the first number : ') second_number = input('Please enter the second number : ') a = int(first_number) b = int(second_number) if operator == '+': print(a, '+', b, '=', a + b) elif operator == '-': print(a, '-', b, ...
true
d7996d9ef1923366651cf33969e97933e7222297
shen-huang/selfteaching-python-camp
/exercises/1901100017/1001S02E03_calculator.py
875
4.15625
4
# calculator # filename 1001S02E03_calculator.py firstchoice = 1 calculatchoice = 0 while firstchoice == 1: print("this is a calculator program 1. use calculator 2. end") firstchoice = int(input("what is your choice ")) if firstchoice == 1: print("I can do 1. plus 2. minus 3. multiply 4. divi...
true
d222aaea0d8a9ede5eb11cbb905686340b2d6a29
shen-huang/selfteaching-python-camp
/exercises/1901080011/1001S02E03_calculator.py
966
4.25
4
def add(x,y): return x+y def subtract(x,y): return x-y def multiply(x,y): return x*y def divide(x,y): return x/y first_num = float(input("Enter first number: ")) second_num = float(input("Enter second number: ")) operator = input("Enter operator: ") if operator=='+': result = add(first_nu...
true
0886f4ae059aa95e703646c7bdcb7a19eed5b78a
shen-huang/selfteaching-python-camp
/exercises/1901050061/1001S02E03_calculator.py
2,535
4.375
4
output = 0 num1 = "" operation = "" num2 = "" ''' In python, user input on the command line can be taken by using the command input(). Putting in a string (optional) as a paramter will give the user a prompt after which they can input text. This statement returns a string with the text the user typed, so it needs to ...
true
bb0d6aa3d6c274b5783ad1c154724c31f2aaea75
vladkudiurov89/PY111-april
/Tasks/a0_my_stack.py
836
4.34375
4
"""My little Stack""" my_stack = [] """Operation that add element to stack :param elem: element to be pushed :return: Nothing""" def push(elem): global my_stack my_stack.append(elem) return None """Pop element from the top of the stack :return: popped element""" def pop(): global my_stack if len(my_stack) ...
true
b2f358cfc90b32d48a3cae4c613763fd066702a7
billpoon12138/python_study
/Advance_Features/Iteration.py
426
4.125
4
from collections import Iterable d = {'a': 1, 'b': 2, 'c': 3} # iterate key in default condition for key in d: print(key) # iterate value for value in d.values(): print(value) # iterate items for k, v in d.items(): print(key, ':', value) # judge an object whether can be iterated isiterable = isinstance('abc',...
true
ddcbead5ff1a78eaed4e1d81b4cf1adc088c2170
JakNowy/python_learn
/decorators.py
2,109
4.15625
4
# # FUNCTION BASED DECORATORS # def decorator_function(original_function): # def wrapper_function(): # print('Logic before') # result = original_function() # print('Logic after') # return result # return wrapper_function # # @decorator_function # def original_function(): # pr...
true
c842cd6d2a6c01b8b4301fb82e45bd812b8b2b86
gregmoncayo/Python
/Python/arrayList.py
2,099
4.21875
4
lis = [] # array list # Main menu for user display def Menu(): print("A. See the list ") print("B. Add to the list ") print("C. Subtract from the list") print("D. Delete the entire list") print("E. See the size of your list") print("F. Reverse") print("G. Search the list") print("H. Qui...
true
2400616ad90902a303878407bc543b56103e48b4
jgambello2019/projectSet0
/ps0.py
2,877
4.4375
4
# 0. Write a boolean function that takes a non-negative integer as a parameter and returns True if the number is even, False if it is odd. It is common to call functions like this is_even. def is_even(int): '''Returns true if number is even, false if odd''' divisibleByTwo = int % 2 return divisibleByTwo == 0 # 1. W...
true
62c63539e4b9b726a3fb5d41ead0ebcb669c8df5
AHKerrigan/Think-Python
/exercise3_2.py
1,435
4.5
4
# A function object is a value you can assign to a variable or pass as an argument. For # example, do_twice is a function that takes a function object as an argument and calls # it twice: # def do_twice(f): # f() # f() #Here’s an example that uses do_twice to call a function named print_spam twice: # def print_spa...
true
65fa427c004588b2ea12bc496314b9a46e1b0f71
AHKerrigan/Think-Python
/exercise9_4.py
934
4.28125
4
""" This is a solution to an exercise from Think Python, 2nd Edition by Allen Downey http://thinkpython2.com Copyright 2015 Allen Downey License: http://creativecommons.org/licenses/by/4.0/ Exercise 9-4: Write a function named uses_only that takes a word and a string of letters, and that returns True if the word co...
true
a3dab7ee3a4f4219af5795df3251825ed25e22f4
AHKerrigan/Think-Python
/exercise5_5.py
554
4.28125
4
""" This is a solution to an exercise from Think Python, 2nd Edition by Allen Downey http://thinkpython2.com Copyright 2015 Allen Downey License: http://creativecommons.org/licenses/by/4.0/ Exercise 5-5: This exercise is simply a copy-paste to determine if the reader understands what is being done. It is a fractal ...
true
31f411dbe5909272f0ddd95da8b43b7718da423c
AHKerrigan/Think-Python
/exercise10_9.py
1,007
4.15625
4
""" This is a solution to an exercise from Think Python, 2nd Edition by Allen Downey http://thinkpython2.com Copyright 2015 Allen Downey License: http://creativecommons.org/licenses/by/4.0/ s Exercise 10-9: Write a function that reads the file words.txt and builds a list with one element per word. Write two versions...
true
57a8b9a6d6d36e3046373e8e018e4e48c8c6ebe3
ypratham/python-aio
/Games/Rock Paper Scissor/rps.py
2,469
4.1875
4
import random print('ROCK PAPER SCISSORS') print('-' * 20) print('\nInstructions:' '\n1. This game available in only Computer v/s Player mode' '\n2. You play 1 round at a time' '\n3. Use only rock, paper and scissor as input') input('\nPress Enter to continue') while True: choice = str(input('Do...
true
80503d61dc785101e8ccfdb85a0de5bedf55600d
harerakalex/code-wars-kata
/python/usdcny.py
523
4.15625
4
''' Create a function that converts US dollars (USD) to Chinese Yuan (CNY) . The input is the amount of USD as an integer, and the output should be a string that states the amount of Yuan followed by 'Chinese Yuan' For Example: usdcny(15) => '101.25 Chinese Yuan' usdcny(465) => '3138.75 Chinese Yuan' The convers...
true
aeb7486fae65a77dc97c2b4151a900dcf8ac4b36
harerakalex/code-wars-kata
/python/fibonacci.py
1,918
4.15625
4
''' Problem Context The Fibonacci sequence is traditionally used to explain tree recursion. def fibonacci(n): if n in [0, 1]: return n return fibonacci(n - 1) + fibonacci(n - 2) This algorithm serves welll its educative purpose but it's tremendously inefficient, not only because of recursion, but beca...
true
a56defabab48718524a7eac281fd4fc28052488c
NotGeobor/Bad-Code
/Password Generator.py
2,307
4.40625
4
# user input word = input("Choose a website: ").lower() # list tracks repeats in string repeats = [] # length variable makes working with 2 different lengths of the "word" string easier length = len(word) # tracks even/odd position in string index with 2 being even and 1 odd odd = 2 # dictionaries used to capitaliz...
true
4e33aa5b846349604f6aa5b5361fb0c00407c221
nileshnegi/hackerrank-python
/day009/ex55.py
778
4.375
4
""" Company Logo Given a string ```s``` which is the company name in lowercase letters, your task is to find the top three most common characters in the string. Print the three most common characters along with their occurrence count. Sort in descending order of occurrence count. If occurrence count is the same, sort ...
true
085de4e412b65c6610e8fd079bfe151dd6598725
nileshnegi/hackerrank-python
/day015/ex98.py
699
4.40625
4
""" Map and Lambda Function You have to generate a list of the first `N` fibonacci numbers, `0` being the first number. Then, apply the map function and a lambda expression to cube each fibonacci number and print the list. """ cube = lambda x: x**3 # complete the lambda function def fibonacci(n): # return a list...
true
de64cf80d0e029df3e4c97f366071ce001653fec
nileshnegi/hackerrank-python
/day001/ex5.py
1,178
4.5625
5
""" Lists Consider a list. You can perform the following functions: insert i e: Insert integer ```e``` at position ```i``` print: Print the list remove e: Delete the first occurrence of integer ```e``` append e: Insert integer ```e``` at the end of the list sort: Sort the list pop: Pop the last element from the list r...
true
4951d729fe33ec638a78ff43dbf3b0c474ee74ac
nileshnegi/hackerrank-python
/day014/ex89.py
644
4.1875
4
""" Validating Credit Card Numbers A valid credit card has the following characteristics: It must start with `4`, `5` or `6`. It must contain exactly 16 digits `[0-9]`. It may have digits in groups of 4, seperated by a hyphen `-`. It must not use any seperators like ` `, `_`, etc. It must not have `4` or more consecut...
true
19649a71c597222f34d4e1192683c9a27c4c586c
nileshnegi/hackerrank-python
/day009/ex59.py
320
4.15625
4
""" Set .add() The first line contains an integer ```N```, the total number of country stamps. The next ```N``` lines contains the name of the country where the stamp is from. """ if __name__ == "__main__": country = set() for _ in range(int(input())): country.add(input()) print(len(country))
true
0e91aad14d9c1287ecdf38786cdad445c4bc36ed
Daniyal56/Python-Projects
/Positive OR Negative Number.py
622
4.5625
5
# Write a Python program to check if a number is positive, negative or zero # Program Console Sample Output 1: # Enter Number: -1 # Negative Number Entered # Program Console Sample Output 2: # Integer: 3 # Positive Number Entered # Program Console Sample Output 3: # Integer: 0 # Zero Entered user_input = int(input("E...
true
d9ea424c5adcd7c2d7ad207f2ad1c254d7ff90ff
Daniyal56/Python-Projects
/Sum of a Number.py
584
4.25
4
## 14. Digits Sum of a Number ### Write a Python program to calculate the sum of the digits in an integer #### Program Console Sample 1: ##### Enter a number: 15 ###### Sum of 1 + 5 is 6 #### Program Console Sample 2: ##### Enter a number: 1234 ###### Sum of 1 + 2 + 3 + 4 is 10 print('=================================...
true
5f52bd1beda25e36c57098ac0187b79688e45457
seed-good/mycode
/netfunc/calculator.py
1,968
4.28125
4
#!/usr/bin/env python3 """Stellantis || Author: vasanti.seed@stellantis.com""" import crayons # function to calculate def calculator(first_operand, second_operand, operator): print('Attempting to calculate --> ' + crayons.blue(first_operand) + " " + crayons.blue(operator) + ...
true
ebaf0f43bc2fbe1238c48669acd256fc949dccaf
ostrbor/prime_numbers
/public_key.py
538
4.125
4
#!/usr/bin/env python #Find two random prime number of same size #and return it's product. from functools import reduce from check import is_prime size = input('Enter size of number: ') min = 10**(size-1) max = 10**size-1 def find_primes(min, max): '''Find two different biggest prime number''' res = [] ...
true
9d68d62847e213ca97ba6d8805b0c1ab73afcf7e
Lucky0214/machine_learning
/isin_pd.py
544
4.25
4
# isin() function provides multiple arguments import pandas as pd df = pd.read_csv("testing.csv") print(df) #We are taking same concept which is not better for coder mask1 = df["class"] =="a" #mask is used for finding same type in a perticular column print(df[mask1]) mask2 = df["class"] == "b" mask3 = df["class"...
true
e46cbac7f53f918c16c35bdc0121a64e8fd7d0f4
ShreyashSalian/Python_count_vowel
/Program2.py
295
4.34375
4
#Wap to count the number of each vowel in string def count_vowel(string): vowel = "aeiou" c = {}.fromkeys(vowel,0) string = string.lower() for co in string: if co in c: c[co] += 1 return c string = input("Enter The String : ") print(count_vowel(string))
true
2a20357da5c6c782ee190906d8706fdb793dc0b2
Pixelus/MIT-6.0.0.1-problems
/ps1a.py
1,686
4.4375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Nov 7 17:02:11 2018 @author: PixelNew """ ############################################################################### # You decide that you want to start saving to buy a house. You realize you are # going to have to save for several years before you...
true
e7bed62194217f93e2508a54436dae60e9dd08f6
jsillman/astr-119-hw-1
/functions.py
618
4.46875
4
#this program prints every value of e^(x) for x ranging from 0 to one less than # a given value, or 9 by default import numpy as np import sys def exponent(x): #exponent(x) function: returns e^(x) return np.exp(x) def show_exponent(x): #show_exponent(x) function: prints the result of for i in range(x): ...
true
9b02571f769a49486363f882624e8a33a5799bd8
fszatkowski/python-tricks
/2_decorators_and_class_methods/6.py
959
4.34375
4
import abc # ABC (abstract base classes) package provides tools for creating abstract classes and methods in python # Abstract classes must inherit from abc.ABC class # Then @abd.abstractmethod can be defined class BaseClass(abc.ABC): @abc.abstractmethod def greet(self): pass # Abstract class ca...
true
1c6a8a019de03c58205068b13ea9aa343867ba30
Alasdairlincoln96/210CT
/Week 1/Question 1.py
1,805
4.28125
4
from random import * newarray = [] used = [] def create_array(): '''A function which asks the user to enter numbers into an array, the user can carry on entering numbers as long as they want. All the inputs are checked to make sure they are an integer.''' array = [] done = False print("To finis...
true
a90ef4442ea6bb682b1d193310c3ad7b0a670310
Alasdairlincoln96/210CT
/Week 0/Question 1.py
1,255
4.125
4
number1 = False number2 = False number3 = False number4 = False while number1 == False: try: a = int(input("Please enter a number: ")) number1 = True except valueerror: print("Thats not a number. Please enter a whole number: ") number1 = False while number2 == False: try: ...
true
269bd14dc41c21e35ddce507a7a1bb2154c79010
tobitech/code-labs
/machine learning/complete_python_programming_for_beginners/primitive types/numbers.py
738
4.375
4
x = 1 y = 1.1 # a + bi # complex numbers, where i is an imaginary number. # we use `j` in python syntax to represent the imaginary number z = 1 + 2j # standard arithmetic math operations print(10 + 3) # addition print(10 - 3) # substraction print(10 * 3) # multiplication print(10 / 3) # division - returns a floa...
true
7fd189d0f76b16e509eabcd8a12786f19641a6fa
tobitech/code-labs
/machine learning/complete_python_programming_for_beginners/popular python packages/pynumbers/app.py
2,543
4.4375
4
import numpy as np # use of alias to shorten module import # array = np.array([1, 2, 3]) # print(array) # print(type(array)) # returns `<class 'numpy.ndarray'>` # creating multi-dimensional array # this is a 2D array or a matrix in mathematics # this is a matrix with 2-rows and 3-columns # array = np.array([[1, 2, ...
true
33603d4f428fa7eb1e4a44390281a94547a5503f
tobitech/code-labs
/machine learning/complete_python_programming_for_beginners/data structures/map_function.py
408
4.28125
4
items = [ ("Product1", 10), ("Product2", 9), ("Product3", 12) ] # say we want to transform the above list into a list of prices (numbers) # prices = [] # for item in items: # prices.append(item[1]) # print(prices) # returns a map object which is iterable # x = map(lambda item: item[1], items) # conv...
true
12bfdf8a61a8cacf952be845fb1a449e480d7f9c
tobitech/code-labs
/machine learning/complete_python_programming_for_beginners/data structures/finding_items.py
347
4.15625
4
letters = ["a", "b", "c"] print(letters.index("a")) # get the index of an object in a list # print(letters.index("d")) # you get a ValueError for object not in list if "d" in letters: # `in` operator to check if object is in list print(letters("d")) # returns the number of occurences of a given item in a list...
true
6165a1189d01bd464652660b70ee618906a6a53a
tobitech/code-labs
/machine learning/complete_python_programming_for_beginners/control flow/infinite_loops.py
381
4.25
4
# this program is the same as the one we did in the while_loop lesson # while True: # command = input("> ") # print("ECHO", command) # if command.lower() == "quit": # break # Exercise: dispaly even numbers between 1 to 10 count = 0 for x in range(1, 10): if x % 2 == 0: print(x) ...
true
76c76d7de9ea0086277091f516bf37460301c664
tobitech/code-labs
/machine learning/complete_python_programming_for_beginners/classes/constructors.py
670
4.25
4
class Point: # `self` is a reference to the current object def __init__(self, x, y): # `x` and `y` are new attributes we are adding to the object # using the passed values to set them self.x = x self.y = y # we have a reference to the current object here with `self` # wi...
true
a9c7e3106ad820fa80cf9895a3a6d77d7ddf92bd
richardcsuwandi/data-structures-and-algorithms
/Recursive Algorithms/fibonacci.py
547
4.1875
4
# Create an empty dict to store cached values fibonacci_cache = {} def fibonacci(n): # If the value is cached, return the value if n in fibonacci_cache: return fibonacci_cache[n] # Compute the nth term if n == 1: value = 1 elif n == 2: value = 1 else: value = fib...
true
2eb9ef055524934cb078711a5faf5a4028f2b926
keshavgbpecdelhi/Algorithmic-Toolbox
/Algorithmic Toolbox/5.1 money change.py
1,201
4.21875
4
# -------------------------Money Change Again---------------------------- # As we already know, a natural greedy strategy for the change problem does not work correctly for any # set of denominations. For example, if the available denominations are 1, 3, and 4, the greedy # algorithm will change 6 cents using three c...
true
a65fb8222c63c2d94701bea3363d705b209757ca
alexander-fraser/learn-python
/Python_010_Reverse_Words.py
791
4.40625
4
# Reverse Words # Alexander Fraser # 28 Febuary 2020 """ Write a program (using functions!) that asks the user for a long string containing multiple words. Print back to the user the same string, except with the words in backwards order. """ def collect_input(): # Get the input from the user. input_string =...
true
d398fdbb843796180ac067a16217743a43bbc0a1
alexander-fraser/learn-python
/Python_002_Primes.py
1,304
4.5
4
# Primes # Alexander Fraser # 8 Febuary 2020 # This program outputs all the prime numbers up to the # integer specified by the user. def collect_stop_value(): # This function prompts the user for an integer. # It loops until an integer is entered by the user. while True: try: user_inp...
true
1d856ff4c9c072949c50cf8631b87e6ad90ab87c
vinaykath/PD008bootcamp
/Dev's Work/palindrome.py
260
4.3125
4
def palindrome_check(str): str = str.replace(" ", "") print(str) return str == str[::-1] str = input("Enter a string:" ) result = palindrome_check(str) if result: print("String is a palindrome!") else: print("String is not a palindrome")
true
0da05c32e114f858801b3323c36a16633872ba25
ecxr/matrix
/hw0/hw0.py
2,632
4.1875
4
# Please fill out this stencil and submit using the provided submission script. ## Problem 1 def myFilter(L, num): """ input: list of numbers and a number. output: list of numbers not containing a multiple of num. >>> myFilter([1,2,4,5,7], 2) [1, 5, 7] """ return [ x for x in L if x % num...
true
c90cbb758d1b0caf0bacbea3c8ea36a9cac55138
mandaltu123/learnpythonthehardway
/basics/few_more_commandlines.py
286
4.21875
4
# some more tests on commanline args from sys import argv if len(argv) == 3: num1 = int(argv[1]) num2 = int(argv[2]) else: num1 = int(input("Enter number 1 : ")) num2 = int(input("Enter number 2 : ")) print("the sum of number1 and number2 is {}".format(num1 + num2))
true
00a5e7ffa38f1cb9e296ab0e82765bcf6a76a7f9
mandaltu123/learnpythonthehardway
/basics/dictionaries.py
1,052
4.25
4
# Dictionaries are the most commonly used datastructure in python # They are key value pairs dic = {1: 'one', 2: 'two', 3: 'three'} print("print my first dictionary {}".format(dic)) # I did not write dick # it has keys and values keys = dic.keys() values = dic.values() print("keys are {}".format(keys)) print("valu...
true
2cff4e9e9ff1b7a3df2937541795ea7f8356f07a
nyxgear/TIS-diversity-algorithms
/diversity/default_diversity_functions.py
1,248
4.6875
5
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ The functions below are used as a default by algorithms to compute a set of diverse elements. """ def diversity_element_element(e1, e2): """ Default diversity function to compare an ELEMENT against another ELEMENT :param e1: element :param e2: elemen...
true
3eec349bfcca6bb0a154d7cf22d46568a6ad3ba6
SolutionsDigital/Yr10_Activities
/Activity06/Act06_proj5.py
1,956
4.1875
4
# File : Act06_proj5.py # Name :Michael Mathews # Date :1/4/19 """ Program Purpose : Deleting items using Del index or Remove for item Name """ myCountriesList=["Greenland", "Russia", "Brazil", "England", "Australia", "Japan", "France"] userSelection ="y" def showOptions(): print("----------------------------...
true
2cb7fcb58a5f39cf15526035a37475eb1928e1d1
SolutionsDigital/Yr10_Activities
/Activity02/Act02_proj1.py
1,289
4.15625
4
""" File : Act02_Py_p1.py Name : Michael Mathews Date : 25/01/2020 This program will accept the score from the user and find the Average The average is used in a selection Construct to check on PASS or Fail - Pass reuires >= 65 """ # Welcomes the user print("Welcome to the Pass Fail Calculator") # Puts a line br...
true
bea55b3e79ea96b209624c982c38e18e618e573e
SolutionsDigital/Yr10_Activities
/Activity04/Act04_proj5.py
1,857
4.15625
4
# File : Act04_proj5.py # Name : Michael Mathews Date : 1/4/19 # Program Purpose : Convert Temperature # Farenheit to Celsius,Celsius to Farenheit # Show Boiling and Freezing Points for both def fahr_to_Celsius(): far = float(input("Please enter the temperature in Farenheit: ")) cels = ((far-32)*(5/9)) p...
true
e508ebb8eea7327116e450eebb7684a3c31cd43c
SolutionsDigital/Yr10_Activities
/Activity01/Act01_proj3.py
695
4.28125
4
""" File : Act01_proj3.py Name : Michael Mathews Date :25/01/2020 Program Purpose: The user enters the Name, Address and Age This info will be displayed on the screen including age next year. """ # request for user to enter their first name FName= input("Enter your first name : ") # request for user to enter their S...
true
634a09a2b56eb7b564c56de6546297150b2af7f5
sholatransforma/hello-transforma
/cylinder.py
332
4.25
4
#program to find the area of a cylinder pi = 20/6 height = float(input(' what is height of cylinder')) radius = float(input('what is radius of cylinder')) volume = pi * radius * radius * height surfacearea = (height * (2 * pi * radius)) + (2 * (pi * radius**2)) print('volume is', volume) print('surface area', su...
true
6e858df9b2a8fa0f0e1ccbc42e9a17aa14eec066
lkfken/python_assignments
/assn-4-6.py
1,272
4.53125
5
__author__ = 'kleung' # 4.6 Write a program to prompt the user for hours and rate per hour using raw_input to compute gross pay. # Award time-and-a-half for the hourly rate for all hours worked above 40 hours. # Put the logic to do the computation of time-and-a-half in a function called computepay() and # use the func...
true
eb7bac332ef99d88940b266c62db3015592268ed
sudhanshu-jha/python
/python3/Python-algorithm/Bits/drawLine/drawLine.py
1,420
4.125
4
# A monochrome screen is stored as a single array of bytes, allowing # eight consecutive pixels to be stored in one byte. The screen has # width w, where w is divisible by 8(that is no byte will be split # across rows). Height of screen can be derived from the length of the # array and the width. Implement a function t...
true
3d1ccaceeee56c703069c90028669e6dc37ef5c0
sudhanshu-jha/python
/python3/Python-algorithm/ArraysAndStrings/isRotation/isRotation.py
294
4.1875
4
# Accepts two strings and returns if one is rotation of another # EXAMPLE "waterbottle" is rotation of "erbottlewat" def isRotation(str1, str2): if len(str1) == len(str2) and len(str1) > 0: str1str1 = "".join([str1, str1]) return str1str1.find(str2) >= 0 return False
true
a484920a839689704cd09da05cb6a327b65fc5a2
jdangerx/internet
/bits.py
2,119
4.125
4
import itertools def bytes_to_ints(bs): """ Convert a list of bytes to a list of integers. >>> bytes_to_ints([1, 0, 2, 1]) [256, 513] >>> bytes_to_ints([1, 0, 1]) Traceback (most recent call last): ... ValueError: Odd number of bytes. >>> bytes_to_ints([]) [] """ i...
true
eb7d1d9f48e4f2079232d0f05f76d8bd82b513b5
ma7modsidky/data_structures_python
/Queue/queue.py
1,121
4.28125
4
from collections import deque class Queue: def __init__(self): self.buffer = deque() def enqueue(self, val): self.buffer.appendleft(val) def dequeue(self): return self.buffer.pop() def is_empty(self): return len(self.buffer) == 0 def size(self): return le...
true
b171bb9dc81ec1e100edc31c61bbc05a13e9a8cf
bhavikjadav/Python_Crash_Course_Eric_Matthes_Chapter_5
/5.11_Ordinal Numbers.py
808
4.59375
5
#!/usr/bin/env python # coding: utf-8 # # 5-11. Ordinal Numbers: Ordinal numbers indicate their position in a list, such as 1st or 2nd. Most ordinal numbers end in th, except 1, 2, and 3. # # • Store the numbers 1 through 9 in a list. # # • Loop through the list. # # • Use an if-elif-else chain inside the loop to prin...
true
5662b37a922038c74948d92ccad0319f39aee4f6
artificialbridge/hello-world
/BillCalculator.py
1,018
4.125
4
def tip(bill, percentage): total = bill*percentage*0.01 return total def total_bill(bill,percentage): total = bill+tip(bill, percentage) return total def split_bill(bill,people): total = float(bill)/people return total def main(): choice = raw_input("Enter 1 to calculate tip or 2 to split...
true
bccf02c621aafa681f2303f24442eabf6e3a5a57
roshsundar/Code_Archive
/Python_programs/LookForCharac.py
300
4.15625
4
occurences=0 print "Please enter a group of words" userPut=raw_input() print "Now enter a character that you want me to find in it" charac=raw_input() for letter in userPut: if letter == charac: occurences += 1 print "I found",occurences,"ocurrences of your character in the words"
true
e3d017f081d9b76417b13ba725de6910a91f1742
aribajahan/Projects
/learnPTHW/ex31.py
1,360
4.28125
4
print "You enter a dark room with two doors. Do you go through door #1 or door #2?" door = raw_input(">>> ") if door == "1": print "There's a huge bear here eating a cheesecake. What do you do now?" print "1. Take the damn cheesecake." print "2. Scream at the bear" print "3. Call Batman" bear =raw_input("---> "...
true
d7af5f75c15b02c9a1bc839f1f6ee9c32942e53d
mochimasterman/hello-world
/mathtime.py
1,231
4.1875
4
print("hello!") print("lets do math!") score = 0 streak = 0 answer1 = input("What is 1 + 1?") if answer1 == "2": print("Correct!") score = score+1 streak += 1 else: print("Incorrect!") streak = 0 print("Your score is", answer1) #start level 2 print("To level 2!") answer2 = input("what is 7 plus 2?"...
true
6f2c1d479982891bd6900b0c4b00ed30144f62c8
Requinard/merge-sort
/sqrt.py
1,189
4.125
4
""" Try to find the square root of a number through approximation Estimated operational time: O((number * 10)*precision) """ def brute_sqrt(number, power=2, precision=13): var = 1.0 mod = 1.0 # 13 is the max amount of numbers we can actually count with floats, going above 13 is useless if precision >...
true
82a2e068371c6790528cb4319a3b5f36788263a9
sprajjwal/spd1.4-interview-practice
/problem2.py
1,199
4.125
4
# https://leetcode.com/problems/merge-two-sorted-lists/ # Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. # Example: # Input: 1->2->4, 1->3->4 # Output: 1->1->2->3->4->4 # Definition for singly-linked list. class ListNode:...
true
00eaa267b38e765580f2dfa24a11e2f7b2538559
ansh8tu/Programming-with-python-Course
/Tetrahedron.py
236
4.3125
4
# This is a Python Program to find the volume of a tetrahedron. import math def vol_tetra(side): volume = (side ** 3 / (6 * math.sqrt(2))) return round(volume, 2) # Driver Code side = 3 vol = vol_tetra(side) print(vol)
true
8370e8d257bab5bfeedafbfe6307682dffd916f9
hraf-eng/coding-challenge
/question03.py
1,473
4.3125
4
# 3. Check words with typos: # There are three types of typos that can be performed on strings: insert a character, # remove a character, or replace a character. Given two strings, write a function to # check if they are one typo (or zero typos) away. # Examples: # pale, ple ­> true # pales, pale ­> true # pale, bale ­...
true
3d99c11bd5d21fa09e7f9bacedcb2da703477599
meta3-s/K-Nearest-Neighbors-Python
/KNN.py
1,753
4.21875
4
## Tutorial on the implementation of K-NN on the MNIST dataset for the recognition of handwritten numbers. from sklearn.datasets import * import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn.cluster import KMeans from sklearn import datasets from sklearn.model_selection import train_tes...
true
34aeb29e9f40139d27530f54a7d595984a88974a
SurajKakde/Blockchain
/assignments/Assignment_Suraj.py
657
4.25
4
# collecting input from the user for name and age name=input('Please enter your name: ') age=input('Please enter your age: ') def my_intro(name, age): """ Concatenate the name and age and print""" print('Hello! My name is '+name+' and my age is ' +age) def add_strings(string1, string2): """concatenates ...
true
e6763855509e00ddf98426472a37c79d1f464df8
vibhor-vibhav-au6/APJKalam
/week8/day03.py
570
4.15625
4
''' Tell space complexity of following piece of code: (5 marks) for i in range(n): for j in range(n): print(“Space complexity”) ''' # O(N) = o(n) * o(n) = o(n^2) ''' Reverse an array of integers and do not use inbuilt functions like “reverse”, don’t use shorts hands like “arr[::-1]”. Only use following approac...
true
5e48f5bb5cffdf1bd49a9ca6f026ae06bbf7f1e4
isemona/codingchallenges
/18-SwapCase.py
1,476
4.1875
4
#https://www.coderbyte.com/editor/Swap%20Case:Python #Difficulty easy #Implemented built in function .swapcase() def SwapCase(str): # code goes here # swap letters small for cap, i/o str-str mutation; symbols stay as is, refactor new_str = [] for i in str: if i == i.lower(): ...
true
988dd42a48919561214433608e085431fc0fac80
obebode/EulerChallenges
/EulerChallenge/Euler4.py
685
4.25
4
def checkpalindrome(nums): # return the palindrome numbers i.e original num equals to the same number in reverse form return nums == nums[::-1] def largestpalindrome(): # Initial largest to zero largest = 0 # Nested for loop to generate three digit numbers for 100-999 # Check if product is h...
true
1a474a4d6ccfdbe6c954766fa96ebaef9fb1c7c3
arajitsamanta/google-dev-tech-guide
/python-basics/fundamentals/repition-statements.py
2,738
4.15625
4
def whileLoop(): theSum = 0 i = 1 while i <= 100: theSum = theSum + i i = i + 1 print("The sum = ", theSum) # The while loop is a compound statement and thus requires a statement block even if there is only a single statement to be executed. Consider the user of # the while loo...
true
3a2b69e1e977c7de04dd12b6b0d7d3f78b5e6efe
justien/lpthw
/ex_11xtnsn.py
1,186
4.4375
4
# -*- coding: utf8 -*- # Exercise 11: Asking Questions print "==================================================" print "Exercise 11: Asking Questions" print print # With this formulation, I can combine the string name with the question # and the raw_input all at once. name = raw_input("What is your name? ") #^-...
true
de4a884792759d26a039007727f5387d802bafba
justien/lpthw
/ex8.py
1,364
4.4375
4
# -*- coding: utf-8 -*- # Exercise 8: Printing, Printing print "==================================================" print "Printing, Printing" print print # Formatter is a string, which text can be used as four values. # It is a string that's made up of four raw inputs. formatter = "%r %r %r %r" # We now demonstrat...
true
a61b900e548eb869c5470b35139674bca31bcd3b
justien/lpthw
/ex10_formatting_cats.py
1,005
4.1875
4
# -*- coding: utf8 -*- # Exercise 10: What was that? print "==================================================" print "Exercise 10: What was that?" print print # here are the defined strings, including: # * the use of \t to show a tab indentation # * the use of \n to show a new line # * the use of \ to esc...
true
7136768c1f9c5aa645fc47517444c423d59e3989
justien/lpthw
/ex11.py
810
4.3125
4
# -*- coding: utf8 -*- # Exercise 11: Asking Questions print "==================================================" print "Exercise 11: Asking Questions" print print # With this formulation, I can combine the string name with the question # and the raw_input all at once. name = raw_input("What is your name? ") prin...
true
448bc46010c439ef8bbb4682dd71f4182799c994
himynameismoose/Printing-Variables
/main.py
2,048
4.4375
4
# Lab 1.3: Printing & Variables # Part 1: Printing Practice # There are five lines of code provided to you in the Google Document. # Enter the five lines of Python code below, and run it to see what happens. # Make sure to respond to the prompts in the Google Document. # /ghttps://docs.google.com/document/d/1Wt4zeX6yI...
true
bffc4b4dd0c997c57a348360d052283d95409dad
4rude/WGUPS_Delivery_Program_C950
/dsa_2/Truck.py
754
4.21875
4
class Truck: """ The Truck class is used to hold packages to delivery, hold location data about where the truck is at and where it should go next, time data about the current time of the truck/driver, and the total mileage of the truck objet. """ # Set the init method for the Truck class so a T...
true
7a89f3ce8e82e16430e307a7647e84053b1c84b5
Anjalibhardwaj1/Hackerrank-Solutions-Python
/Basics/Write_a_func.py
1,243
4.1875
4
#An extra day is added to the calendar almost every four years as February 29, # and the day is called a leap day. It corrects the calendar for the fact that # our planet takes approximately 365.25 days to orbit the sun. A leap year # contains a leap day. #In the Gregorian calendar, 3 conditions are used to identif...
true