blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
e4bc895b6c639fda81703d162b07034888231d50
Laurensvaldez/PythonCrashCourse
/CH8: Functions/try_it_yourself_ch8_8_8.py
986
4.375
4
# Start with your program from exercise 8-7. Write a while loop that allows users to enter an album's artist and title. # Once you have that information, call make_album() with the user's input and print the dictionary that's created. # Be sure to include a quit value in the while loop. def make_album(artist, title, t...
true
9cb4ce71d22344f24e1d3cc338bb9e83ed1ad3ad
Laurensvaldez/PythonCrashCourse
/CH8: Functions/making_pizzas.py
1,837
4.3125
4
# In this file we will import the function of pizza_import.py import pizza_import print("Importing all the functions in the module") pizza_import.make_pizza(16, 'pepperoni') pizza_import.make_pizza(12, 'mushrooms', 'green peppers', 'extra cheese') print("-------------------------------------------") # To use the import...
true
146541bd8096d3dada3b6b651f7d74caf3d8fe68
Laurensvaldez/PythonCrashCourse
/CH9: Classes/9-6_ice_cream_stand.py
2,095
4.5625
5
# Write a class called IceCreamStand that inherits from the Restaurant class you wrote in Exercise 9-1 or Exercise 9-4 # Either version of the class will work; just pick the one you like better class Restaurant: """A simple restaurant class""" def __init__(self, restaurant_name, cuisine_type): """Initi...
true
f14e51cff185f2277385b1a0d580fd0a077e7195
Laurensvaldez/PythonCrashCourse
/Ch6: Dictionaries/try_it_yourself_ch6_6_1.py
514
4.3125
4
# Try it yourself challenge 6-1 # Person # Use a dictionary to store information about a person you know. # Store their first name, last name, age, and the city in which they live. You should have keys such as # first_name, last_name, age, and city. Print each piece of information stored in your dictionary. person = ...
true
755616213684796cb48d924e5bf927e994e030d1
Laurensvaldez/PythonCrashCourse
/CH4: working with lists/try_it_yourself_ch4_4_11.py
500
4.21875
4
print ("More Loops") # all versions of foods.py in this section have avoided using for loops when printing to save space # Choose a version of foods.py, and write two for loops to print each list of foods my_foods = ['pizza', 'falafel', 'carrot cake'] print ("My favorite foods are: ") for food in my_foods: print...
true
2593aeaf239015183c48861a96af3d1feb21d6d3
Laurensvaldez/PythonCrashCourse
/CH9: Classes/9-5_login_attempts.py
2,622
4.46875
4
# Add an attribute called login_attempts to your User class from Exercise 9-3 class User: """A class to describe a user""" # Create two attributes called first_name and last_name # and then create several other attributes that are typically stored in a user profile def __init__(self, first_name, last_n...
true
a4ca9323e0c5bbd2cd4f81cb49151482d2a3d802
phu-mai/calculate
/calculate.py
777
4.125
4
from datetime import datetime def string_to_date(input): return datetime.strptime(input, "%d/%m/%Y") def check_date(input): if string_to_date(input) < datetime.strptime("01/01/1900", "%d/%m/%Y") or string_to_date(input) > datetime.strptime("31/12/2999", "%d/%m/%Y"): return False else: retu...
true
56490d658082b16ec7ec9140147f0e3e0544c630
subhendu17620/RUAS-sem-04
/PP/Java/lab03/a.py
1,391
4.1875
4
# Python3 program to print all Duplicates in array # A class to represent array of bits using # array of integers class BitArray: # Constructor def __init__(self, n): # Divide by 32. To store n bits, we need # n/32 + 1 integers (Assuming int is stored # using 32 bits) self.arr = [0] * ((n >> 5) + ...
true
f600b3970b3c556a9aa03af8d6ef7b1f1dd124f7
MirjaLagerwaard/MountRUSHmore
/main.py
1,500
4.28125
4
import sys from algorithm import * if __name__ == "__main__": # Error when the user did not give the right amount of arguments if len(sys.argv) <= 1 or len(sys.argv) > 3: print "Usage: python main.py <6_1/6_2/6_3/9_1/9_2/9_3/12> <breadth/depth/random>" exit() # update fp to the CSV file t...
true
90bda58a280724875f5ba10d8171e81e093338ac
prince-singh98/python-codes
/ConditionalStatements/DigitAlphabateOrSpecialCharecter.py
229
4.28125
4
char = input("enter a alphabet") if((char>='a' and char<='z') or (char>='A' and char<='Z')): print(char,"is alphabet") elif(char>='0' and char<='9'): print(char, "is digit") else: print(char, "is special character")
true
68e536bf4e5f3b3a7f8a853223e83f6f03511a98
Chrisgo-75/intro_python
/conditionals/switch_or_case.py
696
4.15625
4
#!/usr/bin/env python3 # Index # Python does not have a "switch" or "case" control structure which # allows you to select from multiple choices of a single variable. # But there are strategies that can simulate it. # # 1. def main(): # 1. choices = dict( one = 'first', two = 'second', ...
true
85145d7b919824030bb2ce9a1f2132cfadcac9df
Chrisgo-75/intro_python
/general_syntax/strings.py
1,433
4.9375
5
#!/usr/bin/env python3 # Index # 1. Strings can be created with single or double quotes. # 2. Can introduce new line into a string. # 3. Display escape characters (literally). Use "r" per example below. # - r == "raw string" which is primarily used in regular expressions. # 4. Format or replace characte...
true
7a16498f5039f500dbb9b916d5f6a87ba3215c4b
datarocksAmy/APL_Python
/ICE/ICE02/ICE2.py
2,515
4.125
4
''' * Python Programming for Data Scientists and Engineers * ICE #2 * Q1 : Frequencies of characters in the string. * Q2 : Max word length in the string. * Q3 : Count numbers of digits and characters in the string. * #11 Chia-Hui Amy Lin ''' # Prompt user for a sentence user_input_sentence = input("Please ...
true
9094b07c5ef5da96a89870a898db9b9c010dbc45
datarocksAmy/APL_Python
/Lab Assignment/Lab04/Lab04_b_MashDictionaries.py
1,293
4.125
4
# ------------------------------------------------------------ # * Python Programming for Data Scientists and Engineers # * LAB #4-b Mash Dictionaries # * #11 Chia-Hui Amy Lin # ------------------------------------------------------------ # Dictionary from statistics import mean # Function def mash(input_dict): ...
true
5db43d9103f910dfeb21e7196142c38fc112af38
datarocksAmy/APL_Python
/ICE/ICE03/ICE3-2 New List.py
1,845
4.1875
4
''' * Python Programming for Data Scientists and Engineers * ICE #3-2 Make new list * Take in a list of numbers. * Make a new list for only the first and last elements. * #11 Chia-Hui Amy Lin ''' # Function for prompting user for numbers, append and return the list def user_enter_num(count_prompt, user_num_...
true
dbc3dfae249a74877e71007e05cd933c92d13459
lelong03/python_algorithm
/array/median_sorted_arrays.py
2,041
4.125
4
# Find median of two sorted arrays of same size # Objective: Given two sorted arrays of size n. # Write an algorithm to find the median of combined array (merger of both the given arrays, size = 2n). # What is Median? # If n is odd then Median (M) = value of ((n + 1)/2)th item term. # If n is even then Median (M) = ...
true
0847e2a138d297ceb53d34e5c15004424227907e
lelong03/python_algorithm
/array/next_permutation.py
1,358
4.125
4
# Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. # If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order). # The replacement must be in-place, do not allocate extra memory. # Here are so...
true
429a91d928bbf33f9ddf0c5daea25a8777d65084
anutha13/Python
/demo.py
1,058
4.21875
4
from time import sleep from threading import Thread class Hello(Thread): def run(self): for i in range(5): print("hello") sleep(1) class Hi(Thread): def run(self): for i in range(5): print("Hi") t1=Hello() t2=Hi() t1.start() ...
true
5a0140339b66c37c3d1f7056f8a2b8520630d39c
JasleenUT/Encryption
/ElGamal/ElGamal_Alice.py
1,669
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Nov 23 20:07:58 2018 @author: jasleenarora """ # Read the values from intermediate file with open('intermediate.txt','r') as f: content = f.readlines() p = int(content[0]) g = int(content[1]) a = int(content[2]) c1 = int(content[3]) c2 = ...
true
31437cfb86cb0bdd9ce378ba6aacd44a48c1a3dd
opember44/Engineering_4_Notebook
/Python/calculator.py
1,426
4.34375
4
# Python Program 1 - Calculator # Written by Olivia Pemberton def doMath (num1, num2, operation): # defines do math function # program will need yo to enter 2 numbers to do operation if operation == 1: x = round((num1 + num2), 2) return str(x) if operation == 2: x = round((num1 - num2), 2) return str(x) if...
true
d95b1bfa19fa52013079f7d63f7794d1c6736d84
hectorzaragoza/python
/functions.py
1,985
4.1875
4
#functions allow us to put something into it, does something to it, and gives a different output. #We start with def to define the function, then we name it, VarName() #def function(input1, input2, input3,...): # code # more code # return value #result = functionName(In1, In2, In3,...) #result = value def addO...
true
ef58048b8b05de8a3239b61c320f601d02da1daa
manjushachava1/PythonEndeavors
/ListLessThanTen.py
498
4.21875
4
# Program 3 # Take a list and print out the numbers less than 5 # Extras: # 1. Write program in one line of code # 2. Ask the user for a number and return a list that contains elements that are smaller than that user number. a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [] c = [] # Extra 1 for element in a: if...
true
7f66d0d287df330aaad8d58a3d74308a85171942
JavaScriptBach/Project-Euler
/004.py
518
4.125
4
#coding=utf-8 """ A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. """ def is_palindrome(num): string = str(num) for i in range(0, len(string) / 2): if stri...
true
592e65372e0cbbbbaaaa50e61b16a4546e6301a5
pgiardiniere/notes-WhirlwindTourOfPython
/06-scalarTypes.py
2,782
4.53125
5
### Simple Types in Python :: # --- Python Scalar Types --- # ---------------------------------------------- # Type Example Description # `````````````````````````````````````````````` # int x = 1 integers # float x = 1.0 floating point nums # complex x = 1 + 2j complex n...
true
6b43604d2d995874639262c7995a22dde3bd5b41
eshulok/2.-Variables
/main.py
604
4.53125
5
#Variables are like nicknames for values #You can assign a value to a variable temperature = 75 #And then use the variable name in your code print(temperature) #You can change the value of the variable temperature = 100 print(temperature) #You can use variables for operations temp_today = 85 temp_yesterday = 79 #How...
true
37499520285d5a5b5b8746d02a4fc06854627f13
riyaasenthilkumar/riya19
/factorial.py
270
4.125
4
num=7 num=int(input("Enter a number:")) factorial=1 if num<0: print("factorial does not exist for negative number") elif num==0: print("the factorial of0 is 1") else: for i in range (1,num+1): factorial=factorial*i print("the factorial of",num,"is",factorial)
true
ccf67c2b2625e3ae6d1acc1e7cca475f8b3e5f67
Xtreme-89/Python-projects
/main.py
1,424
4.1875
4
<<<<<<< HEAD is_male = True is_tall = False if is_male and is_tall: print("You are a tall male") elif is_male and not is_tall: print("You are a short male") elif not is_male and is_tall: print("You are a tall female") else: print("You are a short female") #comparisons def max_num(num1, num2, num3): ...
true
3b6c35f55899dbc8819e048fdbdebb065cd01db1
brunomatt/ProjectEulerNum4
/ProjectEulerNum4.py
734
4.28125
4
#A palindromic number reads the same both ways. #The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. #Find the largest palindrome made from the product of two 3-digit numbers. products = [] palindromes = [] three_digit_nums = range(100,1000) for k in three_digit_nums: for j in t...
true
18187aef39ed5cdb6edad56d8599bc80586d93f8
TokarAndrii/PythonStuff
/pythonTasks/data_structures/moreOnList.py
1,760
4.71875
5
# https: // docs.python.org/3.0/tutorial/datastructures.html # list.append(x) # Add an item to the end of the list # equivalent to a[len(a):] = [x]. # list.extend(L) # Extend the list by appending all the items in the given list # equivalent to a[len(a):] = L. # list.insert(i, x) # Insert an item at a given positio...
true
1f3aaa0e48d787f2b1ec361d800cbc8d4606c7af
wicarte/492
/a3.py
845
4.125
4
#Assignment 3 (W3D4) - William Carter #What I think will happen before running the code: #I think the code prompts the user to enter a number, casts #the number as an int, counts up by 1 on the interval (2, user #provided number), and prints whenever the outer loop iterator (i) #is not cleanly divisible by the inner l...
true
1a948637866f58b51f76d1b69c070d67a6a615c8
nbenkler/CS110_Intro_CS
/HW #5/untitled folder/convertFunctions.py
955
4.15625
4
# Program to read file HW5_Input.txt and convert characters in the file to their unicode, hexadecimal, and binary representations. #Noam Benkler #2/12/18 def fileIngest(fileName): inFile = open(fileName, "r") return inFile inFile.close() def conversionOutput(file): for line in file: full = (line) characte...
true
590d5ad63a0fcf7f0f27a6352051093acfc9923c
nbenkler/CS110_Intro_CS
/Lab 3/functions.py
1,026
4.4375
4
'''function.py Blake Howald 9/19/17, modified for Python 3 from original by Jeff Ondich, 25 September 2009 A very brief example of how functions interact with their callers via parameters and return values. Before you run this program, try to predict exactly what output will appear, and in what order....
true
78ef5fc28e3f4ae7efc5ed523eeffe246496c403
alexmkubiak/MIT_IntroCS
/week1/pset1_2.py
413
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu May 24 18:00:03 2018 This code determines how many times the string 'bob' occurs in a string s. @author: Alex """ s = 'azcbobobegghakl' count = 0 index = 0 for index in s: if s[index] == 'b': if s[index + 1] == 'o': if s[index...
true
9ecd69b1dc1bd808055cea00eabc82428dc12056
TheChuey/DevCamp
/range_slices_in_pythonList.py
982
4.3125
4
tags = [ 'python', 'development', 'tutorials', 'code', 'programing', 'computer science' ] #tags_range = tags[:-1:2] tags_range = tags[::-1] # reverses the oder of the list # slicing function print(tags_range) """ # Advanced Techniques for Implementing Ranges and Slices in Pyth...
true
09a4ae07c0b9e3c8d1604bfaea0ce58078d52936
asim09/Algorithm
/data-types/List/sort-list-of-string.py
256
4.1875
4
# Python Program to sort a list according to the length of the elements a = ['Apple', 'Ball', 'Cat', 'Ox'] for i in range(len(a)): for j in range(len(a) - i - 1): if len(a[j]) > len(a[j+1]): a[j], a[j+1] = a[j+1], a[j] print(a[-1])
true
234a8bc6f168afac7ab18c566b0a783e5e9080fd
prabalbhandari04/python_
/labexercise2.py
312
4.28125
4
#Write a program that reads the length of the base and the height of a right-angled triangle and prints the area. Every number is given on a separate line.# length_of_base = int(input("Enter the lenght of base:")) height = int(input("Enter the height:")) area = (1/2)*(length_of_base*height) print(area)
true
06fe1661b93a940e28adb9c5fab488df85e19eb8
ankush-phulia/Lift-MDP-Model
/simulator/Elevator.py
2,956
4.25
4
class Elevator(object): """ - state representation of the elevator """ def __init__(self, N, K): self.N = N # number of floors self.K = K # number of elevators # initial positions of all elevators self.pos = [0]*...
true
1d8df8f0fd6996602088725eaef8fb63429cdf99
mileshill/HackerRank
/AI/Bot_Building/Bot_Saves_Princess/princess.py
2,127
4.125
4
#!/usr/bin/env python2 """ Bot Saves Princess: Mario is located at the center of the grid. Princess Peach is located at one of the four corners. Peach is denoted by 'p' and Mario by 'm'. The goal is to make the proper moves to reach the princess Input: First line contains an ODD integer (3<=N<=99) ...
true
f1d0eed5c88aff33508a9b32e9aaec1a3f962de3
rahulkumar1m/exercism-python-track
/isogram/isogram.py
528
4.3125
4
def is_isogram(string) -> bool: # Tokenizing the characters in the string string = [char for char in string.lower()] # initializing an empty list of characters present in the string characters = [] # if a character from string is already present in our list of characters, we return False for c...
true
122a3f71dd406d2cea9d838e3fe1260cd0e3adcf
hardlyHacking/cs1
/static/solutions/labs/gravity/solution/system.py
2,283
4.21875
4
# system.py # Solution for CS 1 Lab Assignment 3. # Definition of the System class for gravity simulation. # A System represents several Body objects. # Based on code written by Aaron Watanabe and Devin Balkcom. UNIVERSAL_GRAVITATIONAL_CONSTANT = 6.67384e-11 from math import sqrt from body import Body class System:...
true
490389021ee556bb98c72ae687389445ebb6dcb7
Andras00P/Python_Exercise_solutions
/31 - Guess_Game.py
855
4.46875
4
''' Build a simple guessing game where it will continuously ask the user to enter a number between 1 and 10. If the user's guesses matched, the user will score 10 points, and display the score. If the user's guess doesn't match, display the generated number. Also, if the user enters "q" stop the game. ''...
true
3607e93c5431e03789f3f980fd2220c4a8dc9b10
Andras00P/Python_Exercise_solutions
/24 - Reverse_String.py
443
4.375
4
""" Reverse a string. If the input is: Hello World. The output should be: .dlroW olleH """ def reverse_string(text): result = "" for char in text: result = char + result return result # Shortcut def reverse_string2(text): return text[::-1] usr_text = input("Wri...
true
a5fd62036f3dd8a6ec226ffae14b48c6c5ab06ca
Andras00P/Python_Exercise_solutions
/21 - Check_Prime.py
357
4.21875
4
''' For a given number, check whether the number is a prime number or not ''' def is_prime(num): for i in range(2, num): if (num % i) == 0: return False return True usr_num = int(input("Enter number: \n")) if is_prime(usr_num): print("The number is a Prime") else: ...
true
06afe217a85fc98b1689ac6e6119a118fe91f9b5
garciacastano09/pycourse
/intermediate/exercises/mod_05_iterators_generators_coroutines/exercise.py
2,627
4.125
4
#-*- coding: utf-8 -*- u''' MOD 05: Iterators, generators and coroutines ''' def repeat_items(sequence, num_times=2): '''Iterate the sequence returning each element repeated several times >>> list(repeat_items([1, 2, 3])) [1, 1, 2, 2, 3, 3] >>> list(repeat_items([1, 2, 3], 3)) [1, 1, 1, 2, 2, 2,...
true
014e36604daf04ec73c663fe223cd445fcd01ca5
garciacastano09/pycourse
/advanced/exercises/mod_05_functools/exercise_mod_05.py
585
4.25
4
#!/usr/bin/env python #-*- coding: utf-8 -*- u""" Created on Oct 5, 2013 @author: pablito56 @license: MIT @contact: pablito56@gmail.com Module 05 functools exercise >>> it = power_of(2) >>> it.next() 1 >>> it.next() 2 >>> it.next() 4 >>> it.next() 8 >>> it.next() 16 >>> it = power_of(3) >>> it.next() 1 >>>...
true
c3d462c1e5cd9bb28a67ee54f8f80c03ec14f06a
ACEinfinity7/Determinant2x2
/deter_lib.py
792
4.125
4
def deter2x2(matrix): """ function to calculate the determinant of the 2x2 matrix. The determinant of a matrix is defined as the upper-left element times the lower right element minus the upper-right element times the lower left element """ result = (matrix[0][0]*matrix[1][1])-(matri...
true
e354f576673621e8dc851bda02d495a5196f9f7d
mitchellflax/lpsr-samples
/3-6ATkinterExample/remoteControl.py
464
4.28125
4
import turtle from Tkinter import * # create the root Tkinter window and a Frame to go in it root = Tk() frame = Frame(root, height=100, width=100) # create our turtle shawn = turtle.Turtle() # make some simple buttons fwd = Button(frame, text='fwd', fg='red', command=lambda: shawn.forward(50)) left = Button(frame, ...
true
ed15cbf4fd067d8b9c8194d22b795cb55005797f
mitchellflax/lpsr-samples
/ProblemSets/PS5/teamManager.py
1,525
4.3125
4
# a Player on a team has a name, an age, and a number of goals so far this season class Player(object): def __init__(self, name, age, goals): self.name = name self.age = age self.goals = goals def printStats(self): print("Name: " + self.name) print("Age: " + str(self.age)) print("Goals: " + str(self.goa...
true
505b7944e773905bd8b1c5c8be4ce6d9a3b58730
mitchellflax/lpsr-samples
/4-2WritingFiles/haikuGenerator2.py
1,548
4.3125
4
# haikuGenerator.py import random # Ask the user for the lines of the haiku print('Welcome to the Haiku generator!') print('Would you like to write your haiku from scratch or get a randomized first line?') print('(1) I\'ll write it from scratch') print('(2) Start me with a random line') user_choice = int(raw_input()...
true
7e13745a73f6d77bbebcc267c0d4481ba6a86d3a
mitchellflax/lpsr-samples
/3-4FunctionsInTurtle/samplePatternTemplate.py
495
4.25
4
# samplePattern.py import turtle # myTurtle is a Turtle object # side is the length of a side in points def makeTriangle(myTurtle, side): pass # make our turtle kipp = turtle.Turtle() kipp.forward(150) kipp.right(180) # kipp makes triangles centered at a point that shifts # and decreases in size with each loop len...
true
f9f2cbd0408139865c1cb412a80c1d60b5cc038c
Brian-Musembi/ICS3U-Unit6-04-Python
/array_average.py
1,839
4.1875
4
#!/usr/bin/env python3 # Created by Brian Musembi # Created on June 2021 # This program prints a 2D array and finds the average of all the numbers import random def average_2D(list_2D): # This function finds the average total = 0 rows = len(list_2D) columns = len(list_2D[0]) for row_value in l...
true
c054b2383fd5b7d7a042d69673d2708aef9be0b1
coreman14/Python-From-java
/CPRG251/Assignment 6/Movie.py
2,090
4.40625
4
class Movie(): def __init__(self, mins:int, name:str, year:int): """Creates an object and assign the respective args Args: mins (int): Length of the movie name (str): Name of the movie year (int): Year the movie was released """ self.mins...
true
34d705727c44475ce5c1411558760a01969ef75b
Syvacus/python_programming_project
/Session number 2.py
2,246
4.1875
4
# Question 1 # Problem: '15151515' is printed because the chairs variable is text instead of a number # Solution: Convert the chairs variable from text to number chairs = '15' # <- this is a string (text) rather than an int (number) nails = 4 total_nails = int(chairs) * nails # <- convert string to int by wrapping...
true
95d7dd2afe45d705d1bbb3884245e1258651f0c0
DHANI4/NUMBER-GUESSING-GAME
/NumberGuessing.py
443
4.28125
4
import random print("Number Guessing Game") rand=random.randint(1,20) print("Guess a Number between 1-20") chances=0 while(chances<5): chances=chances+1 guess=int(input("Enter Your Guess")) if(guess==rand): print("Congratulations You Won!!") break elif(guess<rand): p...
true
949b939ef934fb793119900d36b377d7069c1916
vivianlorenaortiz/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/4-print_square.py
345
4.3125
4
#!/usr/bin/python3 """ Funtion that prints a square with the character #. """ def print_square(size): """ Function print square. """ if type(size) is not int: raise TypeError("size must be an integer") elif size < 0: raise ValueError("size must be >= 0") for i in range(size): ...
true
809e7e3a4be9be995241c67909ae61fc5796d98d
drummerevans/Vector_Multiply
/cross_input.py
564
4.125
4
import numpy as np items = [] max = 3 while len(items) < max: item = input("Add an element to the list: ") items.append(int(item)) print("The length of the list is now increased to {:d}." .format(len(items))) print(items) things = [] values = 3 for i in range(0, values): thing = input("Add an eleme...
true
44a4dda12809ebd8ba6e3c6c52c96e130a0fa7e1
PrateekMinhas/Python
/assignment14.py
1,555
4.4375
4
Q.1- Write a python program to print the cube of each value of a list using list comprehension. lst=[1,2,3,4,5] lstc=[i**3 for i in lst] print(lstc) #Q.2- Write a python program to get all the prime numbers in a specific range using list comprehension. lst_pr= [ i for i in range(2,int(input("Enter the end input of th...
true
cc1aa3c2ec38ffc869b942af0491d3c44baf9ba1
PrateekMinhas/Python
/assignment3.py
2,048
4.25
4
#Q.1- Create a list with user defined inputs. ls=[] x=int(input("enter the number of elements")) for i in range (x): m=input() ls.append(m) print (ls) #Q.2- Add the following list to above created list: #[‘google’,’apple’,’facebook’,’microsoft’,’tesla’] ls1=['google','apple','facebook','micr...
true
cef5dd3e9ca6fe8f9ce33b6e4f8aca9e35f368f4
0xch25/Data-Structures
/2.Arrays/Problems/Running sum of 1D Array.py
497
4.21875
4
'''Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]). Return the running sum of nums. Example 1: Input: nums = [1,2,3,4] Output: [1,3,6,10] Explanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4]''' def runningSum(nums): sum =0 for i in range(len(...
true
7816262c0cda16be8c7d255780fba2c1203905a8
0xch25/Data-Structures
/3.Stacks/Palindrome using Stacks.py
544
4.15625
4
'''Program to check weather the given string is palindrome or not''' class Stack: def __init__(self): self.items = [] def push(self, data): self.items.append(data) def pop(self): return self.items.pop() def is_empty(self): return self.items == [] s = Stack() str= inp...
true
e70a83469f49d7f0dcb0ce94f8621e1b8b032836
0xch25/Data-Structures
/10.Strings/Problems/Shuffle String.py
776
4.1875
4
''' Given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string. Return the shuffled string. Example 1: Input: s = "codeleet", indices = [4,5,6,7,0,2,1,3] Output: "leetcode" Explanation: As shown, ...
true
355a3568f845a02c8c3af90bf627ea2a207d7b84
ndri/challenges
/old/33.py
1,139
4.125
4
#!/usr/bin/env python # 33 - Area Calculator import sys try: shape, args = sys.argv[1], ' '.join(sys.argv[2:]) except: sys.exit('Error. Use -h for help.') if shape == '-h': print 'Challenge 33 - Area Calculator' print '-h\t\t\tDisplay this help' print '-r width height\t\tArea for a rectangle' ...
true
42096d931802f6a0edcfa5702f2a91d0bbba2cd5
LaloGarcia91/CrackingTheCodingInterview
/Chapter_1/CheckPermutation.py
775
4.125
4
class CheckPermutation: def __init__(self, str1, str2): self.checkIfIsPermutation(str1, str2) def checkIfIsPermutation(self, str1, str2): str1_len = len(str1) str2_len = len(str2) if str1_len == str2_len: counterIfEqualLetters = 0 for str1_letter in str...
true
13550a3bd2b683327b96a2676f5d006b69353b73
AndreiBratkovski/CodeFights-Solutions
/Arcade/Intro/Smooth Sailing/isLucky.py
614
4.21875
4
""" Ticket numbers usually consist of an even number of digits. A ticket number is considered lucky if the sum of the first half of the digits is equal to the sum of the second half. Given a ticket number n, determine if it's lucky or not. Example For n = 1230, the output should be isLucky(n) = true; For n = 239017,...
true
27f090cb703d12372205b7308efe17f5e0a73980
AndreiBratkovski/CodeFights-Solutions
/Arcade/Intro/Smooth Sailing/commonCharacterCount.py
718
4.34375
4
""" Given two strings, find the number of common characters between them. Example For s1 = "aabcc" and s2 = "adcaa", the output should be commonCharacterCount(s1, s2) = 3. Strings have 3 common characters - 2 "a"s and 1 "c". """ def commonCharacterCount(s1, s2): global_count = 0 char_count1 = 0 ...
true
b7315bf9114c641c1b3493ffef65109da2dc9046
Surenu1248/Python3
/eighth.py
434
4.15625
4
# Repeat program 7 with Tuples (Take example from Tutorial) tpl1 = (10,20,30,40,50,60,70,80,90,100,110) tpl2 = (11,22,33,44,55,66,77,88,99) # Printing all Elements..... print("List Elements are: ", tpl1) # Slicing Operations..... print("Slicing Operation: ", tpl1[3:6]) # Repetition..... print("Repetition of list f...
true
251b26428c895b27abb3e0db7ff0316e5bc8a7e1
Filjo0/PythonProjects
/Ch3.py
2,197
4.25
4
""" Chapter 3. 11. In the game of Lucky Sevens, the player rolls a pair of dice. If the dots add up to 7, the player wins $4; otherwise, the player loses $1. Suppose that, to entice the gullible, a casino tells players that there are lots of ways to win: (1, 6), (2, 5), and so on. A little mathematical analysis re...
true
3cd6ff12af16a6a3d672cad425a9df0d398cedb1
lslewis1/Python-Labs
/Week 5 Py Labs/Seconds converter.py
747
4.21875
4
#10/1/14 #This program will take a user input of a number of seconds. #The program will then display how many full minutes, hours, days, and leftover seconds there are #ts is the input of seconds #s1 is the leftover seconds for the minutes #s2 is the seconds for hours #s3 is the seconds for days #m is the numb...
true
c46d80d326ba0b65ca97c0679faa2e50aa384371
lslewis1/Python-Labs
/Week 5 Py Labs/BMI.py
530
4.34375
4
#10/1/14 #This program will determine a person's BMI #Then it will display wheter the person in optimal weight, over, or under #bmi is the body mass indicator #w is the weight #h is the height w=float(input("Enter your weight in pounds :")) h=float(input("Enter your height in inches :")) bmi=(w*703)/(h*h) ...
true
f22d1886a08da98b613d9ed89432a39d47679830
lslewis1/Python-Labs
/Week 6 Py Labs/calories burned.py
327
4.125
4
#10/6/14 #This program will use a loop to display the number of calories burned after time. #The times are: 10,15,20,25, and 30 minutes #i controls the while loop #cb is calories burned #m is minutes i=10 while i<=30: m=i cb=m*3.9 i=i+5 print(cb,"Calories burned for running for", m,"minut...
true
29260166c31c491e47c68e1674e384bc56c6a2d5
lslewis1/Python-Labs
/Week 8 Py Labs/Temperature converter.py
919
4.4375
4
#10/20/14 #This program will utilize a for loop to convert a given temperature. #The conversion will be between celsius and fahrenheit based on user input. ch=int(input("Enter a 1 for celsuis to fahrenheit, or a 2 for fahrenheit to celsius: ")) if ch==1: start=int(input("Please enter your start value: ")) ...
true
d31c472acb56ddda5e696e10c957d3d85cf88220
lslewis1/Python-Labs
/Week 4 Py Labs/Letter grade graded lab.py
536
4.375
4
#9/26/14 #This program will display a student's grade. #The prgram will print a letter grade after receiving the numerical grade #Grade is the numerical grade #Letter is the letter grade Grade=float(input("Please enter your numerical grade :")) if Grade>=90: print("Your letter grade is an A.") elif Grad...
true
6b6bee3144bce48f71c9eb02c574d7540f0f42da
aaqibgouher/python
/numpy_random/generate_rn.py
815
4.34375
4
from numpy import random # 1. for random integer till 100. also second parameter is size means how much you wanna generate # num_1 = random.randint(100) #should give the last value # print(num_1) # 2. for random int array : # num = random.randint(100,size=10) # print(num) # 3. for random float ; # num_2 = ra...
true
962557880d2b679913ac49c86658aa8e5bb1205d
aaqibgouher/python
/numpy_eg/vector/summation.py
995
4.21875
4
import numpy as np # 1. simple add element wise # arr_1 = np.array([1,2,3,4,5]) # arr_2 = np.array([1,2,3,4,5]) # print(np.add(arr_1,arr_2)) # 2. summation - first it will sum the arr_1,arr_2 and arr_3 individually and then sum it at once and will give the output. also axis means it will sum and give the output in on...
true
07923c14b2d3cc7e14a49c0eaff1e20d8769b7cb
Jonaugustin/MyContactsAssignment
/main.py
2,408
4.34375
4
contacts = [["John", 311, "noemail@email.com"], ["Robert", 966, "uisemali@email.com"], ["Edward", 346, "nonumber@email.ca"]] menu = """ Main Menu 1. Display All Contacts Names 2. Search Contacts 3. Edit Contact 4. New Contact 5. Remove Contact 6. Exit """ def displayContact(): if contacts: pr...
true
57d9d25fe134eff49886a76ba6d8ea91f9498073
nikhilpatil29/AlgoProgram
/algo/MenuDriven.py
2,442
4.125
4
''' Purpose: Program to perform all sorting operation like insertion,bubble etc @author Nikhil Patil ''' from utility import * class MenuDriven: x = utility() choice = 0 while 1: print "Menu : " print "1. binarySearch method for integer" print "2. binarySearch method for String...
true
cbfa94e5ab45819bb1dd9ee3834ec98d1b826911
webfarer/python_by_example
/Chapter2/016.py
317
4.125
4
user_rainy = str.lower(input("Tell me pls - is a rainy: ")) if user_rainy == 'yes': user_umbrella = str.lower(input("It is too windy for an umbrella?: ")) if user_umbrella == 'yes': print("It is too windy for an umbrella") else: print("Take an umbrella") else: print("Enjoy your day")
true
126ba2113fe13cb7a8008b772793718001df3c94
KacperKubara/USAIS_Workshops
/Clustering/k-means.py
1,734
4.1875
4
# K-NN classification with k-fold cross validation import pandas as pd import numpy as np import matplotlib.pyplot as plt # Read Data dataset = pd.read_csv("Mall_Customers.csv") # Choose which features to use x = dataset.iloc[:, 3:5].values # Features - Age, annual income (k$) """ K-Means clustering is unsupervise...
true
f0749405938e25a640b1955262887d8e5924397a
betty29/code-1
/recipes/Python/52316_Dialect_for_sort_by_then_by/recipe-52316.py
1,587
4.15625
4
import string star_list = ['Elizabeth Taylor', 'Bette Davis', 'Hugh Grant', 'C. Grant'] star_list.sort(lambda x,y: ( cmp(string.split(x)[-1], string.split(y)[-1]) or # Sort by last name ... cmp(x, y))) # ... then by first name print...
true
da7d9b543243c19783719c409b67347ce4b126a3
betty29/code-1
/recipes/Python/304440_Sorting_dictionaries_value/recipe-304440.py
843
4.21875
4
# Example from PEP 265 - Sorting Dictionaries By Value # Counting occurences of letters d = {'a':2, 'b':23, 'c':5, 'd':17, 'e':1} # operator.itemgetter is new in Python 2.4 # `itemgetter(index)(container)` is equivalent to `container[index]` from operator import itemgetter # Items sorted by key # The new built...
true
809a2e466bf5784e776a0249cf43460147cb14e0
betty29/code-1
/recipes/Python/578935_Garden_Requirements_Calculator/recipe-578935.py
2,723
4.21875
4
''' 9-16-2014 Ethan D. Hann Garden Requirements Calculator ''' import math #This program will take input from the user to determine the amount of gardening materials needed print("Garden Requirements Calculator") print("ALL UNITS ENTERED ARE ASSUMED TO BE IN FEET") print("____________________________________________...
true
e2f6af7d70e34e1fd89e1239bcbac0709810dc25
betty29/code-1
/recipes/Python/577344_Maclaurinsseriescos2x/recipe-577344.py
1,458
4.15625
4
#On the name of ALLAH and may the blessing and peace of Allah #be upon the Messenger of Allah Mohamed Salla Allahu Aliahi Wassalam. #Author : Fouad Teniou #Date : 03/008/10 #version :2.6 """ maclaurin_cos_2x is a function to compute cos(x) using maclaurin series and the interval of convergence is -inf < x < +inf cos...
true
a752a877f7aa023a64622cb406d86f9655133808
betty29/code-1
/recipes/Python/577345_Maclaurinsseriescos_x/recipe-577345.py
1,429
4.21875
4
#On the name of ALLAH and may the blessing and peace of Allah #be upon the Messenger of Allah Mohamed Salla Allahu Aliahi Wassalam. #Author : Fouad Teniou #Date : 03/08/10 #version :2.6 """ maclaurin_cos_pow2 is a function to compute cos(x) using maclaurin series and the interval of convergence is -inf < x < +inf co...
true
a5431bb48049aa784132d0a08a866223d580d2d4
betty29/code-1
/recipes/Python/577574_PythInfinite_Rotations/recipe-577574.py
2,497
4.28125
4
from itertools import * from collections import deque # First a naive approach. At each generation we pop the first element and append # it to the back. This is highly memmory deficient. def rotations(it): """ rotations([0,1,2]) --> [[0, 1, 2], [1, 2, 0], [2, 0, 1]] """ l = list(it) for i in range(len(l)):...
true
d821b07149089dba24a238c3ad83d5c8b6642fd6
betty29/code-1
/recipes/Python/577965_Sieve_Eratosthenes_Prime/recipe-577965.py
986
4.34375
4
def primeSieve(x): ''' Generates a list of odd integers from 3 until input, and crosses out all multiples of each number in the list. Usage: primeSieve(number) -- Finds all prime numbers up until number. Returns: list of prime integers (obviously). Time: around 1.5 seco...
true
849e48eba0db9689f82e2c23ec9d9ae777c78a54
betty29/code-1
/recipes/Python/466321_recursive_sorting/recipe-466321.py
443
4.25
4
""" recursive sort """ def rec_sort(iterable): # if iterable is a mutable sequence type # sort it try: iterable.sort() # if it isn't return item except: return iterable # loop inside sequence items for pos,item in enumerate(iterable): iterable[pos] = rec_sort(item) ...
true
25fc1d2d9fe540cc5e2994ac04c875cb40df2f8c
betty29/code-1
/recipes/Python/334695_PivotCrosstabDenormalizatiNormalized/recipe-334695.py
2,599
4.40625
4
def pivot(table, left, top, value): """ Creates a cross-tab or pivot table from a normalised input table. Use this function to 'denormalize' a table of normalized records. * The table argument can be a list of dictionaries or a Table object. (http://aspn.activestate.com/ASPN/Cookbook/Python/Rec...
true
a2e8e4bc7ec3c702eca1668891cfe72ea1a70113
betty29/code-1
/recipes/Python/502260_Parseline_break_text_line_informatted/recipe-502260.py
1,089
4.1875
4
def parseline(line,format): """\ Given a line (a string actually) and a short string telling how to format it, return a list of python objects that result. The format string maps words (as split by line.split()) into python code: x -> Nothing; skip this word s -> Return this word ...
true
486e319264ee6470f902c3dd3240f614d06dff83
betty29/code-1
/recipes/Python/498090_Finding_value_passed_particular_parameter/recipe-498090.py
1,180
4.125
4
import inspect def get_arg_value(func, argname, args, kwargs): """ This function is meant to be used inside decorators, when you want to find what value will be available inside a wrapped function for a particular argument name. It handles positional and keyword arguments and takes into account d...
true
f15d9fdb5bd40bfa44342919598f3df07340b086
J-Cook-jr/python-dictionaries
/hotel.py
334
4.125
4
# This program creates a dictionary of hotel rooms and it's occupants. # Create a dictionary that lists the room number and it's occupants. earlton_hotel ={ "Room 101" : "Harley Cook", "Room 102" : "Mildred Tatum", "Room 103" : "Jewel Cook", "Room 104" : "Tiffany Waters", "Room 105" : "Dejon Waters...
true
f74e3aaff1778023fc4d7180c9c3e7a96cd871ee
MatthewGerges/CS50-Programming-Projects
/MatthewGerges-cs50-problems-2021-x-sentimental-readability/readability.py
2,780
4.125
4
from cs50 import get_string # import the get_string function from cs50's library def main(): # prompt the user to enter a piece of text (a paragraph/ excerpt) paragraph1 = get_string("Text: ") letters = count_letters(paragraph1) # the return value of count_letters (how many letters there are in a...
true
ae6a511723cc0f54dc39d56b2c9ed70ed3bb9305
lnbe10/Math-Thinking-for-Comp-Sci
/combinatory_analysis/dice-game.py
2,755
4.1875
4
# dice game: # a shady person has various dices in a table # the dices can have arbitrary values in their # sides, like: # [1,1,3,3,6,6] # [1,2,3,4,5,6] # [9,9,9,9,9,1] # The shady person lets you see the dices # and tell if you want to choose yor dice before # or after him # after both of you choose, # them roll your ...
true
a60df60f1bd19896da30e8d46be5fee3a020413c
battyone/Practical-Computational-Thinking-with-Python
/ch4_orOperator.py
220
4.125
4
A = True B = False C = A and B D = A or B if C == True: print("A and B is True.") else: print("A and B is False.") if D == True: print("A or B is True.") else: print("A or B is False.")
true
255c09b29bc9cd76e730a64a0722d24b003297c8
ugneokmanaite/api_json
/json_exchange_rates.py
1,068
4.3125
4
import json # create a class Exchange Rates class ExchangeRates: # with required attributes def __init__(self): pass # method to return the exchange rates def fetch_ExchangeRates(self): with open("exchange_rates.json", "r") as jsonfile: dataset = json.load(jsonfile) ...
true
9445b358d4c35b1caec4c3bc2620b47ef514d331
MathewsPeter/PythonProjects
/biodata_validater.py
1,124
4.5625
5
'''Example: What is your name? If the user enters * you prompt them that the input is wrong, and ask them to enter a valid name. At the end you print a summary that looks like this: - Name: John Doe - Date of birth: Jan 1, 1954 - Address: 24 fifth Ave, NY - Personal goals: To be the best programmer there ever was. ''...
true
f105606ceb0d3a72e2d35e88a78952fed10f38a7
MathewsPeter/PythonProjects
/bitCountPosnSet.py
408
4.15625
4
''' input a 8bit Number count the number of 1s in it's binary representation consider that as a number, swap the bit at that position ''' n = (int)(input("enter a number between [0,127] both inclusive")) if n<0 or n>127: print("enter properly") else: n_1= n c = 0 while n: if n&0b1: ...
true
3966d55212271c1a681156beaee25f6820a076fc
zsamantha/coding_challenge
/calc.py
1,217
4.125
4
import math print("Welcome to the Calculator App") print("The following operations are available: + - / *") print("Please separate entries with a space. Ex: Use 1 + 2 instead of 1+2") print("Type \"Q\" to quit the program.") result = None op = None while(True): calc = input().strip().split() if calc[0].lower...
true
31d0b19e04fce106e14c19aec9d7d6f463f0d852
panchaly75/MyCaptain_AI
/AI_MyCaptainApp_03(1).py
863
4.3125
4
#Write a Python Program for Fibonacci numbers. def fibo(input_number): fibonacci_ls=[] for count_term in range(input_number): if count_term==0: fibonacci_ls.append(0) elif count_term==1: fibonacci_ls.append(1) else: fibonacci_ls.append(fibonacci_ls[count_term-2]+fibonacci_ls[count_ter...
true
ebb169123be03b88cdd6dcfab33657bd4a60f573
Devlin1834/Games
/collatz.py
1,792
4.15625
4
## Collatz Sequence ## Idea from Al Sweigart's 'Automate the Boring Stuff' def collatz(): global over over = False print("Lets Explore the Collatz Sequence") print("Often called the simplest impossible math problem,") print("the premise is simple, but the results are confusing!") print("Lets s...
true
26a77eaf507d1b0107e311ee09706bc352e70ced
ScottG489/Task-Organizer
/src/task/task.py
2,528
4.125
4
"""Create task objects Public classes: Task TaskCreator Provides ways to instantiate a Task instance. """ from textwrap import dedent # TODO: Should this be private if TaskCreator is to be the only # correct way to make a Task instance? class Task(): """Instantiate a Task object. Provides att...
true