Files
2022-10-05 16:34:28 -04:00

84 lines
2.0 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# File: Pease-hw3d.py \n",
"# Author: PEASE, NICHOLAS \n",
"# Date: 05 OCT 2022\n",
"# Section: 1002-LAB\n",
"# E-mail: nicholas.pease@maine.edu \n",
"# Description: \n",
"# Write a small program that asks the user for two numbers (x, y). For each \n",
"# number from 1 to x (inclusive), print the first y multiples of that number on the same line. \n",
"# Keep repeating this action until the user inputs any negative number\n",
"# Collaboration: \n",
"# I collaborated with no one."
]
},
{
"cell_type": "code",
"execution_count": 82,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1 2 3 4\n",
"5 6 7 8\n",
"9 10 11 12\n",
"1 2 3\n",
"4 5 6\n",
"7 8 9\n",
"10 11 12\n",
"Goodbye\n"
]
}
],
"source": [
"x=1;y=1\n",
"while x > 0 and y > 0:\n",
" y = int(input(\"Hello, what is your first number? \"))\n",
" x = int(input(\"Hello, what is your second number? \"))\n",
" for y_i in range(y):\n",
" x_list = [0]*(x)\n",
" for x_i in range(1,x+1):\n",
" x_list[x_i-1] = x_i+(y_i*x)\n",
" print(*x_list)\n",
"print(\"Goodbye\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10.5 64-bit",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.5"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "369f2c481f4da34e4445cda3fffd2e751bd1c4d706f27375911949ba6bb62e1c"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}