vanatu
1/15/2019 - 7:45 PM

## Summerfild_Start

``````'''
convert numbers to graphic
'''
import sys

ZERO = ["  **  ", " *  * ", "*    *", "*    *", "*    *", " *  * ", "  **  "]
ONE = ["   *  ", "  **  ", " * *  ", "   *  ", "   *  ", "   *  ", "  *** "]
TWO = ["  *** ", " *   *", " *   *", "    * ", "   *  ", "  *   ", " **** "]
THREE = [" **** ", "     *", "   ** ", "     *", "     *", " *   *", "  *** ",]
FOUR = [" *  * ", " *  * ", " *  * ", " **** ", "    * ", "    * ", "    * ",]
FIVE = [" **** ", " *    ", " ***  ", "    * ", "     *", "    * ", " ***  ",]
SIX = ["  *** ", " *    ", " **** ", " *   *", " *   *", " *   *", "  *** ",]
SEVEN = [" **** ", "    * ", "    * ", "   *  ", "  *   ", " *    ", " *    ",]
EIGHT = ["  *** ", " *   *", "  *** ", " *   *", " *   *", " *   *", "  *** ",]
NINE = ["  *** ", " *   *", " *   *", "  ****", "     *", " *   *", "  *** ",]

GRAPHIC_DIGITS = [ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE]

try:
USER_DIGITS = sys.argv[1]
for line in range(len(GRAPHIC_DIGITS[0])):
output_line = ''
for digit in USER_DIGITS:
for char in GRAPHIC_DIGITS[int(digit)][line]:
output_line += digit if char == '*' else char
output_line += ' '
print(output_line)
except ValueError as err:
print('must be integer')

except IndexError:
print('usage: python bigdigits.py <numbers>')
``````
``````'''
input numbers to list
print COUNT, sum, lowest, highest, MEAN
'''
numbers = []
total = 0
lowest = None
highest = None

while True:
user_input = input('enter a number or Enter to finish: ')
if user_input != "":
try:
number = int(user_input)
total += number
if lowest is None or number < lowest:
lowest = number
if highest is None or number > highest:
highest = number
numbers.append(number)
except ValueError as err:
print(err)
else:
break

if numbers:
COUNT = len(numbers)
MEAN = total/COUNT
print('numbers: ', numbers)
print('COUNT = ', COUNT, 'sum = ', total,
'lowest = ', lowest, 'highest = ', highest,
'MEAN = ', MEAN)
``````
``````import random

articles = ["the", "a", "another", "her", "his"]
subjects = ["cat", "dog", "horse", "man", "woman", "boy", "girl"]
verbs = ["sang", "ran", "jumped", "said", "fought", "swam", "saw",
"heard", "felt", "slept", "hopped", "hoped", "cried",
"laughed", "walked"]
"rudely", "politely"]

counter = 5
while counter > 0:
article = random.choice(articles)
subject = random.choice(subjects)
verb = random.choice(verbs)

if random.randint(0,1):
print(article, subject, verb)
else:
counter -= 1``````
``````import sys, random

articles = ["the", "a", "another", "her", "his"]
subjects = ["cat", "dog", "horse", "man", "woman", "boy", "girl"]
verbs = ["sang", "ran", "jumped", "said", "fought", "swam", "saw",
"heard", "felt", "slept", "hopped", "hoped", "cried",
"laughed", "walked"]
"rudely", "politely"]

lines = 5
if len(sys.argv) > 1:
try:
arg = int(sys.argv[1])
if 1 <= arg <= 10:
lines = arg
else:
print('lines must be from 1 to 10 inclusive')

except ValueError:

print()

while lines > 0:
article = random.choice(articles)
subject = random.choice(subjects)
verb = random.choice(verbs)

line = f'{article} {subject} {verb}'

if random.randint(0,1):

print(line)
lines -= 1
``````
``````"""
- input numbers to list
- sort list
- print count, sum, lowest, highest, mean, median
"""

numbers = []
total = 0

def sort_list(unsorted_list):
"""sorting list"""
lenght = len(unsorted_list)
swapped = True
while swapped:
swapped = False
index = 0
while index < lenght - 1:
cur = unsorted_list[index]
nxt = unsorted_list[index + 1]
if cur > nxt:
swapped = True
unsorted_list[index] = nxt
unsorted_list[index + 1] = cur
index += 1
return unsorted_list

while True:
user_input = input('enter a number or Enter to finish: ')
if not user_input:
break
try:
number = int(user_input)
total += number
numbers.append(number)
except ValueError as err:
print(err)

if numbers:
numbers = sort_list(numbers)
COUNT = len(numbers)
LOWEST = numbers[0]
HIGHEST = numbers[-1]
MEAN = total/COUNT

HALF = len(numbers)//2
median = numbers[HALF]
if len(numbers)/2 == HALF:
median = (median + numbers[HALF - 1])/2

print('numbers: ', numbers)
print('COUNT = ', COUNT, 'sum = ', total,
'lowest = ', LOWEST, 'highest = ', HIGHEST,
'mean = ', MEAN, 'median = ', median)
``````