# # Author: Jessica Joyce Borlongan # Student ID: 998420844 # Date: 11/15/2013 # # Problem 1: dealing with numbers # This program was designed to give 15% and 20% of the bill. # 1. Input print "Problem 1: dealing with numbers" Bill = raw_input("Please enter your restaurant bill -->") Bill= float(Bill) # # 2. Multiply bill total by 15% # Fifteen_Tip = Bill*0.15 print "15% of your bill is --> ",Fifteen_Tip, " dollars" # # 3. Multiply bill total by 20% # Twenty_Tip = Bill * 0.20 print "20% of your bill is --> ", Twenty_Tip, " dollars" print "\n" # # Problem 2: dealing with strings. # # 1. Input # print "Problem 2: dealing with strings" # Sentence = raw_input("Enter a sentence-->") print Sentence # print "\n" print "The sentence will be converted to lower case." Sentence = raw_input("Enter a sentence -->") Sentence = Sentence.lower() print Sentence # print "\n" print "Next, the vowels will be converted to uppper case and consants to lower case." Sentence = raw_input("Enter a sentence -->") Sentence = Sentence.lower () Sentence = Sentence.replace("a","A") Sentence = Sentence.replace("e", "E") Sentence = Sentence.replace("i", "I") Sentence = Sentence.replace("o", "O") Sentence = Sentence.replace("u", "U") Sentence = Sentence.replace ("y", "Y") print Sentence print "\n" print "The sentence will be spelled backwards." Sentence = raw_input("Enter a sentence -->") Sentence[::-1] print Sentence[::-1] print "\n" # # Problem 3: Counting words and characters # # 1. Input # print "Problem 3: Counting words and characters" print "\n" print "This will show the number of characters." Sentence = raw_input("Enter a sentence-->") Count_Characters = len(Sentence) Count_Blank = Sentence.count (" ") Total_Characters = Count_Characters - Count_Blank print Total_Characters print "\n" print "This will show the number of words, excluding the space." Sentence = raw_input("Enter a sentence-->") Count_Words = len(Sentence) Count_Blank = Sentence.count (" ") Total_Words = Count_Blank + 1 print Total_Words # # END #
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question