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)
|
61
python-csi160/week02/croce_week02_lab.py
Normal file
61
python-csi160/week02/croce_week02_lab.py
Normal file
|
@ -0,0 +1,61 @@
|
|||
"""
|
||||
Author: Charlotte Croce
|
||||
Class: CSI160
|
||||
Assignment: Week 2: Lab - Conversation with a Computer
|
||||
Due Date: 1/27/25
|
||||
|
||||
Certification of Authenticity:
|
||||
I certify that this is entirely my own work, except where I have given
|
||||
fully-documented references to the work of others. I understand the definition
|
||||
and consequences of plagiarism and acknowledge that the assessor of this
|
||||
assignment may, for the purpose of assessing this assignment:
|
||||
- Reproduce this assignment and provide a copy to another member of academic
|
||||
- staff; and/or Communicate a copy of this assignment to a plagiarism checking
|
||||
- service (which may then retain a copy of this assignment on its database for
|
||||
- the purpose of future plagiarism checking)
|
||||
"""
|
||||
|
||||
|
||||
"""
|
||||
Write a program that has a conversation with the user. The program must ask for strings, integers and floats as input.
|
||||
The program must ask for at least 4 different inputs from the user. The program must reuse atleast 4 of these inputs in what it displays on the screen.
|
||||
The program must perform at least 2 arithmetic operations on the numbers the user inputs. Please turn in your .py file.
|
||||
"""
|
||||
|
||||
print("hello! i am a robot. beep beep")
|
||||
# ask for name
|
||||
name = input("what is your name?")
|
||||
# say hi and ask for favorite color
|
||||
favorite_color = input("hello " + name + ", what is your favorite color?")
|
||||
# ask if user likes ice cream
|
||||
user_likes_icecream = input("mine too, do you like Ice Cream?")
|
||||
# answer differently based on whether user answers 'yes' or not
|
||||
if(user_likes_icecream.lower() == "yes"):
|
||||
print("me too!")
|
||||
else:
|
||||
print("okay, not for everyone")
|
||||
# ask for age
|
||||
age = int(input(name + ", how old are you?"))
|
||||
# ask for number of siblings
|
||||
siblings = int(input("...and how many siblings do you have?"))
|
||||
# display how many kids you a part of; ask if favorite color is shared by anyone in the house
|
||||
is_favorite_color_of_house = input("that means you are one of " + str(siblings + 1) + " kid(s). is " + favorite_color + " the favorite color of anyone else in your house?")
|
||||
# answer differently based on whether user answers 'yes' or not
|
||||
if(is_favorite_color_of_house.lower() == "yes"):
|
||||
print("good you can agree")
|
||||
else:
|
||||
print("too bad")
|
||||
# ask for parent's age
|
||||
parent_age = int(input('how old is one of your parents?'))
|
||||
# respond with age of parents when they had the user
|
||||
print("that means they were likely " + str(parent_age - age) + " when they had you")
|
||||
# ask for GPA
|
||||
gpa = float(input("what is your GPA[4-point scale]?"))
|
||||
# answer differently based on the GPA value entered
|
||||
if(gpa >= 3.5):
|
||||
print("great job!")
|
||||
elif(gpa >= 2.5):
|
||||
print("keep it up!")
|
||||
else:
|
||||
print("time to study more!")
|
||||
print("goodbye!")
|
Loading…
Add table
Add a link
Reference in a new issue