blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
165662dd2df0759cb43172f690558cdd2b62e9cc
one-last-time/python
/Data Types and Operators/ArithmeticOperators.py
665
4.1875
4
#addtion,subtraction,multiplication,division,mod are same as other language print(((1+2+3)*(4/2)-5)%3) #power #get 2^3 print(2**3) #integer divison #it rounds the result print(8//3) print(-8//3) """ Quiz: Calculate In this quiz you're going to do some calculations for a tiler. Two parts of a floor need tiling. ...
true
46ca34ac7cff4689deb3f0acbede5503534c2ca6
FinchyG/Python_testing_fridge_temperatures
/Testing_fridge_temperatures.py
920
4.28125
4
# Test whether fridge temperatures are between 1 and 5 degrees Celsius # function with one parameter, temperatures: a list of numbers def test_temperature(temperatures): # initialise empty list to store temperatures outside of range 1 to 5 unacceptable_temperatures = [] # iterate through input list ...
true
b9dac96e603a2af6b4db973904175d7e808dc9c8
DeepankJain/Python-Programs
/Prog3.py
238
4.3125
4
#To check whether a number is postive, negative or Zero num1 = int(input("Enter any number:")) if num1 > 0: print("Number is positive") elif num1 == 0: print("Number entered is Zero") else: print("Number is negative")
true
42838d219ffd6d447c796649fe4cc9579a1348d4
raezir/The-Hoodrat-Repository
/test1.py
551
4.125
4
#!/usr/bin/env python #import sys ''' Created on Jan 28, 2017 This code opens a text file and reads it, saving it to line and then printing it. @author: rkbergsma ''' f = open('Article1.txt','r') #open to read line = f.readlines() #reads all lines in file #line = [x.strip() for x in line...
true
08f6f7b1c7fa5c063ce5be8f1d8e7213ac9c7b01
Melwyn12/Python-Projects
/simpleAdditionQuiz.py
2,166
4.125
4
# Math game quiz # prompts users to answer simple addition problems using random numbers from 0-100 # added subtraction, multiplication, and division def printBanner(): print("\t\t\t ##################### ") print("\t\t\t Math Quiz ") print("\t\t\t By Falconscrest123 ") print("\t\t\t ###...
true
4c73f3903714e956a47065cfb51c2438159bcfa9
teosss/HomeWorkPyCore
/lesson_8/task_1.py
938
4.25
4
import super_module_t1 def input_area(value): """" This function determines the type of figure Input: value(str) Result: (int,float) """" if value is '1': s = int(input("Enter first side: ")) b = int(input("Enter second side: ")) return super_module_t1....
true
dae37bc59b17b2e7e9b6118b19a3bcac1fadc43b
Panic-point1/Algorithmia
/python/binary_search.py
857
4.25
4
''' In binary search, - Compare x with the middle element. - If x matches with the middle element, we return the mid index. - Else if x is greater than the mid element, then x can only lie in the right (greater) half subarray after the mid element. Then we apply the algorithm again for the right half. - Else i...
true
57ba2c2cfe3ab44fc716e148322c16268f2204a3
JessicaJang/cracking
/Chapter 3/q_3_5.py
1,185
4.15625
4
# Chapter 3 Stacks and Queues # 3.5 Sort Stack # Write a program to sort a stack such that the smallest items are on the top # You can use an additiona temporary stack, but you may not copy the elements # into any other data structure (such as an array). The stack supports # the following operations: push, pop, peek a...
true
0e447a93b2db7926b93b73bad2ea46111e7a493e
JessicaJang/cracking
/Chapter 2/q_2_3.py
453
4.28125
4
# Chapter 2 Linked Lists # Interview Questions 2.3 # Delete middle node: # Implement an algorithm to delete a node in the middle import os from LinkedList import LinkedList from LinkedList import LinkedListNode def delete_middle_node(node): node.value = node.next.value node.next = node.next.next ll = LinkedList() ...
true
9baa2091eff6073b7f0642899a0ee3f07fbf96c0
Cosmo767/Practice
/Udemy_Python_refresher/review_2_getting_input.py
304
4.1875
4
# name = input("Enter your name: ") # print(name) # input gives you a string, not a number size_input = input("How big your house in sq feet?:" ) square_feet = int(size_input) sqr_meters = square_feet /10.8 string = f"{square_feet} square feet is equal to {sqr_meters:.2f} square meters" print(string)
true
1114f176bb5c3b78c22c54aad4c61f258b5a1579
Cosmo767/Practice
/jason_algos_one/most_common_letter.py
1,906
4.25
4
def most_common_letter(text): """Returns the letter of the alphabet that occurs most frequently. If there is a tie, choose the letter that comes first in the alphabet. If there are no letters, return the empty string""" ''' create a dictionary with a value for each key that counts how many time ...
true
0d4a3ed33566dd1980674c2ad18336f3c3b6b597
Cosmo767/Practice
/Udemy_Python_refresher/33_unpacking_args.py
748
4.28125
4
def add(*args): total = 0 for arg in args: total = total + arg return total def mutliphy(*args): # print(args) total = 1 for arg in args: total = total*arg return total # print(mutliphy(1,3,5)) def apply(*args, operator): # creates a named operator at the end, must pass ...
true
0906b7cc9dda5c140134c5a68fde84daa6453166
100sun/python_programming
/chp5_ex.py
1,340
4.28125
4
# 5.1 Capitalize the word starting with m: song = """ When an eel grabs your arm, ... And it causes great harm, ... That's - a moray!""" song = song.replace('m', ' M') print(song) # 5.2 Print each list question with its correctly matching answer in the form: Q: question A: answer > > > questions = [ "We don't serve...
true
e5eccbc671e5225f8da0c3dbf9666ef6b81ec8c2
tomasvalda/dt211-3-cloud
/Euler/solution7.py
616
4.21875
4
#!/usr/bin/python def is_prime(num): # function for check if the number is prime, returns true or false if num == 2: return true if num < 2: return false if not num & 1: return false # for x in range # number is prime when we can divide it only by the exact number or 1 ################# return true def ...
true
4189cbe031375dd974083eb6e006b04852b29392
Snehal2605/Technical-Interview-Preparation
/ProblemSolving/450DSA/Python/src/string/MinimumSwapsForBracketBalancing.py
1,674
4.3125
4
""" @author Anirudh Sharma You are given a string S of 2N characters consisting of N ‘[‘ brackets and N ‘]’ brackets. A string is considered balanced if it can be represented in the for S2[S1] where S1 and S2 are balanced strings. We can make an unbalanced string balanced by swapping adjacent characters. Calculate ...
true
3ea12eeb1275db5ca2a730ad5cd55e8f9da5e755
Snehal2605/Technical-Interview-Preparation
/ProblemSolving/450DSA/Python/src/binarytree/LevelOrderTraversal.py
1,314
4.21875
4
""" @author Anirudh Sharma Given a binary tree, find its level order traversal. Level order traversal of a tree is breadth-first traversal for the tree. Constraints: 1 <= Number of nodes<= 10^4 1 <= Data of a node <= 10^4 """ def levelOrderTraversal(root): # Special case if root is None: return None...
true
355c5ba49e9a5ee0d5862f1155800456b10fdb6c
Snehal2605/Technical-Interview-Preparation
/ProblemSolving/450DSA/Python/src/dynamicprogramming/MobileNumericKeypad.py
1,471
4.28125
4
""" @author Anirudh Sharma Given the mobile numeric keypad. You can only press buttons that are up, left, right, or down to the current button. You are not allowed to press bottom row corner buttons (i.e.and # ). Given a number N, the task is to find out the number of possible numbers of the given length. """ def ge...
true
a0faf6dc0aaddd8e0cfbf57ff9ed2a53b47a380c
Snehal2605/Technical-Interview-Preparation
/ProblemSolving/450DSA/Python/src/dynamicprogramming/LongestIncreasingSubsequence.py
1,346
4.125
4
""" @author Anirudh Sharma Given an integer array nums, return the length of the longest strictly increasing subsequence. A subsequence is a sequence that can be derived from an array by deleting some or no elements without changing the order of the remaining elements. For example, [3,6,2,7] is a subsequence of the...
true
e7d9e7d85e9e3912415fb2947c392157ab7414e3
mdcowan/SSL
/Lecture_Files/Wk1_2/python.py
722
4.375
4
# To get user input, you must first import system functionality import sys # You can then use 'raw user input' to get data from the user name = raw_input("What is your name?") # From there you can use the variable with the user input data # Writing to a file # a = append, w = overwrite # Template to open a file to wr...
true
c6a687f92ae05d2411702febf255dd02ca34d561
ishitach/AI-and-PyTorch
/Neural network using relu.py
714
4.15625
4
#Creating a neural network with 128,64 hidden layers and 10 output layers and ReLU activation import torch.nn.functional as F class Network(nn.Module): def __init__(self): super().__init__() # Inputs to hidden layer linear transformation self.hidden1 = nn.Linear(784, 128) self.hidd...
true
0a61e216e7bbade2dd5090e75285384bc92159f3
clagunag/Astr-119
/HW_1_1.py
489
4.1875
4
# -*- coding: utf-8 -*- ''' Cesar Laguna Python 3.6.1 ''' import numpy as np ''' # 1 Takes inputs (b, c) and provides output of A (area of a rectangle) Rectangle = rec ''' b = int(input('Base (rec) :')) #input allows for user to input their own data/ numbers c = int(input('Height (rec) :')) A_rec = b*c print ('Area o...
true
b84e10fbca2bba78cad0cd936f4902e5cd06af8d
Data-Winnower/Python-Class-Projects
/Turtle Star Drawing.py
2,866
4.40625
4
# Kale Perry # Programming Concepts and Applications # CSC1570-4914 Fall 2020 # 01 October 2020 # Repeating Turtle # Repeating Turtle # Repeating Turtle # Did I remember to say, Repeating Turtle? import turtle turtle.speed(5) again = "Yes" print ("LET'S DRAW A STAR!") while again =="Yes" or again == "Y" o...
true
0276d2004f3ec6f8ac3fa40257e53460485caf46
RaspiKidd/PythonByExample
/Challenge44.py
542
4.28125
4
# Python By Example Book # Challenge 044 - Ask how many people the user wants to invite to a party. If they enter a number below 10. # ask for the names and after each name display "(name) has to be invited to the party". If they enter a number which is # 10 or higher display the message "Too many people". invite = in...
true
75ba36c9c802dfbdb8f96e10a7a417a6f99c338e
RaspiKidd/PythonByExample
/Challenge72.py
448
4.5
4
# Python By Example Book # Challenge 072 - Create a list of six school subjects. Ask the user which of these subjects they # don't like. Delete the subject they have chosen from the list before you display the list again. subjects = ["maths", "english", "p.e", "computing", "science", "history"] print (subjects) print ...
true
4a139d8ec093a78e7f7dad5bc47fbd67c4edc808
RaspiKidd/PythonByExample
/Challenge92.py
615
4.28125
4
# Python By Example Book # Challenge 092 - Create two arrays (one containing three numbers that the user enters and # one containing a set of five random numbers). Join these two arrays together into one large array. # Sort this large array and display it so that each number appears on a seperate line. from array impo...
true
2113eeb68b5b660c78d568123082b411750f3a4a
RaspiKidd/PythonByExample
/Challenge54.py
552
4.4375
4
# Python By Example Book # Challenge 054 - Randomly chose heads or tails ("h" or "t"). Ask the user to make their choice. # If their choice is the same as the randomly selected value, display the message "You win", # otherwise display "bad luck". At the end, tell the user if the computer selected heads or tails. impor...
true
40c6fccf41c2424e1d787d59e3c42bf8724004d0
RaspiKidd/PythonByExample
/Challenge87.py
402
4.4375
4
# Python By Example Book # Challenge 087 - Ask the user to type in a word and then display it backwards on seperate lines. # For instance, if they type in "Hello" it should display as shown below: ''' Enter a word: Hello o l l e H ''' word = input("Enter a word: ") length = len(word) num = 1 for x in word: positi...
true
a4264a9c28edd71030c523ff9f18de6f01e76e38
RaspiKidd/PythonByExample
/Challenge83.py
462
4.375
4
# Python By Example Book # Challenge 083 - Ask the user to type a word in uppercase. If they type it in lowercase, ask them to try again. # Keep repeating this until they type in a message all in uppercase. msg = input("Enter a message in uppercase: ") tryAgain = False while tryAgain == False: if msg.isupper(): ...
true
ab858ab774b8f552cd18e61d31dae22f7d2de6b0
RaspiKidd/PythonByExample
/Challenge17.py
574
4.21875
4
# Python By Example Book # Challenge 017 - Ask the users age. If they are 18 or over , display the message "You can vote", if they are aged 17, display the # message "You can learn to drive", if they are 16 , display the message "You can buy a lottery ticket", if they are under 16, display # the message "You can go tri...
true
663de86686531f0522892249b03b0169d46cdb62
gomsvicky/PythonAssignmentCaseStudy1
/Program13.py
318
4.28125
4
list1 = [] num = input("Enter number of elements in list: ") num = int(num) for i in range(1, num + 1): ele = input("Enter elements: ") list1.append(ele) print("Entered elements ", list1) max1 = list1[0] for x in list1: if x > max1: max1 = x print("Biggest number is ", max1)
true
a3c327eacdfddf49ddaaff474414f2eaffae397c
brittany-morris/Bootcamp-Python-and-Bash-Scripts
/python/learndotlab/evenorodd.py
272
4.15625
4
#!/usr/bin/env python3 import sys list = sys.argv[1] with open(list, 'r') as f: for num in f: num = num.strip() value = int(num) if value % 2 == 0: print(num, True) # True means number is Even else: print(num, False) # False means number is Odd
true
bfa6ad316c5a87c2b3c724ed7e1129c01e0a193f
Sam-stiner/science-fairproject
/science fair.py
1,697
4.15625
4
def convertString(str): try: returnValue = int(str) except ValueError: returnValue = float(str) return returnValue print 'welcome to satilite tracker 0.2.1' print 'what object would you like find the orbit around?' print ' 1: earth' print ' 2: the sun' print ' 3: a custom ...
true
40e018205dbc3671f3751ab5d0f359282f3150a4
DivyangPDev/automate-Boring-Stuff-With-Python
/Chapter 6/Chapter_6.py
2,374
4.1875
4
#! /usr/bin/env python3 #Practice Questions # 1. What are escape characters? # Escape characters lets you use characters that otherwise impossible to put into a string. An escape character # consists of a backslash (\n) followed by the character you want to add to the string # 2. What do the \n and \t escape characte...
true
1bfb612ed8408426e7cc5c6a28ad3393e797844d
ardenercelik/Python
/convert_to_alt_caps.py
1,093
4.40625
4
""" Write a function named convert_to_alt_caps that accepts a string as a parameter and returns a version of the string where alternating letters are uppercase and lowercase, starting with the first letter in lowercase. For example, the call of convert_to_alt_caps("Pikachu") should return "pIkAcHu". """ def conver...
true
5ae848cedbd3dd5b0cc94f0404dd7e9daf40b638
Bashir63/pands
/code/Week02/bmi.py
454
4.28125
4
# This is my first weekly problem solving program for this course # This program calculates the user's BMI using their inputs # Author : Bashir Ahammed # inputs for user's height and weight weight = float (input ("Enter weight: ")) height = float (input ("Enter height: ")) # Conversion of centimeters to meter squa...
true
a6589717a9591f153892ead3989283aa4e676401
PriyankaSahu1/Practise-Python
/handson/handson15.py
409
4.125
4
#handson 15 list=["abc","bcd","jkl","xyz","mno"] #using membership operator if("abc" in list): print("abc is available") else: print("abc is not present") #without using membership operator for i in range(5): if(list[i]=="abc"): print("available") break else: p...
true
d425842338650746eb7de3fc1a2ad7d922c0deaa
stellakaniaru/simple-python-games
/tictactoe.py
1,375
4.125
4
''' Tic Tac Toe game. ''' import random def drawBoard(board): # This function prints out the board that it was passed. # "board" is a list of 10 strings representing the board (ignore index 0) print(' | |') print(' ' + board[7] + ' | ' + board[8] + ' | ' + board[9]) print(' | |') print('-----------') pri...
true
3821a69333bbbe017c04c25f68df88c3b3c61706
ramesh1990/Python
/Easy/stock.py
894
4.28125
4
''' Stock Buy Sell to Maximize Profit The cost of a stock on each day is given in an array, find the max profit that you can make by buying and selling in those days. For example, if the given array is {100, 180, 260, 310, 40, 535, 695}, the maximum profit can earned by buying on day 0, selling on day 3. Again buy on...
true
aa9e99206b9458bbb76c6e2d557d63301e5662ce
lavenderLatte/python_practice
/word_autoCorrection/edit_distance.py
2,024
4.28125
4
""" Function to compute edit distance between two words. Edit distance -- the minimum number of +, -, r operations that are needed to convert str2 to str1. +, -, r are addition, subtraction and replacement. For example: str1 = "abc", str2 = "ac". edit distance is 1 --> addition of b str2. str1 = "abc", str2 = "axc". ...
true
c8acc4486cb24f3219cda93255d5c0a822483cf9
GeburtstagsTorte/Homework
/Projects/Genetic Algorithm/Bubble Arena/Populations.py
1,105
4.46875
4
""" Step 1: Initialize: Create a population of N elements, each with randomly generated DNA (genes) (drawing) Step 2: Selection: Evaluate the fitness of each element of the population and create a pool (mating pool) Step 3: Reproduction: a) Pick two parents with probability according to t...
true
45b58f45a716e59aea24bf7b11b81b1815a408e9
riadassir/MyFirstRepository
/ex_06_02.py
973
4.5
4
############################################################# # Riad Assir - Coursera Python Data Strucutres Class - ex_06_02.py # Dealing with Files ############################################################# #FileHandle = open('mbox-short.txt') FileName = input('Enter the file name: ') try: FileHandle = open(...
true
92e6e640eca88f65c651ef4b156992b7fb8c52fb
dtauxe/hackcu-ad
/plot.py
2,690
4.15625
4
#!/bin/python # From: # https://stackoverflow.com/questions/6697259/interactive-matplotlib-plot-with-two-sliders from numpy import pi, sin import numpy as np import matplotlib.pyplot as plt from matplotlib.widgets import Slider, Button, RadioButtons import math # Draw the plot def do_plot(sigstr): def signal(t): ...
true
8bf9e58c2d775db3e3c77f7e852de92dc521be55
jjennas/web-ohjelmointi
/assignment2/2.py
621
4.21875
4
import re, statistics #function finds numbers in string def finding_numbers(s): return re.findall(r"-?\d+",s) answer = input("Give integers, can be separated by any character") if not answer: print("Please input integers separated by any character") else: numbers = finding_numbers(answer) # Tries to co...
true
98eb13251a8780adc7acdb61c5db8fec32e1a741
lw2533315/leetcode
/uniquePaths_test.py
876
4.40625
4
# A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). # The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). # How many possible unique paths are there? ...
true
9346d7d92949c4037d1bf5a76b65b48b2a398276
newmayor/pythonlearning
/selectionSort.py
666
4.1875
4
def selSort(L): """Assumes that L is a list of elements that can be compared using >. Sorts L in ascending order. """ suffixStart = 0 while suffixStart != len(L): #look at each element in suffix for i in range(suffixStart, len(L)): if L[i] < L[suffixStart]: #...
true
c947b7d0e412238a284ce7a8ca8515b77ff454a6
newmayor/pythonlearning
/ex_IO.py
2,724
4.1875
4
def print_numbers(numbers): print("These are the currently stored phone numbers: ") for k, v in numbers.items(): print("Name:", k, "\tNumber:", v) print() def add_number(numbers, name, number): numbers[name] = number #use a dict to define name as the dict key and the associated number as the ...
true
a4ce076b6389af67d906657b1653cdaad0e5996e
the-aerospace-corporation/ITU-Rpy
/tiler.py
1,472
4.25
4
# -*- coding: utf-8 -*- """ Turns a rectangle into a number of square tiles. Created on Thu Oct 15 17:24:31 2020 @author: MAW32652 """ def tiler(m, n, dimList = []): """ Tiler outputs the size of the tiles (squares), that are required to fill a rectangle of arbitrary dimension. Note: It does ...
true
a429f0cf76e5617d958e23514f1a4ba2d67d6e4f
rock-chock/leetcode
/412_fizzbuzz.py
804
4.125
4
""" https://leetcode.com/problems/fizz-buzz/ Write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three and five output “FizzBuzz”. """ ...
true
e3551871af7f069111a413ee63db06796503aa90
Tylerman90/PythonPractice
/odd_even_funk.py
821
4.375
4
#Write a program that reads a list of integers, #and outputs whether the list contains #all even numbers, odd numbers, or neither. #The input begins with an integer #indicating the number of integers that follow. def user_values(): my_list = [] num_in_list = int(input()) for num in range(num_in_list): ...
true
f145873536f4f3fcdec1bfc5fcc8cb065f5742f6
kapiltiwari1411/python-lab
/kapil4reverse.py
246
4.25
4
#program to find reverse of enterd number. num=int(input("please enter any number")) reverse=0. while(num>0): reminder=num%10 reverse=(reverse*10)+reminder num=num//10. print(" reverse of the entered number\n", reverse)
true
a37d0bfdb5defc86998701657f9c11ff27113a1a
ItsPepperpot/hangman
/hangman.py
2,362
4.125
4
# Hangman. # Made by Oliver Bevan in July 2019. import random print("Welcome to hangman!") menu_choice = 0 while menu_choice != 3: print("Please pick an option.") print("1. Begin game") print("2. Show rules") print("3. Exit") menu_choice = int(input()) if menu_choice == 1: # Begin game. ...
true
cbd3e856cce1ba5c088408c9722989b82ee30709
JamieBort/LearningDirectory
/Python/Courses/LearnToCodeInPython3ProgrammingBeginnerToAdvancedYourProgress/python_course/Section3ConditionalsLoopsFunctionsAndABitMore/22ExerciseLoops.py
1,226
4.28125
4
# First of two. # Create a program that asks a user for 8 names of people. # Store them in a list. # When all the names have been given, pick a random one and print it. # Second of two. # Create a guess game with the names of colors. # At each round pick a random color and let the user guess it. # After a successful g...
true
7096d9987e86cdc601fa4d2fbb6f748b69a4eb00
Youngjun-Kim-02/ICS3U-Assignment2-python
/volume_of_cone.py
726
4.40625
4
#!/usr/bin/env python3 # Created by: Youngjun Kim # Created on: April 2021 # This program calculates the volume of a cone # with radius and height inputted from the user import math def main(): # this function calculates the volume of a cone # main function print("We will be calculating the area of ...
true
4b80e51dc0a98003cf82bc271886b0b61ff284e7
sinugowde/PythonWorkSpace
/PP_006.py
433
4.21875
4
# PythonPractice_006: Polindrome def checkPolindrome(stringVar): for i in range(0, len(stringVar)//2): if stringVar[i] != stringVar[-i-1]: resVar = False break resVar = True return resVar # Main Function/Method stringVar = input() resVar = checkPolindrome(stringVar) if resVar: print("the Entered string...
true
a2cbae5516ae86338884900c57ea0a60433b8260
bradweeks7/CPE202
/Labs/Lab1/lab1/lab1.py
933
4.3125
4
def max_list_iter(int_list): # must use iteration not recursion """finds the max of a list of numbers and returns the value (not the index) If int_list is empty, returns None. If list is None, raises ValueError""" if int_list == None: raise ValueError # An empty list should return None if len(...
true
a93d3bd1ef9fee237e33689359553aef83b26b22
sdawn29/cloud-training
/list_ex.py
1,317
4.375
4
#list -> class l1 = list([10, 20, 30]) # a list of 3 elements l2 = [10, 12.5, 'python', ['a','b']] #shortcut of creating a list print(l2) print(l2[1]) print(l2[2][1]) print(l2[-1:1:-1]) #add element ot the list l2.append(200) print('append=',l2) l2.insert(2,300) print('Insert=',l2) l3 = [10,20] l4 ...
true
8eb9843678140e25e75f2a9030c2480d0fdd649c
SafiyatulHoque/Bootcamp-NSU
/Bootcamp 11/Pre Bootcamp Contest 11 (1)/Q.py
436
4.625
5
# Python3 code to demonstrate # to extract words from string # using split() # initializing string test_string = 'Adventures in Disneyland Two blondes were going to Disneyland when they came to a fork in the road. The sign read: "Disneyland Left." So they went home.' # printing original string print ("The original st...
true
66ea622dc4018f5849cb4a2f938a7837ae418635
shreyansh-tyagi/leetcode-problem
/power of 2.py
808
4.25
4
''' Given an integer n, return true if it is a power of two. Otherwise, return false. An integer n is a power of two, if there exists an integer x such that n == 2x. Example 1: Input: n = 1 Output: true Explanation: 20 = 1 Example 2: Input: n = 16 Output: true Explanation: 24 = 16 Example 3: Input: n = 3 Output...
true
0c121b96785c7586221dd6a08d0a5ec24ee5abaf
shreyansh-tyagi/leetcode-problem
/wildcard matching.py
1,248
4.28125
4
''' Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*' where: '?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence). The matching should cover the entire input string (not partial). Example 1: Input: s = "...
true
926c7b7076a25daef60b3d3b300670b30e73e575
shreyansh-tyagi/leetcode-problem
/backspace string compare.py
1,175
4.125
4
''' Given two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character. Note that after backspacing an empty text, the text will continue empty. Example 1: Input: s = "ab#c", t = "ad#c" Output: true Explanation: Both s and t become "ac". Example 2...
true
4d5d7368ff9248788d9fbd3acf136b51a8f35c00
shreyansh-tyagi/leetcode-problem
/planning a meeting.py
1,748
4.25
4
''' You have to organize meetings today. There are meetings for today. Meeting must start at time and end at time . Unfortunately, there are only two meeting rooms available today. Consider meetings and intersecting in time if . You cannot conduct two meetings in the same room at the same time. Your task is to d...
true
18e31179f424c66e561bcd7d88536f73381c423e
shreyansh-tyagi/leetcode-problem
/permutations.py
662
4.125
4
''' Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. Example 1: Input: nums = [1,2,3] Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] Example 2: Input: nums = [0,1] Output: [[0,1],[1,0]] Example 3: Input: nums = [1] Output: [[1]] ...
true
cc19150ea53ef523c336039b30c3d79dfd12fdd2
ElizabethRoots/python_practice
/mini_projects/ft_converter.py
711
4.40625
4
#!/usr/bin/env python3 import sys height = float(input("Enter your height in the format: ft.in ")) inches = height * 12 dvd = 7.48 creditCard = 3.375 iPadAir = 9.4 select = int( input("Select unit of measurement: 1 = DVD case, 2 = Credit Cards, 3 = iPad Air Gen-One ")) def divide(inches, select): formatted...
true
351ecae3df591709bba7a5ad0e0c44005338b615
calebhews/Ch.08_Lists_Strings
/8.0_Jedi_Training.py
1,650
4.46875
4
# Sign your name: Caleb Hews ''' 1.) Write a single program that takes any of the three lists, and prints the average. Use the len function. There is a sum function I haven't told you about. Don't use that. Sum the numbers individually as shown in the chapter. Also, a common mistake is to calculate the average each ti...
true
fa2880ed5dfb7e0fe4986a84097af2ca38aa0eb4
FazeelUsmani/Scaler-Academy
/017 String Algorithm/A3 reverseString.py
1,038
4.28125
4
/* Reverse the String Problem Description Given a string A of size N. Return the string A after reversing the string word by word. NOTE: A sequence of non-space characters constitutes a word. Your reversed string should not contain leading or trailing spaces, even if it is present in the input string. If there are mult...
true
37209057e5842fb3a827b0588918d4ee291bcdfd
k4u5h4L/algorithms
/leetcode/Symmetric_Tree.py
935
4.34375
4
''' Symmetric Tree Easy Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center). Example 1: Input: root = [1,2,2,3,4,4,3] Output: true Example 2: Input: root = [1,2,2,null,3,null,3] Output: false ''' # Definition for a binary tree node. # class TreeNode: # ...
true
a8ffbc2d433ae45bf4f87875e663b4853be83cc2
k4u5h4L/algorithms
/nuclei/max_profit.py
486
4.15625
4
''' For the given array of length and price find the maximum profit that can be gained. ''' def maxProfit(prices): max_profit = 0 min_price = prices[0] for price in prices: min_price = min(price, min_price) max_profit = max(max_profit, price - min_price) return m...
true
fb775e5361af5b84e1b1be3bae5f526bab67ea19
k4u5h4L/algorithms
/leetcode/ZigZag_Conversion.py
1,955
4.34375
4
''' ZigZag Conversion Medium The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take a...
true
f6846b1ccb90f6eb86bee2970132941cf498c102
k4u5h4L/algorithms
/leetcode/Second_Largest_Digit_in_a_String.py
1,017
4.28125
4
''' Second Largest Digit in a String Easy Given an alphanumeric string s, return the second largest numerical digit that appears in s, or -1 if it does not exist. An alphanumeric string is a string consisting of lowercase English letters and digits. Example 1: Input: s = "dfa12321afd" Output: 2 Explanation: The ...
true
0a7df1ce50f54435c9a653bd0c4c5bc54e6179a9
k4u5h4L/algorithms
/leetcode/Rotate_Image.py
1,123
4.46875
4
''' Rotate Image Medium You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise). You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation. Example 1: Input: matrix = [[1,2,3],[...
true
cc9934f6d827570fd8bb3ad05b6acc36b3c37495
k4u5h4L/algorithms
/leetcode/Add_to_Array-Form_of_Integer.py
508
4.1875
4
''' Add to Array-Form of Integer Easy The array-form of an integer num is an array representing its digits in left to right order. For example, for num = 1321, the array form is [1,3,2,1]. Given num, the array-form of an integer, and an integer k, return the array-form of the integer num + k. ''' class Solution...
true
f2da2236b2af5e8cc428d8bc6dac3e08b19e574c
k4u5h4L/algorithms
/leetcode/Set_Matrix_Zeroes.py
926
4.28125
4
''' Set Matrix Zeroes Medium Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's, and return the matrix. You must do it in place. Example 1: Input: matrix = [[1,1,1],[1,0,1],[1,1,1]] Output: [[1,0,1],[0,0,0],[1,0,1]] Example 2: Input: matrix = [[0,1,2,0],[3,4,5,2],[1,...
true
8a91d4bf14c9215077834ed74748ee2e6b8fa163
TheHugeHaystack/Solucion-a-problemas-con-Programacion
/temperature.py
1,636
4.65625
5
#Code by: rghost Academic Purposes #This code is to do the following: # Write a program that will prompt the user for a temperature asking the user between Fahrenheit and Celsius; # then, convert it to the other. You may recall that the formula is C = 5 ∗ (F − 32)/9. # Modify the program to state whether or not...
true
69ba50bcd982901a944ae4c5be100dce7ceebe79
mrinfosec/cryptopals
/c10.py
2,265
4.15625
4
#!/usr/bin/python # Implement CBC mode # CBC mode is a block cipher mode that allows us to encrypt irregularly-sized # messages, despite the fact that a block cipher natively only transforms # individual blocks. # # In CBC mode, each ciphertext block is added to the next plaintext block before # the next call to the ci...
true
8be0d2e9a8d67dcad48786a68b37d216bee1b28d
cdean00/PyNet
/pynetweek4_excersise3.py
1,361
4.21875
4
""" Week 4, Excersise 3 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ III. Create a program that converts the following uptime strings to a tim...
true
aa7924e7483d1757d0ebf8e3b8ed6008f143060d
nilskingston/String-Jumble
/stringjumble.py
1,277
4.28125
4
""" stringjumble.py Author: Nils Kingston Credit: Roger Assignment: The purpose of this challenge is to gain proficiency with manipulating lists. Write and submit a Python program that accepts a string from the user and prints it back in three different ways: * With all letters in reverse. * With words in reverse...
true
a60fd066512a2fe60e465b8556d046b344e94dc3
Kalpesh14m/Python-Basics-Code
/Basic Python/8 Function.py
756
4.34375
4
# The idea of a function is to assign a set of code, and possibly variables, known as parameters, to a single bit of text. # You can think of it a lot like why you choose to write and save a program, rather than writing out the entire program every time you want to execute it. # # To begin a function, the keyword 'def'...
true
124765cd61ad7ba8518b3027531cfc5b535ad353
Kalpesh14m/Python-Basics-Code
/Basic Python/TKinter/33 Tkinter intro.py
1,268
4.3125
4
""" The tkinter module is a wrapper around tk, which is a wrapper around tcl, which is what is used to create windows and graphical user interfaces. Here, we show how simple it is to create a very basic window in just 8 lines. We get a window that we can resize, minimize, maximize, and close! The tkinter module's purpo...
true
b4b3bff8bf1922b70e8d3e38af1fbb69e30f318e
smrmkt/project_euler
/problem_001.py
822
4.21875
4
#!/usr/bin/env python #-*-coding:utf-8-*- ''' 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. ''' import timeit # slow # simple loop def loop(n): t = 0 for i in range(1, n...
true
262e88040edd2f5724ed93e282e5945b07d52d01
ismailasega/Python_Cert_2019
/Python Basics/Q2.py
267
4.28125
4
#accepts a sequence of words as input and prints the words in a sequence after sorting them alphabetically. str = input("type 7 names, then press enter: \n ") names = str.split() names.sort() print("The names in alphabetic order:") for name in names: print(name)
true
833c17c00e98c40643bf0db2a04220a48e77b7a2
ismailasega/Python_Cert_2019
/Data visualisation/CaseStudy1/Qn1.py
616
4.34375
4
# You are given a dataset, which is present in the LMS, containing the number of # hurricanes occurring in the United States along the coast of the Atlantic. Load the # data from the dataset into your program and plot a Bar Graph of the data, taking # the Year as the x-axis and the number of hurricanes occurring as the...
true
177170fd7f050b898cb18642d6e22e9ab45dccad
Falsaber/mhs-python
/Basics Tutorial #1 - Python.py
2,065
4.125
4
#This is a comment. #Comments are ignored during code activation. print("The shell will print what is contained within this area.") var = input("var will now become a variable that can be called upon later. var is now:") print(var) #This will print the text in the variable "var" and require a response. #input asks for...
true
60db9080ef8cf89aed97749191a024bc2bb50e42
jvillega/App-Academy-Practice-Problems-I
/SumNums.py
456
4.4375
4
#!/usr/bin/env python3 # Write a method that takes in an integer `num` and returns the sum of # all integers between zero and num, up to and including `num`. # # Difficulty: easy. # Precondition: num is a defined integer # Postcondition: sum of all integers between zero and num are returned def sumNums( num ): ...
true
ea70a815fe1af0e4a9d744be5e65716583d905b0
shefreyn/Exercise_1-100
/Ex_(2).py
498
4.21875
4
print('__ Tip Calculator __') totalBill = input('Total bill amount : ') totalBill = int(totalBill) percentage = input('Percentage you would like to tip : ') percentage = int(percentage) totalPeople = input('Total no of people you want to split the bill : ') totalPeople = int(totalPeople) tip = percentage/totalBi...
true
7cf1e38bed3059b0e455ee77a91c394c7307b3d4
gitBlackburn/Learn-Python-The-Hard-Way
/ex15.py
614
4.21875
4
# uses argv from the sys lib # adds arguments # from sys import argv # # two arguments scripts and filename # script, filename = argv # # opens the text file and stores it in txt # txt = open(filename) # # notifies the user # print "Here's your file %r:" %filename # # reads the text file # print txt.read() # promp...
true
84252e3008a9d3e59636948801cff89ef25ae676
samfrances/coding-challenges
/codewars/6kyu/write_number_in_expanded_form.py
875
4.1875
4
#!/usr/bin/env python3 """ Solution to https://www.codewars.com/kata/5842df8ccbd22792a4000245/ You will be given a number and you will need to return it as a string in Expanded Form. For example: expanded_form(12) # Should return '10 + 2' expanded_form(42) # Should return '40 + 2' expanded_form(70304) # Should retur...
true
959d90c339a63bc8fe81a2c82cf03d06fed6a3d6
samfrances/coding-challenges
/codewars/5kyu/calculating_with_functions.py
1,685
4.40625
4
#!/usr/bin/env python2 """ Solution to https://www.codewars.com/kata/525f3eda17c7cd9f9e000b39/ This time we want to write calculations using functions and get the results. Let's have a look at some examples: JavaScript: seven(times(five())); // must return 35 four(plus(nine())); // must return 13 eight(minus(three(...
true
f688003052f4e3dff5422dc4eb669322434fc3b4
Biraja007/Python
/Looping-Statements.py
1,423
4.625
5
# Looping statements is used to repeatedly perform a block of operations. # For loop: It is used to iterate over a sequence starting from first value to the last. Numbers = [1,2,3,4,5] for number in Numbers: print (number , end=' ') print() print() # While loop: It is used to repeatedly execute a block of ...
true
027f5fd55ea60cddc723d52fd8bcba69789f7f8c
bondarum/python-basics
/examples/ex19_object_and_classes.py
2,575
4.375
4
# class # Tell Python to make a new type of thing. # object # Two meanings: the most basic type of thing, and any instance of some thing. # instance # What you get when you tell Python to create a class. # def # How you define a function inside a class. # self # Inside the functions in a class, self ...
true
2c0499d4e9b9a35f6b5157932fa2d58bcdf5f7d3
bnsreenu/python_for_microscopists
/052-GMM_image_segmentation.py
2,975
4.125
4
#!/usr/bin/env python __author__ = "Sreenivas Bhattiprolu" __license__ = "Feel free to copy, I appreciate if you acknowledge Python for Microscopists" # https://www.youtube.com/watch?v=kkAirywakmk """ @author: Sreenivas Bhattiprolu NOTE: I was alerted by one of the viewers that m.bic part needs more explana...
true
15acd9528c16d6b48e195e8d34fec459cd356560
hossainlab/numpy
/book/_build/jupyter_execute/notebooks/07_ChangingShapeOfAnArray.py
1,828
4.125
4
#!/usr/bin/env python # coding: utf-8 # ## Array Shape Manipulation # In[1]: import numpy as np # ### 1. Flattening # In[2]: a = np.array([("Germany","France", "Hungary","Austria"), ("Berlin","Paris", "Budapest","Vienna" )]) # In[3]: a # In[4]: a.shape # #### The ravel() function # The...
true
aa0b0faf17e8610c304726adae4c0ec31b4ecdc4
subramario/Data_Structures_Algos_Practice
/Sorting/Quicksort.py
1,711
4.15625
4
#Classic quicksort - chooses the first element in the array as the pivot point and sorts accordingly class Solution: def partition(self, array, start, end): # [start|low_ _ _ _ _ _high] --> Three pointers pivot = array[start] low = start + 1 high = end while True: ...
true
a0e48325dedb2e416c7ac28f68cf33202886cdc5
laomao0/Learn-python3
/Function/ex20.py
876
4.125
4
from sys import argv script, input_file = argv def print_all(f): print(f.read()) # Each time you do f.seek(0) you're moving to the start of the file # seek(0) moves the file to the 0 byte(first byte) in the file def rewind(f): f.seek(0) # each time you do f.readline() you're reading a line from the file ...
true
cfe855ef9cdf7a05a083fd5c3b39ef1b20e16589
sushmitaraii1/Python-Datatypes-Fucntions
/Function/15.py
226
4.15625
4
# 15. Write a Python program to filter a list of integers using Lambda. lst = [1, 5, 6, 4, 8, 5, 6, 9, 5, 3, 5, 9] sorted_list = list(filter(lambda x:x%2==0,lst)) print("The even numbers from list are: ") print(sorted_list)
true
158c692aa383ca6f426cabf70d2dc45db3de20b5
sushmitaraii1/Python-Datatypes-Fucntions
/Function/16.py
319
4.25
4
# 16. Write a Python program to square and cube every number in a given list of # integers using Lambda. lst = [1, 5, 6, 4, 8, 5, 6, 9, 5, 3, 5, 9] print(lst) print("After squaring items.") square = list(map(lambda x:x**2,lst)) print(square) print("After cubing items.") cube = list(map(lambda x:x**3,lst)) print(cube)
true
f3a5622a1badea10083c9a1990aefbcdef124dfa
sushmitaraii1/Python-Datatypes-Fucntions
/Datatype/2.py
480
4.40625
4
# 2. Write a Python program to get a string made of the first 2 and the last 2 chars # from a given a string. If the string length is less than 2, return instead of the empty string. # Sample String : 'Python' # Expected Result : 'Pyon' # Sample String : 'Py' # Expected Result : 'PyPy' # Sample String : ' w' # Expected...
true
8ccf58ee6e37889d78fff8fdc2a21a5ec99c10e3
sushmitaraii1/Python-Datatypes-Fucntions
/Function/17.py
201
4.125
4
# 17. Write a Python program to find if a given string starts with a given character # using Lambda. start = lambda x: True if x.startswith('P') else False print(start('Python')) print(start('Java'))
true
e089c675631f21a21b35ab49e805bc7016d337f1
jingyiZhang123/leetcode_practice
/dynamic_programming/62_unique_paths.py
824
4.1875
4
""" A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). How many possible unique paths are there...
true
2b31d4a4790e35c9d384e9c8f3e8c1bd3eb19696
jingyiZhang123/leetcode_practice
/recursion_and_backtracking/17_letter_combinations_of_a_phone_number.py
1,025
4.15625
4
""" Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. 2: abc 3: def 4: ghi 5: jkl 6: mno 7: pqrs 8: tuv 9: wxyz Input:Digit string "23" Output: ["ad", "ae", "af", "bd", "be", "...
true
830e22e15f52ce5d1d0eb65a39c1ea345caadf5a
gokarna123/Gokarna
/classwork.py
333
4.125
4
from datetime import time num=[] x=int(input("Enter the number:")) for i in range(1,x+1): value=int(input(" Please Enter the number: ")) num.append(value) num.sort() print(num) num=[] x=int(input("Enter the number:")) for i in range(1,x+1): value=int(input(" Please Enter the number: ")) num.reverse()...
true