blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
97d12c33b2d142eaf238ae867bf6324c08a02bf9 | lanvce/learn-Python-the-hard-way | /ex32.py | 1,033 | 4.46875 | 4 | the_count=[1,2,3,4,5]
fruits=['apples','oranges','pears','apricots']
change=[1,'pennies',2,'dimes',3,'quarters']
#this fruit kind of fora-loop goes through a list
for number in the_count:
print(f"this is count {number}")
#same as above
for fruit in fruits:
print(f"A fruit of type :{fruit}")
#also we can g... | true |
ce5457678e0742d76a9e7935a257cd1af6e05617 | RobertElias/PythonProjects | /GroceryList/main.py | 1,980 | 4.375 | 4 | #Grocery List App
import datetime
#create date time object and store current date/time
time = datetime.datetime.now()
month = str(time.month)
day = str(time.day)
hour = str(time.hour)
minute = str(time.minute)
foods = ["Meat", "Cheese"]
print("Welcome to the Grocery List App.")
print("Current Date and Time: " + month ... | true |
0cf8bac0a47bb1156eaaff40503bc1cdcadb50a1 | RobertElias/PythonProjects | /Arrays/main_1.py | 309 | 4.375 | 4 | #Write a Python program to create an array of 5 integers and display the array items.
from array import *
array_num = array('i', [1,3,5,7,9])
for i in array_num:
print("Loop through the array.",i)
print("Access first three items individually")
print(array_num[0])
print(array_num[1])
print(array_num[2])
| true |
2dae568f69ab9c93d43fb38f7f5a776844bb5e3e | Isco170/Python_tutorial | /Lists/listComprehension.py | 723 | 4.84375 | 5 | # List Comprehension offers a shorter syntax when you want to create a new list based on the values of an existing list.
# Example: Based on a list of fruits, you want a new list, containing only the fruits with the letter "a" in the name
# Without list comprehension
# fruits = ["apple", "banana", "cherry", "kiwi", ... | true |
a315863eeb4b603354fc7f681e053554a35582fc | IonutPopovici1992/Python | /LearnPython/if_statements.py | 276 | 4.25 | 4 | is_male = True
is_tall = True
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 not a male, but you are tall.")
else:
print("You are not a male.")
| true |
3f4261421609d3248060d7b9d12de47ad8bac76d | becomeuseless/WeUseless | /204_Count_Primes.py | 2,069 | 4.125 | 4 | '''
Count the number of prime numbers less than a non-negative number, n.
Example:
Input: 10
Output: 4
Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7.
'''
class Solution(object):
def countPrimes(self, n):
"""
:type n: int
:rtype: int
"""
#attemp 1... | true |
77665880cde79a8f833fb1a3f8dfe9c88368d970 | codexnubes/Coding_Dojo | /api_ajax/OOP/bike/bikechain.py | 1,120 | 4.25 | 4 | class Bike(object):
def __init__(self,price,max_speed):
self.price = price
self.max_speed = max_speed
self.miles = 0
def displayinfo(self):
print "Here are your bike stats:\n\
Price: ${}\n\
Max Speed: {}\n\
Miles Rode: {}".format(self... | true |
256f3e7cfe573c0bed1c8e5e62c6df1226d9cc79 | AlenaGB/hw | /5.py | 465 | 4.125 | 4 | gain = float(input("What is the revenue this month? $"))
costs = float(input("What is the monthly expenses? $"))
if gain == costs:
print ("Not bad. No losses this month")
elif gain < costs:
print("It's time to think seriosly about cutting costs")
else:
print("Great! This month you have a profit")
staff... | true |
c619f9cd9cef317f81eab2637a5b454ef9c745e5 | TwiggyTwixter/Udemy-Project | /test.py | 309 | 4.15625 | 4 | print("This program calculates the average of two numbers")
firstNumber = float (input({"What will the first number be:"}))
secondNumber = float (input({"What will the second number be:"}))
print("The numbers are",firstNumber, "and",secondNumber)
print("The average is: ", (firstNumber + secondNumber )/ 2) | true |
37899a51d576727fdbde970880245b40e7e5b7b4 | dusanvojnovic/tic-tac-toe | /tic_tac_toe.py | 2,430 | 4.125 | 4 | import os
board = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " "]
def print_board(board):
print(board[7] + ' |' + board[8] + ' |' + board[9])
print("--------")
print(board[4] + ' |' + board[5] + ' |' + board[6])
print("--------")
print(board[1] + ' |' + board[2] + ' |' + board[3])
def game()... | true |
f4247987858702440a4739dc84674cec373d9384 | league-python-student/level0-module1-dencee | /_02_variables_practice/circle_area_calculator.py | 1,345 | 4.53125 | 5 | import turtle
from tkinter import messagebox, simpledialog, Tk
import math
import turtle
# Goal: Write a Python program that asks the user for the radius
# of a circle and displays the area of that circle.
# The formula for the area of a circle is πr^2.
# See example image in package to chec... | true |
6d63273b82815d33226d51ddf224e22434bbaded | WalterVives/Project_Euler | /4_largest_palindrome_product.py | 975 | 4.15625 | 4 | """
From: projecteuler.net
Problem ID: 4
Author: Walter Vives
GitHub: https://github.com/WalterVives
Problem:
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... | true |
74914ed8c197d826a7c557c8a1fcd3c8e3c805aa | aryanirani6/ICS4U-Classwork | /example.py | 866 | 4.5625 | 5 | """
create a text file with word on a number of lines
1. open the text file and print out 'f.read()'. What does it look like?
2. use a for loop to print out each line individually. 'for line in f:'
3. print our words only with "m", or some other specific letter.
"""
# with open("Some_file.txt", 'r') as f:
# print(f.re... | true |
6798074572ee5e82a5da113a6ace75b4670ae00c | aryanirani6/ICS4U-Classwork | /classes/classes2.py | 2,179 | 4.375 | 4 | """
name: str
cost: int
nutrition: int
"""
class Food:
""" Food class
Attributes:
name (str): name of food
cost (int): cost of food
nutrition (int): how nutritious it is
"""
def __init__(self, name: str, cost: int, nutrition: int):
""" Create a Food object.
Arg... | true |
7416e1c946d17374332e7e4ebabb09eb159aaa97 | GribaHub/Python | /exercise15.py | 967 | 4.5 | 4 | # https://www.practicepython.org/
# PRACTICE PYTHON
# Beginner Python exercises
# Write a program (using functions!) that asks the user for a long string containing multiple words.
# Print back to the user the same string, except with the words in backwards order.
# clear shell
def cls():
print(50 * "\n"... | true |
dca9c5f3548711b16c7736adc0588fff766c95a1 | kirubakaran28/Python-codes | /valid palindrome.py | 359 | 4.15625 | 4 | import re
def isPalindrome(s):
s = s.lower()
#removes anything that is not a alphabet or number
s = re.sub('[^a-z0-9]','',s)
#checks for palindrome
if s == s[::-1]:
return True
else:
return False
s = str(input("Enter ... | true |
97a07ff8610f9950da31b1891698fd8b4514b1aa | agchen92/CIAfactbook | /CIAfactbook.py | 2,209 | 4.125 | 4 | #This project, I will be working with the data from the CIA World
#Factbook, which is a compendium of statistics about all of the
#countries on Earth. This Factbook contains demographic information
#and can serve as an excellent way to practice SQL queries in
#conjunction with the capabilities of Python.
import pandas ... | true |
45848f3c302f10ff1eb1e48363f4564253f02aa5 | kevinaloys/Kpython | /make_even_index_less_than_odd.py | 502 | 4.28125 | 4 | # Change an array, such that the indices of even numbers is less than that of odd numbers,
# Algorithnms Midterm 2 test question
def even_index(array):
index = []
for i in range(len(array)):
if(array[i]%2==1):
index.append(i) #Append the index of odd number to the end of the list 'index'
else:
index.i... | true |
bf94c8922a49d0e1c39bd4b7d0a1155c49dff54c | kevinaloys/Kpython | /k_largest.py | 463 | 4.1875 | 4 | # Finding the k largest number in an array
# This is the Bubble Sort Variation
# Will be posting selection sort variation soon..
def k_largest(k,array):
for i in range(0,len(array)-1):
for j in range(0,len(array)-1):
if (array[j] < array[j+1]):
temp = array[j+1]
array[j+1] = array[j]
array[j] = temp... | true |
a8f50b8321af1c44645978eceb1d4dd2061d22fe | IreneLopezLujan/Fork_List-Exercises | /List Exercises/find_missing_&_additional_values_in_2_lists.py | 420 | 4.25 | 4 | '''Write a Python program to find missing and additional values in two lists.'''
list_1 = ['a','b','c','d','e','f']
list_2 = ['d','e','f','g','h']
missing_values_in_list_2 = [i for i in list_1 if i not in list_2]
additional_values_in_list_2 = [i for i in list_2 if i not in list_1]
print("Missing values in list 2: "+str... | true |
975acb3772e411de687fe70e3f202841b38fb9d7 | IreneLopezLujan/Fork_List-Exercises | /List Exercises/retrurn_length_of_longest_word_in_given_sentence.py | 396 | 4.375 | 4 | '''Write a Python function that takes a list of words and returns the length of the longest one. '''
def longest_word(sentence):
words = sentence.split()
length_words = [len(i) for i in words]
return words[length_words.index(max(length_words))]
sentence = input("Enter a sentence: ")
print("Longest word: "... | true |
8df7f9a787d95033855b58f28bd082d7a363e793 | SiriShortcutboi/Clown | /ChatBot-1024.py | 1,652 | 4.21875 | 4 | # Holden Anderson
#ChatBot-1024
#10-21
# Start the Conversation
name = input("What is your name?")
print("Hi " + name + ", nice to meet you. I am Chatbot-1024.")
# ask about a favorite sport
sport = input("What is your favorite sport? ")
if (sport == "football") or (sport == "Football"):
# respond to football wit... | true |
309c009372f668d3027e0bb280ae4f7f2d1920b3 | Matttuu/python_exercises | /find_the_highest.py | 473 | 4.1875 | 4 | print("Using only if sentences, find the highest number no matter which of the three variables has the highest one. To make it simpler, you can assume that the values will always be different to each other.")
print(".............")
print("a=1")
print("b=2")
print("c=3")
print(".............")
a = 1
b = 2
c = 3
if a >... | true |
3df77e2d92eebe8f33515c01005e96215c1e8d04 | ykcai/Python_Programming | /homework/week4_homework.py | 1,691 | 4.3125 | 4 | # Python Programming Week 4 Homework
# Question 0:
# --------------------------------Code between the lines!--------------------------------
def less_than_five(input_list):
'''
( remember, index starts with 0, Hint: for loop )
# Take a list, say for example this one:
# my_list = [1, 1, 2, 3, 5, 8, 1... | true |
f28ce6bcb95689c7244c3aacf89e275f353c4174 | 5tupidmuffin/Data_Structures_and_Algorithms | /Data_Structures/Graph/dijkstrasAlgorithm.py | 2,882 | 4.25 | 4 | """
Dijkstra's Algorithm finds shortest path from source to every other node.
for this it uses greedy approach therefore its not the best approach
ref:
https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
https://www.youtube.com/watch?v=XB4MIexjvY0
https://www.geeksforgeeks.org/... | true |
40af8890f93b44c087cebb7295c7eb49bfae775a | 5tupidmuffin/Data_Structures_and_Algorithms | /Data_Structures/Graph/bfs.py | 1,650 | 4.1875 | 4 | """
in BFS we travel one level at a time it uses queue[FIFO]
to counter loops we use keep track of visited nodes with "visited" boolean array
BFS is complete
ref:
https://en.wikipedia.org/wiki/Breadth-first_search
time complexity: O(|V| + |E|) or O(V^2) if adjacency matrix is used
space... | true |
62c55d7147e1f06b7b9692751f0133f64d2ee752 | edunsmore19/Computer-Science | /Homework_Computer_Conversations.py | 1,174 | 4.21875 | 4 | # Homework_Computer_Conversations
# September 6, 2018
# Program uses user inputs to simulate a conversation.
print("\n\n\nHello.")
print("My name is Atlantia.")
userName = input("What is yours? \n")
type(userName)
print("I share a name with a great space-faring vessel.")
print("A shame you do not, " + userName + ".")
... | true |
c6bd53512252f2819483027102fbcb868b53ed26 | edunsmore19/Computer-Science | /Homework_Challenge_Questions/Homework_Challenge_Questions_1.py | 766 | 4.1875 | 4 | ## Homework_Challenge_Questions_1
## September 27, 2018
## Generate a list of 10 random numbers between 0 and 100.
## Get them in order from largest to smallest, removing numbers
## divisible by 3.
## Sources: Did some reasearch on list commands
import random
list = []
lopMeOffTheEnd = 0
## Generate the 10 random n... | true |
95eb45ad083a43ce1db7ffe5a2f47d0bd30b43c2 | edunsmore19/Computer-Science | /Homework_Monty_Hall_Simulation.py | 2,767 | 4.59375 | 5 | ## Homework_Monty_Hall_Simulation
## January 8, 2018
## Create a Monty Hall simulation
## Thoughts: It's always better to switch your door. When you first choose your door,
## you have a 1/3 chance of selecting the one with a car behind it. After a door holding
## a penny is revealed, it is then eliminated. If you sw... | true |
f192e797cab3f4c72d5b1a3d97a2c95818325a77 | Muirgeal/Learning_0101_NameGenerator | /pig_latin_practice.py | 982 | 4.125 | 4 | """Turn an input word into its Pig Latin equivalent."""
import sys
print("\n")
print("Welcome to 'Pig Latin Translator' \n")
VOWELS = 'aeiou'
while True:
original = input("What word would you like to translate? \n")
print("\n")
#Remove white space from the beginning and the end
orig... | true |
b6258eec43be05516943ba983890e315cce167ae | NicholasBaxley/My-Student-Files | /P3HW2_MealTipTax_NicholasBaxley.py | 886 | 4.25 | 4 | # CTI-110
# P3HW2 - MealTipTax
# Nicholas Baxley
# 3/2/19
#Input Meal Charge.
#Input Tip, if tip is not 15%,18%,20%, Display error.
#Calculate tip and 7% sales tax.
#Display tip,tax, and total.
#Ask for Meal Cost
mealcost = int(input("How much did the meal cost? "))
#Ask for Tip
tip = int(input('How... | true |
7853a9ecea62dc22a5e80b7dbbda7fbf8b9c185f | eburnsee/python_2_projects | /icon_manipulation/icon_manipulation.py | 1,999 | 4.28125 | 4 | def create_icon():
# loop through to make ten element rows in a list
for row in row_name_list:
# loop until we have ten rows of length 10 composed of only 1s and 0s
while True:
# gather input
row_input = input("Please enter ten characters (zeros and ones only, please!) for row " + row + ": ")
# check if ... | true |
e5523dc99c2287fb7b3343dc8da70cb5ce99b9e5 | anandabhaumik/PythoncodingPractice | /NumericProblems/FibonacciSeries.py | 1,063 | 4.25 | 4 | """
* @author Ananda
This is one of the very common program in all languages.
Fibonacci numbers are used to create technical indicators using a mathematical sequence
developed by the Italian mathematician, commonly referred to as "Fibonacci,"
For example, the early part of the sequence is 0, 1, 1, 2, 3, 5, 8, 13, ... | true |
30631e0c883005e305163f0292ac0b9b916aa77b | davejlin/py-checkio | /roman-numerals.py | 2,444 | 4.125 | 4 | '''
Roman numerals come from the ancient Roman numbering system.
They are based on specific letters of the alphabet which are combined to signify
the sum (or, in some cases, the difference) of their values.
The first ten Roman numerals are:
I, II, III, IV, V, VI, VII, VIII, IX, and X.
The Roman numeral system is dec... | true |
6db7ad876f33ee75bdd744eb81ea35980578702d | pdawson1983/CodingExcercises | /Substring.py | 1,316 | 4.15625 | 4 | # http://www.careercup.com/question?id=12435684
# Generate all the possible substrings of a given string. Write code.
# i/p: abc
# o/p: { a,b,c,ab,ac,bc,abc}
"""begin
NOTES/DISCUSSION
All substrings is not the same as all combinations
Four distinct patterns comprise all substrings
1. The original string
2. Each ch... | true |
5517280b78495d7c131208e78b3d2667165c8337 | Vimala390/Vimala_py | /sam_tuple_exe.py | 268 | 4.4375 | 4 | #Write a program to modify or replace an existing element of a tuple with a new element.
#Example:
#num= (10,20,30,40,50) and insert 90.
#Expected output: (10,20,90,40,50)
lst = [10,20,30,40,50]
lst[2] = 90
print(lst)
lst1 = tuple(lst)
print(lst1)
print(type(lst1))
| true |
60cebb65097a49a1c55af2ab49483e149d6cd4db | byunghun-jake/udamy-python-100days | /day-26-List Comprehension and the NATO Alphabet/Project/main.py | 469 | 4.28125 | 4 | import pandas
# TODO 1. Create a dictionary in this format:
# {"A": "Alfa", "B": "Bravo"}
data_frame = pandas.read_csv("./nato_phonetic_alphabet.csv")
# data_frame을 순환
data_dict = {row.letter:row.code for (index, row) in data_frame.iterrows()}
print(data_dict)
# TODO 2. Create a list of the phonetic code words from... | true |
9c0f99f8deea5f4f1f38d737a0e04ee8ad066042 | SimonTrux/DailyCode | /areBracketsValid.py | 1,006 | 4.1875 | 4 | #Imagine you are building a compiler. Before running any code, the compiler must check that the parentheses in the program are balanced.
#Every opening bracket must have a corresponding closing bracket. We can approximate this using strings.
def isBraces(c):
return c == '(' or c == ')'
def isCurly(c):
retu... | true |
0ef7995dbfc5ffa785a88d5456771876897cdcd0 | spentaur/DS-Unit-3-Sprint-1-Software-Engineering | /sprint/acme_report.py | 1,610 | 4.125 | 4 | from random import randint, uniform, choice
from acme import Product
# Useful to use with random.sample to generate names
ADJECTIVES = ['Awesome', 'Shiny', 'Impressive', 'Portable', 'Improved']
NOUNS = ['Anvil', 'Catapult', 'Disguise', 'Mousetrap', '???']
def generate_products(num_products=30):
"""Generate rando... | true |
7202e752d0907a36648cc13282e113689117c0c5 | j4s1x/crashcourse | /Projects/CrashCourse/Names.py | 572 | 4.125 | 4 | #store the names of your friends in a list called names.
#print each person's name in the list
#by accessing each element in the list, one at a time
friends = ["you", "don't", "have", "any", "friends"]
print (friends[0])
print (friends[1])
print (friends[2])
print (friends[3])
print (friends[4])
#So that was one long... | true |
2a53c61a3b1a235e4721983b872a9785ce3db31f | j4s1x/crashcourse | /Projects/CrashCourse/slices.py | 626 | 4.28125 | 4 | #Print the first three, the middle 3, and the last three of a list using slices.
animals = ['cat', 'dog', 'cow', 'horse', 'sheep', 'chicken', 'goat', 'pig', 'alpaca']
print(animals[:3])
print(animals[3:6])
print(animals[-3:])
#Let's make a copy of that list. One list will be my animals, the other will be a friend's... | true |
95574484bf6a54088492ae1e69dd2d5f4babb155 | j4s1x/crashcourse | /Projects/CrashCourse/polling.py | 669 | 4.40625 | 4 | # make a list of people who should take the favorite languages poll
#Include some names in the dictionary and some that aren't
#loop through the list of people who should take the poll
#if they have taken it, personally thank them
#elif tell them to take the poll
favorite_languages = {
'jen': 'python',
'sarah': 'c',
'e... | true |
e80dbd61d099540b05ef8366e859cb4c66c7ca6a | j4s1x/crashcourse | /Projects/CrashCourse/rivers.py | 643 | 4.65625 | 5 | #list rivers and the provinces they run through. Use a loop to print this out.
#Also print the river and provinces individually
rivers = {
'MacKenzie River': 'Northwest Territories',
'Yukon River': 'British Columbia',
'Saint Lawrence River': 'Ontario',
'Nelson River': 'Manitoba',
'Saskatchewan River': 'Saskatchewan',
... | true |
602ded7ccd367e8a8f1fe3e3cdc389eb932a0ced | Gaskill/Python-Practice | /Spirit.py | 662 | 4.21875 | 4 | #find your spirit animal
animals = ["Horse", "Pig", "Kangaroo", "Whale", "Pony", "Lobster", "Chicken", "Seahorse", "Wolf", "Bat", "Tiger", "Lion", "Pufferfish", "Swan", "Bear", "Pigeon", "Salamander", "Iguana", "Lizard", "Bee", "Crow", "Beetle", "Ant", "Elk", "Deer", "Jellyfish", "Fly", "Parrot", "Hamster", "Cow"]
prin... | true |
919274fb66cad43bd13214839b8bc7cd8b2ba625 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/Steven/lesson08/circle_class.py | 2,445 | 4.5 | 4 | #!/usr/bin/env python3
"""
The goal is to create a class that represents a simple circle.
A Circle can be defined by either specifying the radius or the diameter, and the user can query the circle for either its radius or diameter.
Other abilities of a Circle instance:
Compute the circle’s area.
Print the circle and... | true |
b302b5c46666bc07835e9d4e115b1b59c0f9e043 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/franjaku/Lesson_2/grid_printer.py | 1,311 | 4.4375 | 4 | #!/Lesson 2 grid printer
def print_grid(grid_dimensions=2,cell_size=4):
"""
Print a square grid.
Keyword Arguments
grid_dimensions -- number of rows/columns (default=2)
cell_size -- size of the cell (default=4)
Both of the arguments must be interger values. If a non-integer value
is input... | true |
a89dce9f76910fbacb0cfbe8b2ffab5b861a85bd | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/cbrown/Lesson 2/grid_printer.py | 577 | 4.25 | 4 | #Grid Printer Excercise Lesson 2
def print_grid(x,y):
'''
Prints grid with x blocks, and y units for each box
'''
#get shapes
plus = '+'
minus = '-'
bar = '|'
#minus sign sequence
minus_sequence = y * minus
grid_line = plus + minus_sequence
#Create bar pattern
bar_sequ... | true |
4eb0fd45ed58ab5e57d6dba2518fab2cc325b46a | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/kyle_lehning/Lesson04/book_trigram.py | 2,987 | 4.3125 | 4 | # !/usr/bin/env python3
import random
import re
import os
def build_trigrams(all_words):
"""
build up the trigrams dict from the list of words
returns a dict with:
keys: word pairs
values: list of followers
"""
trigrams = {}
for idx, word in enumerate(all_words[:-2]):
wo... | true |
01a438810a58c2b072b8a6823796408cf91bcb44 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/chelsea_nayan/lesson02/fizzbuzz.py | 793 | 4.5 | 4 | # chelsea_nayan, UWPCE PYTHON210, Lesson02:Fizz Buzz Exercise
# This function prints the numbers from low to high inclusive. For multiples of three, "Fizz" is printed instead of the numer and for multiples of five, "Buzz" is printed. If the number both divisble by three and five, it prints out "FizzBuzz"
def fizzbuzz... | true |
60c4c7cebe6342a7735d5633ec26ea31b4adc1c3 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/thomas_sulgrove/lesson02/series.py | 1,899 | 4.28125 | 4 | #!/usr/bin/env python3
"""
a template for the series assignment
#updated with finished code 7/29/2019 T.S.
"""
def fibonacci(n):
series = [0,1] #Define the base series values in a list
while len(series) < n + 1: #add one so normalize lenth and index number
series.append(sum(series[-2:])) #Add last two... | true |
ad66a6638692e2db39b565bdd0d495e0663263e5 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/alexander_boone/lesson02/series.py | 2,193 | 4.21875 | 4 | def fibonacci(n):
"""Return nth integer in the Fibonacci series starting from index 0."""
if n == 0:
return 0
elif n == 1:
return 1
else:
return fibonacci(n - 1) + fibonacci(n - 2)
def lucas(n):
"""Return nth integer in the Lucas series starting from index 0."""
if n == ... | true |
d6273747b57f69b222565ccfe94ee5dcfe1e271e | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/nskvarch/Lesson2/grid_printer_part2.py | 492 | 4.15625 | 4 | #Part 2 of the grid printer exercise, created by Niels Skvarch
plus = '+'
minus = '-'
pipe = '|'
space = ' '
def print_grid(n):
print(plus, n * minus, plus, n * minus, plus)
for i in range(n):
print(pipe, n * space, pipe, n * space, pipe)
print(plus, n * minus, plus, n * minus, plus)
for i in r... | true |
a7974c7692bd8e6d9105879cb823a173b81a084d | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/Isabella_Kemp/lesson02/series.py | 2,165 | 4.25 | 4 | #Isabella Kemp
#Jan-6-20
#Fibonacci Series
'''def fibonacci(n): #First attempt at this logic
fibSeries = [0,1,1]
if n==0:
return 0
if n == 1 or n == 2:
return 1
for x in range (3,n+1):
calc = fibSeries[x-2] + fibSeries[x-1]
fibSeries.append(calc)
print (fibSeries[:... | true |
17ff33d3d3f30f91fad231d74de4869231456302 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/anthony_mckeever/lesson8/assignment_1/sphere.py | 1,218 | 4.40625 | 4 | """
Programming In Python - Lesson 8 Assignment 1: Spheres
Code Poet: Anthony McKeever
Start Date: 09/06/2019
End Date: 09/06/2019
"""
import math
from circle import Circle
class Sphere(Circle):
"""
An object representing a Sphere.
"""
def __init__(self, radius):
"""
Initializes a S... | true |
34c3ad9f2aaaa6e83e863724cb3a7fd5c03318e6 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/roslyn_m/lesson07/Lesson07_Notes.py | 1,632 | 4.28125 | 4 | class Employee:
num_of_emps = 0
raise_amt = 1.04
def __init__(self, first, last, pay): # "self" refers to automatically taking in the instance
self.first = first
self.last = last
self.email = first + '.' + last + '@email.com'
self.pay = pay
def fullname(self):
... | true |
d299bb80ff5ce871c90f7d5e2733e8e93482d5d1 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/becky_larson/lesson03/3.1slicingLab.py | 2,622 | 4.1875 | 4 | #!/usr/bin/env python """
"""Exchange first and last values in the list and return"""
"""learned that using = sign, they refer to same object, so used copy."""
""" Could also use list command"""
"""tuple assert failing: RETURNING: (32, (54, 13, 12, 5, 32), 2). """
""" How to remove the parans"""
"""Is ... | true |
c28354828f26d6285ac455873abbe17ca68c0d2a | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/andrew_garcia/lesson_02/series.py | 2,455 | 4.21875 | 4 | '''
Andrew Garcia
Fibonacci Sequence
6/9/19
'''
def fibonacci(n):
""" Computes the 'n'th value in the fibonacci sequence, starting with 0 index """
number = [0, 1] # numbers to add together
if n == 0:
return(number[0])
elif n == 1:
return(number[1])
else:
for item in rang... | true |
b159c6b75befa81b3fecd3a208d6ad2f4bbcb873 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/lee_deitesfeld/lesson03/strformat_lab.py | 2,058 | 4.21875 | 4 | #Task One - Write a format string that will take a tuple and turn it into 'file_002 : 123.46, 1.00e+04, 1.23e+04'
nums = 'file_%03d : %.2f, %.2E, %.2E' % (2, 123.4567, 10000, 12345.67)
print(nums)
#Task Two
def f_string(name, color, ice_cream):
'''Takes three arguments and inserts them into a format string'''
... | true |
3bc82c02bc4a26db706f0cbcf4a772b96ede820a | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/adam_strong/lesson03/list_lab.py | 1,715 | 4.25 | 4 | #!/usr/bin/env python3
##Lists##
fruits = ['Apples', 'Pears', 'Oranges', 'Peaches']
fruits_original = fruits[:]
## Series 1 ##
print('')
print('Begin Series 1')
print('')
print(fruits)
response1 = input("Please add another fruit to my fruit list > ")
fruits.append(response1)
print(fruits)
response2 = input("Type a n... | true |
01e6e518fe93f0e2b8df5b26d563fd39960de252 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/pkoleyni/lesson04/trigram.py | 1,811 | 4.21875 | 4 | #!/usr/bin/env python3
import sys
import random
def make_list_of_words(line):
"""
This function remove punctuations from a string using translate()
Then split that string and return a list of words
:param line: is a string of big text
:return: List of words
"""
replace_reference = {ord('-... | true |
565b617a8b5c9d9fd86bc346abee60266b04092d | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/thecthaeh/Lesson08/circle_class.py | 2,228 | 4.46875 | 4 | #!/usr/bin/env python3
import math
import functools
""" A circle class that can be queried for its:
radius
diameter
area
You can also print the circle, add 2 circles together, compare the size of 2 circles (which is bigger
or are they equal), and list and sort circles.
"""
@functools.tot... | true |
8b7b1831a6a0649a23ba3028d1c3fec8f93528b6 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/will_chang/lesson04/dict_lab.py | 2,145 | 4.15625 | 4 | # Dictionaries 1
print("Dictionaries 1\n--------------\n")
dict_1 = {'name': 'Chris', 'city': 'Seattle', 'cake': 'Chocolate'}
print(dict_1)
print("\nThe entry for cake was removed from the dictionary.")
dict_1.pop('cake')
print(dict_1)
print("\nAn entry for fruit was added to the dictionary.")
dict_1['fruit'] = 'Man... | true |
d49ab47b15ea9d4d3033fc86dc627cdc019444a9 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/brgalloway/Lesson_5/except_exercise.py | 1,268 | 4.15625 | 4 | #!/usr/bin/python
"""
An exercise in playing with Exceptions.
Make lots of try/except blocks for fun and profit.
Make sure to catch specifically the error you find, rather than all errors.
"""
from except_test import fun, more_fun, last_fun
# Figure out what the exception is, catch it and while still
# in that cat... | true |
ea194097dee6ee3c57267d60835892c923316f6d | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/Steven/lesson04/trigrams.py | 1,998 | 4.34375 | 4 | #! bin/user/env python3
import random
words = "I wish I may I wish I might".split() # a list
filename = r"C:\Users\smar8\PycharmProjects\Python210\lesson04\sherlock_small.txt"
def build_trigrams(words):
trigrams = {}
# build up the dict here!
for word in range(len(words)-2): # stops with the last two w... | true |
0c47d864adfe1e2821609c2d4d3e1b312790127f | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/steve-long/lesson02-basic-functions/ex-2-2-fizzBuzz/fizzBuzz.py | 2,557 | 4.21875 | 4 | #!/usr/bin/env python3
# ========================================================================================
# Python210 | Fall 2020
# ----------------------------------------------------------------------------------------
# Lesson02
# Fizz Buzz Exercise (fizzBuzz.py)
# Steve Long 2020-09-19 | v0
#
# Requirements... | true |
c65f36c96fb3e5f1579b165fb4e52c28bf5efa82 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/Isabella_Kemp/lesson03/list_lab.py | 2,349 | 4.46875 | 4 | # Isabella Kemp
# 1/19/2020
# list lab
# Series 1
# Create a list that displays Apples, Pears, Oranges, Peaches and display the list.
List = ["Apples", "Pears", "Oranges", "Peaches"]
print(List)
# Ask user for another fruit, and add it to the end of the list
Question = input("Would you like another fruit? Add it here:... | true |
f2b721313e23b99aea53565563efd9b5373e0883 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/karl_perez/lesson03/list_lab.py | 2,968 | 4.25 | 4 | #!/usr/bin/env python3
"""Series 1"""
#Create a list that contains “Apples”, “Pears”, “Oranges” and “Peaches”.
list_original = ['Apples', 'Pears', 'Oranges', 'Peaches']
series1 = list_original[:]
#Display the list (plain old print() is fine…).
print(series1)
#Ask the user for another fruit and add it to the end of the... | true |
b0cdb8c87c76f5f383b473fb57aadb72d3399e06 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/csimmons/lesson02/series.py | 2,274 | 4.46875 | 4 | #!/usr/bin/env python3
# Craig Simmons
# Python 210
# series.py - Lesson02 - Fibonacci Exercises
# Created 11/13/2020 - csimmons
# Modified 11/14/2020 - csimmmons
def sum_series(n,first=0,second=1):
""" Compute the nth value of a summation series.
:param first=0: value of zeroth element in the series
:par... | true |
4174277a463cf7388a64db50feda0265596121ba | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/andrew_garcia/lesson_02/Grid_Printer_3.py | 1,306 | 4.21875 | 4 | '''
Andrew Garcia
Grid Printer 3
6/2/19
'''
def print_grid2(row_column, size):
def horizontal(): # creates horizontal sections
print('\n', end='')
print('+', end='')
for number in range(size): # creates first horizontal side of grid
print(' - ', end='')
print('+', end=... | true |
f6463a3d08dd4150f242193982444722f533bcd7 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/kimc05/Lesson03/List_lab.py | 2,427 | 4.34375 | 4 | #!/usr/bin/env python3
#Christine Kim
#Series 1
print("Series 1")
print()
#Create and display a list of fruits
fruits = ["Apples", "Pears", "Oranges", "Peaches"]
print(fruits)
#Request input from user for list addition
fruits.append(input("Input a fruit to add to the list: "))
print(fruits)
#Request input from user... | true |
47496e40702fa399ae03bc775318aa066a171394 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/steve_walker/lesson01/task2/logic-2_make_bricks.py | 451 | 4.375 | 4 | # Logic-2 > make_bricks
# We want to make a row of bricks that is goal inches long. We have a number of
# small bricks (1 inch each) and big bricks (5 inches each). Return True if it
# is possible to make the goal by choosing from the given bricks. This is a
# little harder than it looks and can be done without any lo... | true |
7c9c1a235810e9b3b3ed02099b481e6032eb5f54 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/Deniss_Semcovs/Lesson04/trigrams.py | 728 | 4.125 | 4 | # creating trigram
words = "I wish I may I wish I might".split()
import random
def build_trigrams(words):
trigrams = {}
for i in range(len(words)-2):
pair = tuple(words[i:i+2])
follower = [words[i+2]]
if pair in trigrams:
trigrams[pair] += follower
else:
... | true |
5919313d0bec108626f9f9b2ae9761bfa9b2dc24 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/gregdevore/lesson02/series.py | 2,388 | 4.34375 | 4 | # Module for Fibonacci series and Lucas numbers
# Also includes function for general summation series (specify first two terms)
def fibonacci(n):
""" Return the nth number in the Fibonacci series (starting from zero index)
Parameters:
n : integer
Number in the Fibonacci series to compute
"""... | true |
a745d05e6a02ef1dcbf8e66aff92ad23dda0e30f | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/jason_jenkins/lesson04/trigrams.py | 2,038 | 4.3125 | 4 | #!/usr/bin/env python3
"""
Lesson 4: Trigram assignment
Course: UW PY210
Author: Jason Jenkins
Notes:
- Requires valid input (Error checking not implemented)
- Future iteration should focus on formating input
-- Strip out punctuation?
-- Remove capitalization?
-- Create paragraphs?
"""
import random
import sys
def... | true |
6f5a61cf17281a202ca28d43e110d25235a76334 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/nam_vo/lesson02/fizz_buzz.py | 445 | 4.1875 | 4 | # Loop thru each number from 1 to 100
for number in range(1, 101):
# Print "FizzBuzz" for multiples of both three and five
if (number % 3 == 0) and (number % 5 == 0):
print('FizzBuzz')
# Print "Fizz" for multiples of three
elif number % 3 == 0:
print('Fizz')
# Print "Buzz" for multip... | true |
0ccb3742f5f6bc680207c82d952d102f7125e36f | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/annguan/lesson02/fizz_buzz.py | 524 | 4.375 | 4 | #Lesson 2 Fizz Buzz Exercise
#Run program "FizzBuzz()"
def fizz_buzz():
"""fizz_buzz prints the numbers from 1 to 100 inclusive:
for multiples of three print Fizz;
for multiples of five print Buzz
for numbers which are multiples of both three and Five, print FizzBuzz
"""
for i in range (1,101):... | true |
dfded6161f67b76fac8ff7fd0893496e81e4f4c4 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/lisa_ferrier/lesson05/comprehension_lab.py | 1,532 | 4.53125 | 5 | #!/usr/bin/env python
# comprehension_lab.py
# Lisa Ferrier, Python 210, Lesson 05
# count even numbers using a list comprehension
def count_evens(nums):
ct_evens = len([num for num in nums if num % 2 == 0])
return ct_evens
food_prefs = {"name": "Chris",
"city": "Seattle",
"cake"... | true |
16a17d11e32521f8465723d8a72354833bcd84e1 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/Shweta/Lesson08/test_circle.py | 1,762 | 4.1875 | 4 | #!/usr/bin/env python
#test code for circle assignment
from circle import *
#######1- test if object can be made and returns the right radius or not####
def test_circle_object():
c=Circle(5)
assert c.radius == 5
def test_cal_diameter():
c=Circle(5)
#diameter=c.cal_diameter(5)
assert c.diameter ... | true |
94d6b57a7d5ea05430442d28f3a8bbf235fa0463 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/chris_delapena/lesson02/series.py | 1,604 | 4.40625 | 4 | """
Name: Chris Dela Pena
Date: 4/13/20
Class: UW PCE PY210
Assignment: Lesson 2 Exercise 3 "Fibonacci"
File name: series.py
File summary: Defines functions fibonacci, lucas and sum_series
Descripton of functions:
fibonacci: returns nth number in Fibonacci sequence, where fib(n)=fib(n-1)+fib(n-2), n(0)=0 and n(1)=1... | true |
d526c9b6894043043b1069120492a35ea443d20d | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/Deniss_Semcovs/Lesson04/dict_lab.py | 1,906 | 4.15625 | 4 | #!/usr/bin/env python3
#Create a dictionary
print("Dictionaries 1")
dValues = {
"name":"Cris",
"city":"Seattle",
"cake":"Chocolate"
}
print(dValues)
#Delete the entry
print("Deleting entery for 'city'")
if "city" in dValues:
del dValues["city"]
print(dValues)
#Add an entry
print("Adding a new item")
dValues.upd... | true |
e878fd49b17b152e93fd91f6cfc88178b97fbf29 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/will_chang/lesson03/slicing_lab.py | 2,639 | 4.3125 | 4 | def exchange_first_last(seq):
"""Returns a copy of the given sequence with the first and last values swapped."""
if(len(seq) == 1): #Prevents duplicates if sequence only has one value.
seq_copy = seq[:]
else:
seq_copy = seq[-1:]+seq[1:-1]+seq[:1]
return seq_copy
def exchange_ev... | true |
5fdd8e8217317417bb9e5494433ce7d7db8998d7 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/Steven/lesson03/slicing.py | 2,184 | 4.5 | 4 | #! bin/user/env python3
'''
Write some functions that take a sequence as an argument, and return a copy of that sequence:
* with the first and last items exchanged.
* with every other item removed.
* with the first 4 and the last 4 items removed, and then every other item in the remaining sequence.
* with the elements... | true |
bc451f5e451696d92d005cf465993681ed70f4ae | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/tim_lurvey/lesson02/2.4_series.py | 2,205 | 4.34375 | 4 | #!/usr/bin/env python
__author__ = 'Timothy Lurvey'
import sys
def sum_series(n, primer=(0, 1)):
"""This function returns the nth values in an lucas sequence where n is sum of the two previous terms.
:param n: nth value to be returned from the sequence
:type n: int
:param prime... | true |
3e99ca23f0cb352898de2c6d948857e7d19c4648 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/mitch334/lesson04/dict_lab.py | 2,131 | 4.3125 | 4 | """Lesson 04 | Dictionary and Set Lab"""
# Goal: Learn the basic ins and outs of Python dictionaries and sets.
#
# When the script is run, it should accomplish the following four series of actions:
#!/usr/bin/env python3
# Dictionaries 1
# Create a dictionary containing “name”, “city”, and “cake” for “Chris” from “Se... | true |
4e5d2fddbb38e7f243c2302203c692e238740ee5 | xudaniel11/interview_preparation | /robot_unique_paths.py | 1,808 | 4.21875 | 4 | """
A robot is located at the top-left corner of an M X N grid. 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.
How many possible unique paths are there?
Input: M, N representing the number of rows and cols, respectively
Output: an in... | true |
b72c2595f1863a8a3a681657428dd4d6caceefb2 | xudaniel11/interview_preparation | /calculate_BT_height.py | 1,621 | 4.15625 | 4 | """
Calculate height of a binary tree.
"""
import unittest
def calculate_height(node):
if node == None:
return 0
left, right = 1, 1
if node.left:
left = 1 + calculate_height(node.left)
if node.right:
right = 1 + calculate_height(node.right)
return max(left, right)
class... | true |
3c419ab15020a8827a24044dfa180da9a7a5c47f | xudaniel11/interview_preparation | /array_of_array_products.py | 1,044 | 4.15625 | 4 | """
Given an array of integers arr, write a function that returns another array at the same length where the value at each index i is the product of all array values except arr[i].
Solve without using division and analyze the runtime and space complexity
Example: given the array [2, 7, 3, 4]
your function would retur... | true |
8268e7d5e29f7ccb1616fa17c022ad060256c569 | xudaniel11/interview_preparation | /check_balanced_tree.py | 1,516 | 4.4375 | 4 | """
Implement a function to check if a tree is balanced. For the purposes of this question,
a balanced tree is defined to be a tree such that no two leaf nodes differ in distance
from the root by more than one.
Solution taken from CTCI: recursive algorithms calculate the maximum and minimum length
paths in the tree. C... | true |
67f02f80af5d677d4752503c9947c994be1ad901 | Roooommmmelllll/Python-Codes | /conversion_table.py | 453 | 4.1875 | 4 | #print a conversion table from kilograms to pounds
#print every odd number from 1 - 199 in kilograms
#and convert. Kilograms to the left and pounds to the right
def conversionTable():
print("Kilograms Pounds")
#2.2 pound = 1kilograms
kilograms = 1
kilograms = float(kilograms)
while kilograms <= ... | true |
648905f5d1d15cccd1a9356204ad69db0f30ce31 | Roooommmmelllll/Python-Codes | /rightTriangleTest.py | 970 | 4.21875 | 4 | def getSides():
print("Please enter the three sides for a triagnle.\n" +
"Program will determine if it is a right triangle.")
sideA = int(input("Side A: "))
sideB = int(input("Side B: "))
sideC = int(input("Side C: "))
return sideA, sideB, sideC
def checkRight(sideA, sideB, sideC):
if sideA ... | true |
5ba3a2d27ec8f58f97c54cc837c81f210362508a | Roooommmmelllll/Python-Codes | /largerNumber.py | 241 | 4.125 | 4 |
def largeNumbers():
value = 0
for i in range(7):
user = int(input("Please input seven numbers: "))
if user > value:
value = user
print("The largest number you entered was: " + str(value) + ".")
largeNumbers()
| true |
4ef007bae17e06e2f2f81f160d2d07e8e029375f | kahnadam/learningOOP | /Lesson_2_rename.py | 688 | 4.3125 | 4 | # rename files with Python
import os
def rename_files():
#(1) get file names from a folder
file_list = os.listdir(r"C:\Users\adamkahn\learningOOP\lesson_2_prank")
#find the current working directory
saved_path = os.getcwd()
print("Current Working Directory is "+saved_path)
#change directory to the one with t... | true |
7118bf76fbb295f78247342b3b341f25d2d0a5c0 | adikadu/DSA | /implementStack(LL).py | 1,181 | 4.21875 | 4 | class Stack:
def __init__(self):
self.top = None
self.bottom = None
self.length = 0
def node(self, value):
return {
"value": value,
"next": None
}
def peek(self):
if not self.length: return "Stack is empty!!!"
return self.top["value"]
def push(self, value):
node = self.node(value)
node["nex... | true |
c27205377f4de9ef50f141c30b502a795c6dc118 | wmjpillow/Algorithm-Collection | /how to code a linked list.py | 2,356 | 4.21875 | 4 | #https://www.freecodecamp.org/news/python-interview-question-guide-how-to-code-a-linked-list-fd77cbbd367d/
#Nodes
#1 value- anything strings, integers, objects
#2 the next node
class linkedListNode:
def __init__(self,value,nextNode=None):
self.value= value
self.nextNode= nextNode
def insertNode(h... | true |
ca845b51f55cef583bfc6b9ff05741d56f474fec | mbravofuentes/Codingpractice | /python/IfStatement.py | 625 | 4.21875 | 4 | import datetime
DOB = input("Enter your DOB: ")
CurrentYear = datetime.datetime.now().year
Age = CurrentYear-int(DOB) #This will change the string into an integer
if(Age>=18):
print("Your age is {} and you are an adult".format(Age))
if(Age<=18):
print("Your age is {} and you are a Kid".format(Age))
#In Pyt... | true |
9bb1168da52c3bdbb7015f7a61f515b10dc69267 | ubercareerprep2019/Uber_Career_Prep_Homework | /Assignment-2/src/Part2_NumberOfIslands.py | 2,348 | 4.28125 | 4 | from typing import List, Tuple, Set
def number_of_islands(island_map: List[List[bool]]) -> int:
"""
[Graphs - Ex5] Exercise: Number of islands
We are given a 2d grid map of '1's (land) and '0's (water). We define an island as a body of land surrounded by
water and is formed by connecting adjacent la... | true |
bd829c3ee9c8593b97d74d5a1820c050013581f0 | lepy/phuzzy | /docs/examples/doe/scatter.py | 924 | 4.15625 | 4 |
'''
==============
3D scatterplot
==============
Demonstration of a basic scatterplot in 3D.
'''
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
def randrange(n, vmin, vmax):
'''
Helper function to make an array of random numbers having shape (n, )
with each n... | true |
529738259a0398c322cda396cfc79a6b3f5b38d3 | nancydyc/algorithms | /backtracking/distributeCandies.py | 909 | 4.21875 | 4 | def distributeCandies(candies, num_people):
"""
- loop through the arr and add 1 more candy each time
- at the last distribution n, one gets n/remaining candies
- until the remaining of the candies is 0
- if no candy remains return the arr of last distribution
>>> distributeCand... | true |
f0fa4b9c13b33806a80c6582e15bda397fafe5b9 | JonRivera/cs-guided-project-time-and-space-complexity | /src/demonstration_1.py | 1,053 | 4.3125 | 4 | """
Given a sorted array `nums`, remove the duplicates from the array.
Example 1:
Given nums = [0, 1, 2, 3, 3, 3, 4]
Your function should return [0, 1, 2, 3, 4]
Example 2:
Given nums = [0, 1, 1, 2, 2, 2, 3, 4, 4, 5]
Your function should return [0, 1, 2, 3, 4, 5].
*Note: For your first-pass, an out-of-place solut... | true |
0e9bb8e8d914754431f545af8cf6358012c52ca1 | MikeyABedneyJr/python_exercises | /challenge7.py | 677 | 4.1875 | 4 | '''
Write one line of Python that takes a given list and makes a new list that has only the even elements of this list in it. http://www.practicepython.org/exercise/2014/03/19/07-list-comprehensions.html
'''
import random
from random import randint
given_list = random.sample(xrange(101),randint(1, 101))
# even_numbe... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.