python代码作业代写代做、代做python代码作业、代写python代码作业, 代写python代码编程


Q1 Write a Python program that asks the user to enter a full name in the following
format :LastName, FirstName MiddleName (for Example: "Hun, Attila The”). The
input will have a single space after the comma and only a single space between
the first name and the middle name. The last name and first name should not be
more than 10 characters long. You are to use the methods in the str class in Python
to convert the input string to a new String having the form:
<FirstName><MiddleInitial>.<LastName>
For example the input string “Hun, Attila The” changes to:
< Attila >< T>.<Hun >
? FirstName is displayed centered in a field 10 characters wide within angular
brackets
? MiddleInitial is displayed right-justified in a field 5 characters wide within
angular brackets followed by a dot
? LastName is displayed left-justified in a field 10 characters wide within angular
brackets
Be sure to test it with more than one input and not just "Hun, Attila The".
HINT:
1. Consider the following names as inputs: "Hun, Attila The" and "Newton, Sir
Isaac". You need to find the locations of the special characters that separate
the pieces. What separates the last name from the first name in each of the
strings? What separates the middle name from the first name in each of the
strings?
2. Write a search for each of those special characters using the index method in
the str class. That will give you the index of the separator between the last and
first names and also the index of the separator between the first and middle
names.
Sample Output 1:
Enter name [LastName, FirstName MiddleName]>Newton, Sir Isaac
The new name is:< Sir >< I>.<Newton >
Sample Output 2:
Enter name [LastName, FirstName MiddleName]>Spencer, Brian Joe
The new name is:< Brian >< J>.<Spencer >
NOTE: You may assume that the user always enters a non-empty string in the
format specified in the question. You may also assume that first,middle and
last name will always be there. For example you don't need to test if middle
name is missing.
Q2 FizzBuzz is a children’s counting game where players count out starting at 1. For
numbers that are multiples of 3 , they say “Fizz”. For numbers that are multiples of 5
they say “Buzz”. For numbers that are multiples of both 3 and 5, they say
“FizzBuzz”. For all other numbers they say the number. Write a function called
play_fb that takes in a maximum number in its parameter and displays the
appropriate output as per the rules of the game. Here is the main function that you
need to include in your program:
def main():
number = int(input('Enter maximum number to start counting >'))
play_fb(number)

Q3 Write a program that reads in an unspecified number of integers separated by
spaces and finds the occurrences of each number.
Sample Outputhttp://www.daixie0.com/contents/3/1672.html
Enter numbers separated by spaces :1 2 3 3 2 2 2 1 3 4 5 3
{'1': 2, '3': 4, '2': 4, '5': 1, '4': 1}
1 occurs 2 times
3 occurs 4 times
2 occurs 4 times
5 occurs one time
4 occurs one time
NOTE: You must use the dictionary to solve the problem. Also note that if the
number occurs only once then time not times is printed.
You can always assume that the user enters number separated by a single space
i.e no input validation is required.

因为专业,所以值得信赖。如有需要,请加QQ99515681 或邮箱:[email protected] 

微信:codinghelp

猜你喜欢

转载自www.cnblogs.com/javacodinghelp/p/9642779.html