Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

On the next page is a function valid_street(name), which takes in one string parameter, name, representing a potential street name. The function is intended to

image text in transcribed
image text in transcribed
image text in transcribed
On the next page is a function valid_street(name), which takes in one string parameter, name, representing a potential street name. The function is intended to return the boolean value True if the name follows the above rules, or False if it doesn't, but it contains several logic errors in the second line of code. Also included is a set of test cases in an if __ name == '_main_': block, along with their expected outputs. Copy the code on the next page into a file called ex3-5.py. Fix the logic errors by changing only the second line of code (the return statement). Do not add any additional lines of code - this can be done without using if/elif/else by using logic and boolean operators. Submit the fixed ex3-5.py file to the Make-up Exercise 3-5 link on Gradescope. Hints: - If an integer X is divisible by another integer Y, then X%Y equals 0 . - You may want to review zyBooks 1.11 for how to access individual characters in a string. - Remember your order of operations! The formula for the number of graduate TAs the CSCI department assigns to a course is complicated, but here is a simplified version: - If the course number starts with ' 1 ' or ' 2 ', then one graduate TA will be assigned, regardless of other factors. - If the course number starts with anything else, then the number of graduate TAs is equal to the number of students divided by 50 , rounded down to the nearest integer. There is an exception to this: if the course has less than 50 students but has at least one lab section, then one graduate TA will be assigned, not zero. Write a function grad_TAs (number, labs, students) that takes in three parameters: - number represents the course number. This is a string, because there are some courses that end with a letter, like 1133H or 3081W. - labs is an integer representing the number of lab sections associated with the course - students is an integer representing the number of students enrolled in the course. The function should use the rules specified above to return the number of graduate TAs assigned to the course as an integer. Submit your code in a file called ex3-6.py to the Make-up Exercise 3-6 link on Gradescope. Hints: - You can use the int function, or integer division (//) to round down to the nearest integer. - Recall from zyBooks that you can get the first character of a string var by accessing the element at index 0:var[] Test Cases, with expected output in comments: Test Cases, with expected output in comments

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

Oracle 12c SQL

Authors: Joan Casteel

3rd edition

1305251032, 978-1305251038

More Books

Students also viewed these Databases questions

Question

What are some common virus carriers?

Answered: 1 week ago