Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Part A:

Leap Year A leap year in the Gregorian calendar system is a year that is divisible by 400 or a year that is divisible by 4 but not by 100. Write a function named leap_year that takes one string parameter.

It returns True if the string represents a leap year, and returns False otherwise. For example, 1896, 1904, and 2000 are leap years, but 1900 is not.

Therefore, leap_year(‘1896') returns True.

Part B:

Rotate Write a function rotate(s,n) that has one string parameter s followed by a positive integer parameter n. It returns a rotated string such that the last n characters have been moved to the beginning.

If the string is empty or a single character, the function should simply return the string unchanged. Assume that n is less than or equal to the length of s and that n is a positive intger.

For example: rotate('abcdefgh',3) returns 'fghabcde'

Part C:

Digit Count Write a function named digit_count that takes one parameter that is a number (int or float) and returns a count of even digits, a count of odd digits, and a count of zeros that are to the left of the decimal point.

Return the three counts in that order: even_count, odd_count, zero_count. Be careful of the "edge case" where the number starts with a decimal point-conversion of such a number to a string places a zero before the decimal point. See correct behavior in the final test case below.

For example: digit_count(1234567890123) returns (5, 7, 1) digit_count(123400.345) returns (2, 2, 2) print(digit_count(123.)) returns (1, 2, 0) print(digit_count(.123)) returns (0, 0, 0)

Part D: Float Check String has a method s.isdigit() that returns True if string s contains only digits and False otherwise, i.e. s is a string that represents an integer.

Write a function named float_check that takes one parameter that is a string and returns True if the string represents a float and False otherwise.

For the purpose of this function we define a float to be a string of digits that has at most one decimal point. Note that under this definition an integer argument will return True.

Remember "edge cases" such as "45." or ".45"; both should return True.

For example: float_check('1234') returns True float_check('123.45') returns True float_check('123.45.67') returns False float_check('34e46') returns False float_check('.45') returns True float_check('45.') returns True float_check('45..') returns False

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93079069

Have any Question?


Related Questions in Computer Engineering

Suppose a life insurance company sells a 230000 one-year

Suppose a life insurance company sells a $230,000 ?one-year term life insurance policy to a 20?-year-old female for ?$330. The probability that the female survives the year is 0.999642. Compute and interpret the expected ...

The sales figures for a business are as follows for the

The sales figures for a business are as follows for the first six months of the year: R40 000, R44 000, R52 000, R64 000, R80 000, R84 000. The owner believes that the sales curve can be approximated by a quadratic funct ...

Generate a c program for fibonacci function using

Generate a C++ program for Fibonacci function using Stack Fibonacci function Fib(n) is given below. Fib(n)= Fib(n-1) + Fib(n-2) for n > 1 Fib(n)= 1 for n=1 Fib(n)= 0 for n=0 Using following initialization unsigned int *F ...

Identify and evaluate at least three considerations that

Identify and evaluate at least three considerations that one must plan for when designing a database. Suggest at least two types of databases that would be useful for small businesses, two types for regional level organi ...

Salariestask compute the weekly pay for each employee at

Salaries Task: Compute the weekly pay for each employee at the Wahoo Widget Company. For each employee, you will calculate the base pay according to the appropriate salary category, and then subtract taxes and deductions ...

You are starting a company on a tight budget you can get

You are starting a company on a tight budget. You can get DSL line to your office with a static IP address, but ISP does not offer any DNS services. At this point you do not want to set up your own DNS, so you want to fi ...

Writing a research paperprepare a research paper on

Writing a Research Paper Prepare a research paper on Antisocial Personality Disorder. In this project, you will modify a research paper. You will add and format text and format the document using themes and paragraph for ...

Question suppose your system is designed in such a way that

Question : Suppose your system is designed in such a way that your computer needs to wait for some while to check if the channel is clear before transmitting. You take your measurement overtime and you come to find out t ...

A firm faces the following inverse demand curvep

A firm faces the following inverse demand curve P= 54-0.5Q Where P is the price of output and Q is the number of outputs sold per hour. This firm is the only employer in town and faces an hourly supply of labor given by: ...

Question suppose you are given n positive integers to sort

Question : Suppose you are given n positive integers to sort on a special computer which has access to special memory containing p slots. The special memory supports storing a key-value pair (a, b) into the memory in O(1 ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As