blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
0d533fc1830ec11bab5fef1a327a42f1c5a7574b
morningred88/data-structure-algorithms-in-python
/Array/string-slicing.py
957
4.25
4
def sliceString(s): # Specify the start index and the end index, separated by a colon, to return a part of the string. The end index is not included # llo, get the characters from position 2 to position 5 (not included) s = s[2:5] # Slice from the start # hello world, whole string s = s[:] # h...
true
70478953dc18bd961f381cea434778136ad37f03
morningred88/data-structure-algorithms-in-python
/Stack-Queue/stack.py
1,301
4.125
4
# LIFO:last item we insert is the first item we take out class Stack(): # Use one dimensional array as underlying data structure def __init__(self): self.stack = [] # Insert item into the stack //O(1) def push(self, data): self.stack.append(data) # remove and return the last item we have ins...
true
a2c12bafe8d659445718e4ad683d41205e2b07e7
rahulmajjage/Learning
/exercisescripts/list_methods.py
1,353
4.375
4
#High Scores program #Demonstrate List methods #Create an empty list scores = [] choice = None #Print the options while choice !="0": print (\ """ \t High Scores Keeper 0: Exit 1: Show score 2: Add a score 3: Delete a score 4: Sort scores """) choice= input ("Choice: ") # Exit ...
true
a1d8aa288a9d40f7068da878e79bc3a8e476df31
rahulmajjage/Learning
/exercisescripts/for loop demo.py
216
4.5
4
#loopy string #Demonstrates the for loop with a string. word= input ("Enter the word: ") print ("\n Here is each letter in your word:") for letter in word: print (letter) input ("Press enter to exit")
true
0d35bfe204dd9c003ced7b934546c60829c43e2e
rupeshjaiswar/ekLakshya-Assignments
/Python Codes/Day 2 Assignments/23_code.py
345
4.3125
4
str = input("Enter a string:") print("The String is:", str) str1 = str[0:3] print("The first three characters in the string str:", str1) for i in str1: print(f"The ASCII value of the character {i} in str1 is:", ord(i)) print("The position of str1 in str is:", str.find(str1)) print("Count of str1 in s...
true
7e6ee9617f1a07ea20de8eb3c7c3e3dfcf08bdc4
presian/HackBulgaria
/Algo1/Week_4/Monday/my_queue.py
1,533
4.15625
4
from vector import Vector class Queue: def __init__(self): self.__queue = Vector() # Adds value to the end of the Queue. # Complexity: O(1) def push(self, value): self.__queue.add(value) # Returns value from the front of the Queue and removes it. # Complexity: O(1) def p...
true
2939d0c2b6cbf0f63e1f9a9c3ade0f9a699f661b
willzh0u/Python
/ex34.py
2,085
4.625
5
# Accessing Elements of Lists # REMEMBER: Python start its lists at 0 rather than 1. # ordinal numbers, because they indicate an ordering of things. Ordial numbers tell the order of things in a set, first, second, third. # cardinal numbre means you can pick at random, so there needs to be a 0 element. Cardial numbers...
true
aaa1b169899f0e91693b98f042442080f13d0c13
YanteLB/pracs
/week1/python/weeek.py
440
4.34375
4
#getting current day currentDay = input("Enter the number of our current day: ") currentDay = int(currentDay) #getting the length of the holiday holidayLength = input("How long is your holiday: ") holidayLength = int(holidayLength) returnDay = currentDay + holidayLength if returnDay < 7: print("You will return ...
true
cae2f7f0945939ecdf220fd7cb06a402e7638348
moakes010/ThinkPython
/Chapter17/Chapter17_Exercise3.py
321
4.25
4
''' Exercise 3 Write a str method for the Point class. Create a Point object and print it. ''' class Point(object): def __init__(self, x, y): self.x = x self.y = y def __str__(self): return "Point (x,y) at (%.2d,%.2d)" % (self.x, self.y) p = Point(10, 11) print(p...
true
3114191f140ad280a6a71b3855580606f036cc93
moakes010/ThinkPython
/Chapter11/Chapter11_Exercise10.py
1,084
4.21875
4
''' Exercise 10 Two words are “rotate pairs” if you can rotate one of them and get the other (see rotate_word in Exercise 12). ''' import os def rotate_pairs(word, word_dict): for i in range(1, 14): r = rotate_word(word, i) if r in word_dict: print(word, i, r) def rotate_letter(lett...
true
58b91fc4ac376d1f0b197c704cad38ba602b4200
bmatis/atbswp
/chapter12/multiplicationTable.py
1,259
4.28125
4
#!/usr/bin/env python3 # multiplicationTable.py - takes a number (N) from command line and creates # an N x N mulitplication table in an Excel spreadsheet # example: multiplicationTable.py 6 to create a 6 x 6 multiplication table import sys, openpyxl from openpyxl.styles import Font from openpyxl.utils import get_colu...
true
7183239071eca81ac679704880918eb4d22b86da
SimantaKarki/Python
/class4.py
983
4.125
4
#Basic2 is_old = True is_licenced = True #if is_old: # print("You are old enough to drive!") # elif is_licenced: # print("You can Drive on Highway") # else: # print("Your age is not eligible to drive!") # print("end if") if (is_licenced and is_old): print("You are in age and you can drive") ...
true
4ed2886bafb58f67dcb6fa4b0e0160357b4ecd19
alvas-education-foundation/ISE_3rd_Year_Coding_challenge
/4AL17IS012_Danush_Kumar/SharanSir_codingchallenge/SharanSir_codingchallenge2/prg1.py
686
4.5625
5
''' We are given 3 strings: str1, str2, and str3. Str3 is said to be a shuffle of str1 and str2 if it can be formed by interleaving the characters of str1 and str2 in a way that maintains the left to right ordering of the characters from each string. For example, given str1="abc" and str2="def", str3="dabecf" is a v...
true
4c18f4a6bfefdb2c2de251e5a11cc4c215abb468
alvas-education-foundation/ISE_3rd_Year_Coding_challenge
/4AL17IS001_Ahimsa_Jain/SK-Challenge-1/s2.py
1,182
4.15625
4
2) Given an array,A, of N integers and an array, W, representing the respective weights of A's elements, calculate and print the weighted mean of A's elements. Your answer should be rounded to a scale of decimal place Input format: 1. The first line contains an integer, N, denoting the number of elements in arrays ...
true
c2920b0657f7a2d5bec5230c29e894dff78571f5
alvas-education-foundation/ISE_3rd_Year_Coding_challenge
/4AL17IS006_VISHAK_AMIN/22May20/fourth.py
1,126
4.15625
4
# Given the names and grades for each student in a Physics class of students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade. # Note: If there are multiple students with the same grade, order their names alphabetically and print each name on a new line. # Input For...
true
54672ba72d2d620401fe22b3eea9873b352c6b86
suvo-oko/intermediate-python-course
/dice_roller.py
956
4.25
4
import random def main(): dice_rolls = int(input('How many dice would you like to roll? ')) dice_size = int(input('How many sides are the dice? ')) dice_sum = 0 for i in range(0, dice_rolls): # for every Index in this range, do this: roll = random.randint(1,dice_size) # the random...
true
368cf1d3c85fe5a6cdad6b15036627fb17f3bd6e
Faiax/Python_Basics
/dictionaries.py
954
4.125
4
fruit = {"orange":"a sweet orange citrus fruit", "apple":"good for making cider", "lemon":"a sour yellow citrus fruit", "grape":"a small sweet fruit growing in brunches", "lime":"a sour green citrus fruit", "banana":"long yellow tasty things"} print(fruit) #ordered_keys = li...
true
27b480f773db0209aca8871b367e96c1c2a8fefe
S-web7272/tanu_sri_pro
/strings/creating_string.py
844
4.15625
4
# for creating a single line string value name = "Abraham " bookname = "An Ancient Journey" # for creating multi line string value author_info = '''Most of us wonder if there is a God and if He really is the God of the Bible. In the Bible God says ‘I will make your name great’ and today the name of Abraham/Abr...
true
c6e39018e2f32eda3bc2df390274b9473b4e9891
daviddumas/mcs275spring2021
/samplecode/debugging/puzzle2/biggest_number.py
2,117
4.125
4
"""Debugging puzzle: Script to find largest integer in a text file (allowing Python int literal syntax for hexadecimal, binary, etc.)""" # MCS 275 Spring 2021 Lecture 11 # This script is written in a way that avoids some constructions # that would make the code more concise (e.g. list comprehensions). # This gives mor...
true
8b14536bc036c4716ac3a321b47bc018f83cdb1f
daviddumas/mcs275spring2021
/projects/lookup.py
2,787
4.125
4
# MCS 275 Spring 2021 Project 3 Solution # David Dumas # Project description: # https://www.dumas.io/teaching/2021/spring/mcs275/nbview/projects/project3.html """ Reads a list of chromaticities and names from the CSV file (name given as first command line argument) and provides a lookup service using keyboard input. ...
true
a30fa837584e9b52c04c8d75a2489790900f331d
wfgiles/P3FE
/Week 7/Exercise 5..10.1.py
1,425
4.21875
4
##number = raw_input('Enter number: ') ##num = int(number) ##print num ## ##Write a program which repeatedly reads numbers until the ##user enters "done". Once done is entered, print out the ##total, count and average of the numbers. If the user enters ##anything other than a number, detect the mistake usinf a try ##an...
true
02dcca5997e80c2d3f6b49f96a3a95b836e5d01e
kermitt/challenges
/py/bouncing_ball.py
1,820
4.34375
4
""" https://www.codewars.com/kata/5544c7a5cb454edb3c000047/train/python A child is playing with a ball on the nth floor of a tall building. The height of this floor, h, is known. He drops the ball out of the window. The ball bounces (for example), to two-thirds of its height (a bounce of 0.66). His mother looks out ...
true
ab96c922d0b0fc454e81188cdd9195956402e578
truongductri01/Hackerrank_problems_solutions
/Problem_Solving/Data_Structure/Linked_list/Reverse_linked_list.py
1,519
4.21875
4
# Link: https://www.hackerrank.com/challenges/reverse-a-linked-list/problem class SinglyLinkedListNode: def __init__(self, node_data): self.data = node_data self.next = None class SinglyLinkedList: def __init__(self): self.head = None self.tail = None def insert_node(self,...
true
ca4f516b17d4ba871e9cb61e65e8d392621c5a42
truongductri01/Hackerrank_problems_solutions
/Problem_Solving/Medium/Almost_Sorted/Almost_Sorted.py
2,418
4.3125
4
# link: https://www.hackerrank.com/challenges/almost-sorted/problem explanation = ''' Output Format If the array is already sorted, output yes on the first line. You do not need to output anything else. If you can sort this array using one single operation (from the two permitted operations) ...
true
aa3893ed9501800385b644fc8ba7945f54962830
KiemNguyen/data-structures-and-algorithms
/coding_challenges/linked_lists/delete.py
1,999
4.3125
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: # Function to initialize head def __init__(self): self.head = Node(-1) # Function to insert a new node at the beginning def insert_at_head(self, new_data): # 2. Create a new n...
true
239a5babfec5b5fecb3e9a11f6a168d75fa779b6
LadislavVasina1/PythonStudy
/ProgramFlow/trueFalse.py
285
4.25
4
day = "Monday" temperature = 30 raining = True if (day == "Saturday" and temperature > 27) or not raining: print("Go swimming.") else: print("Learn Python") name = input("Enter your name: ") if name: print(f"Hi, {name}") else: print("Are you the man with no name?")
true
2b53bc3f72d5ea1528666abe1d9a5e174b17d7c2
federicociner/leetcode
/graphs/valid_tree.py
1,690
4.15625
4
"""Given n nodes labeled from 0 to n-1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree. Example 1: Input: n = 5, and edges = [[0,1], [0,2], [0,3], [1,4]] Output: true Example 2: Input: n = 5, and edges = [[0,1], [1,2], [2,...
true
cbcfea6a3d9052c030b2dd071269a3506bf1dd54
federicociner/leetcode
/arrays/find_duplicate_number.py
1,336
4.21875
4
"""Given an nums nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one. Example 1: Input: [1,3,4,2,2] Output: 2 Example 2: Input: [3,1,3,4,2] Outpu...
true
4f6eb16985300e4634b3788f5493185c2654b606
federicociner/leetcode
/design_problems/design_max_stack.py
1,944
4.25
4
"""Design a max stack that supports push, pop, top, peekMax and popMax. push(x) -- Push element x onto stack. pop() -- Remove the element on top of the stack and return it. top() -- Get the element on the top. peekMax() -- Retrieve the maximum element in the stack. popMax() -- Retrieve the maximum element in the stack...
true
1e287847a48951f62d8fa99795bb792453396603
federicociner/leetcode
/dynamic_programming/palindromic_substrings.py
1,247
4.21875
4
"""Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters. Example 1: Input: "abc" Output: 3 Explanation: Three palindromic strings: "a", "b",...
true
d57d848792e49d6eb6c6667dc1ad1143ad402ceb
gvnn/csv_perimeter_calculator
/perimeter.py
2,382
4.34375
4
#!/usr/bin/env python import csv import glob import os import sys def calculate_length(file_name): """ read a list of points from a CSV file and print out the length of the perimeter of the shape that is formed by joining the points in their listed order """ fp = open(file_name) reader = csv.r...
true
a1e9fb6536c4221f5f58fa3b800550806f0163d9
MohammadQu/Summer2348
/Homework1/ZyLab2.19.py
1,447
4.125
4
# Mohammad Qureshi # PSID 1789301 # LAB 2.19 # PART 1 # INPUT NUMBER OF LEMON, WATER, AND NECTAR CUPS AND SERVINGS print('Enter amount of lemon juice (in cups):') lemon = int(input()) print('Enter amount of water (in cups):') water = int(input()) print('Enter amount of agave nectar (in cups):') nectar = flo...
true
d977177bd14dbc7910f183544d23f1e1f4752ee4
Kallikrates/adv_dsi_lab_2
/src/features/dates.py
477
4.34375
4
def convert_to_date(df, cols:list): """Convert specified columns from a Pandas dataframe into datetime Parameters ---------- df : pd.DataFrame Input dataframe cols : list List of columns to be converted Returns ------- pd.DataFrame Pandas dataframe with converte...
true
4745c3664cdb74b4a67f3afb2ee126cbae225994
m-samik/pythontutorial
/itterativeapproach.py
255
4.15625
4
# Itterative Approach for a Function def factorial_itr(n): fac=1 for i in range(n): fac=fac*(i+1) return fac number=int(input("Enter the Nunber\n")) print("factorial of the number using itterative method is :\n",factorial_itr(number))
true
9dbb209e95bdadd3f722101dc2915b5242f6e37c
m-samik/pythontutorial
/dictionary.py
258
4.21875
4
#creating a dictionary with words and meanings d1 ={"Mutable":"Which Changes","Immutable" : "Which doesn't Change","Luminous":"Object with Light","Sonorous" : "Sound Producing Utencils"} print("Enter the word to which you want meaning") print(d1[input()])
true
4ba42df9e051ece562b5d6f9d4b537ad8da1bb28
vineetpathak/Python-Project2
/reverse_alternate_k_nodes.py
965
4.21875
4
# -*- coding: UTF-8 -*- # Program to reverse alternate k nodes in a linked list import initialize def reverse_alternate_k_nodes(head, k): count = 0 prev = None curr = head # reverse first k nodes in link list while count < k and curr: next = curr.nextnode curr.nextnode = prev prev = curr ...
true
3f86e2b16b0ef7f9fec2f6bac05bf8031dea71fc
vineetpathak/Python-Project2
/convert_to_sumtree.py
679
4.21875
4
# -*- coding: UTF-8 -*- # Program to convert tree to sumTree import binary_tree def convert_to_SumTree(root): '''Convert a tree to its sum tree''' if root is None: return 0 old_value = root.data root.data = convert_to_SumTree(root.left) + convert_to_SumTree(root.right) return root.data + old_val...
true
5438bd96360a3d93a74c37c8f1465864324ebb2a
Lckythr33/CodingDojo
/src/python_stack/python/fundamentals/insertion_sort.py
571
4.15625
4
# Python Insertion Sort # Function to do insertion sort def insertionSort(myList): # Traverse through 1 to len(myList) for i in range(1, len(myList)): curr = myList[i] # Move elements of myList[0..i-1], that are # greater than curr, to one position ahead # of ...
true
f53745c1d0b91273b69fa4c70ad77a53a8837fbf
dannielshalev/py-quiz
/quiz3.py
1,129
4.46875
4
# An anagram is a word obtained by rearranging the letters of another word. For example, # "rats", "tars", and "star" are anagrams of one another, as are "dictionary" and # "indicatory". We will call any list of single-word anagrams an anagram group. For # instance, ["rats", "tars", "star"] is an anagram group, as is [...
true
c809124aaadfe3ca974ab4a6ce3bd0944fe9182c
Alcatrazee/robot_kinematic
/python code/ABB_Robot.py
855
4.15625
4
# -*- coding: utf-8 -*- from forward_kinematic import * from inverse_kinematic import * import numpy as np #Before running,you need to make sure you have installed numpy,scipy,matplotlib. #All you need to do is to alternate the angle of each joint on below #Set the theta vector to determine the angle of each joint th...
true
2a18b4e470a4f6352cac822144f2a180bd372174
SACHSTech/ics2o-livehack1-practice-GavinGe3
/minutes_days.py
829
4.3125
4
""" ------------------------------------------------------------------------------- Name: minutes_days.py Purpose: Converts given minutes into days, hours and minutes Author: Ge.G Created: 08/02.2021 ------------------------------------------------------------------------------ """ print("******Minutes to days,...
true
67393c0a1b38f784e6e035a01363a630622d2ac1
c4collins/PyTHWay
/ex16.py
996
4.4375
4
from sys import argv script, filename = argv print "Opening %r for reading..." % filename target = open(filename, 'r') # opens the file with the read attribute print "It currently says:" print target.read() print "Closing the file." target.close() # close the file after reading print "We're going to erase %r." % f...
true
93f075fa8c8f9e7017e74be4e4ce2bceb329b13b
leoswaldo/pythonchallenge
/0.py
411
4.3125
4
#!/python/python3.4/bin/python3 ## Function: pow, return a number to a power # Parameters: base, power # base: base number to pow # power: number of pow def pow(base, power): result = 1 while(power > 0): power-=1 result = result * base return result if __name__ == '__main__': ...
true
8ede9e26eb72585afb7424bf72cd9e28f5562e68
haokai-li/ICS3U-Unit3-08-Python-Leap-Year
/leap_year.py
911
4.21875
4
#!/usr/bin/env python3 # Created by: Haokai Li # Created on: Sept 2021 # This Program calculate leap year def main(): # This function calculate leap year # input user_string = input("Please enter the year: ") print("") # process try: user_year = int(user_string) if user_year...
true
359ae83a4c2f4184a35587ab2dca1c2840629e5d
Gokulancv10/CodeBytes
/2-Week_Array/Spot The Difference.py
1,723
4.125
4
""" This question is asked by Google. You are given two strings, s and t which only consist of lowercase letters. t is generated by shuffling the letters in s as well as potentially adding an additional random character. Return the letter that was randomly added to t if it exists, otherwise, return ''. Note: You may...
true
612234d53d3d28701fdb0d4992a6b9be51fdc0c3
Raymond-P/Github-Dojo
/Python_200_Problems/arrays/array_rotate.py
405
4.15625
4
# Rotate an array of n elements to the right by k steps. # For example, with n = 7 and k = 3, # the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. # Note: # Try to come up as many solutions as you can, # there are at least 3 different ways to solve this problem. def rotate1(array, steps): if len(array) > st...
true
7da8c3be50b482c5e40d2e94b7dda7650ea0bfa3
Mariakhan58/simple-calculator
/calculator.py
1,343
4.25
4
# Program to make a simple calculator # This function adds two numbers def Calculate(): def add(a, b): return a+b # This function subtracts two numbers def subt(a, b): return a-b # This function multiplies two numbers def mult(a, b): return a*b #This function divides...
true
416bce7ea5543c5d05b52d9cfb0e26d1d3cbd510
Reece323/coding_solutions
/coding_solutions/alphabeticShift.py
467
4.15625
4
""" Given a string, your task is to replace each of its characters by the next one in the English alphabet; i.e. replace a with b, replace b with c, etc (z would be replaced by a). """ def alphabeticShift(inputString): #97(a) - 122(z) to_list = list(inputString) for i in range(len(to_list)): ...
true
25916d96dec4108171537a9ac039b2110ee31bc4
Reece323/coding_solutions
/coding_solutions/first_not_repeating_character.py
843
4.21875
4
""" Given a string s consisting of small English letters, find and return the first instance of a non-repeating character in it. If there is no such character, return '_'. Example For s = "abacabad", the output should be first_not_repeating_character(s) = 'c'. There are 2 non-repeating characters in the string:...
true
d869fc6cf5f3cdf029c4d8ea4439fb6a62c4cd28
Digikids/Fundamentals-of-Python
/if statements.py
477
4.21875
4
number_1 = int(input("Input a number: ")) number_2 = int(input("Input a second number: ")) operation = input("What do you want to do with the two numbers: ") output = "" if operation == "+": output = number_1 + number_2 elif operation == "-": output = number_1 - number_2 elif operation == "*": output = n...
true
e5bd64932169fa7beed4c6f919d07d97d2b02dab
shaokangtan/python_sandbox
/reverse_linked_list.py
662
4.21875
4
class Node: def __init__(self, value): self.value = value self.nextnode = None def reverse_linked_list(node): current = node prev = None next = None while current: next = current.nextnode current.nextnode = prev prev = current curr...
true
e14bb95ae0b24e82ed8f92fcfa17bc7d6e339cf8
JianFengY/codewars
/codes/bit_counting.py
627
4.15625
4
# -*- coding: utf-8 -*- ''' Created on 2018年2月2日 @author: Jeff Yang ''' ''' Write a function that takes an (unsigned) integer as input, and returns the number of bits that are equal to one in the binary representation of that number. Example: The binary representation of 1234 is 10011010010, so the functio...
true
65260f9763e0ebeb995c3a7c5260c2b8420206c7
JianFengY/codewars
/codes/binary_addition.py
486
4.21875
4
# -*- coding: utf-8 -*- ''' Created on 2018年2月1日 @author: Jeff Yang ''' ''' Implement a function that adds two numbers together and returns their sum in binary. The conversion can be done before, or after the addition. The binary number returned should be a string. ''' def add_binary(a, b): """a...
true
98638499b765de5668015c9425b882f5721ede52
afrazn/Projects
/MemoizationDynamicProgramming.py
1,144
4.1875
4
'''This program uses memoization dynamic programming to find the optimal items to loot based on weight capacity and item value''' from util import Loot def knapsack(loot, weight_limit): grid = [[0 for col in range(weight_limit + 1)] for row in range(len(loot) + 1)] for row, item in enumerate(loot): row = row ...
true
8437ae1338934cdf4937ab1e97967a097731e77c
srirachanaachyuthuni/object_detection
/evaluation.py
2,508
4.1875
4
"This program gives the Evaluation Metrics - Accuracy, Precision and Recall" def accuracy(tp, tn, total): """ Method to calculate accuracy @param tp: True Positive @param tn: True Negative @param total: Total @return: Calculated accuracy in float """ return (tp + tn ) / total def pre...
true
3f15cde13c1183324a580bac67c3f2ffcee42c73
simplifies/Coding-Interview-Questions
/hackerrank/noDocumentation/countingValleys.py
1,393
4.125
4
#!/bin/python3 import math import os import random import re import sys # Complete the countingValleys function below. def countingValleys(n, s): # so instantly i'm thinking switch the DD UU to 1 and -1 # so [DDUUUU] would become [-1, -1, 1, 1, 1, 1] # So a valley is determined when he goes below sea leve...
true
c1904c47cfe04e5bacb7261cf7a1d2501dfc3332
viththiananth/My-Python-Practise
/11. Check Primality Functions.py
1,713
4.1875
4
#Ask the user for a number and determine whether the number # is prime or not. (For those who have forgotten, # a prime number is a number that has no divisors.). # You can (and should!) use your answer to Exercise 4 to # help you. Take this opportunity to practice using functions, # described below. #num=int(input("P...
true
8b3bfb58367bd57f4e474a7dc475b983214b3bcd
viththiananth/My-Python-Practise
/16. Password Generator.py
1,118
4.1875
4
#Write a password generator in Python. Be creative with how you generate passwords - strong passwords have a mix of lowercase letters, uppercase letters, numbers, and symbols. The passwords should be random, generating a new password every time the user asks for a new password. Include your run-time code in a main meth...
true
946deb8b75fb2f6aa256423df749acd46b53af28
lroolle/CodingInPython
/leetcode/336_palindrome_pairs.py
1,150
4.1875
4
#!usr/bin/env python3 """LeetCode 336. Palindrome Pairs > Given a list of unique words. Find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome. - Example 1: Given words = ["bat", "tab", "cat"] Return [[0,...
true
4197a945fa1cea1dfd132bb21a12340640d50c69
Virjanand/LearnPython
/005_stringFormatting.py
474
4.3125
4
# String formatting with argument specifiers name = "John" print("Hello, %s!" % name) # Use two or more argument specifiers name = "Jane" age = 23 print("%s is %d years old." % (name, age)) # objects have "repr" method to format it as string mylist = [1, 2, 3] print("A list: %s" % mylist) # Exercise: write Hello John...
true
cdfc3b31fed2480004ec70e5e03cfb0ff491716b
Virjanand/LearnPython
/009_functions.py
1,455
4.40625
4
# Functions are blocks of code #block_head: # 1st block line # 2nd block line # Functions are defined using def func_name def my_function(): print("Hello from my function!") # Arguments def my_function_with_args(username, greeting): print("Hello, %s, from my function! I wish you %s" % (username, gree...
true
0d23ff1b5d66a7d90d77af0a6d30ae3c6bac8118
herereadthis/timballisto
/tutorials/abstract/abstract_04.py
808
4.4375
4
"""More on abstract classes.""" """ AbstractClass isn't an abstract class because you can create an instance of it. Subclass must implement the (abstract) methods of the parent abstract class. MyClass does not show an implementation of do_something() """ from abc import ABC, abstractmethod class AbstractClass(ABC):...
true
abc124c578327b3e4b9a4ee3ce9e5300d6374af9
amaurya9/Python_code
/fileReverseOrder.py
762
4.375
4
#Write a program to accept a filename from user & display it in reverse order import argparse items=[] def push(item): items.append(item) def pop(): return items.pop() def is_empty(): return (items == []) def ReadFile(i): fd=open(i) char1=fd.read(1) while char1: push(cha...
true
29877f7706f9b95ae71fd344bfd4ec031e481b35
Shaners/Python
/collatzSeq.py
424
4.25
4
def collatz(num): if num % 2 == 0: return num // 2 else: return 3 * num + 1 while True: try: print("Please provide a number.") num = int(input('> ')) except ValueError: print("Error: Invalid argument. You did not provide a number.") continue else: ...
true
0e7d16c28f81bd3a89965e28314437257da5bf72
Shaners/Python
/weightHeightConverter.py
354
4.15625
4
# Height and Weight Converter # Set height variable to height in inches # Set weight variable to weight in lbs # This will print to console height in centimeters and weight in Kilograms height = 74 # inches weight = 180 # lbs print(f"{height} inches is {height * 2.54} centimeters tall.") print(f"{weight} lbs is {weig...
true
2276cbfff7abb897c84bfba8b32999689da9890e
juliagarant/LearningPython
/COMP2057/Assignment3_104987469.py
657
4.21875
4
""" Assignment 3 for Programming for Beginners Julia Garant 104987469 Mar 29 2020 """ def main(): user_num = int(input("Enter an integer greater than 1: ")) numbers = [] for count in range(2, user_num + 1): # range is (inclusive,exclusive) which is why I need +1 numbers.append(count) for i...
true
87e55d48afe12116907a2c60c8639a3312e34568
RodrigoTXRA/Python
/If.Statement.py
527
4.40625
4
# If statements are either true or false # If condition is true it will action something otherwise it action sth else # boolean variable below is_male = True is_tall = True # Using OR one of the condition can be true # Using AND both conditions must be true if is_male and is_tall: print("You are a male or t...
true
a677bbd4b38851ef90af67fc9be48af051c29cec
EllaT/pickShape
/pickShape.py
573
4.1875
4
from turtle import * from random import randint shapes = int(input("How many shapes?")) for i in range(shapes): length_of_side = int(input("How many sides?")) size = int(input("How many forward steps?")) color = (input("What color?")) number = (randint (20, 90)) for i in range(length_of_side): pencolor(color) ...
true
832c2e39b074233947a2783eaeba6f4f7ce44114
mehakgarg911/Basics_of_Python_Programming_1
/question7.py
246
4.125
4
def factorial(num1): fact =1 for x in range(2,num1+1): fact*=x return fact def rec_factorial(num1): if num1==0 or num1==1: return 1; else: return num1*rec_factorial(num1-1); print(factorial(6)) print(rec_factorial(6))
true
87eb176f50ef2a325f6bb8408fd4e4e3bfce1a01
feminas-k/MITx---6.00.1x
/problemset6/applycoder.py
396
4.15625
4
def applyCoder(text, coder): """ Applies the coder to the text. Returns the encoded text. text: string coder: dict with mappings of characters to shifted characters returns: text after mapping coder chars to original text """ r = '' for char in text: if char in coder: ...
true
fe8f96cff7baa842c2397a7a4d0750ee8a7aa292
AJsenpai/codewars
/titleCase.py
1,295
4.25
4
""" Write a function that will convert a string into title case, given an optional list of exceptions (minor words). The list of minor words will be given as a string with each word separated by a space. Your function should ignore the case of the minor words string -- it should behave in the same way even if the cas...
true
16f4933df1f63e9e92a5f136e4d61802f376bb16
AJsenpai/codewars
/isSquare.py
1,028
4.21875
4
# Kyu 7 """ Given an integral number, determine if it's a square number: In mathematics, a square number or perfect square is an integer that is the square of an integer; in other words, it is the product of some integer with itself. The tests will always use some integral number, so don't worry about that in dynami...
true
e0fc750cd3c4a2260e6cc12a364d9d2efbdf4c64
mepky/verzeo-project
/verzeo minor project/prime_or_not.py
378
4.125
4
n=int(input('Enter the number:')) def checkprime(n): if n<=1: return False for i in range(2,n): if (n%i==0): return False return True if checkprime(n): print(n,"is prime number") else: print(n,'is not a prime ...
true
b1c3e745d09b7a1ce161a41b5bf1ec70d6f33353
953250587/leetcode-python
/LargestTriangleArea_812.py
1,748
4.1875
4
""" You have a list of points in the plane. Return the area of the largest triangle that can be formed by any 3 of the points. Example: Input: points = [[0,0],[0,1],[1,0],[0,2],[2,0]] Output: 2 Explanation: The five points are show in the figure below. The red triangle is the largest. Notes: 3 <= points.length <...
true
ae33090f151b891fe79a8e2286e13745ff2f3900
953250587/leetcode-python
/KdiffPairsInAnArray_532.py
2,322
4.125
4
""" Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j), where i and j are both numbers in the array and their absolute difference is k. Example 1: Input: [3, 1, 4, 1, 5], k = 2 Output: 2 Explanation: Th...
true
3cea738e3ba2ed6322d0ca1c5beaf65379977b69
953250587/leetcode-python
/DifferentWaysToAddParentheses_MID_241.py
2,744
4.15625
4
""" Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *. Example 1 Input: "2-1-1". ((2-1)-1) = 0 (2-(1-1)) = 2 Output: [0, 2] Example 2 Input: "2*3-4*5" (2*(3-(4*5))) = -34 ((2*3)-(4*...
true
738e8c67cba389fb6720beb1e5872f7713a20275
953250587/leetcode-python
/ShortestPalindrome_HARD_214.py
2,620
4.21875
4
""" Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation. For example: Given "aacecaaa", return "aaacecaaa". Given "abcd", return "dcbabcd". """ class Solution(object): def shor...
true
07f2ab307ebc2804f0ff99df449cb7b358b5ef12
David-sqrtpi/python
/returning-functions.py
463
4.375
4
def calculate_recursive_sequence(number): print(number) if number == 0: return number return calculate_recursive_sequence(number-1) def calculate_iterative_sequence(number): for i in range(number, -1, -1): print(i) number = int(input("Write a number to calculate its descending sequenc...
true
322465c7512f10bcaa51192c186995ef1af0f6c1
Dzhevizov/SoftUni-Python-Fundamentals-course
/Programming Fundamentals Final Exam - 14 August 2021/01. Problem.py
1,250
4.34375
4
username = input() command = input() while not command == "Sign up": command = command.split() action = command[0] if action == "Case": case = command[1] if case == "lower": username = username.lower() else: username = username.upper() print(us...
true
e5d9e9b8bbebea5b78b1ba4eb97cf9ca27021337
ZTatman/Daily-Programming-Problems
/Day 3/problem3.py
2,180
4.25
4
# Author: Zach Tatman # Date: 5/26/21 ''' Good morning! Here's your coding interview problem for today. This problem was asked by Google. Given the root to a binary tree, implement serialize(root), which serializes the tree into a string, and deserialize(s), which deserializes the string back into the tree. ...
true
c3eadb1541b822fcad2aee32bd7700639f765f15
soccergame/mincepie
/mincepie/demo/wordcount.py
2,197
4.125
4
""" Wordcount demo This demo code shows how to perform word count from a set of files. we show how to implement a simple mapper and reducer, and launch the mapreduce process. To run the demo, run: python wordcount.py --input=zen.txt This will execute the server and the client both locally. Optionally, you can ru...
true
dde50d7e399e4d3e9414fa3a92492d5edbfdcc81
rwu8/MIT-6.00.2x
/Week 1/Lecture 2 - Decision Trees/Exercise1.py
751
4.21875
4
def yieldAllCombos(items): """ Generates all combinations of N items into two bags, whereby each item is in one or zero bags. Yields a tuple, (bag1, bag2), where each bag is represented as a list of which item(s) are in each bag. """ # Your code here N = len(items) #...
true
fc1863c9d52aeb479680be82aa4201694b9a0e21
rmoore2738/CS303e
/assignment4_rrm2738.py
1,599
4.28125
4
#Rebecca Moore RRM2738 #Question 1 print("I’m thinking of a number from 1 to 10000. Try to guess my \nnumber! (Enter 0 to stop playing.)") guess = input("Please enter your guess:") guess = int(guess) number = 1458 if guess == number: print("That's correct! You win! You guessed my number in X guesses.") while guess...
true
ad7f18c17fb1757033f7647597c12a8187f1e824
rohitx/DataSciencePrep
/PythonProblems/coderbyte/Second_Great_Low.py
790
4.15625
4
''' Using the Python language, have the function SecondGreatLow(arr) take the array of numbers stored in arr and return the second lowest and second greatest numbers, respectively, separated by a space. For example: if arr contains [7, 7, 12, 98, 106] the output should be 12 98. The array will not be empty and will con...
true
318f7d8acb098cd424025e2dd8bb9e085e8e3c58
rohitx/DataSciencePrep
/PythonProblems/precourse/problem9.py
499
4.25
4
def word_lengths2(phrase): ''' INPUT: string OUTPUT: list of integers Use map to find the length of each word in the phrase (broken by spaces) and return the values in a list. ''' # I will make use of the lambda function to compute the # length of the words # first I will break the s...
true
699f4acd1a878494f7294565e6cafde8296398bc
rohitx/DataSciencePrep
/PythonProblems/precourse/problem6.py
1,121
4.4375
4
import numpy as np def average_rows1(mat): ''' INPUT: 2 dimensional list of integers (matrix) OUTPUT: list of floats Use list comprehension to take the average of each row in the matrix and return it as a list. Example: >>> average_rows1([[4, 5, 2, 8], [3, 9, 6, 7]]) [4.75, 6.25] '''...
true
b2860e5741a5196f5cfded6bc2a8c8e7d1cd41e5
rohitx/DataSciencePrep
/PythonProblems/coderbyte/longest_word.py
780
4.46875
4
''' Using the Python language, have the function LongestWord(sen) take the sen parameter being passed and return the largest word in the string. If there are two or more words that are the same length, return the first word from the string with that length. Ignore punctuation and assume sen will not be empty. ''' def L...
true
5bbca24e796907dd70f15221aa58438e860f97c0
rohitx/DataSciencePrep
/PythonProblems/coderbyte/Ex_Oh.py
761
4.3125
4
''' Using the Python language, have the function ExOh(str) take the str parameter being passed and return the string true if there is an equal number of x's and o's, otherwise return the string false. Only these two letters will be entered in the string, no punctuation or numbers. For example: if str is "xooxxxxooxo" t...
true
16f44df0d5b4db85c87ec8bc0e7d4415802f14eb
elad-allot/Udemy
/cake/is_binary_search_tree.py
1,496
4.125
4
class BinaryTreeNode(object): def __init__(self, value): self.value = value self.right = None self.left = None def insert_left(self, value): self.left = BinaryTreeNode(value) return self.left def insert_right(self, value): self.right = BinaryTreeNode(value)...
true
caee4a4b0415440b3d790033e791762a8542fe5c
syeluru/MIS304
/basic.py
696
4.125
4
# Program to demonstrate basic python statements print("Welcome to Python Programming") message = "Welcome to Python Programming!!!" print (message) print(type(message)) # message is a variable of type str number = 25 print (number) print (type(number)) # number is a variable of type num price = 12.99 print (price)...
true
93842a724512bb1c706efd214c07bde85f43809d
syeluru/MIS304
/ComputeArea.py
1,693
4.40625
4
#program to compute area """ length = 20 width = 5 area = length * width print (type(length)) print (type(width)) print (area) print (type(area)) length = 12.8 width = 5.6 area = length * width print (type(area)) print (area) #f is format specifier for floating numbers #.2 is two decimal places print ("Area = %.3f...
true
a7301fbb2f49e5c3d6bfcba808ee87687797796b
spencerf2/coding_temple_task3_answers
/question3.py
426
4.34375
4
# Question 3 # ---------------------------------------------------------------------- # Please write a Python function, max_num_in_list to return the max # number of a given list. The first line of the code has been defined # as below. # ---------------------------------------------------------------------- # def ma...
true
393c9787c87ac3ec229da96a87d394fd681b744b
laxos90/MITx-6.00.1x
/Problem Set 2/using_bisection_search.py
1,425
4.46875
4
__author__ = 'm' """ This program uses bisection search to find out the smallest monthly payment such that we can pay off the entire balance within a year. """ from paying_debt_off_in_a_year import compute_balance_after_a_year def compute_initial_lower_and_upper_bounds(balance, annual_interest_rate): monthly_in...
true
5a23a290af8452c425a290c8201146b14cc7081f
badladpancho/Python_103
/While_loop.py
204
4.34375
4
# This is the basic to a while loop # will loop through until it is false # This is like it is done in C programing i = 0 while i <= 10: print(i); i += 1; print("Done with this loop")
true
ccaca618954119e58e0d107e36cd5ce48be68e0c
badladpancho/Python_103
/Guessing_Game.py
692
4.25
4
# This is going to be a simple game in order to guess # We are going to be using if statments while loops and other things that i have # learned. # MADE BY BADLADPANCHO print("Player 1 enter the secret word\n"); secret_word = input(""); print("OK lets play!"); guess = "" i = 0; chance_limit = 3; w...
true
df294dbacb1c93363b2c3e7a2b5a4a5b1470a116
reddevil7291/Python
/Program to find the sum of n natural 2.py
302
4.125
4
print("Program to Find the sum of n Natural Numbers") n = eval(input("\nEnter the value of n:")) sum = float if(not isinstance(n,int)): print("\nWRONG INPUT") else: if(n<=0): print("\nERROR") else: sum1 = (n*(n+1))/2 print("The sum is ",sum1)
true
d135fd7ec20c5ad900a18256337f55c4272b4bb5
Galyopa/SoftServe_Marathon
/Sprint_05/question04.py
1,879
4.5625
5
""" Question text Write the function check_number_group(number) whose input parameter is a number. The function checks whether the set number is more than number 10: in case the number is more than 10 the function should be displayed the corresponding message - "Number of your group input parameter of function is v...
true
f01841425d4f7d890e3f170bfb7cdefcf53c28bf
Galyopa/SoftServe_Marathon
/Sprint_03/question3.py
2,039
4.3125
4
""" Create function create_account(user_name: string, password: string, secret_words: list). This function should return inner function check. The function check compares the values of its arguments with password and secret_words: the password must match completely, secret_words may be misspelled (just one element). ...
true
4fa8cd4350ce3c53c4c3b861463a461962633197
dkhroad/fuzzy-barnacle
/prob2/string_validator.py
2,026
4.40625
4
class StringValidator(object): '''validate a string with brackes and numbers''' def validate_brackets(self,s): ''' ensures that string s is valid :type s: str :rtype: bool valiation criteria: - the string only contains the followin characters ...
true
554b090af2ba3bc3040e9e9acccf883928375c9c
dariclim/python_problem_exercises
/Directions_Reduction.py
2,372
4.1875
4
""" Once upon a time, on a way through the old wild west, a man was given directions to go from one point to another. The directions were "NORTH", "SOUTH", "WEST", "EAST". Clearly "NORTH" and "SOUTH" are opposite, "WEST" and "EAST" too. Going to one direction and coming back the opposite direction is a needless eff...
true