Interactive program Three

Source: Internet
Author: User

The core of this program is the DEF statement, the IF statement, and the repeating use of the while statement loop.

Reference: Exercise-35

# Coding:utf-8

Def dead (Why): # defines the dead function, exit () can be used to exit the loop
Print why, ' you dead! ' # exit (0) indicates normal exit, exit (1) indicates an error occurred
Exit (0)

def start ():
Print U ">>> dear sir, your place is the Red Pavilion, was once the local fifth, is also the only preserved \n\
Shing mun. Founded in tomorrow Gianyan. Because of the arrival of the palace, to take the meaning of the scholar, so called Jin Xian door. "
Print ">>>choose:turn East or Western?"

Next = Raw_input ("Turn:")

If ' East ' in Next:
Tomb_of_goddness () # Jump to another location

Elif ' West ' in Next:
Tomb_of_general ()
Else
Dead (")

Def tomb_of_goddness ():
Print "-" * 80 # Repeat Printing "-"
Print U "God of God: the person who dares to break the moon, Madame Holy Land." "
Print U "God of God: Still not fast back." Lest disturb Mrs. Peace. "
Print ">>>choose: ' bow ', ' kneel ', ' flee ', ' taunt ' or others?"
Mountaingod = True

While True: # creates an infinite loop until dead () or exit (0)
Next = Raw_input (">>")
Print "-" * 80

If ' bow ' in next or ' kneel ' in Next and Mountaingod: # because the above Mountaingod is true, the IF statement can execute
Print U "I: May I ask you, Sir, Lord of the Gods?" The epigenetic, the polite. At the beginning of the new treasure, \n\
Never know the local customs, but also hope the gods. "
Print U "God of God: The Month Mrs. Dreams gave me, said today will have a gentle scholar to graves." \n\
It must be you! "
Mountaingod = False

Print "Choose: ' kneel ', ' flee ', ' taunt ', or others."
# Mountaingod has changed to false, so not Mountaingod

Elif ' kneel ' in Next and not Mountaingod: Is true, which ensures that the above if statement is executed first.
Print U "I: the epigenetic fragrance of the three, I wish to sue the spirit of the lady." Zhuangzi offered, don't blame, don't blame! "
Print U "I: Do not deceive the Lord, the epigenetic is also mistakenly into the forest, Fang know the tomb of the Lady, newcomer, \n\
I don't know anything about Madame. "
Print U "God of God: Madame Moon, is a legendary woman." Her deeds were widely \n\ on this land.
Spread. I'll take you to a place and you'll know. \ n "
Shuangxizui ()
Elif ' flee ' in next:
Print U "Me: good one the old man of the fierce Baba." 36 meters, go for the top. "
Start ()
Elif ' taunt ' in next:
Print U "I: OK you old man, talk so rude, frighten who ah?" "
Monster_tower ()
Else
Dead (")

Def Shuangxizui ():
Print "-" * 80

Print U "I: Gee, I was somehow standing on a boat, in front of Shuangjiang convergence, magnificent ah." More Haoyuedangkong, the night is like water. "
Print U ".... The waves in the distance gradually hit, accompanied by bursts of fishing songs .... "
Print U "Fishing songs: came all with the husband, but there is no way to go." Is there any justice in the world, rather than a long one? \n\
Alas, the moon is tolerant, and shall not be returned. Hao Hao Rongjiang XI, in Split. Sungai Moon XI, difficult to distinguish the turbid! "
Print "Choose: ' Boating ', ' praying ' or others."
Next = Raw_input (">>")

If ' boat ' in Next:
Tomb_of_general ()
Elif ' Pray ' in Next:
Temple ()
Else
Dead (")
Def temple ():
Print "-" * 80

Print U "There was a temple, which had been built for Madame. Madam Name Taboo XI, Yue Yangzhou talented woman. Long Lu Yun XI, the yard. "
Print U "bells around beams, love and Tiejian." Endless, the edge from the ring continued. "
Print U "I: It seems that this is a temple built for Mrs. Moon, and Fong Tai wrote the Zhong Ming." "
Exit (0)

Def monster_tower ():
Print "-" * 80

Print U ".... Pagoda exquisite, implied the universe, surging, demon infestation. ...."
Print U "I: Mom, shouldn't talk, the town tower, are all monsters ah." "
Print "Choose: ' flee ', ' pray ' or others."
Next = Raw_input (">>")

If ' flee ' and ' pray ' in Next:
Start ()
Elif ' flee ' or ' pray ' in Next:
Dead (")
Else
Moster_tower ()

Def tomb_of_general ():
Print "-" * 80

Print U ".... A good faction of flowers, beautiful scenery, West Lake rafting, Pavilions!.... "
Print U ".... A line came, the Tomb of General Song Mafa .... "
Print "Choose: ' Clean ', ' kneel ', go ' or others."
general_moved = True

While True:
Next = Raw_input (">>")
Print "-" * 80

If ' clean ' on Next or ' kneel ' in Next and general_moved:
Print U ".... I saw the grass tufted, the tombstone deserted .... "
Print U "I: it seems that Chaozhou more Jay Ah, before a month madam, after the general horse." "
Print U "I: the Tomb of a national hero, is the Wu bei of the Lucky Ah!" "
general_moved = False

Print "Choose: ' kneel ', ' go ' or others."
Elif ' kneel ' in Next and not general_moved:
Print U "Passers-by: young man, it seems you are a loyal man, and the poet Qiu Fengjia once for the general poem:"
Print U "railing, Korea Shrine, so Jiangshan, let Worthies leave the surname." "
Print U "hanging wine, general horse tomb, but the world, but the mess to pay heroes." "
Print U "I: presumably ... Can the elderly speak to the younger generation about the heroic deeds of General Ma? "
Print ".... Hit Enter to continue or CTRL + C to stop!... "
Raw_input (">>")

Print U "Mafa, Chaozhou Haiyang people (today Chaoan County), the end of the song Chaozhou the Legatus, in a crisis, to stand up to isolated city"
Print U "reject the soldier. Finally because traitor betrayed, Chaozhou city broken, re-retreated to Jinshan son city, Blood war to the last person, family martyred. "
Print U "Chaozhou is the last of the Song Dynasty of the state city, the city broke after the Yuan soldiers massacre, is one of the most tragic history of Chaozhou." "
Exit (0)
Elif ' Go ' in Next:
Start ()
Else
Dead (")

Start ()

Interactive program Three

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.