Assessment: Week Three

Assessment: Week Three >> Python Basics

rainfall_mi is a string that contains the average number of inches of rainfall in Michigan for every month (in inches) with every month separated by a comma. Write code to compute the number of months that have more than 3 inches of rainfall. Store the result in the variable num_rainy_months. In other words, count the number of items with values > 3.0.

Hard-coded answers will receive no credit.

 
 
 
 

ActiveCode (assess_ps3_1_1_1)

Expand Differences

You passed: 100.0% of the tests

Score: 1.0 / 1

 

The variable sentence stores a string. Write code to determine how many words in sentence start and end with the same letter, including one-letter words. Store the result in the variable same_letter_count.

Hard-coded answers will receive no credit.

 
 
 

ActiveCode (assess_ps3_1_1_2)

Expand Differences

You passed: 100.0% of the tests

Score: 1.0 / 1

 

Write code to count the number of strings in list items that have the character w in it. Assign that number to the variable acc_num.

HINT 1: Use the accumulation pattern!

HINT 2: the in operator checks whether a substring is present in a string.

Hard-coded answers will receive no credit.

 
 
 

ActiveCode (assess_ps3_1_1_3)

Expand Differences

You passed: 100.0% of the tests

Score: 1.0 / 1

Comment: autograded

Write code that counts the number of words in sentence that contain either an “a” or an “e”. Store the result in the variable num_a_or_e.

Note 1: be sure to not double-count words that contain both an a and an e.

HINT 1: Use the in operator.

HINT 2: You can either use or or elif.

Hard-coded answers will receive no credit.

 
 
 
 

ActiveCode (assess_ps3_1_1_4)

Expand Differences

You passed: 100.0% of the tests

Score: 1.0 / 1

Comment: autograded

Write code that will count the number of vowels in the sentence s and assign the result to the variable num_vowels. For this problem, vowels are only a, e, i, o, and u. Hint: use the in operator with vowels.

 
 
 
 
 

ActiveCode (assess_ps3_1_1_5)

Expand Differences

You passed: 100.0% of the tests