migrate to git.charlotte.sh
This commit is contained in:
commit
fbd588721e
412 changed files with 13750 additions and 0 deletions
5
python-csi160/week03/Week-3Practice-Problems/part1.py
Normal file
5
python-csi160/week03/Week-3Practice-Problems/part1.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
number = int(input('Enter a two digit number: '))
|
||||
|
||||
# Print the two digits of the number seperated by a space
|
||||
|
||||
print((number // 10),(number % 10))
|
7
python-csi160/week03/Week-3Practice-Problems/part2.py
Normal file
7
python-csi160/week03/Week-3Practice-Problems/part2.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Read an integer:
|
||||
number = int(input('Enter a two digit number: '))
|
||||
|
||||
# Print the digits reversed
|
||||
|
||||
|
||||
print(str(number % 10) + str(number // 10))
|
7
python-csi160/week03/Week-3Practice-Problems/part3.py
Normal file
7
python-csi160/week03/Week-3Practice-Problems/part3.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Read an integer:
|
||||
number = int(input('Enter a 3 digit number: '))
|
||||
|
||||
# Print the sum of the digits:
|
||||
|
||||
a = ((number // 100) + (number % 100 // 10) + (number % 10))
|
||||
print(a)
|
46
python-csi160/week03/Week-3Practice-Problems/part4.py
Normal file
46
python-csi160/week03/Week-3Practice-Problems/part4.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
def days_to_hours(days):
|
||||
""" Converts days to hours
|
||||
|
||||
Arguments:
|
||||
days (int): number of days as an integer
|
||||
|
||||
Return:
|
||||
number of hours (int)
|
||||
|
||||
Assumptions:
|
||||
days must be an int
|
||||
"""
|
||||
return days * 24
|
||||
|
||||
print('Days to hours:', days_to_hours(3))
|
||||
hours = days_to_hours(2)
|
||||
|
||||
|
||||
def days_to_minutes(days):
|
||||
""" Converts days to minutes
|
||||
|
||||
Arguments:
|
||||
days (int): number of days as an integer
|
||||
|
||||
Return:
|
||||
number of minutes (int)
|
||||
|
||||
Assumptions:
|
||||
days must be an int
|
||||
"""
|
||||
return days_to_hours(days) * 60
|
||||
|
||||
|
||||
def days_to_seconds(days):
|
||||
""" Converts days to seconds
|
||||
|
||||
Arguments:
|
||||
days (int): number of days as an integer
|
||||
|
||||
Return:
|
||||
number of seconds (int)
|
||||
|
||||
Assumptions:
|
||||
days must be an int
|
||||
"""
|
||||
return days_to_minutes(days) * 60
|
14
python-csi160/week03/Week-3Practice-Problems/part5.py
Normal file
14
python-csi160/week03/Week-3Practice-Problems/part5.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
def celsius_to_fahrenheit(temperature_in_celcius):
|
||||
"""This function converts a number from Celcius to Fahrenheit
|
||||
|
||||
Arguments:
|
||||
temperature_in_celcius (float): The remperature to convert
|
||||
|
||||
Returns:
|
||||
float: The temperature in Fahrenheit
|
||||
|
||||
Assumptions:
|
||||
Assumes that temperature_in_celcius is a float
|
||||
|
||||
"""
|
||||
return (temperature_in_celcius * 1.8) + 32
|
13
python-csi160/week03/Week-3Practice-Problems/part6.py
Normal file
13
python-csi160/week03/Week-3Practice-Problems/part6.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
from math import pi # This lets you refer to pi in your code
|
||||
|
||||
|
||||
def volume_cone(radius, height):
|
||||
"""Computes volume of a cone
|
||||
|
||||
:param radius: positive float
|
||||
|
||||
:param height: positive float
|
||||
|
||||
:return: volume of given cone
|
||||
"""
|
||||
return 1/3 * pi * (radius*radius) * height
|
Loading…
Add table
Add a link
Reference in a new issue