Вы находитесь на странице: 1из 1

Practice Programs

1. Answer these three questions without typing code. Then type code to check your
answer.
• What is the value of the expression 4 * (6 + 5)? = 44
• What is the value of the expression 4 * 6 + 5? = 29
• What is the value of the expression 4 + 6 * 5? = 34
2. What is the type of the result of the expression 3 + 1.5 + 4?
3. What would you use to find a number’s square root, as well as its Square?
4. Given the string 'hello', give an index command that returns ‘e’.
5. Reverse the string 'hello' using slicing.
6. Given the string ‘hello’, give two methods of producing the letter 'o' using
indexing.
7. Ask the user for a string and print out whether this string is a palindrome or not. (A
palindrome is a string that reads the same forwards and backwards.)
8. Go through the string below and if the length of a word is even or odd print that

st = 'Print every word in this sentence that has an even number of letters’
9. Make a two-player Rock-Paper-Scissors game. (Hint: Ask for player plays (using
input), compare them, print out a message of congratulations to the winner, and ask
if the players want to start a new game)
Remember the rules:
i. Rock beats scissors
ii. Scissors beats paper
iii. Paper beats rock

10. Create a program that asks the user to enter their name and their age. Print out a
message addressed to them that tells them the year that they will turn 100 years
old.

Вам также может понравиться