Skip to main content

Section 7.19 Write Code Questions Orig

Activity 7.19.1.

Fix the code so that only โ€œmeowโ€ is printed.

Activity 7.19.2.

Arrange the blocks on the right side so that only "meow" is printed.

Activity 7.19.3.

Create a function named count that accepts a string and a letter as arguments, then returns the count of that letter in the string. For example, if the function call was count("banana", "a") it would return 3. Hint: use the count method.

Activity 7.19.4.

Create a function named count that accepts a string and a letter as arguments, then returns the count of that letter in the string. For example, if the function call was count("banana", "a") it would return 3. Hint: use the count method.

Activity 7.19.5.

In Robert McCloskeyโ€™s book Make Way for Ducklings, the names of the ducklings are Jack, Kack, Lack, Mack, Nack, Ouack, Pack, and Quack. The following loop tries to output these names in order. Of course, thatโ€™s not quite right because Ouack and Quack are misspelled. Can you fix it?

Activity 7.19.6.

In Robert McCloskeyโ€™s book Make Way for Ducklings, the names of the ducklings are Jack, Kack, Lack, Mack, Nack, Ouack, Pack, and Quack. The following loop tries to output these names in order. Of course, thatโ€™s not quite right because Ouack and Quack are misspelled. Can you put the blocks in order to fix it?

Activity 7.19.7.

Write code to print out the statement โ€œHi my name is Bob2โ€ using only string methods or string slicing. You must get every part of the new string from the given strings, not by using string literals. Name the final string statement.

Activity 7.19.8.

Create code to print out the statement โ€œHi my name is Bob2โ€ using only string methods or string slicing. You must get every part of the new string from the given strings, not by using string literals. Name the final string statement.

Activity 7.19.9.

Write a program that asks for user input and prints their input in all lowercase, as well as the length of their string.

Activity 7.19.10.

Create a program that asks for user input and prints their input in all lowercase, as well as the length of their string.

Activity 7.19.11.

Arrange the blocks to fix the code so that it prints โ€œHiโ€ instead of โ€œhiโ€.

Activity 7.19.12.

Arrange the blocks to evaluate the length of the string โ€œI like green eggsโ€, store it in a variable named length, and print it, so that it prints โ€œThe length is 17โ€.

Activity 7.19.13.

Arrange the blocks to use find and string slicing to extract the portion of string after the colon character and convert it into a floating point number called num.

Activity 7.19.14.

Arrange the blocks to define a function numDigits that returns the number of digits in an integer n.

Activity 7.19.15.

Arrange the blocks to ask the user for their name and print the first letter of their name in lowercase.
You have attempted of activities on this page.