0% found this document useful (0 votes)
5 views

Coding Assignment 6

Uploaded by

angelic.entity3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Coding Assignment 6

Uploaded by

angelic.entity3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

The program first prompts the user to enter their name using the input() function, which allows

the user to
type in their name and press Enter to submit it.
Next, the program prints the first 10 characters of the name using the slice notation [:10]. This slice
selects the characters from the beginning of the string up to and including the 10th character.
Next, the program counts the number of vowels in the name using a for loop. The loop iterates over each
character in the name and checks if it is a vowel using the `in` operator. If the character is a vowel, the
counter variable vowel_count is incremented.
Finally, the program reverses the name using the slice notation [::-1], which reverses the list of characters
in the name. This results in the name being displayed from right to left.
The program prints the results using f-strings, which allows you to easily format strings with expressions
inside curly braces. The output includes the name entered by the user, the first 10 characters of the name,
the number of vowels in the name, and the reversed name.
It's worth noting that this is just one way that I found to perform the requested operations on a name.
There may be other ways to approach the problem with different techniques and algorithms.

Reference

Downey, A. (2015). Think Python: How to think like a computer scientist. Needham, Massachusetts:
Green Tree.

You might also like