# Define a Python function match_gpa () that is passed a string that is.pdf

Define a Python function match_gpa () that is passed a string that is supposed to contain a person's first name followed (after some whitespace) by their GPA with three digits after the decimal point. It checks that the string is matched by a regex-defined pattern that captures two groups: the name and the GPA. The pattern for the name is a capital letter followed by one or more lowercase letters. The pattern for the GPA is a digit between 0 and 3 (inclusive), followed by a decimal point, followed by three digits. (We don't expect anyone to have a 4.0 GPA.) There is any amount of whitespace but nothing else before the name, and any amount of whitespace but nothing else after the GPA. (So, you need to anchor the pattern to the beginning and end of the string.) If the string passed in is matched by the pattern, then the function returns a string of the form name , GPA is GPA where name is the string matching the name pattern, and GPA is the string matching the GPA pattern. If the string is not matched by the pattern, then the function returns a string of the form Invalid format: st where st is the string that was passed in. The following is test code, followed by its output. if name_== '_main_': print (match_gpa('Allen 2.521 '))) print(match_gpa(' Tyler 3.651 ')) print(match_gpa('George 2.32 '))) print(match_gpa('Alexis =3.545)) print (match_gpa('Ed 2.965x)) Output: Allen, GPA is 2.521 Tyler, GPA is 3.651 Invalid format: George 2.32 \# Only 2 digits after the decimal point Invalid format: Alexis =3.545 \# No non-whitespace between name \& GPA Invalid format: Ed 2.965x \# No non-whitespace allowed after GPA.

1 of 1

## Recommended

regular-expression.pdf
regular-expression.pdfDarellMuchoko

Python (regular expression)
Python (regular expression)Chirag Shetty

Module 3 - Regular Expressions, Dictionaries.pdf
Module 3 - Regular Expressions, Dictionaries.pdfGaneshRaghu4

Regular expressions
Regular expressionsRaj Gupta

Php String And Regular Expressions
Php String And Regular Expressionsmussawir20

Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsEduardo Bergavera

Java căn bản - Chapter9
Java căn bản - Chapter9Vince Vo

## Similar to Define a Python function match_gpa () that is passed a string that is.pdf

Ggplot2 work
Ggplot2 workARUN DN

Strings in Python

Regular Expression
Regular ExpressionBharat17485

Chapter3 basic java data types and declarations
Chapter3 basic java data types and declarationssshhzap

stringsinpython-181122100212.pdf
stringsinpython-181122100212.pdfpaijitk

Input processing and output in Python
Input processing and output in PythonMSB Academy

Input processing and output in Python
Input processing and output in PythonRaajendra M

Inheritance - Extending a class In this lab you will start using Inhe.docx
Inheritance - Extending a class In this lab you will start using Inhe.docxPeterirMBowerv

04slide Update.pptx

Suggestion- Use Netbeans to copy your last lab (Lab 07) to a new proje.pdf
Suggestion- Use Netbeans to copy your last lab (Lab 07) to a new proje.pdfssuser58be4b1

Scala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love GameAntony Stubbs

### Similar to Define a Python function match_gpa () that is passed a string that is.pdf(20)

Variables In Php 1
Variables In Php 1

Sql operators & functions 3
Sql operators & functions 3

Ggplot2 work
Ggplot2 work

Strings in Python
Strings in Python

Strings in c++
Strings in c++

Regular Expression
Regular Expression

String notes
String notes

Chapter3 basic java data types and declarations
Chapter3 basic java data types and declarations

FINAL_TAKE_HOME
FINAL_TAKE_HOME

stringsinpython-181122100212.pdf
stringsinpython-181122100212.pdf

Chap03
Chap03

Chap03
Chap03

Input processing and output in Python
Input processing and output in Python

Input processing and output in Python
Input processing and output in Python

Inheritance - Extending a class In this lab you will start using Inhe.docx
Inheritance - Extending a class In this lab you will start using Inhe.docx

Relational+algebra (1)
Relational+algebra (1)

String functions
String functions

04slide Update.pptx
04slide Update.pptx

Suggestion- Use Netbeans to copy your last lab (Lab 07) to a new proje.pdf
Suggestion- Use Netbeans to copy your last lab (Lab 07) to a new proje.pdf

Scala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love Game

## More from allurafashions98

