Whose binary digits add up to an even number

Assignment Help Basic Computer Science
Reference no: EM13890920

EASY PYTHON CODE!

An evil number is a positive integer whose binary digits add up to an even number (the opposite of an evil number is an odious number, whose binary digits add up to an odd number).

For example, 14 is odious:

14 (base 10) = 1110 (binary)

1 + 1 + 1 + 0 = 3, which is odd.

17, on the other hand, is evil:

17 (base 10) = 10001 (binary)

1 + 0 + 0 + 0 + 1 = 2, which is even.

Write a small Python program that prompts the user to enter an integer and prints whether that number is evil or odious.

HINT: You may want to write a helper function to translate the input into binary before beginning your analysis.

Sample Program Execution

(Program output is in italics, while user input is bold)

Execution 1:

Please enter a number: 23

This number is evil.

Execution 2:

Please enter a number: 25

This number is odious.

Program must prompt for user input, correctly identify evil numbers, and odious numbers

Reference no: EM13890920

Questions Cloud

What can be the b2b e-commerce : What can be the B2B e-commerce in any organization/workplace/etc?
Review the balance sheet of arctic cat in appendix : 1.Review the balance sheet of Arctic Cat in Appendix A. Identify the amount for property and equipment.
Advanced understanding of a complex body of knowledge : The overall purpose of this assignment is to build your understanding of the consumer and how an understanding of consumers is a key input to the development of an effective (the right type) and efficient (minimal or no waste) marketing mix strate..
Discuss intra-familial dynamic created attachment process : Discuss the intra-familial dynamic that created the attachment process. Elaborate on whether or not that process is disruptive, dysfunctional, et cetera, as well as why you feel that way.
Whose binary digits add up to an even number : EASY PYTHON CODE!An evil number is a positive integer whose binary digits add up to an even number (the opposite of an evil number is an odious number, whose binary digits add up to an odd number).For example, 14 is odious:14 (base 10) = 1110 (binary..
Calculate the amounts of net income and retained earnings : Effects of adjustments A bookkeeper prepared the year-end financial statements of Giftwrap, Inc. Calculate the amounts of net income and retained earnings after the preceding adjustments are recorded.
Describe how an enterprise would use 3g : Describe how an enterprise would use 3G, 4G, WWAN, and WIAMX to improve business. Explain why they would use one (1) solution over the remaining three (3).
What is the breakeven stock price at expiration? : What is the breakeven stock price at expiration?
Prepare a project plan for the unhcr : Prepare a project plan for the United Nations High Commissioner for Refugees (UNHCR) Regional Office (Australia, New Zealand, Papua New Guinea and the Pacific) for a selected sub-project within the proposed Utopia Offshore Refugee Solution (Stage ..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Using the sql schema generation feature of the modeling tool

Consider the description of UNIVERSITY database below. Using the SQL schema generation feature of the modeling tool, generate the SQL schema and diagram for an Oracle database.

  The load master for a freighter

The load master for a freighter wants to determine the mix of cargo to be carried on the next trip. The ship's volume limit for cargo is 100,000 cubic meters, and it weight capacity is 2,310 tons.

  Decryption algorithm: reverse the encryption algorithm

Decryption algorithm: Reverse the encryption algorithm. The permutation, however, should (circular) shift the bit pattern by 1 bit to the right

  Suppose a product can be produced using virgin

Suppose a product can be produced using virgin ore at a marginal cost given by MC1 = 0.5q1 and with recycled materials at a marginal cost given by MC2 = 5 + 0.1q2.

  Define a class called counter

The only method that can set the counter is the one that sets it to zero. Write a program to test your class definition. (Hint: you need only one instance variable).

  What are open-ended questions appropriate

What are open-ended questions appropriate for  use in interviewing

  Dss projects

DSS projects succeed more often than they fail or are challenged.

  Discuss the differences between implementation and policy

Discuss the differences between implementation and policy

  Write the create index statements to create clustered index

Write the create index statements to create a clustered index on the groupid column and a nonclustered index on the individualid column of the groupmembership table.

  Address-based authentication works

Explain how address-based authentication works. Is this a secure authentication technique? Why or why not?

  You have been working as a police officer for the

you have been working as a police officer for the centervale police department for two years. you are on your nightly

  Which design strategy wouldyou recommend forthe construction

Assume that you are developing a new system for a local real estate agency. The agency wants to keep a database of its own property listings and also wants to have access to the citywide multiple listings service used by all real estate agents. Which..

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