Question: 1. Assume the variable named reply references a string. The following Python if statement determines whether reply is equal to 'Y' or 'y': if reply
1. Assume the variable named reply references a string. The following Python if statement determines whether reply is equal to 'Y' or 'y': if reply == 'Y' or reply == 'y': Rewrite this statement so that it makes only one comparison and does not use the or operator. (Hint: use either the upper or lower methods.)
2. Write a Python loop that counts the number of digits that appear in the string referenced by the variable named my_string.
3. Write a Python function that accepts a string as an argument and returns True if the argument ends with the substring ".edu". Otherwise, the function should return False.
4. Write a Python function that accepts two string arguments. The function should return the lowest index in the first string where the second string is found. If the first string does not contain the second string, the function should return a value of -1.
5. Assume that a variable named my_string references a string. Write a single Python statement that uses a slicing expression and displays the first three characters in the string.
Programming Exercise (50 points): Average Number of Words Use the file named "text.txt" that is available on Blackboard in the same location as these instructions. The text that is in the file is stored as one sentence per line. Write a Python program that reads the file's contents and calculates and displays the average number of words per sentence as well as the number of uppercase letters in the file.
https://dcccd.blackboard.com/bbcswebdav/pid-25117376-dt-content-rid-193022083_1/xid-193022083_1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
