Lab 2
Lab 2
Lab 2
You must get checked out by your lab CA prior to leaving early. If you leave without being
checked out, you will receive 0 credits for the lab.
Restrictions
The Python structures that you use in this lab should be restricted to those you have learned in
lecture so far. Please check with your course assistants in case you are unsure whether
something is or is not allowed!
For Problems 1 and 2, write your answers on paper or in a text editor on your computer.
Make sure you know how to convert between number systems by hand!
A = True
B = False
C = False
Evaluate the following expressions by hand assuming the above variable values.
(A and C or B) or (C and A)
(3 + 3 == 5) or (C or B and A) or (3 * 3 == 9)
(not("")) or (A and 0) or (A or B)
Create a new python file for each of the following questions. Your files should be named
lab[num]_q[num].py similar to homework naming conventions.
The standard normal distribution is a simple case of the normal distribution in which the
mean = 0 and the standard deviation = 1.
Create a new file and write code to check the value of the probability density function at x = 0,
x = 1, and x = -1. You do not need to read in user input for this problem. Print the value of the
probability density function for each value of x. Your output should be formatted as follows:
This program will solve for the area of a triangle. Take in user input for the lengths of the
triangle base and side and an angle measure. Calculate and print out the area of the
triangle using the following formula.
This problem will help you work on making your own advanced expressions as well as
testing how lucky you are. For this problem, you are not allowed to use conditionals (“if”
statements). For simplicity’s sake, 0 can represent Heads and 1 can represent Tails.
1. Ask the user of the program whether they believe the coin will land on 0 (Heads) or 1
(Tails)
2. Generate a random integer between 0 and 1 (inclusive)
3. Print what side the coin lands on
4. Print if the user was able to correctly guess