Status: Not Started
  • scratchpad.py
  • Unit Test
Font Size
14
Parentheses autocomplete
Wrap lines
Editor
Theme
Code with blocks by default
Console Font Size
12
Console Theme
Display Server Graphics Screen
Show File Tab Bar
Debug Mode
Revolutionary War of 1776
Unit Test
def revolutionary_war_stats(people):
return
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Output
Grading
Docs
Exercise
More
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Pass Test Message

Errors:

This student is viewing this assignment in English. View this page in English?

5 points

Problem Statement

In 1776, the United States declared its independence from Great Britain. This momentous event was marked by the signing of the Declaration of Independence. To celebrate this historical event, you are to write a Python function that processes a list of key figures involved in the Revolutionary War and returns some interesting statistics about them.

Instructions

You will write a function revolutionary_war_stats() that takes a list of dictionaries as input (people). Each dictionary represents a key figure from American history, and contains the following keys:

  • “name”: a string representing the person’s name
  • “side”: a string representing the side they fought for, either “American” or “British”
  • “role”: a string representing their role, such as “General”, “Soldier”, “Spy”, etc.

Your function should return a tuple containing:
1. The total number of people in the list.
2. The number of people who fought for the American side.
3. The number of Generals on the American side.
4. The number of people who were Spies, regardless of the side.

Example

Input: [{"name": "George Washington", "side": "American", "role": "General"}, {"name": "Benedict Arnold", "side": "American", "role": "General"}, {"name": "John Andre", "side": "British", "role": "Spy"}, {"name": "Nathan Hale", "side": "American", "role": "Spy"}, {"name": "William Howe", "side": "British", "role": "General"}]

Expected Result: (5, 3, 2, 2)

Reset Code

Slides and Notes

No slides available for this video

About

Python 3 Practice
3.11.9 (default, Apr 6 2024, 17:59:24)
[GCC 6.4.0]