Cycle Wholesaling sold merchandise on account, with terms n60, to Sa.pdf
Cycle Wholesaling sold merchandise on account, with terms n60, to Sa.pdfallurafashions98

Customers experlencing technical dlfficulty with their Internet cable.pdf
Customers experlencing technical dlfficulty with their Internet cable.pdfallurafashions98

CX Enterprises has the following expected dividends \$1.03 in one yea.pdf
CX Enterprises has the following expected dividends \$1.03 in one yea.pdfallurafashions98

Customers arrive at a hotel at 26.2 per hour (Poisson distributed). T.pdf
Customers arrive at a hotel at 26.2 per hour (Poisson distributed). T.pdfallurafashions98

Custom Cabinetry has one job in process (Job 120) as of June 30 ; at .pdf
Custom Cabinetry has one job in process (Job 120) as of June 30 ; at .pdfallurafashions98

Current Attempt in Prozress The following information ralates to Sher.pdf
Current Attempt in Prozress The following information ralates to Sher.pdfallurafashions98

Current Attempt in Prowressfoe rakh abgrnative, oetarmine the impa.pdf
Current Attempt in Prowressfoe rakh abgrnative, oetarmine the impa.pdfallurafashions98

Current Attempt in Progress The Sanding Department of Oriole Furnitur.pdf
Current Attempt in Progress The Sanding Department of Oriole Furnitur.pdfallurafashions98

Current Attempt in Progress The comparative balance.pdf
Current Attempt in Progress The comparative balance.pdfallurafashions98

Current Attempt in Progress Tamarisk Company has been operating for s.pdf
Current Attempt in Progress Tamarisk Company has been operating for s.pdfallurafashions98

Current Attempt in Progress Sunland Corporation sells three different.pdf
Current Attempt in Progress Sunland Corporation sells three different.pdfallurafashions98

Current Attempt in Progress Shown helow are romnarativa etatamente nf.pdf
Current Attempt in Progress Shown helow are romnarativa etatamente nf.pdfallurafashions98

Current Attempt in Progress Selected information from Ivanhoe Ltd.s s.pdf
Current Attempt in Progress Selected information from Ivanhoe Ltd.s s.pdfallurafashions98

Current Attempt in Progress Record journal entries for the following .pdf
Current Attempt in Progress Record journal entries for the following .pdfallurafashions98

Current Attempt in Progress Pharoah Constructions manufacturing cost.pdf
Current Attempt in Progress Pharoah Constructions manufacturing cost.pdfallurafashions98

Denton Company manufactures and sells a single product. Cost da.pdf
Denton Company manufactures and sells a single product. Cost da.pdfallurafashions98

Denver Post reported that, on average, a large shopping center had an.pdf
Denver Post reported that, on average, a large shopping center had an.pdfallurafashions98

