blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
5ceff881fad153efd3b9ce95dfd6b77c7b9f55fa
cheung1/python
/help.py
441
4.15625
4
#1.write the triangle print code # notice: when you just define, it cannot execute #2.define a function def printTriangle(): 'this is the help document ' print ' * ' print ' * * ' print '* * *' #3.invoke the function #notice:only can via the invoke to use the function # invoke the function: write the functio...
true
520ac63216a371940b7c98b2a152bd67b73c1bff
abhisjai/python-snippets
/Exercise Files/Ch2/functions_start.py
1,780
4.78125
5
# # Example file for working with functions # # define a basic function def func1(): print("I am a function") # func1() # Braces means to execute a function # value on console was any print command inside the function # If there was any return value, it was not assigned to any variable # print(func1()) # Execu...
true
4239a7ae04f3adc3b0546b9e18d03d7dbd90946c
abhisjai/python-snippets
/Misc Code/python-tuples.py
1,180
4.28125
4
# Task # # Given an integer n and n space-separated integers as input, create a tuple t, of those n integers. Then compute and print the result of # Note: hash() is one of the functions in the __builtins__ module, so it need not be imported. # Input Format # The first line contains an integer, n, denoting the number of...
true
708d5102fb648b48abd4dd3886f5bb923cf2b856
varunmalik123/Python-Data-Analysis
/write_columns.py
930
4.53125
5
def write_columns(data,fname): """ The purpose of this function is to take a list of numbers and perform two calculations on it. The function will generate a csv file with three columns containing the original data and the result from the first to calculations respectively :param data(list with elements being e...
true
d8df82383460b7c1730b7d2af1623a797fb35e5e
ra3738/Latext
/hasConsSpace.py
1,261
4.15625
4
#Checks if current index is a space, returns boolean def isThisASpace(str, index): if (str[index] == " "): return True else: return False #Checks if current index and next index are spaces, returns boolean #If at second last index, returns false def hasConsSpaces(str, index): if (index + 1 < len(str)): if (i...
true
3060d4c3f53a1a2a35e9c41f79cf6c5c8b08402f
JadedCoder712/Character-Distribution
/testing123.py
2,877
4.21875
4
""" distribution.py Author: Kyle Postans Credit: Kyle Postans, Mr. Dennison Assignment: Write and submit a Python program (distribution.py) that computes and displays the distribution of characters in a given sample of text. Output of your program should look like this: Please enter a string of text (the bigger th...
true
0cc275639d9847d73865c59c944c271b99605bb7
RohitPr/PythonProjects
/07. Banker Roulette/7.Banker_Roulette.py
502
4.34375
4
""" You are going to write a program which will select a random name from a list of names. The person selected will have to pay for everybody's food bill. Important: You are not allowed to use the choice() function. """ import random names_string = 'Angela, Ben, Jenny, Michael, Chloe' names = names_string.s...
true
b504f63cabe4ac1ad9f493410378566fda23f66b
CihanKeles/ACM114_Sec2
/Week6/nested_for_exp.py
614
4.1875
4
num_students = int(input('How many students do you have? ')) num_test_scores = int(input('How many test scores per student? ')) for student in range(num_students): total = 0.0 print('Student number', student + 1) print('-----------------') for test_num in range(num_test_scores): print('Te...
true
799fcd9e6c1b9ad2b4f8bd37dcb14989a808bb59
CihanKeles/ACM114_Sec2
/Week14/ACM114_Quiz_Week13_solution.py
864
4.125
4
import random # The main function. def main(): # Initialize an empty dictionary. number_dict = dict() # Repeat 100 times. for i in range(100): # Generate a random number between 1 and 9. random_number = random.randint(1, 9) # Establish or increment the number in ...
true
b0b91399237afcfe69a0b2c78428f139f658950f
tanngo1605/ProblemSet1
/problem5/solution.py
583
4.1875
4
#This is a really cool example of using closures to store data. # We must look at the signature type of cons to retrieve its first and last elements. cons takes in a and b, and returns a new anonymous function, which itself takes in f, and calls f with a and b. So the input to car and cdr is that anonymous function, ...
true
bf772445c70ed744a38609bb35aa045d5d5e29ec
sujanay/python-interview-questions
/tree.py
2,011
4.125
4
from __future__ import print_function # Binary Tree Node class TreeNode: def __init__(self, v, l=None, r=None): self.value = v self.left = l self.right = r # insert data to the tree def tree_insert(root, x): attr = 'left' if x < root.value else 'right' side = getattr(ro...
true
2e615d7d4fc73f1a5540ec12938b87b2f769b5b9
sujanay/python-interview-questions
/python/Algorithms/IsAnagram.py
515
4.4375
4
"""check if the two string are anagrams of each other""" """ Method-1: This method utilizes the fact that the anagram strings, when sorted, will be equal when testing using string equality operator """ def Is_Anagram(str1, str2): if len(str1) != len(str2): return False str1_sorte...
true
b3554ace99a9f2df79f386fafd19464937d7d4e6
tapczan666/sql
/homework_03.py
504
4.21875
4
# homework assignment No2 - continued import sqlite3 with sqlite3.connect("cars.db") as connection: c = connection.cursor() # find all car models in the inventory c.execute("SELECT * FROM inventory") inventory = c.fetchall() for car in inventory: print(car[0], car[1]) print(car[2]) # find all order date...
true
3468722bd044822a7f85464074bc0a6cdae623bb
prydej/WordCount
/Tracker.py
712
4.1875
4
""" Author: Julian Pryde Name: Essay Tracker Purpose: To count the number of words over two letters in a string Dat: 22MAR16 Input: A String Output: An integer containing the number of words over 2 letters in input """ import sys # Read String from file essay_handle = open(sys.argv[1]) essay = essay_handle.read() essa...
true
6199c577d8e6bef67694d770bded9339a9293ac4
AzwadRafique/Azwad
/Whacky sentences.py
602
4.3125
4
import random adj = input("Insert an adjective ") noun = input("Insert a noun ") verb = input("Insert a verb ending with 'ing' ") if verb.count('ing') == 0: verb = False while verb == False: verb = input("Please insert a verb ending with 'ing' ") sentences = [f"Our house has {adj} furniture and th...
true
d2b105a85201dc8c909dc6c53854c9dfbe04252e
AzwadRafique/Azwad
/Emailsv.py
1,536
4.21875
4
while 1 == 1: number_emails = { 'manha@gmail.com': '12345', 'jack@gmail.com': '124567' } login_or_sign_in = input('login or sign in: ') if login_or_sign_in.upper() == 'LOGIN': email = input('what is your email: ') if email in number_emails: password...
true
4d20a237a1b8b806e5eea64c7c635dff54b4e8c2
dimamik/AGH_Algorithms_and_data_structures
/PRACTISE/FOR EXAM/Wyklady/W2_QUEUE_STACK.py
2,898
4.15625
4
class Node(): def __init__(self,val=None,next=None): self.val=val self.next=next class stack_lists(): def __init__(self,size=0): first=Node() self.first=first self.size=size def pop(self): if self.size==0:return self.size-=1 tmp=self.first.nex...
true
4e9b9da28608efcd69df0f7706a82d16461dd7d2
JulieBoberg/Learn-Python-3-the-Hard-Way
/ex8.py
931
4.3125
4
# declare variable formatter and set it equal to a string with four sets of brackets. formatter = "{} {} {} {}" # prints the string in the variable formatter with the arguments in format in place of the brackets print(formatter.format(1, 2, 3, 4)) # prints the string in the variable formatter with the arguments in ...
true
5d32181fdadd2ab1ca9b672617a612e03216259e
JulieBoberg/Learn-Python-3-the-Hard-Way
/ex20.py
1,617
4.1875
4
from sys import argv script, input_file = argv # define function print_all that accepts parameter f(a file) def print_all(f): # read the file(f) and print it print(f.read()) # define function rewind which accepts parameter f def rewind(f): # find the (0) start of the file(f) f.seek(0) # de...
true
795ba841a724b31cc3f2963b9bd15b9a4f5346fd
natalialovkis/MyFirstPythonProject_Math
/math_project1.py
2,321
4.3125
4
# -*- coding: utf-8 -*- # Math learning program import random import math import turtle print("Hello Dear User!") name = input("Please, enter your name: ") print() print("Hello %s! Let`s learn the Math!" % name) print() num_of_ex = 0 while True: try: num_of_ex = int(input("How many exercises are you goi...
true
bb36efd1df3edf317fb9a8ba21309202e4582e33
TrilochanSati/exp
/daysInDob.py
832
4.3125
4
#Program to return days from birth of date. from datetime import date def daysInMonth(month:int,year:int)->int: months=[31,28,31,30,31,30,31,31,30,31,30,31] if(year%4==0 and month==2): return 29 else: month-=1 return months[month] def daysInDob(dobDay,dobMonth,dobYear)->int: ...
true
c829a7f379119a3e735a4a9b20de160faa4c3776
alzheimeer/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/3-say_my_name.py
543
4.40625
4
#!/usr/bin/python3 def say_my_name(first_name, last_name=""): """ Args: first_name (str): the first name last_name (str, optional): the last name Raises: TypeError: if the first_name or last_name are not strings """ if first_name is None or type(first_name) is not str: ...
true
d65d22f6a7e69c886203c873e3870359b74f2eed
chenjiahui1991/LeetCode
/P0225.py
1,053
4.1875
4
class MyStack: def __init__(self): """ Initialize your data structure here. """ self.line = [] def push(self, x): """ Push element x onto stack. :type x: int :rtype: void """ self.line.append(0) for i in range(len(self.li...
true
e51c78c3e21eb1c6a1624bd113fa1d94ab353293
Abishekthp/Simple_Assignments
/Assigmnet_1/11Factor_and_largest_factor_of_a_Number.py
247
4.25
4
#FIND THE FACTORS OF A NUMBER AND PRINT THE LARGEST FACTOR n=int(input('Enter the number:')) l=0 print('Factors are:') for i in range(1,n): if(n%i==0): print(i) if(i>l): l=i print('largest factor:',l)
true
9db36b88191861353321686f4209406196385ae1
HolyCoffee00/python_books
/python_books/py_crash/chaper_7/greeter.py
267
4.21875
4
name = input("Please tell me your name: ") print("Hello, " + name.title() + "!") prompt = "If you tell us who you are i will personalize the message: " prompt += "\nWhat is your firtst name: " name = input(prompt) print("Hello, " + name.title() + "!")
true
f58ad48501d9a0a3bf2d2fcb239a1e2ca6ad9870
neilkazimierzsheridan/sqlite3
/sq2.py
1,070
4.1875
4
#sqlite part 2 import sqlite3 conn = sqlite3.connect('customer2.db') c = conn.cursor() #create the cursor instance #c.execute(" SELECT rowid, * FROM customers") #rowid to get autogenerated primary key, this is element 0 now ## USING THE WHERE CLAUSE SEARCHING #c.execute(" SELECT rowid, * FROM c...
true
644335a0226c0b9a54aeb7b689e8452e0705466a
ddib-ccde/pyforneteng2020
/week1/exercise2.py
1,106
4.1875
4
# Print an empty line print(f"") # Ask user for an IP address and store as string ipaddr = input("Please enter an IP address: ") # Split the IP address into four parts and store in a list ipaddr_split = ipaddr.split(".") # Print an empty line print(f"") # Print the header with centered text (^) and width 15 print(f"{...
true
1d9174ea48f7685df67ab36c817ab72f1c1f0f7e
GAURAV-GAMBHIR/pythoncode
/3.A2.py
238
4.21875
4
a=(12,14,14,11,87,43,78) print("smallest element is",min(a)) print("largest element is",max(a)) finding product of all element in tuple result=1 for x in a: result=result*x print("product of all element in tuple is: ",result)
true
c6df819a465084cbaf0ad8de72c2e554a3898a37
Bishwajit05/DS-Algos-Python
/Recursion/CoinChangeProblemRecursion.py
1,649
4.25
4
# Implement coin change problem # Author: Pradeep K. Pant, ppant@cpan.org # Given a target amount n and a list (array) of distinct coin values, what's the fewest coins needed to make the # change amount. # 1+1+1+1+1+1+1+1+1+1 # 5 + 1+1+1+1+1 # 5+5 # 10 # With 1 coin being the minimum amount. # Solution strategy: # Thi...
true
cd49cf9074247537a3d29e2ba4d9ad0dea5634c2
Bishwajit05/DS-Algos-Python
/LinkedLists/DoublyLinkedListImple.py
733
4.34375
4
# Doubly Linked List class implementation # Author: Pradeep K. Pant, ppant@cpan.org # Implement basic skeleton for a doubly Linked List # Initialize linked list class class DoublyLinkedListNode(object): def __init__(self,value): self.value = value self.prev_node = None self.next_node = ...
true
a75396b7a5bbd99390cb90c02857f63c0fc99df4
Bishwajit05/DS-Algos-Python
/Sorting/InsertionSortImple.py
938
4.21875
4
# Insertion Sort Implementation # Author: Pradeep K. Pant, https://pradeeppant.com # Insertion sort always maintains a sorted sub list in the lower portion of the list # Each new item is then "inserted" back into the previous sublist such that the # sorted sub list is one item larger # Complexity O(n2) square # Re...
true
4ce6d7ff07ffd9a199d96f8c522a4c043c1e9043
erien/algorithms
/mergeSort/python/main.py
2,430
4.34375
4
"""Example implementation of the merge sort algorithm""" TO_SORT = "../../toSort.txt" SORTED = "../../sorted.txt" def read_table_from_file(path: str) -> list: """Reads table from a file and creates appropriate table... I mean list! Args: path: Path to the file Returns: Read table ...
true
d3d57dbcde978689fb4122a9266b9ea44a4674c7
mapatelian/holbertonschool-higher_level_programming
/0x0B-python-input_output/3-write_file.py
323
4.25
4
#!/usr/bin/python3 def write_file(filename="", text=""): """Writes a string to a text file Args: filename (str): name of the file text (str): string to be input """ with open(filename, 'w', encoding='utf-8') as filie: characters = filie.write(text) return characte...
true
ec92ebb83400693ea92230c152ec34b490eb1703
mapatelian/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/0-add_integer.py
475
4.28125
4
#!/usr/bin/python3 def add_integer(a, b=98): """Function that adds two integers. Args: a (int): first integer b (int): second integer Return: sum of the arguments """ if isinstance(a, int) is False and isinstance(a, float) is False: raise TypeError("a must be an i...
true
acf85c1dae18cff881547f333fd36114a70e6601
mapatelian/holbertonschool-higher_level_programming
/0x0B-python-input_output/0-read_file.py
284
4.125
4
#!/usr/bin/python3 def read_file(filename=""): """Reads a text file in UTF-8, prints to stdout Args: filename (str): name of the file """ with open(filename, 'r', encoding='utf-8') as filie: for linie in filie: print(linie, end='')
true
202bade662bbd859d43c58c1ed371c2c1a0eaf85
mengnan1994/Surrender-to-Reality
/py/0073_set_matrix_zeroes.py
1,615
4.1875
4
""" Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Example 1: Input: [ [1,1,1], [1,0,1], [1,1,1] ] Output: [ [1,0,1], [0,0,0], [1,0,1] ] Example 2: Input: [ [0,1,2,0], [3,4,5,2], [1,3,1,5] ] Output: [ [0,0,0,0], [0,4,5,0]...
true
dbb8650adc7e732575c33a032004fce683831afa
mengnan1994/Surrender-to-Reality
/py/0646_maximum_length_of_pair_chain.py
1,531
4.28125
4
""" You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. Now, we define a pair (c, d) can follow another pair (a, b) if and only if b < c. Chain of pairs can be formed in this fashion. Given a set of pairs, find the length longest chain which can be formed. You n...
true
6109e08e127c59aa0699d6b7d06e8f65fb1893d7
mengnan1994/Surrender-to-Reality
/py/0151_reverse_words_in_string.py
880
4.375
4
""" Given an input string, reverse the string word by word. Example: Input: "the sky is blue", Output: "blue is sky the". Note: A word is defined as a sequence of non-space characters. Input string may contain leading or trailing spaces. However, your reversed string should not contain leading or trailing spaces. You...
true
40042792515af1f36829f92aaa330ac6cb17555e
mengnan1994/Surrender-to-Reality
/py/0186_reverse_words_in_a_string_ii.py
1,254
4.25
4
""" Given an input string , reverse the string word by word. Example: Input: ["t","h","e"," ","s","k","y"," ","i","s"," ","b","l","u","e"] Output: ["b","l","u","e"," ","i","s"," ","s","k","y"," ","t","h","e"] Note: A word is defined as a sequence of non-space characters. The input string does not contain leading ...
true
2f49b448e55de701569925e9f71c956bd6e1dcdf
mengnan1994/Surrender-to-Reality
/py/0098_valid_binary_search_tree.py
1,395
4.1875
4
""" Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: 1. The left subtree of a node contains only nodes with keys less than the node's key. 2. The right subtree of a node contains only nodes with keys greater than the node's key. 3. Both the left and right ...
true
250013f9d8f1cb624ca63725487ec54ad7985317
WillHTam/reference
/bubble_sort.py
1,239
4.1875
4
# Bubble Sort # compare consecutive pairs of elements # swap elements in pairs such that smaller is first # at end of list, do so again. stop when no more swaps have been made def bubble_sort(L): """ inner for loop does the comparisons outer while loop is doing multiple passes until no more swaps """ ...
true
912f71e7813de37a3e70d91f41c6b8c57353d45b
Nihiru/Python
/Leetcode/maximum_subarray.py
522
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Apr 4 17:34:37 2020 @author: nick """ def maximum_subarray(array): # setting the maximum sub array similar to max_sum = array[0] current_sum = max_sum for ele in array[1:]: current_sum = max(ele + current_sum, ele) # adding el...
true
00c305f72eb4ca256dd67b8596097b834fb7c910
sandesh-chhetry/basic-python-
/Python Assignment 4/session3_functional.py
2,584
4.25
4
""" ---------------------------------------------------------------------------------------------------------------------------------------------------- """ """ 1. Write a program to display all prime numbers from 1 to """ ##function to find prime number in a range def findPrimeNumber(initial,final): for i i...
true
c29246c37d513184514a1319aec0688b4e3db1f2
sandesh-chhetry/basic-python-
/Python Assignment 1/listGetExample.py
421
4.15625
4
##Exercise 4. Consider a list of any arbitrary elements. Your code should print the length of the list ##and first and fourth element of the list. ##list which contain some element elements = ["1st position", "2nd position", "3rd position", "4th position", "5th position", "6th position"] print("Length of the give...
true
181b5324ba8239fc341d0304edc0007e2e73fde9
wiselyc/python-hw
/swap.py
352
4.34375
4
def swap_last_item(input_list): """takes in a list and returns a new list that swapped the first and the last element""" input_list[0], input_list[-1] = input_list[-1], input_list[0] # gets the first and last element and makes the first element = the last and the last element = the first return input_l...
true
62482eb26b465185c7301587a6667e2b8fa18603
phttrang/MITx-6.00.1x
/Problem_Sets_3/Problem_2.py
1,834
4.25
4
# Problem 2 - Printing Out the User's Guess # (10/10 points) # Next, implement the function getGuessedWord that takes in two parameters - a string, secretWord, and a list of letters, # lettersGuessed. This function returns a string that is comprised of letters and underscores, based on what letters in # lettersGuessed...
true
2945e387eb1a73bd8610e69bf79b7d0ff0b9462b
qrzhang/Udacity_Data_Structure_Algorithms
/3.Search_Sorting/recursion.py
1,221
4.1875
4
"""Implement a function recursively to get the desired Fibonacci sequence value. Your code should have the same input/output as the iterative code in the instructions.""" def get_fib_seq(position): first = 0 second = 1 third = first + second seq = [first, second, third] if position < 1: r...
true
aa00145cfff0c3d87d1ebc57537143777a49c728
opeoje91/Election_Analysis
/CLASS/PyPoll_Console.py
1,634
4.4375
4
#The data we need to retrieve # Assign a variable for the file to load and the path. #file_to_load = 'Resources/election_results.csv' # Open the election results and read the file #with open(file_to_load) as election_data: # To do: perform analysis. #print(election_data) import csv import os # Assign a varia...
true
418c14a4ae1e95d39e400b389bf6d16c6575559f
ar012/python
/learning/sets.py
948
4.1875
4
num_set = {1, 2, 3, 4, 5} word_set = {"mango", "banana", "orange"} subjects = set(["math", "bangla", "english"]) print(1 in num_set) print("mango" not in word_set) print(subjects) print(set()) # duplicate elements nums = {1, 2, 3, 5, 1, 2, 6, 3, 10} print(nums) # To add a element to a set nums.add(9) print(nums) ...
true
84d1c158dd321f99c38ce95c3825a457b21ca9e5
Charles-IV/python-scripts
/recursion/factorial.py
536
4.375
4
no = int(input("Enter number to work out factorial of: ")) def recursive_factorial(n, fact=1): # fact = 1 # number to add to fact *= n # does factorial calculation n -= 1 # prepare for next recursion #print("fact: {}, n = {}".format(fact, n)) - test for debugging if n > 1: # keep repeating unt...
true
d142a70a335d662c1dcc443603f17e2cc3e4996a
MorgFost96/School-Projects
/PythonProgramming/5-16/objects.py
2,685
4.34375
4
#Morgan Foster #1021803 # Intro to Object Oriented Programming ( OOP ) # - OOP enables you to develop large scale software and GUI effectively # - A class defines the properties and behaviors for objects # - Objects are created from classes # Imports import math # --- # OOP # --- # - Use of objects to create programs...
true
97ddb326c2af50e3f61ed34fbe097d61eed12ebd
h4l0anne/PongGame
/Pong.py
2,421
4.28125
4
# Simple Pong Game in Python import turtle wn = turtle.Screen() wn.title("Pong Game") wn.bgcolor("green") wn.setup(width=800, height=600) wn.tracer(0) # Paddle A paddle_left = turtle.Turtle() paddle_left.speed(0) # 0 for maximum possible speed paddle_left.shape("square") paddle_left.color("blue") paddle_left.shap...
true
2aea01ba888855ee4d4d7e024bad881d26d5e9fa
smartpramod/97
/PRo 97.py
449
4.21875
4
import random print("NUMBER GUESSING GAME") number=random.randint(1,9) chances=0 print("GUESS A NUMBER BETWEEN 1 AND 9") while(chances<5): Guess=int(input("Enter your number")) if Guess==number: print("Congrulation, YOU WON") break elif Guess<number: print("Your guess was...
true
bc3e55ea22cd1e7e3aa39a9b020d128df16dfa92
aalhsn/python
/conditions_task.py
1,279
4.3125
4
""" Output message, so the user know what is the code about and some instructions Condition_Task author: Abdullah Alhasan """ print(""" Welcome to Abdullah's Calculator! Please choose vaild numbers and an operator to be calculated... Calculation example: first number [operation] second number = results """...
true
e321759c85fa184f7fdb08811827a36faadc8317
mukesh-jogi/python_repo
/Sem-5/Collections/Set/set1.py
1,960
4.375
4
# Declaring Set set1 = {"Apple","Banana","Cherry","Mango","Pinapple"} print(set1) # Iterate through Set set1 = {"Apple","Banana","Cherry","Mango","Pinapple"} for item in set1: print(item) # Add item to set set1 = {"Apple","Banana","Cherry","Mango","Pinapple"} set1.add("NewFruit") for item in set1: print(item...
true
a6885c761cbf2d54c530a8a114c7782dabb2631b
Karolina-Wardyla/Practice-Python
/list_less_than_ten/task3.py
400
4.15625
4
# Take a random list, ask the user for a number and return a list that contains only elements from the original list that are smaller than the number given by the user. random_list = [1, 2, 4, 7, 8, 9, 15, 24, 31] filtered_numbers = [] chosen_number = int(input("Please enter a number: ")) for x in random_list: if...
true
3b6824ea991b59ccd05b3d42f872c5e8d1313d4a
Karolina-Wardyla/Practice-Python
/divisors/divisors.py
522
4.34375
4
# Create a program that asks the user for a number and then prints out a list of all the divisors of that number. # Divisor is a number that divides evenly into another number. # (For example, 13 is a divisor of 26 because 26 / 13 has no remainder.) chosen_number = int(input("Please enter a number: ")) possible_diviso...
true
0a43c57a016eb641a07c8f0e2ed16080da2866b2
Aaron-Nazareth/Code-of-the-Future-NumPy-beginner-series
/6 - Basic operations on arrays.py
707
4.5
4
# Tutorial 6 # Importing relevant modules import numpy as np # We can create an array between numbers like we can do with lists and the 'range' command. # When using arrays, we use the 'arange' command. a = np.arange(0, 5) # Creates an array from 0 up to 5 - [0 1 2 3 4] print(a) # Basic math operations on arrays b ...
true
9519d25c32ac136ff355e521e4bf36dc80eee71b
meghasundriyal/MCS311_Text_Analytics
/stemming.py
609
4.3125
4
#stemming is the morphological variants of same root word from nltk.tokenize import word_tokenize from nltk.stem import PorterStemmer ps = PorterStemmer() #words to be stemmed (list) stem_words = ["eat", "eats", "eating", "eaten", "eater", "received","receiving"] #find stem word for each of the word in the list for ...
true
9937cae75d06147093025d2482225550aace9f9a
Reena-Kumari20/code_war
/Reversed_Words.py
213
4.1875
4
# Complete the solution so that it reverses all of the words within the string passed def reverse_words(s): a=(' '.join(s.split(" ")[-1::-1])) return a string=["hell0 world!"] print(reverse_words(string))
true
8b99f60f51da55d805fcfdd13bf0e34bc71b8386
Reena-Kumari20/code_war
/sum_of_string.py
586
4.1875
4
'''Create a function that takes 2 positive integers in form of a string as an input, and outputs the sum (also as a string): Example: (Input1, Input2 -->Output) "4", "5" --> "9" "34", "5" --> "39" Notes: If either input is an empty string, consider it as zero.''' def sum_str(a, b): if a=="" and b=="": ...
true
301a64567164a85abdef442a8672c985776a87e0
jreichardtaurora/hmwk_2_test
/HW2_Prob_1_JaredReichardt.py
1,398
4.3125
4
''' Created on Sep 13, 2019 @author: jared r CSC1700 section AM The purpose of this problem was to write a calculator that calculates the user's total shipping cost. It handles negative inputs properly, and prompts the user for their package weight, and what type of shipping they used. ''' def main(): print("Sta...
true
88b954e1465b806c15318999a4715c0e6c7d7cc4
renatocrobledo/probable-octo-spork
/codingame/src/norm_calculation.py
1,538
4.65625
5
''' You are given an integer matrix of size N * M (a matrix is a 2D array of numbers). A norm is a positive value meant to quantify the "size/length" of an element. In our case we want to compute the norm of a matrix. There exist several norms, used for different scenarios. Some of the most common matrix norms are : ...
true
88963ec18f118fca69d3e26b3b57db8c5a2736cc
kundan7kumar/Algorithm
/Hashing/basic.py
476
4.1875
4
# Python tuple can be the key but python list cannot a ={1:"USA",2:"UK",3:"INDIA"} print(a) print(a[1]) print(a[2]) print(a[3]) #print(a[4]) # key Error # The functionality of both dictionaries and defualtdict are almost same except for the fact that defualtdict never raises a KeyError. It provides a default value fo...
true
43a8fae76b90437274501bafd949b39995401233
tongyaojun/corepython-tongyao
/chapter02/Test15.py
430
4.125
4
#!/usr/bin/python #sort input numbers userInput1 = int(input('Please input a number:')) userInput2 = int(input('Please input a number:')) userInput3 = int(input('Please input a number:')) def getBiggerNum(num1, num2): if num1 > num2: return num1 else : return num2 biggerNum = getBiggerNum(user...
true
c328f75f3d0278660d4d544563b5d953af5b7041
jjti/euler
/Done/81.py
2,016
4.21875
4
def path_sum_two_ways(test_matrix=None): """ read in the input file, and find the sum of the minimum path from the top left position to the top right position Notes: 1. Looks like a dynamic programming problem. Ie, start bottom right and find the sum of the minimum path from the current...
true
b3cca4d969aa2be4ad517aad8d903ae2826da02d
jjti/euler
/Done/65.py
2,141
4.1875
4
import utils """ The square root of 2 can be written as an infinite continued fraction. The infinite continued fraction can be written, 2**0.5 = [1;(2)], (2) indicates that 2 repeats ad infinitum. In a similar way, 23**0.5 = [4;(1,3,1,8)]. It turns out that the sequence of partial values of continued fractions for squ...
true
d6a3a1abfac543f817434f9b903515db63993c02
jjti/euler
/Done/57.py
1,511
4.125
4
import utils """ It is possible to show that the square root of two can be expressed as an infinite continued fraction. 2 ** 1/2 = 1 + 1/(2 + 1/(2 + 1/(2 + ... ))) = 1.414213... By expanding this for the first four iterations, we get: 1 + 1/2 = 3/2 = 1.5 1 + 1/(2 + 1/2) = 7/5 = 1.4 1 + 1/(2 + 1/(2 + 1/2)) = 17/12 = ...
true
4c28efd8124035ef404c5cdabf8279a25ffdead2
nasingfaund/Yeppp-Mirror
/codegen/common/Argument.py
1,926
4.4375
4
class Argument: """ Represents an argument to a function. Used to generate declarations and default implementations """ def __init__(self, arg_type, name, is_pointer, is_const): self.arg_type = arg_type self.name = name self.is_pointer = is_pointer self.is_const = is...
true
7432e574d515aadac24d93b6aa1568d3add65fc6
johnpospisil/LearningPython
/try_except.py
873
4.21875
4
# A Try-Except block can help prevent crashes by # catching errors/exceptions # types of exceptions: https://docs.python.org/3/library/exceptions.html try: num = int(input("Enter an integer: ")) print(num) except ValueError as err: print("Error: " + str(err)) else: # runs if there are no errors print('...
true
d78585044147f77090dc54494e1a3c24b36c5b37
johnpospisil/LearningPython
/while_loops.py
592
4.21875
4
# Use While Loops when you want to repeat an action until a certain condition is met i = 1 while i <= 10: print(i, end=' ') i += 1 print("\nDone with loop") # Guessing Game secret_word = "forge" guess = "" guess_count = 0 guess_limit = 3 out_of_guesses = False print("\nGUESSING GAME") while guess != secret_...
true
9fc9df1a3b6028dffaae5efdfacc2b5577929ce2
lihaoyang411/My-projects
/Encryption-Bros-master/Main.py
1,947
4.15625
4
import sys typeChosen = 0 def choose(choice): while True: if choice.find(".") >= 0 or choice.find("-") >= 0: choice = input("You didn't type in a positive integer. Please try again: ") else: try: choice = int(choice) dummyNum = 2/choice ...
true
23334bd9745a107a337460c8cd4a2b8dcfa6a52d
Shiliangwu/python_work
/hello_world.py
1,037
4.21875
4
# this is comment text # string operation examples message="hello python world" print(message) message="hello python crash course world!" print(message) message='this is a string' message2="this is also a string" print(message) print(message2) longString='I told my friend, "Python is my favorite language!"' pri...
true
bde6d52ed8e8578510e2e3ed47ca03fd13172c33
anindo78/Udacity_Python
/Lesson 3 Q2.py
698
4.15625
4
# Define a procedure, greatest, # that takes as input a list # of positive numbers, and # returns the greatest number # in that list. If the input # list is empty, the output # should be 0. def greatest(list_of_numbers): if len(list_of_numbers) == 0: return 0 else: maximum = list_of_numbers[0]...
true
0fc6e1ae13fecbc47013ddecc2b29ef71f13b8c6
hamsemare/sqlpractice
/291projectReview.py
2,985
4.28125
4
import sqlite3 connection = None cursor = None name= None # Connect to the database def connect(path): global connection, cursor connection=sqlite3.connect(path) cursor=connection.cursor() def quit(): exit(0) def findName(): global name studentName= input("Enter Student Name: ") if(studentName=="q" or stud...
true
3f30bad898e7fbaa90495f3f609f6f6c3d43ba78
HunterOreair/Portflio
/RollDie.py
942
4.1875
4
#A simple python program that rolls die and returns the number that has been rolled. Made by Hunter Oreair. from random import randint # imports randint. duh. min = 1 #sets the minimum value on the dice that you can roll max = 6 #sets the maximum value def die(): # Creates a method called die rollDie = r...
true
464d00436d9c90def53af9f7b1717e16f1031b23
JerryCodes-dev/hacktoberfest
/1st Assignment.py
884
4.15625
4
# NAME : YUSUF JERRY MUSAGA # MATRIC NUMBER : BHU/19/04/05/0056 # program to find the sum of numbers between 1-100 in step 2 for a in range(1,100,2): print(a) num = 1 while num < 100: print(num) num += 2 # program to find all even numbers between 1-100 for b in range(2,100,2): print (b) numb = 2...
true
5cc890b202f98bb88b5d614c43745cf2b427b0e4
CoffeePlatypus/Python
/Class/class09/exercise1.py
893
4.6875
5
# # Code example demonstrating list comprehensions # # author: David Mathias # from os import listdir from random import randint from math import sqrt print # create a list of temps in deg F from list of temps in deg C # first we create a list of temps in deg C print('Create a list of deg F from a list of deg C tem...
true
7185ccd8e4a6913a24efb58ee17692112564b4d7
CoffeePlatypus/Python
/Class/class03/variables.py
804
4.125
4
# # Various examples related to the use of variables. # # author: David Mathias # x = 20 print type(x) print y = 20.0 print type(y) print s = "a" print type(s) print c = 'a' print type(c) print b = True print type(b) print print('8/11 = {}'.format(8/11)) print print('8.0/11 = {}'.format(8.0/11)) print print('...
true
3e8ea3989cf216ab53e9a493b07ea974dbe17091
rp927/Portfolio
/Python Scripts/string_finder.py
585
4.125
4
''' In this challenge, the user enters a string and a substring. You have to print the number of times that the substring occurs in the given string. String traversal will take place from left to right, not from right to left. ''' def count_substring(string, sub_string): ls = [] o = 0 count = 0 l = le...
true
0fa7471aa14fec407c4b491a338ffaf70f530183
lherrada/LeetCode
/stacks/problem1.py
741
4.28125
4
# Check for balanced parentheses in Python # Given an expression string, write a python program to find whether a given string has balanced parentheses or not. # # Examples: # # Input : {[]{()}} # Output : Balanced # # Input : [{}{}(] # Output : Unbalanced from stack import Stack H = {'{': '}', '[': ']', '(': ')'...
true
4c4cbbf75cd598226f55a08b967597dde477e7a3
odemeniuk/twitch-challenges
/interview/test_palindrome.py
336
4.40625
4
# write a function that tells us if a string is a palindrome def is_palindrome(string): """ Compare original string with its reverse.""" # [::-1] reverses a string reverse = string[::-1] return string == reverse def test_is_palindrome(): assert is_palindrome('banana') is False assert is_pal...
true
d8f9c69874ca0ab5da4dac704f88fedb77b1b30d
dragonRath/PythonBasics
/stringformatting.py
2,162
4.53125
5
#The following will illustrate the basic string formatting techniques used in python age = 24 #print("My age is " + str(age) + " years\n") print("My age is {0} years".format(age)) #{} Replacement brackets print("There are {0} days in {1}, {2}, {3}, {4}, {5}, {6} and {7}".format(31, "January", "March", "May", "July", ...
true
c603d6ab0955cfc0100daa3a9c4c37cceb58876c
loweryk/CTI110
/p3Lab2a_lowerykasey.py
1,026
4.46875
4
#Using Turtle in Python #CTI-110 P3LAB2a_LoweryKasey import turtle #Allows us to use turtles wn = turtle.Screen() #Creates a playground for turtles alex = turtle.Turtle() #Creatles a turtle, assign to alex #commands from here to the last line can be replaced alex.hideturtle() #Hides the turtle i...
true
f643f39546ae35916bf1147df22e1bdfddfd4972
sheriaravind/Python-ICP4
/Source/Code/Num-Py -CP4.py
359
4.28125
4
import numpy as np no=np.random.randint(0,1000,(10,10)) # Creating the array of 10*10 size with random number using random.randint method print(no) min,max = no.min(axis=1),no.max(axis=1) # Finding the minimum and maximum in each row using min and max methods print("Minimum elements of 10 size Array is",min) print("Max...
true
3fb3edce524850dfdc618bc407b47c3f57d89978
TENorbert/Python_Learning
/learn_python.py
637
4.125
4
#!/usr/bin/python """ python """ ''' first_name = input("Enter a ur first name: ") last_name = input("Enter your last name: ") initial = input("Enter your initial: ") person = initial + " " + first_name + " " + last_name print("Ur name is %s" %person) print("Ur name is %s%s%s" %initial %first_name %last_name) ...
true
25b1a46a621054c7d04da0e02ce0acc6181c46eb
keithrpotempa/python-book1
/sets/cars.py
1,539
4.21875
4
# Create an empty set named showroom. showroom = set() # Add four of your favorite car model names to the set. showroom.update(["Car1", "Car2", "Car3", "Car4"]) # Print the length of your set. print("Showroom length", len(showroom)) # Pick one of the items in your show room and add it to the set again. showroom.upda...
true
d4a524ea19b19afd811e32a9f0c58916b4cabb8f
BrutalCoding/INFDEV01-1_0912652
/DEV_01_1___Assignment_4___Exercise_1.b/DEV_01_1___Assignment_4___Exercise_1.b/DEV_01_1___Assignment_4___Exercise_1.b.py
227
4.25
4
celcius = -273.15 #This is the default value to trigger the while loop here below while celcius <= -273.15: celcius = input("Enter Celcius to convert it to Kelvin:\n") print "Celcius:", celcius, "Kelvin = ", celcius+273.15
true
b0985c06edbb8bc0ff8d86e3f7b5772d204954a3
olivepeace/ASSIGNMENT-TO-DETERMINE-DAYOF-BIRTH
/ASSIGNMENT TO DETERMINE DAY OF BIRTH.py
1,960
4.375
4
""" NAME: NABUUMA OLIVIA PEACE COURSE:BSC BIOMEDICAL ENGINEERING REG NO: 16/U/8238/PS """ import calendar print("This Program is intended to determine the exact day of the week you were born") print(".....................................................") day = month = year = None #Next code ensures that o...
true
afad2695aa4dff1ce100cfaf65cbdcca9b6c37d4
RaazeshP96/Python_assignment1
/function12.py
305
4.3125
4
''' Write a Python program to create a function that takes one argument, and that argument will be multiplied with an unknown given number. ''' def multi(n): a = int(input("Enter the number:")) return f"The required result is { n * a }" n = int(input("Enter the integer:")) print(multi(n))
true
8c225b5b0ac4648cfa8e555b9aaf74312d89484f
RaazeshP96/Python_assignment1
/function16.py
237
4.25
4
''' Write a Python program to square and cube every number in a given list of integers using Lambda. ''' sq=lambda x:x*x cub=lambda x:x*x*x n=int(input("Enter the integer:")) print(f"Square -> {sq(n)}") print(f"Cube -> {cub(n)}")
true
d7a0eaf524bd36baf8ef17e6aab4147e32e61e9b
DeepuDevadas97/-t2021-2-1
/Problem-1.py
1,046
4.21875
4
class Calculator(): def __init__(self,a,b): self.a=a self.b=b def addition(self): return self.a+self.b def subtraction(self): return self.a-self.b def multiplication(self): return self.a*self.b def division(self): ...
true
22b5e71d891a902473213c464125bea0ca1526c6
kelpasa/Code_Wars_Python
/5 кю/RGB To Hex Conversion.py
971
4.21875
4
''' The rgb function is incomplete. Complete it so that passing in RGB decimal values will result in a hexadecimal representation being returned. Valid decimal values for RGB are 0 - 255. Any values that fall out of that range must be rounded to the closest valid value. Note: Your answer should always be 6 characters ...
true
efe2f3dd96140dfb7ca59d5a5571e6c031491273
kelpasa/Code_Wars_Python
/5 кю/Scramblies.py
430
4.15625
4
''' Complete the function scramble(str1, str2) that returns true if a portion of str1 characters can be rearranged to match str2, otherwise returns false. Notes: Only lower case letters will be used (a-z). No punctuation or digits will be included. Performance needs to be considered ''' def scramble(s1,s2): fo...
true
4d26fc6d60a59ad20aec5456cf32bc6588018139
kelpasa/Code_Wars_Python
/6 кю/String transformer.py
489
4.40625
4
''' Given a string, return a new string that has transformed based on the input: Change case of every character, ie. lower case to upper case, upper case to lower case. Reverse the order of words from the input. Note: You will have to handle multiple spaces, and leading/trailing spaces. For example: "Example Input" ...
true
a62713c957216d00edf4dbb925e5f561f94c4cf2
kelpasa/Code_Wars_Python
/6 кю/Sort sentence pseudo-alphabetically.py
1,238
4.3125
4
''' Given a standard english sentence passed in as a string, write a method that will return a sentence made up of the same words, but sorted by their first letter. However, the method of sorting has a twist to it: All words that begin with a lower case letter should be at the beginning of the sorted sentence, and sor...
true
4804ed7aa18e361bf99084a6d1f2390b18d8bb8a
kelpasa/Code_Wars_Python
/5 кю/Emirps.py
1,045
4.3125
4
''' If you reverse the word "emirp" you will have the word "prime". That idea is related with the purpose of this kata: we should select all the primes that when reversed are a different prime (so palindromic primes should be discarded). For example: 13, 17 are prime numbers and the reversed respectively are 31, 71 wh...
true
3f821ad7f3538a1066e56a6c8737932fcbda94b0
kelpasa/Code_Wars_Python
/6 кю/Parity bit - Error detecting code.py
1,118
4.21875
4
''' In telecomunications we use information coding to detect and prevent errors while sending data. A parity bit is a bit added to a string of binary code that indicates whether the number of 1-bits in the string is even or odd. Parity bits are used as the simplest form of error detecting code, and can detect a 1 bit ...
true
ab10772302efd8e44c5b0d5a157587cbeea7ce62
kelpasa/Code_Wars_Python
/6 кю/Multiplication table.py
424
4.15625
4
''' our task, is to create NxN multiplication table, of size provided in parameter. for example, when given size is 3: 1 2 3 2 4 6 3 6 9 for given example, the return value should be: [[1,2,3],[2,4,6],[3,6,9]] ''' def multiplicationTable(n): table = [] for num in range(1, n+ 1): row = [] for c...
true
9180bd22fb2a47c8276454dda65caa58fd5116ce
kelpasa/Code_Wars_Python
/6 кю/Matrix Trace.py
1,236
4.34375
4
''' Calculate the trace of a square matrix. A square matrix has n rows and n columns, where n is any integer > 0. The entries of the matrix can contain any number of integers. The function should return the calculated trace of the matrix, or nil/None if the array is empty or not square; you can otherwise assume the inp...
true