Question 6Given myvar = 'hello' , how would you return myvar as uppercase?
Question
Question 6Given myvar = 'hello' , how would you return myvar as uppercase?
Solution
To return the variable 'myvar' as uppercase in Python, you would use the .upper() method. Here are the steps:
- First, you need to define the variable 'myvar' and assign the string 'hello' to it. You can do this with the following line of code:
myvar = 'hello'
- Next, you can use the .upper() method to convert the string to uppercase. This method is called on the string object 'myvar'. Here is how you can do it:
uppercase_myvar = myvar.upper()
- Now, 'uppercase_myvar' contains the uppercase version of 'myvar'. You can print it to the console to check the result:
print(uppercase_myvar)
When you run this code, it will print 'HELLO' to the console.
Similar Questions
Question 6Given myvar = 'hello' , how would you return myvar as uppercase?1 pointlen(myvar)myvar.find('hello')myvar.upper()
Which method can be used to return a string in upper case letters?
How can you convert a lowercase character to uppercase manually in a string?
Write a method that takes a String and returns it in AltCase.This means that the first letter is uppercase and each subsequent character alternates between lowercase and uppercase.Here are some examples of words in AltCase:HeLlOHeLlO WoRlDThIs iS In aLtCaSe.Note: if there is a space, you still treat that as a character, so the String "A B" is in AltCase, since technically, the space between the letters is lower case.
Write a python program to convert all the letters in the string to uppercasestring = "Hello World"print(string.upper())string = "Hello World"print(string.title())string = "Hello World"print(string.capitalize())string = "Hello World"print(string.Upper())
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.