migrate to git.charlotte.sh
This commit is contained in:
commit
fbd588721e
412 changed files with 13750 additions and 0 deletions
10
python-csi160/week02/Week-2Practice-Problems/part1.py
Normal file
10
python-csi160/week02/Week-2Practice-Problems/part1.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
# This program reads two numbers and prints their sum:
|
||||
a = int(input('Enter first number: '))
|
||||
b = int(input('Enter second number: '))
|
||||
c = int(input('Enter third number: '))
|
||||
|
||||
print(a + b + c)
|
||||
|
||||
# Can you change it so it can read and sum three numbers?
|
||||
|
||||
|
5
python-csi160/week02/Week-2Practice-Problems/part2.py
Normal file
5
python-csi160/week02/Week-2Practice-Problems/part2.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Get the user's name
|
||||
name = input('Enter your name:\n')
|
||||
|
||||
# Print hello statement
|
||||
print("Hello, " + name + "!")
|
7
python-csi160/week02/Week-2Practice-Problems/part3.py
Normal file
7
python-csi160/week02/Week-2Practice-Problems/part3.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Read an integer:
|
||||
number = int(input('Enter a number:\n'))
|
||||
|
||||
# Print output for next and previous that matches the instructions
|
||||
|
||||
print("The next number for the number " + str(number) + " is " + str(number + 1))
|
||||
print("The previous number for the number " + str(number) + " is " + str(number - 1))
|
7
python-csi160/week02/Week-2Practice-Problems/part4.py
Normal file
7
python-csi160/week02/Week-2Practice-Problems/part4.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Read the numbers b and h like this:
|
||||
base = float(input('Enter Base: '))
|
||||
height = float(input('Enter Height: '))
|
||||
|
||||
# Print the result with print()
|
||||
area = 0.5 * (base * height)
|
||||
print(area)
|
7
python-csi160/week02/Week-2Practice-Problems/part5.py
Normal file
7
python-csi160/week02/Week-2Practice-Problems/part5.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Read the numbers like this:
|
||||
num_students = int(input("Number of students: "))
|
||||
num_apples = int(input("Number of apples: "))
|
||||
|
||||
# Print the result with print()
|
||||
print(num_apples // num_students)
|
||||
print(num_apples % num_students)
|
9
python-csi160/week02/Week-2Practice-Problems/part6.py
Normal file
9
python-csi160/week02/Week-2Practice-Problems/part6.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Read an integer:
|
||||
seconds_past_midnight = int(input())
|
||||
|
||||
|
||||
full_hours_past_midnight = (seconds_past_midnight // 3600) % 24
|
||||
full_minutes_past_midnight = (seconds_past_midnight // 60) % 1440
|
||||
|
||||
print (full_hours_past_midnight, full_minutes_past_midnight)
|
||||
|
11
python-csi160/week02/Week-2Practice-Problems/part7.py
Normal file
11
python-csi160/week02/Week-2Practice-Problems/part7.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Input the data
|
||||
cupcake_dollars = int(input())
|
||||
cupcake_cents = int(input())
|
||||
num_cupcakes = int(input())
|
||||
|
||||
# Your code here
|
||||
|
||||
total_cost_cents = (((cupcake_dollars * 100) + cupcake_cents) * num_cupcakes)
|
||||
total_cost_dollars = total_cost_cents // 100
|
||||
total_cost_cents = total_cost_cents % 100
|
||||
print(total_cost_dollars, total_cost_cents)
|
Loading…
Add table
Add a link
Reference in a new issue