Animals think of at least three different animals that have


Python Assignment -

Q1. Given 20 students, 10 of them are males, rest are females. We assign each of them an unique ID from 0 to 19. If the ID is an odd number, we determine that this is a male, otherwise is a female. We want first 10 students go to Northeastern, others go to Midwestern. Create a function named as "gender_geo( )" to show your outputs. Add your comments for each line of your code. Write your code in Jupyter notebook. Submit both PDF and Latex. sample_output.png file is how the outcome look like.

Q2. Solve ALL "Try it yourself" problems on page 29 from Python Crash Course book by using Python. Add your comments for each line of your code. Write your code in Jupyter notebook. Submit both PDF and Latex.

1. Personal Message: Store a person's name in a variable, and print a message to that person. Your message should be simple, such as, "Hello Eric, would you like to learn some Python today?"

2. Name Cases: Store a person's name in a variable, and then print that person's name in lowercase, uppercase, and titlecase.

3. Famous Quote: Find a quote from a famous person you admire. Print the quote and the name of its author. Your output should look something like the following, including the quotation marks:

Albert Einstein once said, "A person who never made a mistake never tried anything new."

4. Famous Quote 2: Repeat Exercise 2-5, but this time store the famous person's name in a variable called famous_person . Then compose your message and store it in a new variable called message. Print your message.

5. Stripping Names: Store a person's name, and include some whitespace characters at the beginning and end of the name. Make sure you use each character combination, "\t" and "\n", at least once.

Print the name once, so the whitespace around the name is displayed. Then print the name using each of the three stripping functions, lstrip(), rstrip(), and strip().

Q3. Solve "Try it yourself" problems

1) Every Function: Think of something you could store in a list. For example, you could make a list of mountains, rivers, countries, cities, languages, or any-thing else you'd like. Write a program that creates a list containing these items and then uses each function introduced in this chapter at least once.

2) Animals: Think of at least three different animals that have a common characteristic. Store the names of these animals in a list, and then use a for loop to print out the name of each animal.

  • Modify your program to print a statement about each animal, such as A dog would make a great pet.
  • Add a line at the end of your program stating what these animals have in common. You could print a sentence such as Any of these animals would make a great pet!

3) Buffet: A buffet-style restaurant offers only five basic foods. Think of five simple foods, and store them in a tuple.

  • Use a for loop to print each food the restaurant offers.
  • Try to modify one of the items, and make sure that Python rejects the change.
  • The restaurant changes its menu, replacing two of the items with different foods . Add a block of code that rewrites the tuple, and then use a for loop to print each of the items on the revised menu.

From Python Crash Course book by using Python. Add your comments for each line of your code. Write your code in Jupyter notebook. Submit both PDF and Latex.

Q4. Solve ALL "Try it yourself" problems on page 102 from Python Crash Course book by using Python. Add your comments for each line of your code. Write your code in Jupyter notebook. Submit both PDF and Latex.

1. Person: Use a dictionary to store information about a person you know. Store their first name, last name, age, and the city in which they live. You should have keys such as first_name, last_name, age, and city. Print each piece of information stored in your dictionary.

2. Favorite Numbers: Use a dictionary to store people's favorite numbers. Think of five names, and use them as keys in your dictionary. Think of a favorite number for each person, and store each as a value in your dictionary. Print each person's name and their favorite number. For even more fun, poll a few friends and get some actual data for your program.

3. Glossary: A Python dictionary can be used to model an actual dictionary. However, to avoid confusion, let's call it a glossary.

  • Think of five programming words you've learned about in the previous chapters. Use these words as the keys in your glossary, and store their meanings as values.
  • Print each word and its meaning as neatly formatted output. You might print the word followed by a colon and then its meaning, or print the word on one line and then print its meaning indented on a second line. Use the newline character (\n) to insert a blank line between each word-meaning pair in your output.

5. In your notebook cell, do the following tasks:

  • type "import this", and then run the cell. You will find "The Zen of Python". Read it very quickly.
  • Select two or three sentences that you love. Create a program to show how many words of your selected sentences. Typically, your outputs need to show "The user entered:" following by your sentences, and "The number of words in the sentence is" following by the number.
  • Create a program to show how many time each word in your sentences appeared. Note you need to show ALL of the words, and ALL lower cases.
  • This time add title and author "The Zen of Python, by Tim Peters" after your sentences, and then redo task 3.
  • Write down what your learned from "Zen of Python" in Markdown format.

Please follow instructions on the work provide.

Python Crash Course Book - A hands-on, Project-Based Introduction to Programming by Eric Matthes.

Attachment:- Assignment Files.rar

Request for Solution File

Ask an Expert for Answer!!
Python Programming: Animals think of at least three different animals that have
Reference No:- TGS02696327

Expected delivery within 24 Hours