This is the first homework where you'll write Python code, so the instructions are detailed and long. The actual problems are brief.
This homework assignment must be submitted in Gradescope by 10am CST on Wednesday, September 8, 2021.
This homework assignment is about the topics of worksheet 2, i.e. variables, the built-in types int, float, and string, and the use of booleans and conditionals.
No collaboration is permitted, and you may only access resources (books, online, etc.) listed below.
The course materials you may refer to for this homework are:
Expected to be most useful:
Allowed and possibly useful, but not the most relevant:
This homework assignment has 2 problems, numbered #2 and #3. Each problem is worth 4 points.
Because of the way Gradescope works, there will also be a problem 1 worth 0 points.
Ask your instructor or TA a question by email, in office hours, or on discord.
In Gradescope, problem 1 is used to report the result of autograder testing. In this homework, the autograder will ONLY give you advice (warn you of syntax issues etc.) but it won't actually assign any points. Everyone will get a full score (0 out of 0) on problem 1.
Write a program hwk2prob2.py
that waits for the user to type one line of text.
If the user types Bumblebee
(capital B) followed by the Enter key, the program should print BUMBLEBEE DETECTED
. Otherwise, it should print NO BUMBLEBEE
.
Sample usage (first line is always what the user typed):
Bumblebee
BUMBLEBEE DETECTED
Feral raccoon holding an improvised spear
NO BUMBLEBEE
This line of text has Bumblebee in it but is not just that word by itself
NO BUMBLEBEE
# Contents of hwk2prob2.py
input_word = input()
if input_word == "Bumblebee":
print("BUMBLEBEE DETECTED")
else:
print("NO BUMBLEBEE")
Write a program hwk2prob3.py
that asks the user for a base $b$ and exponent $x$ (both of them floats) and which then prints the value of $b^x$ (i.e. $b$ raised to the power $x$). You don't need to do any checking to make sure the input is valid.
The interface should look like this (two examples shown):
Base: 2.5
Exponent: 8
1525.87890625
(Here, 2.5
and 8
are values typed by the user.)Base: 64
Exponent: 0.5
8.0
(Here, 64
and 0.5
are values typed by the user.)# Contents of hwk2prob3.py
base = float(input("Base: "))
exp = float(input("Exponent: "))
print(base**exp)