Denen Hadroed Coevamy i. Al of thrie debin {a,b & te2. What is.pdf
Denen Hadroed Coevamy i. Al of thrie debin {a,b & te2. What is.pdfallurafashions98

Denton Company manufactures and sells a single product. Cost data for.pdf
Denton Company manufactures and sells a single product. Cost data for.pdfallurafashions98

Delta Company produces a single product. The cost of producing and se.pdf
Delta Company produces a single product. The cost of producing and se.pdfallurafashions98

### More from allurafashions98(20)

Cycle Wholesaling sold merchandise on account, with terms n60, to Sa.pdf
Cycle Wholesaling sold merchandise on account, with terms n60, to Sa.pdf

Customers experlencing technical dlfficulty with their Internet cable.pdf
Customers experlencing technical dlfficulty with their Internet cable.pdf

CX Enterprises has the following expected dividends \$1.03 in one yea.pdf
CX Enterprises has the following expected dividends \$1.03 in one yea.pdf

Customers arrive at a hotel at 26.2 per hour (Poisson distributed). T.pdf
Customers arrive at a hotel at 26.2 per hour (Poisson distributed). T.pdf

Custom Cabinetry has one job in process (Job 120) as of June 30 ; at .pdf
Custom Cabinetry has one job in process (Job 120) as of June 30 ; at .pdf

Current Attempt in Prozress The following information ralates to Sher.pdf
Current Attempt in Prozress The following information ralates to Sher.pdf

Current Attempt in Prowressfoe rakh abgrnative, oetarmine the impa.pdf
Current Attempt in Prowressfoe rakh abgrnative, oetarmine the impa.pdf

Current Attempt in Progress The Sanding Department of Oriole Furnitur.pdf
Current Attempt in Progress The Sanding Department of Oriole Furnitur.pdf

Current Attempt in Progress The comparative balance.pdf
Current Attempt in Progress The comparative balance.pdf

Current Attempt in Progress Tamarisk Company has been operating for s.pdf
Current Attempt in Progress Tamarisk Company has been operating for s.pdf

Current Attempt in Progress Sunland Corporation sells three different.pdf
Current Attempt in Progress Sunland Corporation sells three different.pdf

Current Attempt in Progress Shown helow are romnarativa etatamente nf.pdf
Current Attempt in Progress Shown helow are romnarativa etatamente nf.pdf

Current Attempt in Progress Selected information from Ivanhoe Ltd.s s.pdf
Current Attempt in Progress Selected information from Ivanhoe Ltd.s s.pdf

Current Attempt in Progress Record journal entries for the following .pdf
Current Attempt in Progress Record journal entries for the following .pdf

Current Attempt in Progress Pharoah Constructions manufacturing cost.pdf
Current Attempt in Progress Pharoah Constructions manufacturing cost.pdf

Denton Company manufactures and sells a single product. Cost da.pdf
Denton Company manufactures and sells a single product. Cost da.pdf

Denver Post reported that, on average, a large shopping center had an.pdf
Denver Post reported that, on average, a large shopping center had an.pdf

Denen Hadroed Coevamy i. Al of thrie debin {a,b & te2. What is.pdf
Denen Hadroed Coevamy i. Al of thrie debin {a,b & te2. What is.pdf

Denton Company manufactures and sells a single product. Cost data for.pdf
Denton Company manufactures and sells a single product. Cost data for.pdf

Delta Company produces a single product. The cost of producing and se.pdf
Delta Company produces a single product. The cost of producing and se.pdf

Barrow Motor Ability Test - TEST, MEASUREMENT AND EVALUATION IN PHYSICAL EDUC...
Barrow Motor Ability Test - TEST, MEASUREMENT AND EVALUATION IN PHYSICAL EDUC...Rabiya Husain

Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with ExamplesTushar Tank

UniSC Fraser Coast library self-guided tour
UniSC Fraser Coast library self-guided tourUSC_Library

Overview of Databases and Data Modelling-1.pdf
Overview of Databases and Data Modelling-1.pdfChristalin Nelson

CONCEPTS OF ENVIRONMENT & ECOSYSTEM.pptx
CONCEPTS OF ENVIRONMENT & ECOSYSTEM.pptxAnupkumar Sharma

Overview of Databases and Data Modelling-2.pdf
Overview of Databases and Data Modelling-2.pdfChristalin Nelson

ICSE English Literature Class X Handwritten Notes
ICSE English Literature Class X Handwritten NotesGauri S

D.pharmacy Pharmacology 4th unit notes.pdf
D.pharmacy Pharmacology 4th unit notes.pdfSUMIT TIWARI

Chromatography-Gas chromatography-Principle
Chromatography-Gas chromatography-Principleblessipriyanka

2.20.24 Asian Americans and the Myth of the Model Minority.pptx
2.20.24 Asian Americans and the Myth of the Model Minority.pptxMaryPotorti1

Unleashing the Power of AI Tools for Enhancing Research, International FDP on...
Unleashing the Power of AI Tools for Enhancing Research, International FDP on...Dr. Vinod Kumar Kanvaria

2.20.24 The March on Washington for Jobs and Freedom.pptx
2.20.24 The March on Washington for Jobs and Freedom.pptxMaryPotorti1

IR introduction Introduction, Principle & Theory
IR introduction Introduction, Principle & Theorynivedithag131

SOCIAL JUSTICE LESSON ON CATCH UP FRIDAY
SOCIAL JUSTICE LESSON ON CATCH UP FRIDAYGloriaRamos83

2.15.24 Making Whiteness -- Baldwin.pptx
2.15.24 Making Whiteness -- Baldwin.pptxMaryPotorti1

Website Fixer-Upper Series to Boost your Online Presence
Website Fixer-Upper Series to Boost your Online PresenceSamantha Russell

Evaluation and management of patients with Dyspepsia.pptx
Evaluation and management of patients with Dyspepsia.pptxgarvitnanecha

BTKi in Treatment Of Chronic Lymphocytic Leukemia
BTKi in Treatment Of Chronic Lymphocytic LeukemiaFaheema Hasan

Barrow Motor Ability Test - TEST, MEASUREMENT AND EVALUATION IN PHYSICAL EDUC...
Barrow Motor Ability Test - TEST, MEASUREMENT AND EVALUATION IN PHYSICAL EDUC...

Bayesian Analysis Fundamentals with Examples
Bayesian Analysis Fundamentals with Examples

UniSC Fraser Coast library self-guided tour
UniSC Fraser Coast library self-guided tour

Overview of Databases and Data Modelling-1.pdf
Overview of Databases and Data Modelling-1.pdf

CONCEPTS OF ENVIRONMENT & ECOSYSTEM.pptx
CONCEPTS OF ENVIRONMENT & ECOSYSTEM.pptx

Overview of Databases and Data Modelling-2.pdf
Overview of Databases and Data Modelling-2.pdf

ICSE English Literature Class X Handwritten Notes
ICSE English Literature Class X Handwritten Notes

D.pharmacy Pharmacology 4th unit notes.pdf
D.pharmacy Pharmacology 4th unit notes.pdf

Capter 5 Climate of Ethiopia and the Horn GeES 1011.pdf
Capter 5 Climate of Ethiopia and the Horn GeES 1011.pdf

Chromatography-Gas chromatography-Principle
Chromatography-Gas chromatography-Principle

2.20.24 Asian Americans and the Myth of the Model Minority.pptx
2.20.24 Asian Americans and the Myth of the Model Minority.pptx

Unleashing the Power of AI Tools for Enhancing Research, International FDP on...
Unleashing the Power of AI Tools for Enhancing Research, International FDP on...

2.20.24 The March on Washington for Jobs and Freedom.pptx
2.20.24 The March on Washington for Jobs and Freedom.pptx

IR introduction Introduction, Principle & Theory
IR introduction Introduction, Principle & Theory

first section physiology laboratory.pptx
first section physiology laboratory.pptx

SOCIAL JUSTICE LESSON ON CATCH UP FRIDAY
SOCIAL JUSTICE LESSON ON CATCH UP FRIDAY

2.15.24 Making Whiteness -- Baldwin.pptx
2.15.24 Making Whiteness -- Baldwin.pptx

Website Fixer-Upper Series to Boost your Online Presence
Website Fixer-Upper Series to Boost your Online Presence

Evaluation and management of patients with Dyspepsia.pptx
Evaluation and management of patients with Dyspepsia.pptx

BTKi in Treatment Of Chronic Lymphocytic Leukemia
BTKi in Treatment Of Chronic Lymphocytic Leukemia

### Define a Python function match_gpa () that is passed a string that is.pdf

• 1. Define a Python function match_gpa () that is passed a string that is supposed to contain a person's first name followed (after some whitespace) by their GPA with three digits after the decimal point. It checks that the string is matched by a regex-defined pattern that captures two groups: the name and the GPA. The pattern for the name is a capital letter followed by one or more lowercase letters. The pattern for the GPA is a digit between 0 and 3 (inclusive), followed by a decimal point, followed by three digits. (We don't expect anyone to have a 4.0 GPA.) There is any amount of whitespace but nothing else before the name, and any amount of whitespace but nothing else after the GPA. (So, you need to anchor the pattern to the beginning and end of the string.) If the string passed in is matched by the pattern, then the function returns a string of the form name , GPA is GPA where name is the string matching the name pattern, and GPA is the string matching the GPA pattern. If the string is not matched by the pattern, then the function returns a string of the form Invalid format: st where st is the string that was passed in. The following is test code, followed by its output. if name_== '_main_': print (match_gpa('Allen 2.521 '))) print(match_gpa(' Tyler 3.651 ')) print(match_gpa('George 2.32 '))) print(match_gpa('Alexis =3.545)) print (match_gpa('Ed 2.965x)) Output: Allen, GPA is 2.521 Tyler, GPA is 3.651 Invalid format: George 2.32 # Only 2 digits after the decimal point Invalid format: Alexis =3.545 # No non-whitespace between name & GPA Invalid format: Ed 2.965x # No non-whitespace allowed after GPA
Current LanguageEnglish
Español
Portugues
Français
Deutsche