Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

Students also viewed these Programming questions

Question

What is American Polity and Governance ?

Answered: 1 week ago