Python Week No. 06: Control and looping

Source: Internet
Author: User

Question 1th: Graphics output 2480


Title Description
Print a shape with a basic output statement:
#
##
###
####
#####
######
Input
No data entered on this topic
Output
The output graph consists of 6 lines, the 1th line has 1 #, and line I has a sequential I # number:
#
##
###
####
#####
######
Sample input
Sample output
#
##
###
####
#####
######
-------------------------

2nd question: Exchanging values for two integers


Title Description
Swap the values of two variables, enter two integers from the terminal to the variable x, y, and then swap the values for x and y, and output x and Y.
Input
Enter two integer variables x and y from the keyboard;
Output
Output x and Y after swapping values for x and Y!
Sample input
4 6
Sample output
6 4
-----------------------------------------

Question 3rd: Python Loop Print graphics (looping structure)


Title Description
Print the following graphs by using the double for Loop statement:
Submit
Input
Output
Sample input
Sample output
*
***
*****
*******
*****
***
*
-----------------------------------------

Question 4th: IBM minus One


Title Description
Heard of the book ' 2001-a Space Odyssey ' by Arthur c. Clarke, or the film of the same name by Stanley Kubri Ck. In it a spaceship are sent from Earth to Saturn. The crew is put to stasis for the long flight, with only the "men" is awake, and the "ship is" controlled by the intelligent com Puter HAL. But during the flight HAL was acting more and more strangely, and even starts to kill the crew on board. We don ' t tell you how the stories ends, in case you want to read the book for yourself:-)

After the movie was released and became very popular, there is some discussion as to what the name ' HAL ' actually meant. Some thought that it might is a abbreviation for ' heuristic algorithm '. But the most popular explanation are the following:if you replace every letter in the word HAL by their successor in the ALP Habet, you get ... Ibm.

Perhaps there is even more acronyms related in this strange way! You is to write a program, which may help to find the out.
Input
The input starts with the integer n in a line by Itself-this are the number of strings to follow. The following n lines each contain one string of of at most upper-case letters.
Output
For each string in the input, first output the number of the string, as shown in the sample output. The print the string start is derived from the input string by replacing every time by the following T, and replacing ' Z ' by ' A '.

Print a blank line after each test case.
Sample input
2
HAL
Swerc
Sample output
String #1
Ibm

String #2
Txfsd

Python Week No. 06: Control and looping

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.