I was in Seattle for 4 days for our band trip so i miss some classes.
Chapter 4
Project 1
"Write a program that asks for a phrase, and then calculates and displays the
number of vowels in the phrase, twice. The first time, your program should
calculate the number of vowels in the phrase using a for loop. The second time,
your program should use a while loop."
My code:
phrase = raw_input("Please enter a phrase: ")
VOWELS = "aeiou"
new = ""
for letter in phrase:
if VOWELS in phrase :
print newv
It keeps printing the phrase not the new string. How would you do this? And
what am i doing wrong?
2. "Write a program that gets a message from the user and prints the message
out backwards."
For this one, i honestly don't have any idea how to make a word print
backwards, I only do it with numbers. Here's my attempt code:"
import random
message = raw_input("Please enter you message:")
raw_input("Please press the enter key to our message.")
high = (message(len(100)))
low = (message(len(0)))
new = random.randrange (high, low)
print new
So how do you put the words backwards?
3."Write a program that prints out a string representation of a random card
from a deck of playing cards. The program should use either "A",
"2","3","4","5","6","7","8","9","10","J","Q" or "K" for the value of the card
and either "c","h","s" or "d" for the suit. So, if the program randomly selects
the jack of clubs, it should display 'Jc.' Use one tuple to represent all of
the possible card values and another tuple for the possible suits."
In the simplest way, how do you do this?
Thanks in advance
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor