Question: Programming Exam: Boolean and Strings 1) Fill in the truth table below to determine if (not (A or B) and B) is always True (3

Programming Exam: Boolean and Strings

1) Fill in the truth table below to determine if (not (A or B) and B) is always True (3 points)

A

B

A or B

not(A or B)

not (A or B) and B

True

True

True

False

False

True

False

False

Is this always True? _______________________________________________________

2) (6 points) Name this python file YourLastNameAlarmTime.py (Example: SpiegelAlarmTime.py)

Let the days of the week be equal to the numbers 1 through 7. For Example: 1=Sunday, 2=Monday, 3=Tuesday, ...7=Saturday, and a boolean variable onVacation, return a string of the form "6:00, meaning when the alarm should go off in the morning.. Weekdays, the alarm should go off at "6:00" and on the weekend it should go off at "9:00". However if it is vacation, then on the weekdays it should go off at 9:00 and on the weekends it should be off.

  1. Determine test cases (complete the table below)

  2. Write the alarmTime function in Python. This function must return a String value as indicated above. Use the function header below.

  3. Write a main function where you print the call to alarmTime using atleast 3 test cases.

Examples: alarmTime(day, onVacation)

alarmTime(2,False) 6:00

alarmTime(7,True) off

alarmTime(2,True) 9:00

Determine Test Cases:

day

onVacation

Result

#Function header

def def alarmTime(day, onVacation):

]3) (6 points) Name this python file YourLastNameNewWord.py (Example: SpiegelNewWord.py)

Write a function with a string and integer, m, parameters that will return a string made of the first and last m letters from the string. The length of the string will be at least m.

Examples:

newWord(word, m)

newWord("Icecream", 2) "Icam"

newWord("Computer", 3) "Comter"

newWord("Chocolate", 1) "Ce"

  1. Write the newWord function in Python. This function must return a string. Use the function header below.

  2. write a main function where you print the call to the function newWord using the three example calls above.

#Function header

def newWord(word, m):

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!