Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

develop a python program A leap year in the Gregorian calendar system is a year that is divisible by 400 or a year that is

develop a python program

image text in transcribed

image text in transcribed

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. (Optional challenge: write the function suite as one line.) Demonstrate your completed program to your TA. On-line students should submit the completed program (named "lab05.py") for grading via the Mirmir system. 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 integer. For example: rotate (abcdefgh, 3) returns fghabcde (Optional challenge: write the function to handle n larger than the length of s.) Demonstrate your completed program to your TA. On-line students should submit the completed program (named "lab05.py") for grading via the Mirmir system. 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 place a zero before the decimal point. See correct behavior in the final test case below. For example: digit _ count(1 2 3 4 5 6 7 8 9 0 1 2 3) returns (5, 7, 1) digit _ count(1 2 3 4 0 0. 3 4 5) returns (2, 2, 2) print(digit _ count(1 2 3.)) returns (1, 2, 0) print(digit _ count (.1 2 3)) returns (0, 0, 0) Demonstrate your completed program to your TA. On-line students should submit the completed program(named "la b05.py") for grading via the Mirmir system. String has a method s. is digit() the 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 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(1 2 3 4) returns True float _ check(1 2 3.4 5) returns True float _ check(1 2 3. 4 5. 6 7) returns False float _ check(3 4e 4 6) returns False float _ check(4 5) returns True float check(4 5.) returns True float _ check(4 5..) returns False (Optional challenge: write this function suite in one line.) Demonstrate your completed program to your TA. On-line students should submit the completed program (named "lab05. py") for grading via the Mirmir system

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions