blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
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 |
faf299ecb5bf22d7a57bed24e4e2c522ede12fc3 | tharang/my_experiments | /python_experiments/10_slice_dice_strings_lists.py | 997 | 4.3125 | 4 | # -*- coding: utf-8 -*-
__author__ = 'vishy'
verse = "bangalore"
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec']
print("verse = {}".format(verse))
print("months = {}".format(months))
#similarities in accessing lists and strings
#1 - Len() function
print("Length of string... | false |
ab33eed9ded9a48108f812dcda7ca6c7b648f78d | mazzuccoda/condicionales_python | /ejemplos_clase/ejemplo_2.py | 1,606 | 4.375 | 4 | # Condicionales [Python]
# Ejemplos de clase
# Autor: Inove Coding School
# Version: 2.0
# Ejemplos con if anidados (elif) y compuestos
# Uso de if anidados (elif)
# Verificar en que rango está z
# mayor o igual 50
# mayor o igual 30
# mayor o igual 10
# menor a 10
z = 25
if z >= 50:
print("z es mayor o igual a... | false |
5339f59f718a304990c3d25c3a9603ca244b8974 | nguyenduongkhai/sandbox | /prac2/word.generator.py | 377 | 4.125 | 4 | import random
def main():
VOWELS = "aeiou"
CONSONANTS = "bcdfghjklmnpqrstvwxyz"
name = input("Please enter a sequence of Consonants(c) and Vowels(v)")
word_format = name
word = ""
for kind in word_format:
if kind == "c":
word += random.choice(CONSONANTS)
else:
... | false |
5f2d916e536f3b8b8cf0610a37c52b2a13938a8a | BW1ll/PythonCrashCourse | /python_work/Chapter_9/9.1-9.3.py | 2,138 | 4.5625 | 5 | '''
Python Crash Course - chapter 9 - Classes
[Try it your self exercises]
'''
# 9.1
class Restaurant:
'''
example Restaurant Class in python
using a generic details a bout Restaurants to build an example class
'''
def __init__(self, restaurant_name, cuisine_type):
self.restaurant_name... | false |
8be4c686a69c1e4a9d1fc1fcea5007775b0344b2 | YonErick/d-not-2021-2 | /data/lib/queue.py | 2,543 | 4.3125 | 4 | class Queue:
"""
ESTRUTURAS DE DADOS FILA
- Fila é uma lista linear de acesso restrito, que permite apenas as operações
de enfileiramento (enqueue) e desenfileiramento (dequeue), a primeira
ocorrendo no final da estrutura e a segunda no início da estrutura.
- Como co... | false |
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 |
57c1a5bbbc88a39ea0eefcba6f54fcc39a1ff57f | saranguruprasath/Python | /Python_Classes.py | 501 | 4.1875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Aug 14 22:27:09 2018
@author: saran
"""
class Circle():
pi = 3.14
def __init__(self,radius=1):
self.radius = radius
self.area = radius * radius * Circle.pi
def get_circumference(self):
return 2 * self.pi * self.radius
... | false |
abb1c338ea69227d8e257f6a3a5de62e54b5d06c | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/barb_matthews/lesson2/series.py | 1,809 | 4.28125 | 4 | ## Lesson 2, Exercise 2.4 Fibonnaci Series
## By: B. Matthews
## 9/11/2020
def fibonacci(n):
#"""Generates a Fibonnaci series with length n"""
if (n == 0):
return 0
elif (n == 1):
return 1
else:
return fibonacci(n-1) + fibonacci(n-2)
def lucas(n):
#"""Generates a Lucas series with... | false |
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 |
d962d3b9a9df195b320e91bd054e9ea78aaf56c6 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/grant_dowell/Lesson_08/test_circle.py | 1,390 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Feb 9 20:13:36 2020
@author: travel_laptop
"""
import math
import unittest as ut
from circle import *
def test_properties():
c = Circle(10)
assert c.radius == 10
assert c.diameter == 20
print(c.area)
assert c.area == math.pi * 100
c.diameter = 6... | false |
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 |
19db572f1e6e1304d43b83ed2cde9ca0845ef36c | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/jason_jenkins/lesson04/dict_lab.py | 1,895 | 4.25 | 4 | #!/usr/bin/env python3
"""
Lesson 4: dict lab
Course: UW PY210
Author: Jason Jenkins
"""
def dictionaries_1(d):
tmp_d = d.copy()
print("\nTesting dictionaries_1")
tmp_d = dict(name="Chris", city="Seattle", cake="Chocolate")
print(tmp_d)
tmp_d.pop('city')
print(tmp_d)
tmp_d.update({'fruit... | false |
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 |
713775c79a03d7c700411131e7f5db82358fc3cd | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/mitch334/lesson02/grid_printer.py | 1,796 | 4.53125 | 5 | # Lesson 02 : Grid Printer Exercise
# Write a function that draws a grid like the following:
#
# + - - - - + - - - - +
# | | |
# | | |
# | | |
# | | |
# + - - - - + - - - - +
# | | |
# | | |
# | | |
# | ... | false |
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 |
7034f87f03b0321c6ebcb22c789ff62b8a3a028e | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/david_baylor/lesson3/Mail_Room_part1.py | 2,002 | 4.21875 | 4 | #!/usr/bin/env python3
"""
Mail_room_part1.py
By David Baylor on 12/3/19
uses python 3
Automates writing an email to thank people for their donations.
"""
def main():
data = [["bill", 100, 2, 50],["john",75, 3, 25]]
while True:
choice = input("""
What would you like to do?
1) Send a Thank You
2) Cr... | false |
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 |
05fe0c6cd5a9136f7c94df7bcbba087e851793ea | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/josh_embury/lesson02/fizzbuzz.py | 574 | 4.15625 | 4 | #--------------------------------------------------------------#
# Title: Lesson 2, FizzBuzz
# Description: Print the words "Fizz" and "Buzz"
# ChangeLog (Who,When,What):
# JEmbury, 9/18/2020, created new script
#--------------------------------------------------------------#
for i in range (1,101):
if i%3==0 and i... | false |
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 |
f5546f8ee7b79dfa119e2e08e76bdc0bf5494789 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/Kollii/lesson04/dict_lab.py | 1,951 | 4.21875 | 4 | #!/usr/bin/env python3
# Lesson 4 - DictLab
# DICTIONARY 1
dict1 = {
'name': 'Chris',
'city': 'Seattle',
'cake': 'Chocolate',
}
print(" This is original Dictionary \n")
print(dict1)
print("\nCake Element removed from Dictionary")
print(dict1.pop("cake"))
print('\n fruit = Mango added added to Diction... | false |
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 |
abfaf78910cf739ebcc1e3a3d9ed8b5945672bb1 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/joli-u/lesson04/dict_lab.py | 2,312 | 4.4375 | 4 | #!/usr/bin/env python
"""
dictionaries 1
"""
print("-----DICTIONARIES 2-----\n")
# create dictionary
_dict = {'name': 'Chris',
'city': 'Seattle',
'cake': 'Chocolate'}
_dict1 = _dict.copy()
# display dictionary
print("display dictionary: {}".format(_dict1))
# delete the "cake" entry
_dict1.pop('... | false |
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 |
4d73c1447d9ec48e3ea9cb14fe30db9b890d7386 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/Shweta/Lesson08/circle.py | 1,505 | 4.3125 | 4 | #!/usr/bin/env python
#circel program assignment for lesson08
import math
class Circle(object):
def __init__(self,radius):
self.radius=radius
# self._radius=radius
@classmethod
def from_diameter(cls,_diameter):
#self=cls()
radius = _diameter/ 2
return cls(radius)
... | false |
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 |
55f48aff0bc258783bf6e1cf91b4668bf5e7b3de | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/scott_bromley/lesson03/strformat_lab.py | 2,725 | 4.40625 | 4 | #!/usr/bin/env python3
# string formatting exercises
def main():
print(task_one())
print(task_two())
print(formatter((2, 3, 5, 7, 9))) #task three
print(task_four())
task_five()
task_six()
def task_one(file_tuple=None):
'''
given a tuple, produce a specific string using string forma... | false |
3ce552c36077599974fada702350f2e1cae0fc14 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/mattcasari/lesson08/assignments/circle_class.py | 2,916 | 4.46875 | 4 | #!/usr/bin/env python3
""" Lesson 8, Excercise 1
@author: Matt Casari
Link: https://uwpce-pythoncert.github.io/PythonCertDevel/exercises/circle_class.html
Description:
Creating circle class and a sphere sub-class
"""
import math
class Circle(object):
# @classmethod
def __init__(self, the_radius=0):
... | false |
b6a265e4836602f5165692a2bbbf1b090d038203 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/kimc05/Lesson03/strformat_lab.py | 2,138 | 4.1875 | 4 | #Christine Kim
#Python210 Lesson 3 String Formatting Lab Exercise
#Task One
#Given tuple
t1_tuple = (2, 123.4567, 10000, 12345.67)
#d for decimal integer, f for floating point, e for exponent notation, g for significant digits
t1_str = "file_{:03d} : {:.2f}, {:.2e}, {:.3g}".format(t1_tuple[0], t1_tuple[1], t1_tup... | false |
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 |
3559a141a2d051c4f05936aeafcb177da8921195 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/Kollii/lesson03/strformat_lab.py | 2,531 | 4.15625 | 4 |
# Task One
"""a format string that will take the following four element tuple:
( 2, 123.4567, 10000, 12345.67)
and produce:
'file_002 : 123.46, 1.00e+04, 1.23e+04'
"""
print("## Task One ##\n")
string = (2, 123.4567, 10000, 12345.67)
print("A string: ", string)
formated_str = "file_{:03d} : {:10.2f}, {:.2e}, {:.3g}... | false |
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 |
bc1fe51df6dabcadf392317ac91e359f7e565e48 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/kimc05/Lesson08/circle.py | 1,443 | 4.4375 | 4 | """
Christine Kim
Lesson 8
Assignment Circles
"""
import math
class Circle():
#initiate circle with radius
def __init__(self, radius):
self.radius = radius
def __str__(self):
return "Circle with radius: {}".format(self.radius)
def __repr__(self):
return "Circle({})".format(se... | false |
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 |
d9a0ff4f9fac9f83291723dfbfd8f010c51e5d3e | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/anthony_mckeever/lesson4/exercise_1/dict_lab.py | 1,660 | 4.28125 | 4 | #!/usr/bin/env python3
"""
Programming In Python - Lesson 4 Exercise 1: Dictionary (and Set) Lab
Code Poet: Anthony McKeever
Start Date: 08/05/2019
End Date: 08/05/2019
"""
# Task 1 - Dictionaries 1
print("Task 1 - Dictionaries:")
fun_dictionary = {"name": "Sophia",
"city": "Seattle",
... | false |
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 |
2bfc44ed603cc4ff70fef4e524918ef13944094d | lucas-cavalcanti-ads/projetos-fiap | /1ANO/PYTHON/ListaExercicios/Lista03/Ex13.py | 600 | 4.125 | 4 | from datetime import date
print("Bem vindo ao programa de informacao de datas")
hoje = date.today()
print("Voce está executando esse programa em:",hoje.day,"/",hoje.month,"/",hoje.year)
dia = int(input("Digite o dia de hoje(Ex:22, 09): "))
mes = int(input("Digite o mes de hoje(Ex:07, 12): "))
ano = int(input("Digite o ... | false |
e5a741e738040de2e2b62dd7515e2ae5afa31440 | lucas-cavalcanti-ads/projetos-fiap | /1ANO/PYTHON/ListaExercicios/Lista02/Ex03.py | 808 | 4.15625 | 4 | teclado = input("Digite o primeiro numero: ")
num1 = int(teclado)
teclado = input("Digite o segundo numero: ")
num2 = int(teclado)
soma = num1 + num2
somar = str(soma)
subtracao = num1 - num2
subtracaor = str(subtracao)
multiplicacao = num1 * num2
multiplicacaor = str(multiplicacao)
divisao = num1 / num2
divisaor = st... | false |
7f2f690fa1b67d1c43566771e783c08d2eb57588 | jamathis77/Python-fundamentals | /conditionals.py | 2,444 | 4.28125 | 4 | # A conditional resolves to a boolean statement ( True or False)
left = True
right = False
# Equality Operators
left != right # left and right are not equivalent
left == right # left and right are equivalent
left is right # left and right are same identity
left is not right # Left and right are not same identit... | false |
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 |
8af20acbd18a8e179396fff27dedfa4cddda7d3c | mayer-qian/Python_Crash_Course | /chapter4/numbers.py | 1,092 | 4.34375 | 4 | #使用函数range生成数字,从1开始到5结束,不包含5
for value in range(1, 5):
print(value)
print("=======================================")
#用range创建数字列表
numbers = list(range(1, 6))
print(numbers)
print("=======================================")
#定义步长
even_numbers = list(range(2, 11, 2))
print(even_numbers)
print("================... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.