Describe two different ways to represent a birthday register

Assignment Help Programming Languages
Reference no: EM131267490

Question 1: The following code is meant to find the largest item of a list, but the lines are out of order. The following code is meant to define such a function, but the lines are out of order. In your answer put the line numbers in the correct order and introduce appropriate indentation (indent the line numbers to show how the corresponding lines would be indented in your code). Do not write the entire corrected program in your answer.

1 if number > largest:

2 numbers = [3, 5, 2, 1, 4]

3 print largest

4 largest = number

5 for number in numbers:

6 largest = 0

Question 2 : Describe two different ways to represent a birthday register, i.e. the names of your friends and their birth dates. Assume that none of your friends have the same name, but that it is possible for two or more of them to share the same birthday. Do not represent the date as a string. Show how the following data would be represented in both models.

2/Jan Asimov

3/Jan Tolkien

18/July Mandela

18/July Branson

Question 3: Explain the purpose of the following code:

d = {}

for x in open("data.txt").read().split():

if x not in d:

d[x] = 0

d[x] += 1

Question 4: Consider the following code: 1. signFlag = False

2. evenFlag = False

3. inputstr = raw_input("Enter two numbers: ")

4. num1 = int(inputstr.split(", ")[0])

5. num2 = int(inputstr.split(", ")[1])

6. if num1 < 0 and num2 = 0 and num2 >= 0:

10. sign = 'positive'

11. signFlag = True

12. if num1%2 == 0 and num2%2 == 0:

13. num = 'even'

14. evenFlag = True

15. if num1%2 != 0 and num2%2 != 0:

16. num = 'odd'

17. evenFlag = True

18. if signFlag and evenFlag:

19. print num1, 'and', num2, 'are both', sign, 'and', num

20. elif signFlag:

21. print num1, 'and', num2, 'are both', sign

22. elif evenFlag:

23. print num1, 'and', num2, 'are both', num

24. else:

25. print num1, 'and', num2, 'have nothing in common'

--Assume that the input is "-12, 14". Using the given line numbers in this code (at the far left of the listing) list the order (by writing down the line number order) that the code will be executed.

--What is the output for the input "-12, -14"?

--What is the output for the input "-3, 9"?

--Explain in detail what the program does.

Question 5: Write a function file_length(filename) which takes the name of a file as its only parameter, and returns an integer specifying the number of lines in the file.

Reference no: EM131267490

Questions Cloud

Major competitor for windows : Apple's Mac OS is a major competitor for Windows, and many people feel very strongly about choosing one over the other. For this assignment, locate articles online that discuss the differences between Windows and Mac OS.
Is your workspace ergonomically designed : Is your workspace ergonomically designed? Do some research into the field of ergonomics. As a response to this topic, report your findings to the class, be sure to cite your resources. Please do NOT make Wikipedia your primary source. You may use ..
Write a memo that is most likely to produce the results : You are the Director of the legal department of a mid-size software firm. Write a memo that is most likely to produce the results you wish
Creating a website for an organization : You are tasked with creating a website for an organization you are familiar with. Write a 1-page proposal in memo format for your website including the following website requirements:
Describe two different ways to represent a birthday register : Describe two different ways to represent a birthday register, i.e. the names of your friends and their birth dates. Assume that none of your friends have the same name.
Analyze the current uses of http and https : Analyze the current uses of HTTP and HTTPS, and predict the future outlook for both protocols. Describe any foreseen changes in the frequency or way each protocol is used.
What is the authors argument : Write a 150 words summary for each article. What is the author's argument, and how is it communicated in the written content of the text -  What key examples are used? What concepts can you relate to your own practice as a designer?
Briefly describe the concept of status : Briefly describe the concept of status. Describe the global implications that status has for an international manager in Western culture, with two (2) original examples. Describe the global implications that status has for an international manager..
Work for all lists of numbers : You may assume that the user will always enter at least two elements, but your function two_length_run should work for all lists of numbers including those of length 0 and 1.

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd