Write a function rotate that has one string parameter

Assignment Help Computer Engineering
Reference no: EM132091598

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

Reference no: EM132091598

Questions Cloud

Create a console application project : In this part of the assignment, you are required to create a C# Console Application project. The project name should be A3P1.
Prepare a class diagram for the following group of classes : Concept to UML Prepare a class diagram for the following group of classes. Add at least 10 relationships (associations and generalizations) to the diagram.
What does it mean if this graph has a cycle : Explain why this graph is a directed graph What is the definition of the indegree of a vertex and what is its meaning in this graph?
Aspect of social media in workplace : Aspect of Social Media in workplace - Focus only on the key points in your Week 6 presentation; avoid discussing less important details
Write a function rotate that has one string parameter : Write a function rotate(s,n) that has one string parameter s followed by a positive integer parameter n.
How can you prevent making a special occasion speech : How can you prevent making a special occasion speech about you? How do you make it something a wider audience is interested in?
Can a firm be effective but inefficient : Can a firm be effective but inefficient? Very efficient but essentially ineffective? Both? Neither?
What is the growth in productivity in this case : For the Apple Lumber: What is the growth in productivity in this case?
What is the growth in productivity in case : For the Apple Lumber: What is the growth in productivity in this case?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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