blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
ffa1662468fe13c126535cae3c4a68d6c3dbe9c6
Harelyac/Python-PROJECTS
/Wikipedia Network/article.py
2,085
4.59375
5
class Article: """ The constructor of Article make an Article object that consist of 2 fields which are title and neighbor - a list that contains more Article objects! """ def __init__(self, article_title): self.__title = article_title self.__neighbors = [] def get_titl...
true
c86f34b28f333c39877855cb0d5555f80e1035e0
nsm-lab/principles-of-computing
/practice_activity3.py
2,484
4.34375
4
# Practice Activity 3 for Principles of Computing class, by k., 07/04/2014 # Analyzing a simple dice game (see https://class.coursera.org/principlescomputing-001/wiki/dice_game ) # skeleton code: http://www.codeskulptor.org/#poc_dice_game_template.py # official solution: http://www.codeskulptor.org/#poc_dice_game_solut...
true
3e840900dee1013038c152b6a6410999b2987e56
sreit/temp_converter
/temp.py
2,124
4.375
4
while True: try: start_degree = float(input('Enter a temperature: ')) break except ValueError: print('ERROR. Not a number.') continue start_unit_list = ['C', 'F', 'K'] start_unit = input('What unit is this? (C, F, K): ').upper() while start_unit not in start_unit_list: print...
true
62f3131125935949819ec706228572e18949a43a
neelchavan/Python
/Dictionary.py
325
4.34375
4
#here we are using dictionaries to give the meaning of some words to the user d1 = {'mes':'In english it means \'more\'','que':'In english it means \'Than\'','un':'In english it means \'A\'','club':'In english it means \'Club\''} #Enter the word to get the meaning of it Word = input("Enter the word\n",) print(d1[Word...
true
642813fb40fa3b52729d1354b74ccb02e6b5e087
neelchavan/Python
/get2ndlargest.py
274
4.125
4
#Unsorted list with duplicates numbers = [3,4,2,4,6,6] #removing duplicates numbers = list(dict.fromkeys(numbers)) #sort the list numbers.sort() #remove first max number numbers.remove(max(numbers)) #then print second highest number as the first highest print(max(numbers))
true
d8d8606d1460657f3b2775228ef03a1bc59f3836
markfj81/Geog565_Assign1
/Assignment1_Part1_[Johnson].py
644
4.3125
4
# Instructions: # Create a script that examines the following string for a particular letter. # "Python in GIS makes work easier". # If the string does contain your letter, the script should print # "Yes, the string contains the letter." # If not, the script should print "No, the string does not contain the lett...
true
306c87093bb07bd010f215455f2c13f0312cf161
ComradYuri/Statistics-LinearRegression
/script.py
1,790
4.125
4
import pandas as pd import matplotlib.pyplot as plt import numpy as np from sklearn import linear_model # Setting up pandas so that it displays all columns instead of collapsing them desired_width = 320 pd.set_option('display.width', desired_width) np.set_printoptions(linewidth=desired_width) pd.set_option('display.ma...
true
6abd018955ab20d6756c7003351bdb0701f80b01
AishaE/Python
/hello_world.py
833
4.15625
4
# 1. TASK: print "Hello World" print("Hello World") # 2. print "Hello Noelle!" with the name in a variable name = "Aisha" print("Hello" , name ) # with a comma print("hello" + name ) # with a + # 3. print "Hello 42!" with the number in a variable name = 7 print("Hello" , name ) # with a comma # print("Hello" + name ) #...
true
1489ff679d4ee25c2610e4389815f2cf079d7790
ko28/homework
/cs/cs540/p1/p1_weather.py
2,785
4.21875
4
# Name: Daniel Ko # Project 1, CS 540 # Email: ko28@wisc.edu # Some comments were taken from the homework directly import datetime # Distance between points in three-dimensional space, # where those dimensions are the precipitation amount (PRCP), # maximum temperature (TMAX), and minimum temperature for the day (T...
true
24712a41292d204f783818546321cdfc0af3b4bd
Douglass-Jeffrey/Unit-3-08-Python
/leap_year_determiner.py
571
4.3125
4
#!/usr/bin/env python3 # Created by: Douglass Jeffrey # Created on: Oct 2019 # This program determines if a user inputted year is a leap year def main(): # variables leap_year = " is not" # process # input useryear = int(input("Enter a year of your choice:")) print("") # Output if ...
true
b81601d4963cda59a132282ed2fe2627aeb32de0
valleyjo/cs0008
/project-2/activity-4.py
1,936
4.125
4
#Email: amv49@pitt.edu #Name: Alex Vallejo #ID: 3578411 #Date: 2/19/2014 #Description: This program is the game of craps! import random user_name = input("Enter your name: "); #Get the user's name print("\nWelcome " + user_name + "!"); #Print a nice welcome message print("This game of craps was written by Alex Valle...
true
712889dc38bb100d13d8f24e93cd99e9a9a2e19f
Pratik-20/Python-Projects.-
/0038.py
617
4.25
4
""" #PracticeCode: 0038 🎯 FORWARD IF YOU LIKE IT 🎯 Task: Create a program to input a number and check if it is multiple of 2 than print "Sel" , if multiple of 5 then print "fish" or if multiple of both then print "Selfish". Sample :- input - 5 output - fish input - 10 output - Selfish _________&___________________...
true
eb0477cf1ceffeedb167c1dd6ef938210f461e61
kyletruong/epi
/9_binary_trees/1_height_balanced.py
1,711
4.1875
4
# Check if binary tree is height-balanced # Difference in height of left sub-tree and right-subtree is at most 1 from binarytree import BinaryTree, Node from collections import namedtuple def is_balanced(root): # namedtuple makes it more expensive but more readable Node = namedtuple('Node', ['balanced', 'heig...
true
1827f2b72badd7a47848e114b18b69076c919d9a
AshrafulH1/Blackjack
/hand.py
2,967
4.40625
4
""" Module with the class definition of Hand. """ from card import Card class Hand(object): """A Hand is a list of at most 5 Cards. Attributes (hidden): __cards: a list of objects from class Card. Initialized to to an empty list. The length of __cards is no greater than ...
true
12860a786e3e82f215c8693cf1c8d3a04a88fd6a
Aakash7khadka/Data-Structures-and-algorithm-in-python
/gpa.py
655
4.28125
4
print('This is a gpa calculator') print('Please enter all your letter grades, one per line. ') print('Enter a blank line to designate the end. ') points = { 'A+' :4.0, 'A' :4.0, 'A-':3.67, 'B+':3.33, 'B' :3.0, 'B-' :2.67,'C+' :2.33, 'C' :2.0, 'C' :1.67, 'D+' :1.33, 'D' :1.0, 'F' :0.0} num_courses=0 total_points=0 done=...
true
65a396b28dd09da1ad26dc0a1fad0464e41beb73
sirdesmond09/univel
/assignment_bank.py
2,102
4.1875
4
class Bank(): def __init__(self, name, bal = 0): self.name = name self.balance = bal def cash_deposit(self): money = float(input("Enter amount to deposit\n> $")) self.balance = money + self.balance print(f"Your account has been credited with ${money}\nCurrent balanc...
true
d90e15aed6356f01189da8b4e916adcf04ef4e84
SajinKowserSK/algorithms-practice
/mocks/skowser_session2_question2.py
2,451
4.21875
4
# PSEUDOCODE '''get letters in string form pairs for pair in pairs see the string with just the pairs check if valid string get length of string return highest length''' # ANSWER def alternate(n, string): string = string.lower() pairs = helper_get_pairs(string) max = 0 for pair in pairs: alt_...
true
c7739593536ff819851c58af470968eb4bec5ad5
mcsquared2/peopleSorting
/quickSort.py
2,154
4.15625
4
import random from debug import * def quickSort(lst): # call the recursive quicksort function passing in the the first and last indecies in the list quickSortR(lst,0,len(lst)) def quickSortR(lst, startIndex, stopIndex): # if you are only looking at one item in the list, return if stopIndex-startIndex...
true
d9e594b5f898515634c5e0bdcd6815d24e7e1484
taylynne/Python-Exercises
/guessinggame.py
870
4.125
4
# Practise Python # Project Guessing Game One, exercise 9 # 8 June 2018 # I think I've done this before with the lrn 2 automate w/ python stuff, # so it'll be good review... If I can recall exactly what I've done. import random def guessingGame(x): num = random.randint(1,10) while True: if x == num: print("Awe...
true
c1c0a41a8bfa94b7d6c17dc46fcd2738d2fe1167
bestbestb/csca08_exercises
/untitled-4.py
1,553
4.21875
4
def transpose(strlist): ''' (list of str) -> list of str Return a list of m strings, where m is the length of a longest string in strlist, if strlist is not empty, and the i-th string returned consists of the i-th symbol from each string in strlist, but only from strings that have an i-th symbo...
true
afda1d805e9585341f83960345682dae2fed70d8
JacobGT/SQLite3PythonTutorial
/whereClause.py
799
4.5
4
import sqlite3 # Connect to database conn = sqlite3.connect("customers.db") # Create a cursor c = conn.cursor() # Query the database (db) # We want to fetch only certain things from the db, so we use the where function c.execute("SELECT * FROM customers WHERE first_name LIKE 'customer%' ") # A comparison operator us...
true
1cef3a92005e6f28ebb6e86ce851b2830861d91f
fadyboy/playground
/compress_string.py
1,037
4.40625
4
#!/usr/bin/env python3 """ Given an input string 'aaabbdddda', write a function such that the output becomes 'a3bbd4a' Looking at the output, if the count of the character sequence is >= 3, the character is compressed and displayed in the format "{character}{count}, otherwise it is displayed the number of times it appe...
true
2f03f7a5b3d9e474b9bab430cad6cea910cbd384
ieferreira/algorithms
/PyBetter/2021-III/01-membership_test.py
525
4.3125
4
# %% # Check if a variable is contained in some multiple values # %% c = 2 x, y, z = 12, 2, 3 if any(i == c for i in (x, y, z)): print("exists") else: print("does not exist") # %% # Membership test with list if c in [x, y, z]: print("It exists!") else: print("It does not exist!") # Membership test w...
true
f3474d35fee19a6e4a94cc0a4da661e221013ff5
wmartin007/ATBS
/passingReference.py
310
4.21875
4
# To display how arguments get passed to functions as references def eggs(someParameter): someParameter.append('Hello') spam = [1, 2, 3] eggs(spam) print(spam) """Notice that when eggs is called, we don't have to assign it to a new variable and print that variable. It modifies the list in place. """
true
77db19955ac0c1f8461b5a38f8d71f7b8b324311
Jovan253/Year-12-Computer-Science
/programming techniques/Basics/rock-paper-scissors (2).py
2,015
4.59375
5
from random import randint print("Lets play rock paper scissors, First to Three!!!") print("Enter 1 for rock") print("Enter 2 for paper") print("Enter 3 for scissors") player_score = 0 comp_score = 0 ### SRC - You typically put import statements at the top of the file while player_score != 3 or comp_score != 3: ##...
true
5f440aa34297949a67e99a472fad682b1ae4fe46
NJC-Spicy-Chef/Slide-2-Conditions-and-Loops
/Guessing number Exercise 4.py
896
4.125
4
# Exercise - 4 Guessing numbers. Write a program that chooses an integer between 0 and 100, inclusive. # The program prompts the user to enter a number continuously until the number matches the chosen number. # For each user input, the program tells the user whether the input is too low or too high, so the user...
true
875f98bf03f353130270cec93b79f455f66b97e3
sotomaque/Python-Coding-Interview-Questions
/firstRecurring.py
896
4.125
4
''' problem: given a string of N characters, return the first recurring character in a string input: string output: character solution 1: first look at character @ index 0 see if you can find it in subsequent string i.e. Given "DBCABA" look for 'D' in "BCABA" run complexity: N choose(2) -> (n)(n-1)/2 -...
true
759ad5b9fb882ed28c10a2ae2abf0bd789e152dd
sotomaque/Python-Coding-Interview-Questions
/secondLargest.py
662
4.25
4
''' problem: given an array, find and return the second largest number in the array ''' def secondLargest(givenArray): '''ideas: 1) sort array, delete largest element, return new max ''' if len(givenArray) == 0 or len(givenArray) == 1: return n = [None] * (len(givenArray) - 1) for i in range(len(givenArr...
true
b7a89ecee230f8b2f0859ecc07e6238a1911a8a3
kyu21/Hunter-CS-Assignments
/127/05/cipher.py
1,037
4.40625
4
def encode_letter(c,r): newVal = ord(c) + r # stores shifted value of letter if c.islower(): # determines if letter is uppercase or lowercase if newVal > ord('z'): # if shifted value is greater than z, loop it back to a newVal -= 26 elif newVal < ord('a'): # if shifted value is less than a, loop back to ...
true
0568592d619ce93f94507b01c61fa69ef315a1dd
sonukrishna/Anandh_python
/chapter_6/q1_product.py
377
4.25
4
""" multiply 2 numbers recursively using + and - operators only. """ def product(x,y): if y==0 or x==0: return 0 # if abs(y)==1: # return 1 if x<0 and y<0: return abs(x)+product(abs(x),abs(y)-1) elif x<0 and y>0: return x+product(x,abs(y)-1) elif x>0 and y<0: return -x+product((-x),abs(y)-1) ...
true
8a5abbd68bad7dfe6fb09d9bad7031a22a05d797
sonukrishna/Anandh_python
/chapter_6/flatten_list.py
254
4.15625
4
"""flatten a nested list """ def flatten(a,result=None): if result is None: result=[] for x in a: if isinstance(x,list): print x flatten(x,result) else: result.append(x) return result print flatten([1,[2,3,4],[5,6],7])
true
8802412197dee90a1ae9577d557950133d11a6cf
malav-parikh/python-for-data-science
/sequence data types.py
2,494
4.34375
4
# python for data science # sequence data types # sequence object initialization # STRING strSample = 'Malav' print(strSample) # strings are immutable i.e. they cannot be changed or altered # LISTS lstNumbers = [1,2,3,3,3,4,5,6] print(lstNumbers) # this is a list containing only numbers basically a single data typ...
true
b88dbcbb26dca5161cc5a302d4d9ff3a6589b540
ElijahBahm/CSE
/Elijah Bahm - Guessgame.py
840
4.1875
4
import random # Elijah Bahm # Initializing Variables number = (random.randint(1, 50)) print("Guess a number 1-50.") guess = "0" guesses = 0 # Describes one turn. The while loop is the Game Controller. while int(guess) != number and guesses < 5: guess = input("What is your guess?") if guess == str(number): ...
true
ad1f5916c1aaa15b30eaf9903aea9a0e37912745
isaac-friedman/codecademy
/python/exercise-3_area_calculator.py
1,085
4.28125
4
""" This program calculates the area of a various shapes. Author: Isaac Friedman """ print "We're running. I'd rather not be running." option = raw_input("What shape are we calculating for today? Enter R for rhomboid (including squares, rectangles and parrallelograms), C for Circle and T for Triangle.") i...
true
db18f8dd4a4f492f85c6cd618659e77d6794dfe7
Jaideep24/Projects
/Test Generator/TestTaker (4).py
1,232
4.34375
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: name=input("Enter name") osnv=input(f"Hello {name}, this test has been made to see how much you have understood your chapter, it contains objective type questions from the notes you have and have to be answered in few words, your final marks will be displayed after your...
true
cc549dd9d3f1d9fb8f761054cbc81f3cacd4701c
rc4gh2021/capstone_evaluation
/capstone_evaluation.py
2,778
4.15625
4
#capstone evaluation point calculator #small light weight python to help you avoid headache calculate your points #All you need is python3 on you machine #Author: Rithea #Date: 7/27/2021 P1 = input("enter your name: ") P2 = input("enter your first teammate name: ") P3 = input("enter your second teammate name: ...
true
3fbb4531198059f81e3481cc838be41889c95fc6
thiernodiallo222/Intro-Python-I
/src/13_file_io.py
942
4.25
4
""" Python makes performing file I/O simple. Take a look at how to read and write to files here: https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files """ # Open up the "foo.txt" file (which already exists) for reading # Print all the contents of the file, then close the file # Note: pay close...
true
619b2500643a3219307b4436266e80684609698b
abhishekkr/tutorials_as_code
/talks-articles/machine-learning/toolbox/numpy/simple-neural-net.py
2,559
4.25
4
#!/usr/bin/env python3 """ Perceptron: with no inner layers synapse(with weight) (Input) -----------> (Neuron) ---> (output) x {x1w1 + ... + xNwN} ### Training Process * take inputs from training example and put through formula to get neuron's output * calculate error which is difference betw...
true
7dce1847df3c226b66b05086e5ebe489f76db05f
BodaleDenis/Codewars-challenges
/find_the_divisors.py
1,262
4.34375
4
""" Create a function named divisors/Divisors that takes an integer n > 1 and returns an array with all of the integer's divisors (except for 1 and the number itself), from smallest to largest. If the number is prime return the string '(integer) is prime' (null in C#) (use Either String a in Haskell and Result<Vec<u32...
true
e01a3efafba42cb555852b0e795f673958dc7d58
Aussiroth/cpy5python
/Practical 01/q3_miles_to_kilometre.py
257
4.5
4
#File Name: q3_miles_to_kilometre #Author: Alvin Yan #Date Created: 21/3/2013 #Date Modified: 21/1/2013 #Description: Converts miles to kilometers miles = float(input("Input the number of miles\n")) area2=float(miles*1.60934) print ("{0:<.3f}".format(area2))
true
79b47fdd7f8c7c3e15320491e21815bd2dd2f83a
Chris-M-Wagner/Hangman
/Hangman.py
2,475
4.28125
4
""" Creator: Chris Wagner Created Date: 12/03/2015 Last Updated: 12/07/2015 Summary: Hangman is a game that prompts the user to guess a word, letter by letter. Word entries are contained in the Hangman.txt file. """ import random def Party_Time(): guessUL = 3 #The amount of guesses the user has. tries ...
true
85922ca99399f57013fa5dc24d97d0832f5a70d1
rajcaptainindia/Assignments
/Assignment27.py
782
4.34375
4
import turtle # allows us to use the turtles library wn = turtle.Screen() # creates a graphics window wn.setup(500,500) # set window dimension alex = turtle.Turtle() # create a turtle named alex alex.shape("turtle") # alex looks like a turtle alex.color("black") # alex has a color alex.righ...
true
be02033434d7c261c244b24e3f4c815a28b19448
quirogas/MTH
/homework5.py
1,030
4.15625
4
# Homework 5 __author__ = "Santiago Quiroga" __version__ = "6/Oct/2017" # This function will return a list with the number of trees per backyard. def binarytoanalogy(list): # local variables for value tracking. answer_list = [] counter = 0 # Iterates though the list. for i in list: # Che...
true
afd7884ce39fa87c6ec614af7e050eb270ffa403
geekslayer/python-udemy-blackjack
/game/deck.py
1,611
4.125
4
""" This deck object is at the middle of all this and is a crucial part of the game. """ from random import shuffle from game.card import Card, Suit class Deck(): """ This will hold 52 cards like a regular deck of cards. One by one we will remove the cards from the deck until no more. "...
true
b23dc837b4a45412474a9eaa5a8c1793a8a06237
VGallardo93/lerning_github
/Test.py
854
4.4375
4
# This is a test file in Python 3 print('Welcome to the new file... By vg.\n') name_ = input('Hi. Insert your name: ') while True: if name_.isdigit(): print('\nInvalid name. Please try again.') name_ = input('Insert your name: ') continue else: print(f'\nHi {name_}! Nice to meet you.\n') bre...
true
754b12d78bfb0cf9a8774f06c78bdad65b0f7e49
mohithasan/mathematician
/mathematician.py
1,755
4.25
4
#Welcome to mathematician.py #Developers are Working on the file to improve the file more. #View the terms of uses befor you start using this Module on your work. #----------------------------------------------------------------------- #The code starts here- #To add nmbers, make list of the numbers and call the ...
true
de931e528976d638c99dcad2f91babbc77518fda
jurrehageman/Informatica-1
/Website/informatics1/seminars/solutions02/seminar2_solution/05_solution.py
1,117
4.625
5
# solution for excersize 05 from lecture1 # define a sequence and assign it to a variable #seq = "ATGAGTAGGATAGGCTAGATGGCGATGAATT" seq = "UCAUUAUCAGACGGCAGUUUAUUAUAUAUAU" # convert to upper case: seq_up = seq.upper() # Always check variables by printing them to screen! print("original sequence:", seq_up) # check if ...
true
a7ac8fc5a9f9225339b04e2806d5d4d4484f8582
phqlong/Internship-Odoo
/Python-Exercise/iterator.py
1,488
4.625
5
# Iterable is an object, which one can iterate over. It generates an Iterator when passed to iter() method. # Iterator is an object, which is used to iterate over an iterable object using __next__() method. # Iterators have __next__() method, which returns the next item of the object. # Note that every iterator is a...
true
8d5fa9ede1449711ea7213452274abe6b73a5af2
slerpy/ilikepy
/part2/2.02-99problems.py
2,266
4.375
4
### # a procedure to add one day to a calendar, assuming all months are 30 days. # a test run into building a full calendar. ### ### # commenting out since we have a better method below. ### # def nextDayMeh(year, month, day): # if day == 30: # day = 1 # if month == 12: # month = 1 # ...
true
393461a838e4e9e65c597e4e6df2d3845b5f1eff
CallumBrown/Assignment
/development exercise 3.py
399
4.15625
4
#Callum Brown #16-09-14 #Exercise - Development 3 height_inches = float(input("Please enter your height in inches: ")) weight_stones = float(input("Please enter your weight in stones: ")) height_cm = (height_inches)*2.54 weight_kg = (weight_stones)*6.364 print("Your height in centremetres is: {0}".format(h...
true
da215def7f73a10a97be2578231883a4c1292997
Denimbeard/PycharmProjects
/Programs/Finite State Acceptors/ExampleSolution
2,638
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # This programs implements an FSA. It keeps track of the current FSA's state # in a variable called "STATE". The algorithm traverses the given string and, # depending on the current character, decides what the next state will be. # The INITIAL state is S1, and the ONLY rec...
true
08d0f5f3424b83750b1b35187df6ba8e653d0757
jatinsinghnp/python-3-0-to-master-course
/2_stringformatting/code.py
427
4.21875
4
#f' string string formatting in python # name ="Bob" greeting =f"hellow ,{name}" print(greeting) print(greeting) # creating template name="bob" greeting="hloow,{}" with_name=greeting.format() with_name=greeting.format("nikhil") with_name=greeting.format("jatin") print(with_name) # also kin a make long ...
true
a1e8aefa37ec4814d1e95cd1d77d0a67f2614039
nisabzahid/Analytics
/Programming/Python/Exercises-Basic/Basics/DateDiff.py
583
4.21875
4
'''Write a Python program to calculate number of days between two dates. Sample dates : (2014, 7, 2), (2014, 7, 11) Expected output : 9 days ''' import datetime d1=int(input("Please enter the day of first date : ")) m1=int(input("Please enter the month of first date : ")) y1=int(input("Please enter the year of first ...
true
a752ed3288e1fadce812db8c219a4052ff0f0f3d
mchao409/python-algorithms
/algorithms/search/fibonacci_modulo.py
1,329
4.46875
4
""" Calculating (n-th Fibonacci number) mod m """ def _fib(number): """ Fibonacci number Args: number: number of sequence Returns: array of numbers """ init_array = [0, 1] for idx in range(2, number + 1): init_array.append(init_array[idx - 1] + init_array[idx - 2...
true
d3c97bbecbae737716e1b0a84d38968f2db76c69
aniaHrrera4/Python-Projects
/Python_Projects/ScavHunt1.py
2,651
4.15625
4
""" Pygame base template for opening a window Sample Python/Pygame Programs Simpson College Computer Science http://programarcadegames.com/ http://simpson.edu/computer-science/ Explanation video: http://youtu.be/vRB_983kUMc """ import pygame import random # Define some colors BLACK = (0, 0, 0) WHITE = (255, 2...
true
f14ca98b0da2469335781ab0179e854ae0789565
BenGilbert98/Python_Week_1
/data_types_&_operators.py
558
4.15625
4
# What are data types and Operators # Boolean gives us the outcome in True or False # a = True # b = False # # print(a == b) #False # print(a != b) #True # print(a >= b) #False greetings = "Hello World!" print(greetings.isalpha()) # Checks if letters in the string are letters # How can we check if the string is low...
true
329dcb06d8525d79fa27b0252b49d9395e98c4ff
tdnam/learncode
/Practice/CrackingAlgo/ArraysAndStrings/StringCompression.py
1,053
4.75
5
#!/usr/bin/env python3 # String Compression: Implement a method to perform basic string compression using the # counts of repeated characters. # For example, the string aabcccccaaa would become a2b1c5a3. # If the "compressed" string would not become smaller than the original string, # your method should return the or...
true
9956cb6b7d201af6f796c95f2832a568115ba51e
ashcoder2020/Python-Practice-Code
/simple find factorial.py
229
4.34375
4
num=int(input("Enter a number which you want to find factorial : ")) fact=1 if num==0 or num==1: print("Factorial is 1") else: for i in range(1,num+1): fact=fact*i print(f"factorial of {num} is {fact}")
true
0d33a1a9223b7cdba089a38e43bf4a5c8df23c82
HanYinnn/cp2019
/p01/q1_fahreheit_to_celsius.py
566
4.53125
5
#Write a program q1_fahrenheit_to_celsius.py that reads a Fahrenheit degree in double (floating point / decimal) from standard input, #then converts it to Celsius and displays the result in standard output. #The formula for the conversion is as follows: celsius = (5/9) * (fahrenheit - 32) #get input Fahrenheit = int...
true
793d4b2846da7fa419afc67de85881accc271533
aekempster/Pyber
/03-Python/3/Activities/Solved/05-Ins_List_comprehensions/comprehensions.py
1,458
4.53125
5
# -*- coding: UTF-8 -*- """Comprehensions""" price_strings = ["24", "13", "16000", "1400"] price_nums = [int(price) for price in price_strings] fish = "halibut" # Comprehensions give handles on each element of a collection letters = [letter for letter in fish] print(f"We iterate over a string, containing the world:...
true
387a706a602f18376859886ddd974451360b1ef7
izham-sugita/python3-tutorial
/python-container.py
1,340
4.5625
5
#List xs = [3, 1, 2] # Create a list print(xs, xs[2]) # Prints "[3, 1, 2] 2" print(xs[-1]) # Negative indices count from the end of the list; prints "2" xs[2] = 'foo' # Lists can contain elements of different types print(xs) # Prints "[3, 1, 'foo']" xs.append('bar') # Add a new element to the end o...
true
738b0632eb0b8c29304b49fa612e38e5592bc3e8
anishcr/iNeuron-Assignments
/MLD6thJune/Assignments/Python-Assignment-3/reduce_filter.py
1,102
4.1875
4
# 1.1 Write a Python Program to implement your own myreduce() function which works exactly # like Python's built-in function reduce() # # 1.2 Write a Python program to implement your own myfilter() function which works exactly # like Python's built-in function filter() def myreduce(function, iterable, initiali...
true
a7381d3830c02a342cb3588b14fa54b5e26d0b11
insigh/Leetcode
/August_18/71. Simplify Path.py
951
4.21875
4
""" Given an absolute path for a file (Unix-style), simplify it. For example, path = "/home/", => "/home" path = "/a/./b/../../c/", => "/c" Corner Cases: Did you consider the case where path = "/../"? In this case, you should return "/". Another corner case is the path might contain multiple slashes '/' together, su...
true
58db5a0d25109bd5b5466b9cc5bb63bf8193ceb6
Fbabsail/Learning-Python
/17.py
533
4.125
4
#total faliure command=input() while command.upper() != 'QUIT': if command.upper() == 'START': print('Car started...') elif command.upper() == 'STOP': print('Car stopped.') elif command.upper() == 'EXIT': break elif command.upper() == 'HELP': print('Start - to start th...
true
288f144096eb930c31c998beecc3fbb256ca68ae
Fbabsail/Learning-Python
/13.py
245
4.40625
4
Name=input("What's your name") name_length=(len(Name)) if name_length<3: print("Name must be at least 3 characters") elif name_length>50: print('Name can be a maximum of 25 characters') else: print('Name looks good')
true
c1219edb00ff71005e07698261215ca4b7dfba8f
hahahayden/CPE202
/LAB1/Lab1.py
793
4.25
4
# Name: # Section: # must use iteration not recursion def max_list_iter(tlist): """ finds the max of a list of numbers and returns it, not the index""" if (len(tlist) == 0): raise ValueError('empty list') """ finds the max of a list of numbers and returns it, not the index""" elif (len(t...
true
7aa9ed2f2be8cbf8d57491a366959ff5a08dd2ff
Meitsuki/testing
/python/miniProjects/diceRoll/diceRollSimulation.py
1,415
4.375
4
import dice print("Welcome to the dice roll simulator program!") validPrompt = False while not validPrompt: numDice = input("To get started, how many dice would you like to roll? ") validInt = False try: numDice = int(numDice) + 0 validInt = True except TypeError: validInt = Fa...
true
1b914b3aec24619f31d76e53b6c211fb810ec187
patricelliG/hacker_rank
/python/classes/complex_numbers.py
2,586
4.3125
4
#!/bin/python import math # this script defines a class for imaginary numbers # it can operate on two numbers with +,-,*,/ # it can also mod a single imaginary number # INPUT: Two lines with two integers each # 2 1 # 5 6 # so the first number is 2+1i and the second is 5+6i # The program then outputs the numbers afte...
true
00c1d5a513bf66ae0701f7b26dd57aa0cc7bc117
CarltonK/PythonScripts
/Fizz Buzz/fizz_buzz.py
302
4.28125
4
def fizz_buzz(number): number = int(number) if number%3 == 0 and number%5 == 0: print('FizzBuzz') elif number%3 == 0: print('Fizz') elif number%5 == 0: print('Buzz') else: print('This number is not divisible by either 3 or 5') user_value = input('Enter a number: ') fizz_buzz(user_value)
true
4108a8843bc66211c7bd44bb701a16d8fe102a65
CarltonK/PythonScripts
/Fibonacci Sequence/fibonacci_sequence.py
547
4.53125
5
def fibonacci_generator(number): number = int(number) num1 = 0 num2 = 1 num_count = 1 fib_list = [num2] while num_count < number: num_total = num1 + num2 #Switch second value to first value num1 = num2 #Switch total value to second value num2 = num_to...
true
5bb0105cb178fa40a33feab048492a8599797b8f
yalothman97/Python
/functions_task.py
703
4.1875
4
def check_birthdate(year, month, day): from datetime import date if year > date.today().year and month > date.today().month and day > date.today().day: return False else: return True def calculate_age(year, month, day): from datetime import date calc_year = date.today().year - year calc_month = date.today()....
true
20d3080e9ede4e7070fc02d26049e795fc9a03fe
pulkitpahwa/Python-practice
/count_vowels.py
1,181
4.21875
4
# !usr/bin/python import fileinput def main(): print "This program will count the number of vowels in a string or in a file." print "Press 1 if you want to enter a string. " print "Press 2 if you want to open a file. " a=raw_input("Enter your choice > ") # 2 cases are possible according to the choice of user...
true
91942c8e37b9b847ecd5dffe41be3c53ee1e944c
nhouston/Ice-Core-Analysis
/ImageAnalysis.nosync/sliceImage.py
1,231
4.125
4
from PIL import Image import os import math """ image_slice is a function that is used to take the input image that the user defines and split the image. The function takes the image and splits the image vertically by 1500 pixels. """ def image_slice(image_path, outdir): Image.MAX_IMAGE_PIXELS = None # Set the max...
true
a8606407b754328ea7574e919ed6547853838709
nwthomas/code-challenges
/src/codewars/7-kyu/least-larger/least_larger.py
874
4.28125
4
""" Task Given an array of numbers and an index, return the index of the least number larger than the element at the given index, or -1 if there is no such index ( or, where applicable, Nothing or a similarly empty value ). Notes Multiple correct answers may be possible. In this case, return any one of them. The given...
true
17531a8d026adbf09e0c5262bfa6d097e21ad68e
nwthomas/code-challenges
/src/interview-cake/cake-thief/cake_thief.py
1,914
4.25
4
""" You are a renowned thief who has recently switched from stealing precious metals to stealing cakes because of the insane profit margins. You end up hitting the jackpot, breaking into the world's largest privately owned stock of cakes—the vault of the Queen of England. While Queen Elizabeth has a limited number of ...
true
27354066da9bace6280e4c7b6ff9864351c5f97b
nwthomas/code-challenges
/src/hacker-rank/medium/frequency-queries/frequency_queries.py
2,475
4.3125
4
""" You are given q queries. Each query is of the form two integers described below: - 1:x Insert x in your data structure. - 2:y Delete one occurence of y from your data structure, if present. - 3:z Check if any integer is present whose frequency is exactly z. If yes, print 1 else 0. The queries are given in the form...
true
bd4b61c1dac3f7071e74c11b2ffa413e8d1e0dac
nwthomas/code-challenges
/src/daily-coding-problem/medium/time-map/time_map.py
2,090
4.1875
4
""" Good morning! Here's your coding interview problem for today. This problem was asked by Stripe. Write a map implementation with a get function that lets you retrieve the value of a key at a particular time. It should contain the following methods: set(key, value, time): sets key to value for t = time. get(key, ...
true
707c872f0d67bf4c04a063be36efbe496b3ef538
nwthomas/code-challenges
/src/interview-cake/inflight-entertainment/inflight_entertainment.py
1,538
4.46875
4
"""" You've built an inflight entertainment system with on-demand movie streaming. Users on longer flights like to start a second movie right when their first one ends, but they complain that the plane usually lands before they can see the ending. So you're building a feature for choosing two movies whose total runtim...
true
ddbde3d2dec3cf2c347a023d349475221443862d
nwthomas/code-challenges
/src/miscellaneous-code-challenges/stock-prices/stock_prices.py
2,079
4.4375
4
""" You want to write a bot that will automate the task of day-trading for you while you're going through Lambda. You decide to have your bot just focus on buying and selling Amazon stock. Write a function `find_max_profit` that receives as input a list of stock prices. Your function should return the maximum profit t...
true
3f19fa1bfb89903e80c56d69db765d3d02b63e59
nwthomas/code-challenges
/src/leetcode/medium/daily-temperatures/daily_temperatures.py
1,068
4.28125
4
""" https://leetcode.com/problems/daily-temperatures Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature. If there is no future day for which this is possible, keep ans...
true
66bbe03dbe57f996d3811e6eca4b290971c24039
nwthomas/code-challenges
/src/leetcode/medium/word-search/word_search.py
2,728
4.125
4
""" https://leetcode.com/problems/word-search/ Given an m x n grid of characters board and a string word, return true if word exists in the grid. The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be us...
true
e33b5c0c12775a3991cbdb1c8cefe4b3c039a780
nwthomas/code-challenges
/src/daily-coding-problem/medium/peekable-iterator/peekable_iterator.py
2,532
4.28125
4
""" Good morning! Here's your coding interview problem for today. This problem was asked by Google. Given an iterator with methods next() and hasNext(), create a wrapper iterator, PeekableInterface, which also implements peek(). Peek shows the next element that would be returned on next(). Here is the interface: cl...
true
819373032f5ed9094e6d42a87c671f643dc9625f
nwthomas/code-challenges
/src/hacker-rank/hard/array-manipulation/array_manipulation.py
1,634
4.3125
4
""" Starting with a 1-indexed array of zeros and a list of operations, for each operation add a value to each the array element between two given indices, inclusive. Once all operations have been performed, return the maximum value in the array. Example n = 10 queries = [[1, 5, 3], [4, 8, 7], [6, 9, 1]] Queries are i...
true
8dcef8821671cead1528c3c36be66ad47cc45daa
nwthomas/code-challenges
/src/interview-cake/merge-sorted-lists/merge_sorted_lists.py
1,581
4.28125
4
""" In order to win the prize for most cookies sold, my friend Alice and I are going to merge our Girl Scout Cookies orders and enter as one unit. Each order is represented by an "order id" (an integer). We have our lists of orders sorted numerically already, in lists. Write a function to merge our lists of orders in...
true
b866fa71fb76291c15d35103c1225afe11513b64
nwthomas/code-challenges
/src/daily-coding-problem/easy/find-most-valuable-path/find_most_weighted_path.py
1,499
4.25
4
""" Good morning! Here's your coding interview problem for today. This problem was asked by Google. You are given an array of arrays of integers, where each array corresponds to a row in a triangle of numbers. For example, [[1], [2, 3], [1, 5, 1]] represents the triangle: 1 2 3 1 5 1 We define a path in the trian...
true
1b1f9ff84258b71e0f4bd0f672d1683a83997705
nwthomas/code-challenges
/src/leetcode/medium/maximum-product-subarray/maximum_product_subarray.py
1,295
4.125
4
""" https://leetcode.com/problems/maximum-product-subarray Given an integer array nums, find a contiguous non-empty subarray within the array that has the largest product, and return the product. The test cases are generated so that the answer will fit in a 32-bit integer. A subarray is a contiguous subsequence of t...
true
a86cf51fd9e36f81a440708fe156aaa862121643
nwthomas/code-challenges
/src/hacker-rank/easy/bubble-sort/bubble_sort.py
1,468
4.3125
4
""" Consider the following version of Bubble Sort: for (int i = 0; i < n; i++) { for (int j = 0; j < n - 1; j++) { // Swap adjacent elements if they are in decreasing order if (a[j] > a[j + 1]) { swap(a[j], a[j + 1]); } } } Given an array of integers, sort the arr...
true
e611c91fdc57a31f9f64a9bfc4e9467478830730
nwthomas/code-challenges
/src/interview-cake/highest-multiple-of-integers/highest_multiple_of_integers.py
1,337
4.59375
5
""" Given a list of integers, find the highest product you can get from three of the integers. The input list_of_ints will always have at least three integers. """ def find_highest_multiple_of_three_ints(int_list): """Takes in a list of integers and finds the highest multiple of three of them""" if type(int_...
true
f5ff60b1380f794c8d19dc465f6e890e8f25becd
Avisikta-Majumdar/Campus-Placement-Coding-Question-And-Answers
/Accenture/FindCount.py
716
4.3125
4
#Question '''You are given a function FindCount The function accpets an int array 'arr' The function will return the no of elements of 'arr' having absolute difference of less than or equal to 'diff' with ' num''' #Input:- '''arr: 12 3 14 56 77 13 num:12 diff:2 ''' #Output : - # 3 def FindCount(ar...
true
092b662940b04da299d3bfa5a4acf9c1f2b41042
Avisikta-Majumdar/Campus-Placement-Coding-Question-And-Answers
/TCS NQT Coding Questions and Answers/Check Palindrome.py
241
4.25
4
''' Write a Python program to check whether the given number is Palindrome or not using command line arguments. ''' def PalinDrome(n): return n==n[::-1] for i in range(int(input("Test case:-"))): print(PalinDrome(input()))
true
809196d5563f89ac9dd9a1be28dc4480b850017d
aarthymurugappan101/loops
/pract4_q2.py
210
4.15625
4
total = 0 count = 0 while count < 5: usrInput = int(input("Your number please")) total += usrInput count += 1 # to add so that it will not become an infinite loop print("While: Total sum is",total)
true
67faf3c41b90be73374613ffe610e522d67117f8
firewb/calculator
/calculator.py
2,091
4.25
4
#!/usr/bin/env python3 title = "This is a scientfic calculator created by firew shafi" titlelen = len(title) def intro(): '''Displays intro ''' title = "This is a scientfic calculator created by firew shafi" titlelen = len(title) print ('*'* titlelen) print (title) print ('*'* titlelen) prin...
true
b5b93fef86f3d5a370da9057021a9f49e5a46cd3
nair97/https-github.com-ABE65100-AUG-2020-assignment-1-python-learning-the-basics-nair97
/Exercise_4.2_flower.py
2,254
4.59375
5
# -*- coding: utf-8 -*- """ Spyder Editor To draw 3 set of flowers using turtle module by Meera - 09-01-2020 """ import math import turtle #math function provides all mathematical functions #turtle module creates images # import the tkinter graphics library tools. Note that is was called Tkinter for # Python 2 from ...
true
d6ffd6a761096bfe324a36cb0fca5ada4ecd9025
ksjksjwin/practice-coding-problem
/CodeSignal/sortByHeight.py
1,001
4.21875
4
''' Some people are standing in a row in a park. There are trees between them which cannot be moved. Your task is to rearrange the people by their heights in a non-descending order without moving the trees. People can be very tall! Example For a = [-1, 150, 190, 170, -1, -1, 160, 180], the output should be sortByHeig...
true
978d5951c4eda9a8af8b08a3fdd99c64586211c3
ksjksjwin/practice-coding-problem
/LeetCode/isPalindrome.py
919
4.15625
4
''' Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note: For the purpose of this problem, we define empty string as valid palindrome. Example 1: Input: "A man, a plan, a canal: Panama" Output: true Example 2: Input: "race a car" Output: false Copyright...
true
ab5255c66430947348c194e9278a7e7056b41861
benblaut/cse491-numberz
/fib_iter/example.py
286
4.46875
4
import fib for n, i in zip(range(3), fib.fib()): print i # additional questions to address: # - what the heck do 'zip' and 'range' do, and why are they there? # "zip" iterates over two ranges, and "range" denotes a range from 0 to the number in parentheses (0-3, so a range of 4)
true
b7f5322889f87f3496af7cefced9db2bad56e168
veena863/python-practice-01
/practice02.py
772
4.125
4
#!/usr/bin/env python # coding: utf-8 # In[10]: #Numbers #1 Integers: Any plane digit is a integer x=2;y=3;z=4 print(x,y,z) #Advanced approach of assignment operator is x,y,z=2,3,4 print(x,y,z) # In[12]: #2 Float:a number with a decimal number x=1.2 y=2.2 print(x+y) # In[15]: #3 Constant:variable whose i...
true
4cb827b971c2e9324355e96b1a3e838d349e57bb
ronl27/Python
/scores.py
819
4.28125
4
# Scores and Grades # Write a function that generates ten scores between 60 and 100. Each time a score is generated, your function should display what the grade is for a particular score. Here is the grade table: # # Score: 60 - 69; Grade - D # Score: 70 - 79; Grade - C # Score: 80 - 89; Grade - B # Score: 90 - 100; G...
true
1f33bddde1ca44bda6c8e9643f836cf3fbc130d4
voidbert/PyTacToe
/CommentRemover.py
2,016
4.59375
5
#A file that removes comments in Python scripts. This is useful to reduce the #size of the game file to save space on the calculator. Empty lines are also #removed but comments after code aren't. Example: #print("Hello, world") #This comment isn't removed #Imported the needed sys module import sys #The function that ...
true
2ab7dcde7fbf76a679aabb0876d9407a42ad53af
jalaldotmy/TTTK2053-Module5
/Fundamentals/Input and Output.py
2,254
4.1875
4
#Task 1: Run the script and explain the implementation ## Break a name into two parts -- the last name and the first names. fullName = input("Enter a full name: ") n = fullName.rfind(" ") # index of the space preceding the last name # Display the desired information. print("Last name:", fullName[n+1:]) #n+1 will f...
true