×
Samples Blogs Make Payment About Us Reviews 4.9/5 Order Now

Different programs using Python Assignment Solution

June 14, 2024
Dr. Nicole
Dr. Nicole
🇬🇧 United Kingdom
Python
Dr. Nicole, an accomplished professional with 6 years of experience, obtained her Ph.D. from Princeton University. Having completed over 400 Python assignments, she brings a wealth of expertise and insight to the table. With a focus on clarity and precision, Dr. Nicole is committed to providing comprehensive support to students seeking assistance with their Python projects.
Key Topics
  • User Name and Initial Printout Programming
Tip of the day
Familiarize yourself with OCaml's pattern matching; it simplifies handling recursive data structures like lists and trees, making your code concise and easier to debug.
News
In 2024, Girls Who Code introduced a Data Science + AI track in their free summer programs for high school students, fostering skills in cybersecurity and creative coding​

User Name and Initial Printout Programming

Assignment 3

  1. Write a python assignmentprogram that asks for the user’s full name and then prints their initials.
  2. Write a program that asks for the user’s birthday in the format of “MM/DD/YYY” and then prints the month they were born in letters. For instance, if the user enters: 01/01/1990, the code should print “January”. Also if the person was born after 1997, the code should print “You are Gen Z”.
  3. Write a program that keeps asking for the user’s favorite foods and stops when the user types “done”. Then if the user has entered “Pizza” as one of their favorite foods, it should print “You do not have a healthy diet”, otherwise it should print “You have a healthy diet”.
  4. Write a program that asks for the user’s opinion on the new iPhone. Define 2 lists of keywords for battery and camera. Then based on those keywords, your code should decide if the review is about battery, about the camera, about both, or about none of them.

Solution:

  1. def main(): name = input("Enter your full name: ") words = name.split(" ") for word in words: print(word[0].upper() + ".", end = " ") if __name__ == '__main__': main()

  2. def main(): months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] date = input("Please enter your birthday in format (MM/DD/YYYY): ") ind = date.split("/") print(months[int(ind[0]) - 1]) if int(ind[2]) > 1997: print("You are Gen Z.") if __name__ == '__main__': main()

  3. def main(): entry = "" output = "You have a healthy diet" while entry.lower() != "done": entry = input("Enter a food you like: ") if entry.lower() == "pizza": output = "You do not have a healthy diet" print(output) if __name__ == '__main__': main()

  4. def main(): battery = ["battery", "large", "backup", "mah", "li", "lithium", "hours"] camera = ["camera", "sharp", "picture", "photo", "mega", "pixel", "zoom", "clarity"] review = input("Enter your opinion about iPhone: ") words = review.lower().split(" ") isBattery = False isCamera = False for word in words: if word in battery: isBattery = True elif word in camera: isCamera = True if isBattery and isCamera: print("Review is about both battery and camera") elif isBattery: print("Review is about battery") elif isCamera: print("Review is about camera") else: print("Review is neither about battery nor camera") if __name__ == '__main__': main()

Similar Samples

Explore our curated selection of programming homework samples to see the quality and depth of our solutions. Each sample represents our expertise in various programming languages and demonstrates our dedication to delivering clear, effective coding solutions. See how we can assist you in mastering programming concepts and achieving academic success.