blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
79f5435bbcf2bd7b757b6e2f1a0da40e4bf82836
starmap0312/refactoring
/composing_method/introduce_explaining_variable.py
930
4.4375
4
# - if have a complicated expression that is hard to understand, put the result of the expression # or parts of the expression in a temp variable with a name explaining its purpose # - an alternative is to use extract method, but sometimes extract method is hard, # because there are too many local temp variables t...
true
18164044687548ed741c2d8833149e564f708fa1
shmishkat/PythonForEveryone
/Week05/forLoopDic.py
436
4.21875
4
#for loop in dictionaries. countsofNames = {'sarowar': 1, 'hossain': 2, 'mishkat': 2, 'mishu': 2} for key in countsofNames: print(key,countsofNames[key]) #converting dictionary to list nameList = list(countsofNames) print(nameList) print(countsofNames.keys()) print(countsofNames.values()) print(countsofNames.it...
true
4d29c7a19f10bd73b6c7a132e8024bf92e0de176
tanmay2298/Expenditure_Management
/database.py
1,715
4.3125
4
import sqlite3 from datetime import date # get todays date def create_table(): conn = sqlite3.connect("Expenditure.db") cur = conn.cursor() cur.execute("CREATE TABLE IF NOT EXISTS Expenditure(ID INTEGER PRIMARY KEY, expenditure_date text, Item text, Cost real)") conn.commit() conn.close() def insert_data(expendi...
true
d6944aa05f2adbb15f1eeeca1bc0713cb8e0000a
geoniju/PythonLearning
/Basics/DictEx1.py
422
4.15625
4
"""" Write a program that reads words in words.txt and stores them as keys in a dictionary. It doesnt matter what the values are. Then you can use the in operator to check whether a string is in the dictionary. """ fhand = open('words.txt') word_dict = dict() for line in fhand: words = line.split() for word...
true
df562ec851108571c9c64114e44b38088a5ca605
lucas-deschamps/LearnPython-exercises
/ex6.py
948
4.40625
4
types_of_people = 10 x = f"There are {types_of_people} types of people." binary = "binary" do_not = "don't" y = f"Those who know {binary} and those who {do_not}." print(x) print(y) print(f"I said: {x}") print(f"I also said: '{y}'") hilarious = False joke_evaluation = "Isn't that joke so funny?! {} {}"...
true
6be6ef4eec51a80a29e1516c6c4e074ccb64f5f7
lucas-deschamps/LearnPython-exercises
/ex38.py
1,772
4.25
4
ten_things = "Apples Oranges Crows Telephone Light Sugar" print("\nWait, there are not 10 things in that list. Let's fix that.\n") # splits string into a list @ emptyspaces stuff = ten_things.split(' ') # 8 items in the list, but ten_things only needs 4 more more_stuff = ['Day', 'Night', 'Song', 'Frisbee', ...
true
bdeddd92cfaed29ffe474b9ce8130046597fcc82
DhivyaKavidasan/python
/problemset_3/q7.py
421
4.40625
4
''' function named uses_only that takes a word and a string of letters, and that returns True if the word contains only letters in the list submitted by : dhivya.kavidasan date: 05/12/2017 ''' def uses_only(word, only_letters): i = 0 while i <len(word): if word[i] in only_letters: i+=1 else: ...
true
cdefa6f65d75c76a213a108b0223122b72b30a2f
morrosquin/aleandelebake
/crypto/caesar.py
385
4.125
4
from helpers import alphabet_position, rotate_char def encrypt (text, rot): encrypted_text = "" for characters in text: encrypted_text += rotate_char(characters, rot) return encrypted_text def main(): text = input('Enter your message: ') rotation = int(input('Enter rotation: ')) prin...
true
89d25d50b13a4ee345ba2aeee3b4f4f2063e0947
tiveritz/coding-campus-lessons-in-python
/src/dcv/oct/day09part01.py
695
4.3125
4
def bubble_sort(arr): sorted = arr.copy() to_swap = True while to_swap: to_swap = False for i in range(1, len(arr)): if (sorted[i - 1] > sorted[i]): to_swap = True sorted[i - 1], sorted[i] = sorted[i], sorted[i - 1] return sorted def hello_wo...
true
0c65b84132465c366b5eb84628cad04d5a80866f
StRobertCHSCS/fabroa-hugoli0903
/Working/Practice Questions/2.livehack_practice_solution2.py
896
4.46875
4
''' ------------------------------------------------------------------------------- Name: 2.livehack_practice_solution2.py Purpose: Determining if the triangle is a right angled Author: Li.H Created: 14/11/2019 ------------------------------------------------------------------------------ ''' # Receive the side leng...
true
f0a756e7cdc7e35be0efcc03def4afdd366376e7
cloudacademy/pythonlp1-lab2-cli
/src/code/YoungestPresident/solution-code/youngest_pres.py
1,449
4.15625
4
#! /usr/bin/python3 import sys sys.version_info[0] lab_exercise = "YoungestPresident" lab_type = "solution-code" python_version = ("%s.%s.%s" % (sys.version_info[0], sys.version_info[1], sys.version_info[2])) print("Exercise: %s" % (lab_exercise)) print("Type: %s" % (lab_type)) print("Python: %s\n" % (pytho...
true
bd3f71a840393b9e85508b627bc234bd20f670bc
CSPon/Workshop_Materials
/Python_Workshop_Files/Works_010.py
2,236
4.34375
4
# Python 2.X workshop # File: Works_010.py # Files I/O and Exceptions # To simply print to the Python shell, use the print keyword print "Hello, Python!" print # Empty line # To read keyboard input within the shell... print "User input Demo" string = raw_input("Enter your name: ") print "Hello, " + string + "!" pri...
true
070f868f26cdeaa2f44ccb0885a9dc5889b1070d
CSPon/Workshop_Materials
/Python_Workshop_Files/Try_Files_Completed/Works_Try_001.py
644
4.125
4
# Python 2.7.X # Try_001.py # Modifying the quadratic equation # Continuing with quadratic equation, modify your code # So it can check with imaginary numbers # If 4 * a * c is negative, program must let user know # quadratic equation is unsolvable import math a = 5.0 b = 2.0 c = 10.0 # Write your code here if ((b*...
true
e8af090f30548f575478a7ef18ac554b77bf2dd4
jonbleibdrey/python-playhouse
/lessons/space/planet.py
971
4.25
4
class Planet: # class level attribute- has acesss to all instances shape = "round" #class methods #this is allso a decorator and it extends the methods below here. @classmethod def commons(cls): return f"All planets are {cls.shape} becuase of gravity" #static methods #this is ...
true
009f0354abb393920fd0570f056dab386960f30f
nateychau/leetcode
/medium/430.py
1,243
4.34375
4
# 430. Flatten a Multilevel Doubly Linked List # You are given a doubly linked list which in addition to the next and previous pointers, it could have a child pointer, which may or may not point to a separate doubly linked list. These child lists may have one or more children of their own, and so on, to produce a multi...
true
33457f0033848661c5312884471133f808943b54
nateychau/leetcode
/medium/735.py
2,073
4.15625
4
# 735. Asteroid Collision # We are given an array asteroids of integers representing asteroids in a row. # For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed. # Find out the state of th...
true
35c0dd06be1544c645f19ff2b6ff101cc04e06c0
macyryan/lists
/main.py
1,855
4.53125
5
# a list is a sequence of items # 1D list like a single row or a single column in Excel # Declare a list using [] and a coma seperated of values list_ints = [0, 1, 10, 20] #there are unique indexes for each element in the list # 0-based, meaning the first element is at zero and the last element is n-1 # where n is th...
true
08ee5d07cc4cd9fa9ac995979b3ae921875651e9
eluttrell/string-exercises
/rev.py
274
4.3125
4
# This way works, but is too easy! # string = raw_input("Give me a string to reverse please\n:") # print string [::-1] string = "Hello" char_list = [] for i in range(len(string) - 1, - 1, - 1): char list.append(string[i]) # output = ' '.join(char_list) print output
true
aae92769398e2798c61f59b17eb3e509c1437bfa
Techie-Tessie/Big_O
/linear.py
766
4.28125
4
#Run this code and you should see that as the number of elements #in the array increases, the time taken to traverse it increases import time #measure time taken to traverse small array start_time = time.time() array1 = [3,1,4] for num in array1: print(num) print("\n%s seconds" % (time.time() ...
true
1bbdf14acb9ddbc2a8d4074b54330152dae6a582
rajeshkr2016/training
/chapter2_list_map_lambda_list_comprehension/51_loopin1.py
681
4.40625
4
#When looping through a sequence, the position index and corresponding value can be retrieved at the same time using the enumerate() function. for i, v in enumerate(['tic', 'tac', 'toe']): print(i, v) # To loop over two or more sequences at the same time, the entries can be paired with the zip() function. question...
true
436590717e700ec74574b56332a1023362f73ee7
rajeshkr2016/training
/chapter4_class_method_inheritance_override_polymorphism/3_method_1.py
585
4.625
5
''' The Constructor Method The constructor method is used to initialize data. It is run as soon as an object of a class is instantiated. Also known as the __init__ method, it will be the first definition of a class and looks like this: ''' class Shark: def __init__(self): print("This is the constructor me...
true
22ea187f2fe994d8aca2eabeda4ea458af8162b9
rajeshkr2016/training
/chapter10-Generator_Fibanocci/8-Nested_list_comp.py
369
4.21875
4
#''' my_list = [] for x in [20, 40, 60]: for y in [2, 4, 6]: my_list.append(x * y) #print(my_list) my_list = [x * y for x in [20, 40, 60] for y in [2, 4, 6]] print(my_list) ''' List comprehensions allow us to transform one list or other sequence into a new list. They provide a concise syntax for compl...
true
798da748346e83c63566d0a2c24d36aa5467b49e
rajeshkr2016/training
/senthil/primeFactor.py
768
4.1875
4
''' Given int x, determine the set of prime factors f(5) = [1,5] f(6) = [2,3] f(8) = [2,2,2] f(10) = [2,5] 1) While n is divisible by 2, print 2 and divide n by 2. 2) After step 1, n must be odd. Now start a loop from i = 3 to square root of n. While i divides n, print i and divide n by i, increment i by 2 and continu...
true
0a72c3b845963090b651d57389478370565788c8
rajeshkr2016/training
/chapter2_list_map_lambda_list_comprehension/10_list_comp_if.py
669
4.3125
4
''' A list comprehension consists of brackets containing an expression followed by a for clause, then zero or more for or if clauses. The result will be a new list resulting from evaluating the expression in the context of the for and if clauses which follow it. For example, this listcomp combines the elements of two ...
true
09300b989cf42a78381dfd25fa4011cb33f346a0
sujitdhamale/Python
/0505_Aggregating_lists_and_tuples.py
892
4.5
4
#!/usr/bin/python #0505_Aggregating_lists_and_tuples.py by SUjit Dhamale def main(): print("Tuple ") #tuple is immutable object. we cannot insert, append, delete in tuple x=(1,2,3,4) print(type(x),x) print("List") # list is mutable object x=[1,2,3,4] print(type(x),x) #list ...
true
e281a51a657d101f2127c4800eb8c2077f434822
BogartZZZ/Python-Word-Reverse
/WordReverse.py
330
4.15625
4
#my_string = input("Input a word to reverse: ") #for char in range(len(my_string) -1, -1, -1): # print(my_string[char], end="") def reverseWord(Word): words = Word.split(" ") newWords = [word[::-1] for word in words] newWord = " ".join(newWords) return newWord Word = "Can't stop me" print(reverseW...
true
b999f987b9b161c094cec43815873c38d18d9c66
PeturOA/2021-3-T-111-PROG
/assignments/while_loops/every_other_int.py
273
4.40625
4
num_int = int(input("Enter a number greater than or equal to 2: ")) # Do not change this line counter = 2 # Fill in the missing code below if num_int < 2: print("The number is too small.") else: while counter <= num_int: print(counter) counter += 2
true
0e5f551d767c513eeaa4c14a635b798555d5d45a
tiannaparmar/Python-Level-2
/Functions.py
1,885
4.34375
4
#Create new file #Save as Functions.py #Save in Python-Level-2 folder ---- repo(repository) #Add two numbers def AddNumbers(x,y,z): #Definition of the function return x + y + z def GetSquares(x): return x * x #Call our Function Total = AddNumbers(4,9,100) #Output the results print(f"The sum ...
true
115c846183893a1b02c883fe8418cd0190958d1d
kumarUjjawal/python_problems
/leap_year.py
349
4.28125
4
# Return true if the given input is a leap year else return false. def leap_year(year): leap = False if (year % 4 == 0): if (year % 100 == 0 and year % 400 == 0): leap = True else: leap = False else: leap = False return leap years = int(input())...
true
b9cba0bc0de5e2ea45ab195ae4a756c419bfe1b4
arbiben/cracking_the_coding_interview
/recursion_and_dynamic_programming/multiply_recursively.py
1,445
4.46875
4
# write a recursive function to multiply two positive integers without using # the * operator. others are allowed, but you should minimize the number of operations def recursive_multiply(a, b): smaller = b if a > b else a larger = a if a > b else b print("recursing and decrementing: {}".format(multiply_de...
true
a3e35c2ef4501db0f733d10746df79993a226ffe
JeffreyYou55/cit
/TermProject/plotting.py
960
4.15625
4
from turtle import * import coordinates import square import linear import quadratic border = { "width" : 620, "height" : 620 } # draw square and coordinate print("< Jeffrey's Plotting Software >") print("drawing rectangular coordinates...") square.draw_square(border["width"], border["height"], -310, -300) penup() se...
true
c8257d92fba77a9b9c006c7b2277c393d546403f
cbain1/DataScience210
/python/ListsQ2.py
924
4.125
4
import sys import random def beret(request): total = 0 strings = 0 #Loops through all words in request for elem in request: count =0 #splits each word into its own string value word = list(elem) # this loops through each letter in each wo...
true
f23c5207a4cab807e897918fa84aea19db8023d9
andrewnnov/100days
/guess_number/main.py
1,530
4.15625
4
import random from art import logo print(logo) print("Welcome to the Number Guessing Game!") def play_game(): guess_number = random.randint(1, 100) print(guess_number) result_of_guess = True while result_of_guess: attempts = 0 print("I'm thinking of number between 1 and 100") ...
true
16ec5926aa96c5a92794b797f3a597b3e60dbe39
mirielesilverio/cursoPython3
/logicOperators/using_logic_operators.py
337
4.21875
4
name = input('What is your name? ') age = int(input('How old are you? ') or 0) if not name: print('The name cannot be empty') elif ' ' in name: print('Very good! You entered your full name') elif ' ' not in name: print('You must enter your full name.') if not age or age < 0: print('Oh no! You entered ...
true
8b84715a6d780d92c3bd97fd0c92496f1c1e8c09
iam-amitkumar/BridgeLabz
/AlgorithmPrograms/Problem1_Anagram.py
605
4.21875
4
"""Anagram program checks whether the given user-input strings are anagram or not. @author Amit Kumar @version 1.0 @since 02/01/2019 """ # importing important modules import utility.Utility import util.Util global s1, s2 try: s1 = utility.Utility.get_string() s2 = utility.Utility.get_string() except Exceptio...
true
6416fd722282681c9da97207183871b94cf9e51f
iam-amitkumar/BridgeLabz
/ObjectOrientedPrograms/Problem1_Inventory.py
1,976
4.28125
4
"""In this program a JSON file is created having Inventory Details for Rice, Pulse and Wheat with properties name, weight, price per kg. With the help of 'json' module reading the JSON file. @author Amit Kumar @version 1.0 @since 10/01/2019 """ # Importing important modules import json # Inventory class class Invent...
true
b0574f764eb2af8d4e06fddc1c9781c13b7f73a2
iam-amitkumar/BridgeLabz
/DataStructureProgram/Problem4_BankingCashCounter.py
2,955
4.375
4
"""this program creates Banking Cash Counter where people come in to deposit Cash and withdraw Cash. It have an input panel to add people to Queue to either deposit or withdraw money and de-queue the people maintaining the Cash Balance. @author Amit Kumar @version 1.0 @since 08/01/2019 """ # importing important module...
true
e1a0391349896b3ab22365f4c9f295240dae6a9a
iam-amitkumar/BridgeLabz
/AlgorithmPrograms/Problem7_InsertionSort.py
963
4.21875
4
"""This program reads in strings from standard input and prints them in sorted order using insertion sort algorithm @author Amit Kumar @version 1.0 @since 04/01/2019 """ # importing important modules import utility.Utility import string global u_string try: u_string = input("Enter the number of string you want t...
true
8e1f1ee70acfa12c836eb7bc7274e1b424e5e747
iam-amitkumar/BridgeLabz
/DataStructureProgram/Problem3_BalancedParentheses.py
1,862
4.1875
4
"""Take an Arithmetic Expression where parentheses are used to order the performance of operations. Ensure parentheses must appear in a balanced fashion. @author Amit Kumar @version 1.0 @since 08/01/2019 """ # importing important modules from DataStructureProgram.Stack import * s1 = Stack() # creating object of Sta...
true
e993fb4db905e0d672d59137c376cbb9368d93a0
PhilipCastiglione/learning-machines
/uninformed_search/problems/travel.py
2,072
4.28125
4
from problems.dat.cities import cities """Travel is a puzzle where a list of cities in North America must be navigated in order to find a goal city. The navigation approach presents a problem to be solved using search algorithms of various strategies. The distance between cities is provided and a heuristic, straight ...
true
c8f4625094cc322c498da1b751ad70e838c98775
namelessnerd/flaming-octo-sansa
/graphs/breadth_first_search.py
1,609
4.25
4
def breadth_first_search(graph, starting_vertex): # store the number of steps in which we can reach a starting_vertex num_level= {starting_vertex:0,} #store the parent of each starting_vertex parent={starting_vertex:None,} #current level level= 1 #store unexplored vertices unexplored=[starting_vertex] print ...
true
8800b16c4518c85952934c96ba8ccf04cb2d3fe7
vaddanak/challenges
/mycode/fibonacci/fibonacci.py
2,392
4.15625
4
#!/usr/bin/env python ''' Author: Vaddanak Seng File: fibonacci.py Purpose: Print out the first N numbers in the Fibonacci sequence. Date: 2015/07/25 ''' from __future__ import print_function; import sys; import re; sequence = [0,1]; ''' Calculate and collect first N numbers in Fibonacci number sequence. Store res...
true
4296c919d465767998bee122b61e3cabc683d101
officialtech/xPython
/static_variable | xpython.py
2,954
4.125
4
**********************************************# STATIC VARIABLES ***************************************** # The variables which are declared inside the class and outside the 'method' are called static variable. # Static variables will holds common values for every object. # Static variables will get memory for one ...
true
6da56124e837982d56bed013942e60fc9068692b
amersulieman/Simple-Encryption-Decryption
/Decryption.py
1,552
4.15625
4
'''@Author: Amer Sulieman @Version: 10/07/2018 @Info: A decryption file''' import sys from pathlib import Path #check arguments given for the script to work if len(sys.argv)< 2: sys.exit("Error!!!!\nProvide <fileName> to decrypt!!"); def decryption(file): #File path to accomdate any running system filePath ...
true
323349df70f4586b2055c9ae5894a0195f1e79ba
vladn90/Algorithms
/Numbers/fibonacci.py
1,940
4.125
4
""" Comparison of different algorithms to calculate n-th Fibonacci number. In this implemention Fibonacci sequence is gonna start with 0, i.e. 0, 1, 1, 2, 3, 5... """ from timeit import timeit from functools import lru_cache def fib_1(n): """ Recursive algorithm. Very slow. Runs in exponential time. """ #...
true
6b974c6dfc21b4d8aeea7cf2a9536b8a33b02929
vladn90/Algorithms
/Sorting/insertion_sort.py
1,207
4.4375
4
""" Insertion sort algorithm description, where n is a length of the input array: 1) Let array[0] be the sorted array. 2) Choose element i, where i from 1 to n. 3) Insert element i in the sorted array, which goes from i - 1 to 0. Time complexity: O(n^2). Space complexity: O(1). """ import random def insertion_sort(a...
true
2f5ea417ad6f0ff70f0efcede02f9579c580533a
vladn90/Algorithms
/Sorting/bubble_sort.py
1,196
4.375
4
""" Bubble sort algorithm description, where n is a length of the input array: 1) Compare consecutive elements in the list. 2) Swap elements if next element < current element. 4) Stop when no more swaps are needed. Time complexity: O(n^2). Space complexity: O(1). """ import random def bubble_sort(array): """ Sor...
true
8c57f071fe179750c8be0d2b81ed023d94299ad7
vladn90/Algorithms
/Matrix_problems/spiral_matrix.py
2,011
4.25
4
""" Problem description can be found here: https://leetcode.com/problems/spiral-matrix/description/ Given a matrix of m x n elements, return all elements of the matrix in spiral order. For example, given the following matrix: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] You should return [1, 2, 3, 6, 9, 8, 7, 4, 5]. ""...
true
cfadda58720b5b635c21235c4a73a91f6cffca40
ayr0/numerical_computing
/Python/GettingStarted/solutions_GettingStarted.py
2,065
4.375
4
# Problem 1 ''' 1. Integer Division returns the floor. 2. Imaginary numbers are written with a suffix of j or J. Complex numbers can be created with the complex(real, imag) function. To extract just the real part use .real To extract just the imaginary part use .imag 3. float(x) where x is the integer. 4. // ''' # ...
true
7eb6f26a36fd55f437aef7510db2d9df1e055d2e
flyburi/python-study
/io_input.py
223
4.375
4
def reverse(text): return text[::-1] def is_palindrome(text): return text == reverse(text) sth = raw_input("Enter text:") if is_palindrome(sth): print "yes it is a palindrome" else: print "no it is not a palindrome"
true
89ebfba3b074ecdf011aff1e1f0a1013f980ab56
rafa761/algorithms-example
/insertion_sort.py
585
4.28125
4
unsorted_list = [7, 3, 9, 2, 8, 4, 1, 5, 6] def insertion_sort(num_list): # We don't need to consider the index 0 because there isn't any number on the left for i in range(1, len(num_list)): # store the current value to sort value_to_sort = num_list[i] # While there are greater values on the left while num...
true
7fac6b0e87c550f517d9bea7834585812ff6ddac
Raeebikash/python_class2
/practice/exercise77.py
538
4.25
4
# define is_palindrome function that take one world in string as input # and return True if it is palindrome else return false # palindrome - word that reads same backwards as forwards #example # is_palindrome ("madam") ------> True # is_palindrome ("naman")------> True #is_palindrome ("horse")----->False # lo...
true
8fa3d457aeb3c0162a2b0d677ce3b089dd8e1e25
BalaKumaranKS/Python
/codes/assignment 01- 01.py
209
4.4375
4
#program for calculating area ofcircle value01 = int (input('Enter radius of circle in mm ')) value02 = (value01 * value01) value03 = (3.14 * value02) print ('The area of circle is',str(value03),'mm^2' )
true
628bfaf8e262ab8186103f95e52f478ed7381082
BalaKumaranKS/Python
/codes/assignment 02- 02.py
235
4.3125
4
# Program to check number is positive or negative inp = int(input('Enter the Number: ')) if inp > 0: print('The number is Positive') elif inp== 0: print ('The number is 0') else: print('The number is Negative')
true
0bd9287e31945c94caf4cb3ee7c41635435a7273
heecho/Database
/webserver-3.py
2,628
4.1875
4
''' Phase three: Templating Templating allows a program to replace data dynamically in an html file. Ex: A blog page, we wouldn't write a whole new html file for every blog page. We want to write the html part, and styling just once, then just inject the different blog data into that page. 1) Add the following l...
true
afc147e559f9589487ce969973e8342beae3a05b
Ulkuozturk/SQL_Python_Integration
/movie_Create_AddData.py
648
4.4375
4
import sqlite3 connection = sqlite3.connect("movie.db") cursor= connection.cursor() cursor.execute('''CREATE TABLE IF NOT EXISTS Movies (Title TEXT, Director TEXT, Yera INT)''' ) famousfilms=[("Pulp Fiction","Quantin Tarantino", 1994),("Back To The Future","Steven Spielberg", 1985), ("Moo...
true
554f4435cd9ec0bdbdff8e5f6b61a50b3ae8f355
taylortom/Experiments
/Python/MyFirstPython/Lists.py
518
4.3125
4
# # Lists # list = [0,1,'two', 3, 'four', 5, 6, 'Bob'] # add to the list list.append('kate') print list # remove an item list.pop(3) # can also use list.pop() to remove last item print list # sort a list list.sort() print list # reverse a list list.reverse() print list # list nesting matrix = [[-1,0,0], [0,-1,0]...
true
fa5e9a2770fbc24836104db247d0d1e6866ee77b
sidmaskey13/python_assignments_2
/P12.py
599
4.375
4
# Create a function, is_palindrome, to determine if a supplied word is # the same if the letters are reversed. givenString = input('Enter string: ') def check_palindrome(given_string): word_length = len(given_string) half_word_length = int(word_length/2) match = 0 for i in range(0, half_wor...
true
61e354e9f4d5c5cabbd6a804150cf5e6c505285a
sidmaskey13/python_assignments_2
/P3.py
586
4.3125
4
# Write code that will print out the anagrams (words that use the same # letters) from a paragraph of text. givenString = input('Enter string: ') def check_anagrams(given_string): word_length = len(given_string) half_word_length = int(word_length/2) match = 0 for i in range(0, half_word_len...
true
70a2412549fe5a7e8bf54f626457e529363f3a9b
mccricardo/project_euler
/problem_46/python/problem46.py
627
4.3125
4
# Start with prime 3. # # If none of the primes in prime_list divide n, then it's also prime and # add it to the list. # # If not, let's put the problem formula with another aspect: # prime = odd_number - 2 * pow(i, 2) # # This means that we can check if any of the primes can be constructed in terms # of the odd numb...
true
a3def7eec0586d8dfdbef1aa55c6feec20b5c854
wreyesus/Learning-to-Code
/python/python_crash_course/chapter_4/4-1.pizzas.py
273
4.6875
5
""" Store three kinds of pizza in a list 1. print them in a for loop 2. write about why you love pizza """ pizzas = ['americana', 'hawaina', 'peperoni'] for pizza in pizzas: #1 print(f'I like {pizza}') print('I REALLY LOVE PIZZA IS MY FAVORITE FOOD IN THE WORLD') #2
true
d1076809fe1826dad2117b9ced283dcb7173fcdb
wreyesus/Learning-to-Code
/python/python_crash_course/chapter_10/10-2.learning_c.py
458
4.28125
4
""" Read in each line from the file you just created, learning_python.txt, and replace the word Python with the name of another language, such as C. Print each modified line to the screen. """ filename = './learning_python.txt' with open(filename) as f: lines = f.readlines() for line in lines: if 'Pyt...
true
8655935a7d3a32c2e1a89ef3091db2f3f3de256a
wreyesus/Learning-to-Code
/python/python_crash_course/chapter_9/9-2.three_restaurants.py
838
4.4375
4
""" Start with your class from Exercise 9-1. Create three different instances from the class, and call describe_restaurant() for each instance. """ class Restaurant: def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type ...
true
085723b30c9de5a3dae534fa25a02f3deaafe065
wreyesus/Learning-to-Code
/python/python_crash_course/chapter_8/8-12.sandwiches.py
545
4.15625
4
""" Write a function that accepts a list of items a person wants on a sandwich. The function should have one parameter that collects as many items as the function call provides, and it should print a summary of the sandwich that is being ordered. """ def sandwiches_order(*sandwich): print('ORDER:') for order...
true
2565e37340942909c482bb4501d45d057fb3960e
wreyesus/Learning-to-Code
/regExp/scripts/exercise_2.py
323
4.25
4
"""Write a Python program that matches a string that has an a followed by zero or more b's.""" import re def finder(string): """using 're.match'""" regex = re.match('^a[\w]*', string) if regex: print('We have a MATCH') else: print('NO MATCH') finder('abc') finder('abbc') finder('abbba...
true
2264c01614e3ba01e621b7cc9ae50920f2a54bc0
wreyesus/Learning-to-Code
/python/python_crash_course/chapter_5/5-2.more_conditional_tests.py
1,021
4.3125
4
# 1. Tests for equality and inequality with strings print('='*5) car = 'Tesla' print(car == 'tesla') print(car == 'Tesla') # 2. Tests using the lower() function print('='*5) name = 'James' test = name.lower() == 'james' print(test) # 3. Numerical tests involving equality and inequality, # greater than and less than,...
true
ab3e9f61cd9942019c125f1d940daff547c80888
Abdulvaliy/Tip-calculator
/Tip calculator.py
468
4.125
4
#If the bill was $150.00, split between 5 people, with 12% tip. #Each person should pay (150.00 / 5) * 1.12 = 33.6 print("Welcometo the tip calculator.") bill = float(input("What was the total bill? $")) percent = int(input("What percentage tip would you like to give? 10, 12 or 15? ")) people = int(input("H...
true
240cad4398853e25f993842413a88eef365af76b
brian-rieder/DailyProgrammer
/DP146E_PolygonPerimeter.py
1,903
4.3125
4
__author__ = 'Brian Rieder' # Link to reddit: http://www.reddit.com/r/dailyprogrammer/comments/1tixzk/122313_challenge_146_easy_polygon_perimeter/ # Difficulty: Easy # A Polygon is a geometric two-dimensional figure that has n-sides (line segments) that closes to form a loop. # Polygons can be in many different shap...
true
7bbd62ff212c1a9a6b33b8bab369ba3b9c025488
amandazhuyilan/Breakfast-Burrito
/Data-Structures/BinarySearchTree.py
2,911
4.1875
4
# Binary Search tree with following operations: # Insert, Lookup, Delete, Print, Comparing two trees, returning tree # elements # example testing tree: # 8 # / \ # 3 10 # / \ \ # 1 6 14 # / \ / # 4 7 13 class node: def __init__(self, data): se...
true
7c9c7bfbaac7077ec4beaa4dac1405d726799eb7
hayleymathews/data_structures_and_algorithms
/Lists/examples/insertion_sort.py
819
4.34375
4
"""python implementation of Insertion Sort with Positional List >>> p = PositionalList() >>> p.add_first(1) Position: 1 >>> p.add_first(3) Position: 3 >>> p.add_first(2) Position: 2 >>> insertion_sort(p) PositionalList: [1, 2, 3] """ from Lists.positional_list import PositionalList def insertion_sort(List): if len...
true
cbe8c75f0538700abf4c7e528176c83944be8080
hayleymathews/data_structures_and_algorithms
/Arrays/examples/insertion_sort.py
439
4.28125
4
""" python implementation of Insertion Sort >>> insertion_sort([3, 2, 1]) [1, 2, 3] """ def insertion_sort(array): """ sort an array of comparable elements in ascending order O(n^2) """ for index in range(1, len(array)): current = array[index] while index > 0 and array[index - 1]> curre...
true
97e9c3f73ab4dfa755eb467fa8bba65f2d4c71f5
epicmonky/Project-Euler-Solutions
/problem020.py
430
4.125
4
# n! means n x (n - 1) x ... x 3 x 2 x 1 # For example, 10! = 10 x 9 x ... x 3 x 2 x 1 = 3628800, # and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. # Find the sum of the digits in the number 100! import math def sum_of_digits(n): s = 0 while n > 0: s += n % 10 ...
true
440f7e019f7621b8f497beb4dd3d6156870bfb3c
colehoener/DataStructuresAndAlgorithms
/Hash/open_hash.py
1,809
4.15625
4
#Mark Boady - Drexel University CS260 2020 #Implement an OPEN hash table import random #Hash Functions to test with def hash1(num,size): return num % size def hash2(num,size): x=2*(num**2)+5*num+num return x % size def hash3(num,size): word=str(num) total=0 for x in range(0,len(word)): c=word[x] total=total+...
true
abf112da79470c8d9b14e7d17747ad699858718b
arcPenguinj/CS5001-Intensive-Foundations-of-CS
/homework/HW1/tables.py
1,226
4.25
4
''' Yici Zhu CS 5001, Fall 2020 it's a program calculating how many table can be assembled test cases : 4 tops, 20 legs, 32 screws => 4 tables assembled. Leftover parts: 0 table tops, 4 legs, 0 screws. 20 tops, 88 legs, 166 screws => 20 tables assembled. Leftover parts: 0 table tops, 8 legs, 6 screws. 100 tops, ...
true
cc47e4a1c80f09bbeb121b624dc1f5d2fca087f8
arcPenguinj/CS5001-Intensive-Foundations-of-CS
/homework/HW2/exercise.py
1,669
4.21875
4
''' Fall2020 CS 5001 HW2 Yici Zhu it's a program for planning exercise based on different conditions ''' def main(): days = input("What day is it? ").title() holidays = input("Is it a holiday? ").title() rains = input("Is it raining? ").title() temps = float(input("What is the temperatur...
true
a77c1e503d0e39d55e2915962131bad2f0970126
algorithmsmachine/PythonAlgorithms
/misc/factorial.py
256
4.1875
4
num = 90 factorial=1 if num <0: print("cannot print factorial of negative num ") elif num == 0: print("The factorial of 0 is 1") else: for i in range(1,num + 1): factorial = factorial*i print("The factorial of",num," is ",factorial)
true
84a41b50164514518b02a83722820605d0468e0e
prabhakarzha/pythonimportantcode
/main.py
2,146
4.125
4
# reduce() function is not a built-in function anymore ,and it can be found in the functools module from functools import reduce def add(x,y): return x+y list =[2,3,4,5,6] print(reduce(add,list)) # map() function -The map() function iterates through all items in the given iterable # and execute the function...
true
ca3819dc5cd360988f9eb8c2f6f3ae7942ac1446
Gowthini/gowthini
/factorial.py
261
4.28125
4
num=int(input("enter the number")) factorial=1 if num<0: print("factorial does not exist for negative numbers") elif num==0: print("The factorial is") else: for i in range(1,num+1): factorial=factorial*i print("The factorial of"num,"is",factorial)
true
d33fb48a41a852ab3d3bfcb4624e7693dad18f9c
jwmarion/daily
/euler/35multiple.py
427
4.21875
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. multiples = [] result = 0 for x in range(0,1000): if x % 3 == 0: multiples.append(x) if x % 5 == 0 and x % 3 !...
true
d19cef12494dc50a7beb21a625a23823ce93d98c
eghadirian/Python
/P10-FindTwoElements.py
377
4.15625
4
# find the if sum of two elements is a value # find pythagoream triplets def sum_of_two(arr, val): found = set() for el in arr: if val - el in found: return True found.add(el) return False def func(arr): n = len(arr) for i in range(n): if sum_of_two(arr[:i]+arr[i+...
true
e358e998f4b59281e990ffd5b41dc2ecc81db548
devpatel18/PY4E
/ex_05_02.py
484
4.21875
4
largest=None smallest=None while True: num1=input("Enter a number:") if num1=="done": break try: num=int(num1) except: print("Please enter numeric value") continue if largest is None: largest=num elif num>largest: largest=num if ...
true
a6d8a0779cfc7092ef6f8651f0b8bc9ab9da774c
joelmedeiros/studies.py
/Fase7/Challange6.py
265
4.28125
4
number = int(input("Tell me the number you want to know the double, triple and square root: ")) double = number*2 triple = number*3 sqrt = number**(0.5) print("The double of {} is {} and the triple is {} and the sqrt is {:.2f}".format(number, double, triple, sqrt))
true
8907a33161a9922cca2925059520c857ee7c4451
Jay-mo/Hackerrank
/company_logo.py
1,604
4.53125
5
""" A newly opened multinational brand has decided to base their company logo on the three most common characters in the company name. They are now trying out various combinations of company names and logos based on this condition. Given a string S, which is the company name in lowercase letters, your task is to find...
true
a163cf56718a5fe33b00f120073ba193292a5933
VickeeX/LeetCodePy
/desighClass/ShuffleArray.py
1,198
4.25
4
# -*- coding: utf-8 -*- """ File name : ShuffleArray Date : 18/05/2019 Description : 384. Shuffle an Array Author : VickeeX """ import random class Solution: def __init__(self, nums: list): # # trick # self.reset = lambda: nums # self.shuffle ...
true
cea604980474aeb6996ab3b925b4c1fe8dc17cd2
Qurbanova/PragmatechFoundationProjects
/Algorithms/week09_day04.py
2,679
4.5625
5
# 1)Write a Python function to sum all the numbers in a list. Sample List : (8, 2, 3, 0, 7) Expected Output : 20 # 2)Write a Python function to multiply all the numbers in a list. Sample List : (8, 2, 3, -1, 7) Expected Output : -336 # 3)Write a function called returnDay. This function takes in one parameter ( a numbe...
true
7dc89b6e60710ae6437519899cb6e3520e6cf53f
nandhinipandurangan11/CIS40_Chapter4_Assignment
/CIS40_Nandhini_Pandurangan_P4_9.py
664
4.15625
4
# CIS40: Summer 2020: Chapter 4 Assignment: Problem 9 : Nandhini Pandurangan # This program reads a string and prints the string in reverse. # print_reverse() reads user input and prints it in reverse def print_reverse(): string = input("Please enter a word: ").strip() for i in range(len(string) - 1, -1, -1)...
true
a9be48c1b64fc1dfdf33f58b9d6c35f8b9caae1a
sich97/WakeyWakey
/server/server_setup.py
2,149
4.375
4
""" File: server_setup.py This file creates / or resets the server database. """ import sqlite3 import os DATABASE_PATH = "server/db" def main(): """ In the case that a database already exists, ask the user if it's really okay to reset it. If no, then do nothing and exit. If yes, delete the existing da...
true
8a2e5a2ed33489e1db0dc410db6cc3aa8e083f44
sweekar52/APS-2020
/Daily-Codes/Median of an unsorted array using Quick Select Algorithm.py
2,067
4.15625
4
# Python3 program to find median of # an array import random a, b = None, None; # Returns the correct position of # pivot element def Partition(arr, l, r) : lst = arr[r]; i = l; j = l; while (j < r) : if (arr[j] < lst) : arr[i], arr[j] = arr[j],arr[i]; i += 1; j += 1; arr[i], arr[r] = a...
true
fa9b017ec497e894b7222af17575ad0abe015f52
sajaram/Projects
/text_adventure_starter.py
1,609
4.375
4
start = ''' You wake up one morning and find that you aren’t in your bed; you aren’t even in your room. You’re in the middle of a giant maze. A sign is hanging from the ivy: “You have one hour. Don’t touch the walls.” There is a hallway to your right and to your left. ''' print(start) print("Type 'left' to go left ...
true
bb7219177527b96c77d15869c247ad16615a0693
sagdog98/PythonMiniProjects
/Lab_1.py
2,248
4.34375
4
# A list of numbers that will be used for testing our programs numbers = [1, 2, 3, 4, 5, 6, 7, 8] # Question 1: Create a function called even, which takes in an integer as input and returns true if the input is even, and false otherwise def even(num): # Provide your code here return True if num % 2 == 0 else F...
true
61fe504a5f0ef1f70db4799e6901f84b8e9f3333
roince/Python_Crash_Course
/Mosh_Python/guessing_game.py
1,073
4.125
4
chance = 3 # get a myth number, and check : whether it is a number and whether it is in # range (0-9) myth = input("your myth number: ") if myth.isdigit(): myth = int(myth) if myth > 9 or myth < 0: print("please enter a number in range (0-9)") quit() else: print("only numbers are allowed!") ...
true
434e727b3400f54428c65c146ec4e44eab74bc6c
Lewis-blip/python
/volume.py
233
4.125
4
pie = 3.14 radius = int(input("input radius: ")) height = float(input("input height: ")) rradius = radius**2 volume = pie * rradius * height final_volume = volume//1 print("the volume of the cyclinder is ", final_volume, "m^3")
true
2e3a8be86da4c724d636afc20f3dbf784c23b6c5
Snafflebix/learning_python
/ex9.py
507
4.125
4
# Here's some new strange stuff, remember type it exactly days = "Mon Tue Wed Thu Fri Sat Sun" #this makes each thing after \n on a new line months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug" #this puts days after the string with a space print "Here are the days: ", days print "Here are the months: ", months print "...
true
f023205fbfb15d2d12ee1460cb13ab31a27e504b
shalemppl/PythunTuts
/Tuples.py
2,143
4.59375
5
# Tuples are similar to lists, but once a tuple is created it cannot be changed #List (created with []) mylist = [1, 2, 3] print(mylist) mylist[2] = 4 print(mylist) #Tuple (created with ()) mytuple = (1, 2, 3) print(mytuple) #mytuple[2]=4 would result in a traceback, as an item within a tuple cannot be changed #So w...
true
4a3c26ab8368289cdb8e20912c26def8660bdd52
AFishyOcean/py_unit_five
/fibonacci.py
482
4.34375
4
def fibonacci(x): """ Ex. fibonacci(5) returns "1 1 2 3 5 " :param number: The number of Fibonacci terms to return :return: A string consisting of a number of terms of the Fibonacci sequence. """ fib = "" c = 0 a = 0 b = 1 for x in range(x): c = a + b a = b ...
true
31bb7ccdea6104bfacbd18e099f0935b3bc2d0e7
eecs110/spring2020
/course-files/lectures/lecture_04/in_class_exercises/08_activity.py
869
4.15625
4
# Write a function that prints a message for any name # with enough stars to exactly match the length of the message. # Hint: Use the len() function. def print_message(first_name:str, symbol:str='*'): message = 'Hello ' + first_name + '!' print(symbol * len(message)) print(message) print(symbol * len(...
true
d740731f12f6aff6f7175086263f0c9308b43b4a
eecs110/spring2020
/course-files/lectures/lecture_03/challenge_problem_2.py
1,900
4.34375
4
from tkinter import Canvas, Tk ##################################### # begin make_grid function definition ##################################### def make_grid(canvas, w, h): interval = 100 # Delete old grid if it exists: canvas.delete('grid_line') # Creates all vertical lines at intevals of 100 fo...
true
3d2de0860b3c106661671232cffcef522c187993
liturreg/blackjack_pythonProject
/deck.py
2,389
4.125
4
import random card_names = { 1: "Ace", 2: "Two", 3: "Three", 4: "Four", 5: "Five", 6: "Six", 7: "Seven", 8: "Eight", 9: "Nine", 10: "Ten", 11: "Jack", 12: "Queen", 13: "King" } card_suits = { 0: "Hearts", 1: "Diamonds", 2: "Clubs", 3: "Spades" } def generate_deck_dict()...
true
eee192feba564a8682d06b98c26abc33c0c31a38
alisiddiqui1912/rockPaperScissors
/Rock Pap S/finalVersion.py
1,229
4.34375
4
import random player_win = 0 computer_win = 0 win_score = input("Enter the Winning Score: ") win_score = int(win_score) while win_score > player_win and win_score > computer_win: print(f"Your Score:{player_win},Computer Score:{computer_win}") player = input("Make your move: ").lower() rand_num = random....
true
a3f70a3c9d8b47aa53eaa3ca9c4337b9b7bb4d2e
vukasm/Problem-set-2019-Programming-and-Scripting-
/question-vii.py
619
4.46875
4
#Margarita Vukas, 2019-03-09 #Program that takes a positive floating number as input and outputs an approximation of its square root. #This will import math module. import math #Asking user to enter a positive floating number which will be tha value of f. f=float(input("Please enter a positive number:")) #Using...
true