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.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 1TF
icon
Related questions
Question

python

SPLITTING STRINGS...MORE OPTIONS
You can use .strip(), rstrip() and.Istrip() methods to remove spaces.
You can split on any
To see the difference, try this code:
character - here it's '.'
stuff = input('Type in a sentence with 3 spaces at the beginning and at the end')
print('1 '+stuff+'!")
print('2 '+stuff.strip()+'T")
A bit shorter, from python.org forum
print('3 '+stuff.rstrip()+'!')
print('4 '+stuff.Istrip()+'!")
sentences = 'This is a sentence. This is too.'
Example 2- adaptation gets rid of empty list item AND extra characters
sentence_list2 = []
sentences = 'This is a sentence. This is too.
sentence_list1 = sentences split".') # has empty item
for sentence in sentences.split('.'):
sentence_list1.pop) #gets rid of empty item
if sentence: # leaves out empty item
print(sentence_list1) # good, but 2nd item has leading space
sentence_list2 = ]
sentence_list2.append(sentence.strip())
for index in range(len(sentence_list1)):
print(sentence_list2)
sentence_list2.append(sentence_list1[index].strip())
print(sentence_list2) # all good, but a pain!
= Notes
85% ộ
Transcribed Image Text:SPLITTING STRINGS...MORE OPTIONS You can use .strip(), rstrip() and.Istrip() methods to remove spaces. You can split on any To see the difference, try this code: character - here it's '.' stuff = input('Type in a sentence with 3 spaces at the beginning and at the end') print('1 '+stuff+'!") print('2 '+stuff.strip()+'T") A bit shorter, from python.org forum print('3 '+stuff.rstrip()+'!') print('4 '+stuff.Istrip()+'!") sentences = 'This is a sentence. This is too.' Example 2- adaptation gets rid of empty list item AND extra characters sentence_list2 = [] sentences = 'This is a sentence. This is too. sentence_list1 = sentences split".') # has empty item for sentence in sentences.split('.'): sentence_list1.pop) #gets rid of empty item if sentence: # leaves out empty item print(sentence_list1) # good, but 2nd item has leading space sentence_list2 = ] sentence_list2.append(sentence.strip()) for index in range(len(sentence_list1)): print(sentence_list2) sentence_list2.append(sentence_list1[index].strip()) print(sentence_list2) # all good, but a pain! = Notes 85% ộ
TEC 1150 OH 6
LA PROUICTS
LAB ASSIGNMENTS
2
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.
3
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
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).
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 & 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.
Slide 2 of 4
A Notes
88
85%
Transcribed Image Text:TEC 1150 OH 6 LA PROUICTS LAB ASSIGNMENTS 2 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. 3 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 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). 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 & 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. Slide 2 of 4 A Notes 88 85%
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr