LAB ASSIGNMENTS IMPORTANT: you need to complete the PDP thinking process for each program. Turn in the following: 1) two complete PDPS for both programs: text_validator and feedback_collector. 2) text_validator.py- until now, we have not validated text input. But some text inputs should follow a pattern. Write a short program that defines and calls a text validation function. Its purpose is to validate a full name or a book title (pick one). You don't have to use the mipo_ex model. Instead, this program has Main() and a function named Block(), plus a function call & print statement, in main(), to show the return value. Welcome to the name validation program. In your function definition, ask the user for input, then use .split() on the string entered, to turn it into a list of words. That way, you can use a loop to check each word, and correct capitalization and spacing. Then, you will add each corrected word back to a new string, and return. Please enter a full name for validation G correction. 8675309 Try again, and enter a full name: Try again, and enter a full name: shanice van der sanden The full name corrected is: Shanice van der Sanden Welcome to the title validation program. Please enter a title for validation & correction. Hint: Inside the loop, use conditional logic to determine the right fix for each word. Parts of names should stay in lower case, like van, der, de or di. In book titles, prepositions and articles are lower case, UNLESS they are Try again, and enter a title: the best of the beatles The corrected title is: The Best of the Beatles е the first word.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

python

**Splitting Strings...More Options**

When working with strings in Python, you can use `strip()`, `rstrip()`, and `lstrip()` methods to remove spaces. Here's how these methods differ:

- **To Explore:**
  - Use the following code:
  
    ```python
    stuff = input('Type in a sentence with 3 spaces at the beginning and at the end')
    print('1 ' + stuff + '!')
    print('2 ' + stuff.strip() + '!')
    print('3 ' + stuff.rstrip() + '!')
    print('4 ' + stuff.lstrip() + '!')
    ```

  - **Example 2:** This adaptation removes empty list items and extra characters:
  
    ```python
    sentences = 'This is a sentence. This is too.'
    sentence_list1 = sentences.split('.')  # has empty item
    sentence_list1.pop(0)  # gets rid of empty item
    print(sentence_list1)  # good, but 2nd item has leading space
    sentence_list2 = []
    for index in range(len(sentence_list1)):
        sentence_list2.append(sentence_list1[index].strip())
    print(sentence_list2)  # all good, but a pain!
    ```

- **Optimization Tip:** You can split on any character—here, it's `'.'`.

  - **A Bit Shorter, from python.org forum:**

    ```python
    sentences = 'This is a sentence. This is too.'
    sentence_list2 = []
    for sentence in sentences.split('.'):
        if sentence:  # leaves out empty item
            sentence_list2.append(sentence.strip())
    print(sentence_list2)
    ```

This illustrates how using string methods effectively can save time and ensure cleaner results in Python programming.
Transcribed Image Text:**Splitting Strings...More Options** When working with strings in Python, you can use `strip()`, `rstrip()`, and `lstrip()` methods to remove spaces. Here's how these methods differ: - **To Explore:** - Use the following code: ```python stuff = input('Type in a sentence with 3 spaces at the beginning and at the end') print('1 ' + stuff + '!') print('2 ' + stuff.strip() + '!') print('3 ' + stuff.rstrip() + '!') print('4 ' + stuff.lstrip() + '!') ``` - **Example 2:** This adaptation removes empty list items and extra characters: ```python sentences = 'This is a sentence. This is too.' sentence_list1 = sentences.split('.') # has empty item sentence_list1.pop(0) # gets rid of empty item print(sentence_list1) # good, but 2nd item has leading space sentence_list2 = [] for index in range(len(sentence_list1)): sentence_list2.append(sentence_list1[index].strip()) print(sentence_list2) # all good, but a pain! ``` - **Optimization Tip:** You can split on any character—here, it's `'.'`. - **A Bit Shorter, from python.org forum:** ```python sentences = 'This is a sentence. This is too.' sentence_list2 = [] for sentence in sentences.split('.'): if sentence: # leaves out empty item sentence_list2.append(sentence.strip()) print(sentence_list2) ``` This illustrates how using string methods effectively can save time and ensure cleaner results in Python programming.
```markdown
## Lab Assignments

### Important Instructions
You must complete the PDP thinking process for each program. Submit the following:
1. Two complete PDPs for both programs: `text_validator` and `feedback_collector`.

### Task 1: text_validator.py
Until now, we have not validated text input. Some text inputs should follow a specific pattern. Write a short program that defines and calls a text validation function. The purpose is to validate a full name or a book title (choose one).

**Steps to Implement:**
- In your function definition, ask the user for input, then use `.split()` on the string entered to turn it into a list of words.
- Utilize a loop to check each word for correct capitalization and spacing. Add each corrected word back to a new string and return it.

**Hint:** 
Inside the loop, use conditional logic to determine the correct case for each word. Parts of names should remain lowercase (e.g., van, der, de, or di). In book titles, prepositions and articles are lowercase unless they are the first word.

### Additional Guidance
You don't need to use the `mipo_ex` model. This program has a `Main()` and a function named `Block()`, plus a function call and print statement in `main()` to show the return value.

### Program Output Examples

**Name Validation Example:**
- **Program Prompt:** "Please enter a full name for validation & correction."
- **User Input:** `shanice van der sanden`
- **Output:** "The full name corrected is: Shanice van der Sanden"

**Title Validation Example:**
- **Program Prompt:** "Please enter a title for validation & correction."
- **User Input:** `the best of the beatles`
- **Output:** "The corrected title is: The Best of the Beatles"
```
Transcribed Image Text:```markdown ## Lab Assignments ### Important Instructions You must complete the PDP thinking process for each program. Submit the following: 1. Two complete PDPs for both programs: `text_validator` and `feedback_collector`. ### Task 1: text_validator.py Until now, we have not validated text input. Some text inputs should follow a specific pattern. Write a short program that defines and calls a text validation function. The purpose is to validate a full name or a book title (choose one). **Steps to Implement:** - In your function definition, ask the user for input, then use `.split()` on the string entered to turn it into a list of words. - Utilize a loop to check each word for correct capitalization and spacing. Add each corrected word back to a new string and return it. **Hint:** Inside the loop, use conditional logic to determine the correct case for each word. Parts of names should remain lowercase (e.g., van, der, de, or di). In book titles, prepositions and articles are lowercase unless they are the first word. ### Additional Guidance You don't need to use the `mipo_ex` model. This program has a `Main()` and a function named `Block()`, plus a function call and print statement in `main()` to show the return value. ### Program Output Examples **Name Validation Example:** - **Program Prompt:** "Please enter a full name for validation & correction." - **User Input:** `shanice van der sanden` - **Output:** "The full name corrected is: Shanice van der Sanden" **Title Validation Example:** - **Program Prompt:** "Please enter a title for validation & correction." - **User Input:** `the best of the beatles` - **Output:** "The corrected title is: The Best of the Beatles" ```
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Introduction to computer system
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education