Hello everybody,
Michael here, and today, I thought I try something different with my Python lessons. See, in 2020, you may recall I posted a lesson on fun R modules aptly titled R Lesson 20: Fun with R. Now this time, I thought we’d have a little fun with different fun Python modules (though unlike in R, Python doesn’t have an aptly-named fun package).
- Keep in mind that you’ll need to PIP install all of the packages we’re playing with.
Now, let’s get started! First off, we’ll explore the pyjokes package, which simply outputs random corny (or funny, depending on your tastes) coding one-liners. Take a look at this:
!pip install pyjokes
pyjokes.get_joke()
"Waiter: He's choking! Is anyone a doctor? Programmer: I'm a Vim user."
- Yes, you can PIP install packages in your IDE-simply place an exclamantion point before the
pip install ...command.
To acutally get one of these one-lines, use the pyjokes module’s .get_joke() method (it takes in no parameters). As you can see, we were able to retrieve a coding joke-"Waiter: He's choking! Is anyone a doctor? Programmer: I'm a Vim user."
- This one is clever-if any of you have ever worked with Git/Github, odds are you’ve used the Vim text editor (and realized how much it sucks).
Here’s another pyjoke:
pyjokes.get_joke()
'What does pyjokes have in common with Adobe Flash? It gets updated all the time, but never gets any better.'
Alright, now that we’ve explored some coding one-liners, let’s move on to our next fun package-antigravity. There’s no need to pip install this package-rather, simply type import antigravity into your IDE and you will be redirected to the (rather cheesy) antigravity web-comic:

- Apparently this webcomic has been running since 2006. Who knew?
Now, let’s move on to our next package-art. Although this package doesn’t have much practical use for coders, it’s entertaining to play around with. Take a look:
!pip install art
from art import *
tprint('Michael`s Analytics Blog')
In this example, I used the art module’s tprint() method, passed in a String to this method, and voila, I get some simplistic ASCII art consisting of the String I passed in (Michael's Analytics Blog).
- I think it looks pretty neat, but don’t expect to see this as my blog logo anytime soon.
Now, what if we wanted to change the style of the ASCII art generated? Take a look at this example:
from art import *
tprint('Coding', font='block')
In this example, I am still generating ASCII art. However, I did add the font parameter to the tprint method and set the value of font to block, which will show each character in the String inside an ASCII-generated block. I personally would only use the block font for short words, as the block font display looks really messy if I tried using a phrase like Michael's Analytics Blog (see picture below for the messy output):
- This is only PART of the messy output.
The next fun little package I want to explore is wikipedia, which serves as a handy-dandy Wikipedia web-scraper library (don’t worry, we’ll explore web scraping in future Python lessons). To install the wikipedia package, run the !pip install wikipedia command in your IDE (or run this command in your command prompt without the exclamation point-that works too).
Now that you’ve installed the package, let’s explore some of the cool things wikipedia can do:
First, let’s print out a summary of an article on Wikipedia:
import wikipedia
print(wikipedia.summary('SouthPark'))
South Park is an American animated sitcom created by Trey Parker and Matt Stone and developed by Brian Graden for Comedy Central. The series revolves around four boys—Stan Marsh, Kyle Broflovski, Eric Cartman, and Kenny McCormick—and their exploits in and around the titular Colorado town. South Park became infamous for its profanity and dark, surreal humor that satirizes a wide range of topics toward an adult audience.
Parker and Stone developed South Park from two animated short films both titled The Spirit of Christmas. The second short became one of the first Internet viral videos, leading to South Park's production. The pilot episode was produced using cutout animation; subsequent episodes have since used computer animation recalling the cutout technique. South Park features a large ensemble cast of recurring characters.
Since its debut on August 13, 1997, 312 episodes (including television films) of South Park have been broadcast. It debuted with great success, consistently earning the highest ratings of any basic cable program. Subsequent ratings have varied, but it remains one of Comedy Central's highest-rated programs. In August 2021, the series was renewed through 2027, and a series of films was announced for the streaming service Paramount+, the first two of which were released later that year.South Park has received numerous accolades, including five Primetime Emmy Awards, a Peabody Award, and numerous inclusions in various publications' lists of greatest television shows. A theatrical film, South Park: Bigger, Longer & Uncut, was released in June 1999 to commercial and critical success, garnering an Academy Award nomination. In 2013, TV Guide ranked South Park the tenth Greatest TV Cartoon of All Time.
In this example, (after importing wikipedia) I used wikipedia‘s .summary() method to retrieve a summary of Wikipedia’s article on South Park-I also used the print() method to print out the article’s summary.
- You can run a
.summary()on literally any topic under the sun, but if your topic has multiple words (as in South Park), pass in the.summary()method parameter as a single word (e.g. SouthPark). Here’s what happened when I tried passing in South Park as two separate words:
import wikipedia
print(wikipedia.summary('South Park'))
---------------------------------------------------------------------------
PageError Traceback (most recent call last)
<ipython-input-5-2fa4221dc36b> in <module>
1 import wikipedia
----> 2 print(wikipedia.summary('South Park'))
~\anaconda3\lib\site-packages\wikipedia\util.py in __call__(self, *args, **kwargs)
26 ret = self._cache[key]
27 else:
---> 28 ret = self._cache[key] = self.fn(*args, **kwargs)
29
30 return ret
~\anaconda3\lib\site-packages\wikipedia\wikipedia.py in summary(title, sentences, chars, auto_suggest, redirect)
229 # use auto_suggest and redirect to get the correct article
230 # also, use page's error checking to raise DisambiguationError if necessary
--> 231 page_info = page(title, auto_suggest=auto_suggest, redirect=redirect)
232 title = page_info.title
233 pageid = page_info.pageid
~\anaconda3\lib\site-packages\wikipedia\wikipedia.py in page(title, pageid, auto_suggest, redirect, preload)
274 # if there is no suggestion or search results, the page doesn't exist
275 raise PageError(title)
--> 276 return WikipediaPage(title, redirect=redirect, preload=preload)
277 elif pageid is not None:
278 return WikipediaPage(pageid=pageid, preload=preload)
~\anaconda3\lib\site-packages\wikipedia\wikipedia.py in __init__(self, title, pageid, redirect, preload, original_title)
297 raise ValueError("Either a title or a pageid must be specified")
298
--> 299 self.__load(redirect=redirect, preload=preload)
300
301 if preload:
~\anaconda3\lib\site-packages\wikipedia\wikipedia.py in __load(self, redirect, preload)
343 if 'missing' in page:
344 if hasattr(self, 'title'):
--> 345 raise PageError(self.title)
346 else:
347 raise PageError(pageid=self.pageid)
PageError: Page id "south part" does not match any pages. Try another id!
- As to why
wikipediathinks I was looking for “south part”-your guess is as good as mine readers.
Now, let’s say I wanted to web-scrape the results of a Wikipedia search. Here’s how to do so:
import wikipedia
wikipedia.search('MCU')
['Marvel Cinematic Universe',
'List of Marvel Cinematic Universe films',
'Marvel Cinematic Universe: Phase Four',
'List of Marvel Cinematic Universe television series',
'Characters of the Marvel Cinematic Universe',
'MCU (disambiguation)',
'Avengers (Marvel Cinematic Universe)',
'What If...? (TV series)',
'Bucky Barnes (Marvel Cinematic Universe)',
'Peter Parker (Marvel Cinematic Universe)']
In this example, I used the .search() method from the wikipedia package to run a search on MCU (the Marvel Cinematic Universe). In my MCU search, the .search() method returned a list of Wikipedia articles that relate to my search-in fact, all but one of the results in the list relates to the Marvel Cinematic Universe.
Now, let’s see what happens when we run .search() on a term that can have multiple meanings:
import wikipedia
wikipedia.search('Archer')
['Archery',
'Jeffrey Archer',
'Archer (2009 TV series)',
'Anne Archer',
'List of Archer characters',
'The Archers',
'Jack Archer',
'Lance Archer',
'Archer (disambiguation)',
'Tasmin Archer']
In this example, I ran a Wikipedia search for Archer, and the output list shows articles related to both people with the surname Archer and articles related to the cartoon Archer.
Pretty neat stuff, right? Let’s see how we can do some cool web-scraping on a Wikipedia page:
BM = wikipedia.page('Baker Mayfield')
print(BM.title)
print()
print(BM.url)
Baker Mayfield
https://en.wikipedia.org/wiki/Baker_Mayfield
To perform web-scraping on a Wikipedia page, run the .page() method of the wikipedia package and pass in a Wikipedia page you would like to web-scrape (I picked Baker Mayfield’s Wikipedia page-he’s the QB of the Cleveland Browns). I stored the result of the wikipedia.page() method in the variable BM.
I then ran two simple web-scraping methods on my BM variable-.title and .url (notice that neither method uses the pair of parentheses)-to retrieve two bits of information-the Wikipedia page’s title and URL.
Simple enough, right? Well, let’s see what other information we can retrieve from web-scraping on a Wikipedia page:
BM = wikipedia.page('Baker Mayfield')
print(BM.images)
print()
print(BM.content)
['https://upload.wikimedia.org/wikipedia/commons/e/ed/2017-0717-Big12MD-BakerMayfield.jpg', 'https://upload.wikimedia.org/wikipedia/commons/4/4e/3_stars.svg', 'https://upload.wikimedia.org/wikipedia/commons/1/1a/Baker_Mayfield_%2849206381928%29.jpg', 'https://upload.wikimedia.org/wikipedia/commons/f/fc/Baker_Mayfield_2020.jpg', 'https://upload.wikimedia.org/wikipedia/commons/f/f1/Baker_Mayfield_training_camp_2018_%282%29_%28cropped%29.jpg', 'https://upload.wikimedia.org/wikipedia/commons/3/3f/Baker_Mayfield_vs_Bengals_2019_%282%29.jpg']
Baker Reagan Mayfield (born April 14, 1995) is an American football quarterback for the Cleveland Browns of the National Football League (NFL). Following a stint with Texas Tech, Mayfield played college football at Oklahoma, where he won the Heisman Trophy as a senior. He was selected by the Browns first overall in the 2018 NFL Draft.
In his NFL debut, Mayfield led Cleveland to their first win in 19 games, ending a 635-day streak, and went on to set the rookie quarterback record for passing touchdowns at 27. Mayfield struggled during his sophomore year, but rebounded in 2020 when he led the Browns to their first playoff appearance since 2002 and victory since 1994. He is also the only quarterback to win a postseason game with the Browns since their 1999 reactivation as an expansion team.
== Early life and high school career ==
Mayfield was born on April 14, 1995, in Austin Texas, to James and Gina Mayfield as the second of two sons. James, a private equity consultant, encountered financial difficulties during his younger son's senior year in high school. These struggles forced the Mayfields to sell their family home and move from rental home to rental home.Mayfield grew up as a fan of Oklahoma, and he attended a number of their games during his childhood. His father played football for three years for the University of Houston, though James never lettered.Mayfield was the starting quarterback for the Lake Travis High School Cavaliers football team. He led Lake Travis to a 25–2 record in two seasons and won the 2011 4A State Championship. He finished his high school football career totaling 6,255 passing yards, 67 touchdowns, and eight interceptions.
== College career ==
=== Texas Tech ===
Shortly before the start of the 2013 season, Mayfield was named as the starting quarterback following a back injury of projected starter and former Lake Travis quarterback Michael Brewer. Mayfield is the first walk-on true freshman quarterback to start a FBS season opener at the quarterback position.In his first start against SMU, Mayfield passed for 413 yards and four touchdowns. His 43 completions of 60 attempts broke a school record held by Billy Joe Tolliver, and fell only four completions short of the NCAA Division I FBS single-game record for completions by a freshman, held by Luke McCown. For his performance, Mayfield was named Big 12 Conference Offensive Player of the Week – the first freshman Texas Tech quarterback to be named so since former Red Raider head coach Kliff Kingsbury in 1999. The game featured the last four former Lake Travis quarterbacks combined on both teams: Garrett Gilbert, Michael Brewer, Collin Lagasse, and Mayfield.Following the Red Raiders' second victory over Stephen F. Austin, Mayfield's 780 season yards and seven touchdowns already exceeded the 755 yards and six touchdowns accrued by Texas Tech's last true freshman quarterback, Aaron Keesee, in 10 games. After being affected by a knee injury and losing the starting job to fellow true freshman Davis Webb, Mayfield finished the season with 2,315 yards on 218-of-340 completions with 12 touchdowns and 9 interceptions.Mayfield was named one of 10 semifinalists for the Burlsworth Trophy in November; the award is given to the best player in Division I football who began his college career as a walk-on.Mayfield earned Big 12 Conference Freshman Offensive Player of the Year for the 2013 season. Mayfield announced that he would be leaving the program due to a "miscommunication" with the coaching staff.
=== Oklahoma ===
After playing for Texas Tech, Mayfield transferred to the University of Oklahoma in January 2014, but had not contacted the Sooners coaching staff. Mayfield further elaborated in an interview with ESPN that he sought to transfer due to scholarship issues and a perception that he had earned the starting position and that further competition was not "really fair." The alleged scholarship issues were denied by Texas Tech coach Kliff Kingsbury.In February 2014, Oklahoma head coach Bob Stoops confirmed that Mayfield would be walking on for the Oklahoma Sooners. Mayfield was not eligible to play until the 2015 season, and he lost a season of eligibility due to Big 12 Conference transfer rules following an unsuccessful appeal of his transfer restrictions.
==== 2015 season ====
On August 24, 2015, Mayfield was named the starting quarterback for the Sooners after winning an open quarterback competition against Trevor Knight. On September 6, 2015, Mayfield started against Akron. Mayfield totaled 388 passing yards with three passing touchdowns on 23 completions in the 41–3 win. In the second game of the 2015 season, Mayfield started at Tennessee at Neyland Stadium. The Sooners were ranked 19th at the time and the Volunteers were ranked 23rd. Mayfield started off very slow in the game, not even reaching midfield until the 13-minute mark of the fourth quarter. Oklahoma came back from a 17-point deficit to win the game by a score of 31–24 in double overtime. Mayfield threw for 187 yards and three touchdowns on 19 completions while throwing two interceptions early in the game. In the third game of the season, Mayfield started against Tulsa. He had a career day, throwing for 487 yards and four touchdowns, including 316 yards in the first half. Mayfield also ran for 85 yards and two touchdowns in the 52–38 win.Mayfield finished the year with 3,700 passing yards, 36 touchdowns, and seven interceptions, a résumé which propelled him to fourth place in voting for the Heisman Trophy. Mayfield helped lead Oklahoma to the 2015 Orange Bowl, which served as the semifinal for the 2015 College Football Playoff. However, Oklahoma lost to Clemson by a score of 37–17.
==== 2016 season ====
Mayfield started off the 2016 season with 323 passing yards and two touchdowns in a 33–23 loss to #15 Houston. In the rivalry game against Texas on October 8, he had 390 passing yards, three touchdowns, and two interceptions in the 45–40 victory. On October 22, in a 66–59 victory over Texas Tech, Mayfield had 545 passing yards and seven touchdowns in a historic matchup against future NFL quarterback Patrick Mahomes. Mahomes tallied 734 passing yards and five touchdowns to go along with Mayfield's numbers in a game that broke various single-game passing records. Over the final five games of the regular season, Mayfield totaled 1,321 passing yards, 15 passing touchdowns, and three interceptions, to go along with three rushing touchdowns. All five games were victories for the Sooners.In December 2016, it was announced that Mayfield and his top receiving target, Dede Westbrook, would be finalists for the 2016 Heisman Trophy. It was also announced that they would play in the 2017 Sugar Bowl. Mayfield ended up finishing third in the Heisman voting.In the 2017 Sugar Bowl, Mayfield helped lead the Sooners to a 35–19 victory over Auburn. He finished the game with 19 completions on 28 attempts for 296 passing yards and two touchdowns, earning him the MVP award.
==== 2017 season ====
On September 9, 2017, after a win against the Ohio State Buckeyes in Columbus, Mayfield planted the Sooners' flag in the middle of the painted "O" at Ohio Stadium, causing a major public backlash. Mayfield issued an apology shortly afterwards.On November 4, 2017, Mayfield threw for a school-high 598 yards against in-state rival Oklahoma State. Mayfield finished 24-for-36 with five passing touchdowns and one rushing touchdown, and Oklahoma won the game by a score of 62–52. Mayfield completed his career 3–0 as the starting Oklahoma quarterback in the Bedlam Series.
In November 2017, Mayfield was under fire again after an interaction during the game against Kansas. Mayfield was seen grabbing his crotch and mouthing "Fuck you!" at the coach of the opposing team. He also told their fans to "Go cheer on basketball." In response, Mayfield issued another public apology. Days after the 41–3 victory over Kansas, Sooners head coach Lincoln Riley announced that Mayfield would not start or be the captain during the upcoming game against West Virginia due to his actions against Kansas.On December 2, 2017, with the return of the Big 12 Championship Game after a six-year hiatus, Mayfield led Oklahoma to its third straight Big 12 championship, with Oklahoma beating the TCU Horned Frogs 41–17. Mayfield won MVP honors while Oklahoma clinched a second playoff berth in three years. A month later, the Sooners lost to the Georgia Bulldogs 54–48 in the 2018 Rose Bowl, which served as the national semifinal game.On December 9, 2017, Mayfield won the 2017 Heisman Trophy with a sweeping majority. He received 732 first-place votes and a total of 2,398 points. This amount translated to 86% of the possible points and the third highest percentage in Heisman history. In addition, Mayfield became the first and only walk-on player to ever win the Heisman Trophy.
=== "Baker Mayfield rule" ===
When Mayfield transferred from Texas Tech to Oklahoma after his freshman year, he filed an appeal to the NCAA to allow him to be eligible to play immediately at Oklahoma on the basis that he was a walk-on and not a scholarship player at Texas Tech; therefore, the transfer rules that apply to scholarship players should not be applicable to his situation. The NCAA denied his appeal as he did not meet the criteria. Big 12 Conference rules additionally stipulate that intra-conference transfers will lose one year of eligibility over and beyond the one-year sit-out imposed by the NCAA. Mayfield attempted to appeal his initial loss of eligibility to the Big 12 Conference faculty athletics representatives but was denied in September 2014.Officials from Oklahoma asked Texas Tech officials to authorize Mayfield's immediate eligibility, but Texas Tech officials objected and declined the request before granting a release in July 2014. Mayfield was thus forced to sit out the 2014 season, while also losing one year of eligibility as required by the rules.On June 1, 2016, the Big 12 faculty athletic representatives voted against a rule proposal that would have allowed walk-on players to transfer within the conference and not lose a year of eligibility. The next day, the rule proposal was amended to allow walk-on players, without a written scholarship offer from the school they are transferring from, to transfer within the conference without losing a season of eligibility. The faculty athletic representatives approved the amended proposal with a vote of 7–3. The rule change made Mayfield eligible to play for Oklahoma through the 2017 season. Texas Tech voted in favor of the rule.
=== College statistics ===
Source:
== Professional career ==
The Cleveland Browns selected Mayfield with the first overall pick in the 2018 NFL Draft. Mayfield signed a four-year rookie contract with the Browns on July 24, 2018, with the deal worth $32.68 million in guaranteed salary.
=== 2018 season ===
Mayfield played in his first NFL game in Week 3 against the New York Jets, replacing an injured Tyrod Taylor with the Browns down 14–0. Mayfield went 17 of 23, passing for 201 yards as the Browns came back and prevailed 21–17, ending their winless streak at 19 games. Mayfield became the first player since Fran Tarkenton in 1961 to come off the bench in his debut, throw for more than 200 yards, and lead his team to its first win of the season.Mayfield started for the first time in the Browns' next game, making him the 30th starting quarterback for the Browns since their return to the NFL in 1999, in a 42–45 overtime loss to the Oakland Raiders. In Week 5, Mayfield threw for 342 passing yards and one touchdown as he earned his first victory as a Browns' starter, in a 12–9 overtime win over the Baltimore Ravens. In Week 10, Mayfield led the Browns to a 28–16 victory over the Atlanta Falcons. throwing for 216 yards, three touchdowns, and a passer rating of 151.2, with no turnovers. The following week, Mayfield led the Browns to their first away win since 2015, against the Cincinnati Bengals. He completed 19 of 26 passes for 258 yards and four touchdowns. In Week 12, in a 29–13 loss to the Houston Texans, Mayfield passed for 397 yards, one touchdown, and three interceptions. Mayfield bounced back in the following game, a 26–20 victory over the Carolina Panthers, going 18 of 22 for 238 passing yards and one touchdown.In Week 16, Mayfield completed 27 of 37 passes for 284 yards and three touchdowns with no interceptions in a 26–18 win over the Cincinnati Bengals, earning him AFC Offensive Player of the Week. He also won the Pepsi NFL Rookie of the Week fan vote for the sixth time. On December 29, Mayfield was fined $10,026 for unsportsmanlike conduct during the game. As reported by The Plain Dealer, Mayfield "pretended to expose his private parts" to Browns offensive coordinator Freddie Kitchens after throwing a touchdown to tight end Darren Fells. Kitchens later defended the gesture as an inside joke between the two. Mayfield's agent Tom Mills said they would appeal the fine. On December 30, in the regular-season finale against the Ravens' league-best defense and fellow rookie quarterback Lamar Jackson, Mayfield threw for 376 yards and three touchdowns, but his three costly interceptions— one of which came at the hands of linebacker C. J. Mosley with 1:02 left in the fourth quarter while attempting to drive the team into range of a game-winning field goal attempt— ultimately contributed to a 26–24 loss.
Nonetheless, Mayfield helped lead the Browns to a 7-8-1 record and their best record since 2007. He finished the season with 3,725 passing yards and also surpassed Peyton Manning and Russell Wilson for most touchdowns thrown in a rookie season with 27.While Mayfield was considered by many to be the favorite for Offensive Rookie of the Year for 2018, the award was given to Giants running back Saquon Barkley. On the annual Top 100 Players list for 2019, Mayfield's peers named him the 50th best player in the league, one spot behind teammate Myles Garrett. He was named 2018 PFWA All-Rookie, the second Cleveland quarterback to receive this honor since Tim Couch in 1999.
=== 2019 season ===
In Week 1 against the Tennessee Titans, Mayfield threw for 285 yards and a touchdown. However, he also threw three fourth-quarter interceptions, one of which was returned by Malcolm Butler for a touchdown. The Browns lost 43–13. After the blowout loss, Mayfield said "I just think everybody just needs to be more disciplined. I think everybody knows what the problem is. We'll see if it's just bad technique or just see what it is. Dumb penalties hurting ourself and then penalties on my part. Just dumb stuff." In Week 2 against the New York Jets, Mayfield finished with 325 passing yards, including a quick-attack pass to Beckham that went 89 yards for a touchdown as the Browns won 23–3. In Week 4 against the Baltimore Ravens, Mayfield threw for 342 yards, one touchdown, and one interception in the 40–25 win. Against the San Francisco 49ers, Mayfield struggled against a stout 49ers defense, completing just 8-of-22 passes for 100 yards with two interceptions as the Browns were routed 31–3.Mayfield recorded his first game of the season with two or more passing touchdowns in Week 10 against the Buffalo Bills, completing 26 of 38 passes for 238 yards and two touchdowns, including the game-winner to Rashard Higgins, as the Browns snapped a four-game losing streak with a 19–16 win. Four days later against the Pittsburgh Steelers and former Big 12 Conference rival Mason Rudolph, Mayfield recorded his first career win against Pittsburgh, accounting for three total touchdowns (2 passing, 1 rushing) as Cleveland won 21–7. In Week 12 against the Miami Dolphins, Mayfield threw for 327 yards, three touchdowns, and one interception in the 41–24 win. In Week 17 against the Cincinnati Bengals, Mayfield became the first Cleveland Browns QB to start all 16 games in a season since Tim Couch in 2001. In the game, Mayfield threw for 279 yards, three touchdowns, and three interceptions as the Browns lost 33–23. Mayfield finished the 2019 season with 3,827 passing yards, 22 touchdowns, and 21 interceptions as the Browns finished with a 6–10 record.
=== 2020 season ===
In Week 1 against the Baltimore Ravens, Mayfield threw for 189 passing yards, a touchdown and an interception in the 38–6 loss. In the following week against the Cincinnati Bengals, Mayfield finished with 218 passing yards, two touchdowns and an interception in the 35–30 win. In Week 6 against the Pittsburgh Steelers, Mayfield completed 10 of 18 passes for 119 yards, with one touchdown, two interceptions and took four sacks during the 38–7 loss. Mayfield was replaced by Case Keenum in the third quarter due to aggravation of a minor rib injury he suffered in the previous week's game. In Week 7 against the Cincinnati Bengals, Mayfield started off slow completing 0 of 5 passes with an interception, but later completed 22 of 23 passes for 297 yards and a career-high five touchdowns including one to Donovan Peoples-Jones with 11 seconds remaining in the fourth quarter to help secure a 37–34 Browns' win. Mayfield was named AFC Offensive Player of the Week for his performance in Week 7.Mayfield was placed on the reserve/COVID-19 list on November 8 after being in close contact with a person who tested positive for the virus, and was activated three days later. In Week 13 against the Tennessee Titans, Mayfield completed 25 of 33 passes for 334 yards and four touchdowns which were all in the first half in a 41–35 victory. Mayfield tied Otto Graham for four first half touchdowns and the victory marked the Browns first winning record since 2007. Hence, Mayfield was named the FedEx Air player of the week for week 13. In Week 14 against the Ravens, Mayfield threw for 343 yards, 2 touchdowns, and 1 interception as well as rushing for 23 yards and a touchdown during the 47–42 loss. In Week 16 against the New York Jets, Mayfield lost a fumble on fourth down with 1:25 remaining in the game while attempting a quarterback sneak during the 23–16 loss. In Week 17, Mayfield and the Browns defeated the Pittsburgh Steelers 24–22 and earned their first post season playoff berth since 2002. The Browns finished the regular season 11–5.In the Wild Card Round against the Pittsburgh Steelers, Mayfield went 21 of 34 for 263 yards and 3 touchdowns during the 48–37 win, leading the Browns to their first playoff victory since the 1994 season In the Divisional Round of the playoffs against the Kansas City Chiefs, Mayfield threw for 204 yards, 1 touchdown, and 1 interception during the 22–17 loss.Overall, Mayfield finished the 2020 season with 4,030 passing yards, 30 touchdowns, and 9 interceptions through 18 total games.
=== 2021 season ===
The Browns exercised Mayfield's fifth-year contract option for the 2022 season on April 23, 2021, worth $18.9 million guaranteed. On October 7, 2021, it was revealed that Mayfield was playing with a partially torn labrum which he suffered during the Browns Week 2 victory over the Houston Texans. Mayfield continued to play with the injury until reaggravating it in Week 6 against the Arizona Cardinals. Due to the injury, Mayfield was ruled out for the Browns' Week 7 game against the Denver Broncos, missing his first game since taking over as the Browns' starter in 2018. On November 14, 2021, Mayfield suffered a right knee contusion during their crushing Week 10 loss to the Patriots. While the injury was not severe, coach Kevin Stefanski decided not to put him in for the rest of the game due to Mayfield absorbing hits and the game being out of reach. After the Browns were eliminated from the postseason following a Week 17 loss to the Pittsburgh Steelers, the Browns announced Mayfield would undergo surgery on the torn labrum, ending Mayfield's season. He was placed on injured reserve on January 5, 2022. Mayfield threw for 3,010 yards, 17 touchdowns, and 13 interceptions in 14 games played.
== NFL career statistics ==
=== Regular season ===
=== Postseason ===
== Career accomplishments ==
=== NCAA ===
==== Accolades ====
Heisman Trophy (2017)
2x Heisman Trophy Finalist (2016, 2017)
Maxwell Award (2017)
Walter Camp Award (2017)
Davey O'Brien Award (2017)
Associated Press Player of the Year (2017)
2× Sporting News Player of the Year (2015, 2017)
2× Burlsworth Trophy (2015, 2016)
2× Big 12 Offensive Player of the Year (2015, 2017)
Big 12 Offensive Freshman of the Year (2013)
2× First-team All-American (2015, 2017)
3× First-team All-Big 12 (2015–2017)
==== Records and accomplishments ====
First former walk-on to win Heisman Trophy
NCAA passer rating leader (2017) [203.8]
2x NCAA passing efficiency rating leader (2016, 2017) [196.4, 198.9]
2x NCAA yards per attempt leader (2016, 2017) [11.1, 11.5]
2x NCAA adjusted passing yards per attempt leader (2016, 2017) [12.3, 12.9]
2x NCAA pass completion percentage leader (2016, 2017) [70.9, 70.5]
NCAA total yards per play leader (2017) [9.9]
NCAA TDs responsible for leader (2017) [49]Oklahoma Sooners football records
Most career total touchdowns — 137 (119 passing, 18 rushing)
Highest career passing completion percentage — 69.8 (tied)
Most passing yards in a game — 598
Most passing touchdowns in a game — 7
=== NFL ===
==== Accolades ====
7× Pepsi NFL Rookie of the Week (2018 Weeks 3, 7, 9, 12, 14, 16, 17)
2x AFC Offensive Player of the Week (2018 Week 16, 2020 Week 7)
PFT Rookie of the Year (2018)
PFWA Rookie of the Year (2018)
PFF Offensive Rookie of the Year (2018)
PFWA All-Rookie Team (2018)
==== Records and accomplishments ====
NFL Rookie QB QBR Leader (2018)
NFL Rookie QB Pass Completions Leader (2018)
NFL Rookie QB Pass Attempts Leader (2018)
NFL Rookie QB Pass Completion Percentage Leader (2018)
NFL Rookie QB Pass Attempts per Game Leader (2018)
NFL Rookie QB Pass Yards Leader (2018)
NFL Rookie QB Pass Yards per Pass Attempt Leader (2018)
NFL Rookie QB Pass Yards per Game Leader (2018)
NFL Rookie QB Pass Touchdowns Leader (2018)Browns franchise records
Most consecutive games with at least 2 passing touchdowns — 5
Most Passing Yards per Game in a season – 266.1
Highest QBR for a rookie — 55.7
Highest Passer Rating by a rookie — 93.7
Highest Completed Pass Percentage by a rookie — 63.8
Highest Net Yards per Pass Attempt by a rookie — 6.95
Highest Adjusted Net Yards per Pass Attempt by a rookie — 6.77
Lowest Percentage of Sacks per Pass Attempt by a rookie — 4.9
Most Passing Completions by a rookie — 310
Most Passing Yards by a rookie — 3,725
Most Passing Yards per Game by a rookie – 266.1
Most 4th quarter Comebacks by a rookie — 3
Most Game Winning Drives by a rookie — 4
Most Passing Yards in a Game by a rookie — 397
Most Touchdown Passes in a game by a rookie — 4
Most passing touchdowns by a rookie — 27
Most Passing Completions in a game by a rookie — 29 (Done twice, tied with Tim Couch)
High Passing Completion Percentage in a game by a rookie — 85.0 (17/20, Week 10)
== Personal life ==
In July 2019, Mayfield married Emily Wilkinson.
== References ==
== External links ==
Official website
Cleveland Browns profile
Oklahoma Soones profile
Baker Mayfield at Heisman.com
Career statistics and player information from NFL.com · Pro Football Reference
In this example, I retrieved the Wikipedia page’s images and content using the wikipedia package’s .images() and .content() methods, respectively. However, you’ll notice that the .images() method doesn’t display all the images on the Wikipedia page but rather a list of the URLs of the images on the Wikipedia page.
So, how can we access the page’s images? Take a look at this code:
print(BM.images[0])
https://upload.wikimedia.org/wikipedia/commons/e/ed/2017-0717-Big12MD-BakerMayfield.jpg
In this example, I’m accessing the first image in the images list and I get that image’s hyperlink, which takes me to the JPG of Baker Mayfield that you see above.
Pretty impressive stuff, right?
Last but not least, let’s explore Python’s freegames package, which allows you to play several free Python games (yes, R isn’t the only programming tool with free games). To access the freegames package, first install the package by running the line pip install freegames on your command prompt (or run this line of code on your IDE preceded by an exclamation point).
Let’s play around with some of the games provided in the freegames package:
!pip install freegames
!python -m freegames.connect
And here’s what the board looks like after a (hypothetical) game:
In this example, after I pip-installed the freegames package, I ran the command !python -m freegames.connect to run the freegames package’s Connect-4 game, which, as you can guess, runs a Pythonic Connect-4 game in a separate window.
However, when you run the game, you’ll notice that, even though you can click on the board and a “chip” will drop in a certain slot (depending on where you click) and the color of the chips dropped will alternate between red and yellow with each click, the game doesn’t end when either color gets 4 in a row-rather, you can keep clicking until you fill in the board if you wish. Why is that the case? Well, the website for the freegames Python package-http://www.grantjenks.com/docs/freegames/index.html-contains not only the list of all the available free games on the freegames package but also the code for each of these games. Take a look at the code for the package’s Connect-4 game:
- You can find this code by scrolling down the page I just hyperlinked in this post and clicking on the “Connect” hyperlink.
When you scroll down the code for the freegames package’s Connect-4 game, you’ll notice that although it has the functionality to generate a Connect-4 board and drop “chips” of alternating colors onto the game board, there is no functionality to detect a winner or create a random computer player (which would make the game more fun). However, from the insights I gathered from the code, that seemed to be the developers’ intent, as they created this tool as a fun way to teach programming to inner-city youth in the early 2010s (this fact is mentioned on their website). The fact that most of these games have missing functionalities (like the fact that Connect-4 doesn’t end when a player gets 4 in a row) was intentional, as this would provide some fun programming challenges for students (or anybody wanting to learn programming).
Let’s run another game from the package-snake. To run the Snake game (yes, Snake like the classic 70s arcade game), run this command on your IDE !python -m freegames.snake.
Here’s what the Snake screen looks like after I’ve finished a game:
And here’s the output you see on the IDE after a game is finished:
Interestingly enough, this is one of the few games in the freegames package that keeps your score and stops running when the game ends (recall the Connect-4 game didn’t do this).
- At least in Python’s
freegamespackage, you start off with one point in Snake and get another point each time you “eat” the green square. As you can see, I managed to get 12 points before my game ended.
Also, remember how I showed you that you could see the game code for the Connect-4 game? You can do the same for the Snake game (and all other games on this package), but to see the code for the Snake game, click on the “Snake” link in the hyperlinked page I posted earlier (the link with grantjenks in the URL).
As you see from the snake code, the developers included some programming exercises for students (perhaps challenging them to see if they can implement the data logic to enhance game functionalities):
- I might revisit the
freegamespackage in a separate lesson, so stay tuned ;-).
Thanks for reading,
Michael