CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

| Download

/home/user/M01 Programming Assignment - Numbers and Types_HipsherKathleen.ipynb

Views: 28
Image: ubuntu2204
Kernel: Python 3 (system-wide)
#3.1 How many seconds are in an hour? #60 sec/min * 60 min/hr 60 * 60
3600
#3.2 Assign the result from the previous task (seconds in an hour) to a variable called seconds_per_hour. seconds_per_hour = 3600
#3.3 How many seconds are in a day? Use your seconds_per_hour variable. 3600 * 24
86400
#3.4 Calculate seconds per day again, but this time save the result in a variable called seconds_per_day. 60 * 60 * 24
86400
#3.5 Divide seconds_per_day by seconds_per_hour. Use floating-point (/) division. 86400 / 3600
24.0
#Divide seconds_per_day by seconds_per_hour, using integer (//) division. Did this number agree with the floating-point value from the previous question, aside from the final .0? 86400 // 3600
24
{ "cells": [ { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "3600" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#60 sec/min * 60 min/hr\n", "60 * 60" ] }, { "cell_type": "markdown", "metadata": {}, "source": [] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "seconds_per_hour = 3600" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "86400" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#seconds_per_hour * 24 hr/day \n", "3600 * 24" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "86400" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#60 sec/min * 60 min/hr * 24 hr/day = seconds_per_day\n", "60 * 60 * 24" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "24.0" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#seconds_per_day / seconds_per_hour\n", "86400 / 3600" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "24" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#seconds_per_day // seconds_per_hour\n", "86400 // 3600" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.10.4 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.4" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "2b03afb13634ca27c3f15c314a7c4796466f880817c3eea1d92f44c87f051b9c" } } }, "nbformat": 4, "nbformat_minor": 2 }