Question

python Suppose city is a variable that holds a string of at least 5 characters. Write...

python

Suppose city is a variable that holds a string of at least 5 characters. Write one statement that assigns to a variable named letter the third letter of the string stored in city as an upper case letter. (Note: We'll assume the third letter of city is a letter)

Homework Answers

Answer #1

city = input("enter the city name ")
  
# printing original string
#print("The original string is : " + str(city))
  
# initializing N
N = 2
  
# Using upper() + string slicing
# Uppercase Nth character
letter = city[N].upper()
  
# printing result
print( str(letter))

Explanation:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
The String Class: 1a.) Given the following delcaration: String modification1; Write a statement that stores the...
The String Class: 1a.) Given the following delcaration: String modification1; Write a statement that stores the uppercase equivalent of the string object called "city" in modification1. 1b.) Write a statement that declares a String variable named city. The variable should be initialized with the string literal "Los Angeles". 1c.) Given the following declaration: int stringSize; Write a statement that stores the length of the string object called "city" in stringSize. 1d.) Given the following declaration: char oneChar; Write a statement...
Q1) Write a Python function partial_print, which takes one parameter, a string, and prints the first,...
Q1) Write a Python function partial_print, which takes one parameter, a string, and prints the first, third, fifth (and so on) characters of the strings, with each character both preceded and followed by the ^ symbol, and with a newline appearing after the last ^ symbol. The function returns no value; its goal is to print its output, but not to return it. Q2) Write a Python function called lines_of_code that takes a Path object as a parameter, which is...
1. Write a statement that assigns an empty list to the variable named empty. 2. Write...
1. Write a statement that assigns an empty list to the variable named empty. 2. Write a statement which assigns all the odd integer values between 0 and 10 (in order) to the variable named odds. 3. Write a statement which assigns the list of three-letter abbreviations of the months of the year to the variable months. That would be: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Capitalize correctly and have no punctuation. 4. Create...
Write a program that takes a string of characters (including spaces) as input, computes the frequency...
Write a program that takes a string of characters (including spaces) as input, computes the frequency of each character, sorts them by frequency, and outputs the Huffman code for each character.   When you are writing your program, you should first test it on a string of 7 characters, so you can check it. PLEASE NOTE: Your program must work for any text that has upper and lower case letters digits 0 - 9, commas, periods, and spaces. Please submit the...
[Python] Write a function named "total_population" that takes a string then a list as parameters where...
[Python] Write a function named "total_population" that takes a string then a list as parameters where the string represents the name of a CSV file containing city data in the format "CountryCode,CityName,Region,Population,Latitude,Longitude" and the second parameter is a list where each element is itself a list containing 3 strings as elements representing the CountryCode, CityName, and Region in this order. Return the total population of all cities in the list. Note that the city must match the country, name, and...
python Suppose that a variable named temp exists and contains a valid integer temperature in degrees...
python Suppose that a variable named temp exists and contains a valid integer temperature in degrees Fahrenheit. Write one if-elif-else statement that would output cold if the value in temp is below 40; mild if the temp is in the range 40 through 79; and Hot if temp is 80 or above. You may hard-code in numeric literals such as 40, 79, and 80 without creating named constants.
3. Write function, leastChar(inputString) that takes as input a string of one or more letters (and...
3. Write function, leastChar(inputString) that takes as input a string of one or more letters (and no other characters) and prints 1) the "least" character in the string, where one character is less than another if it occurs earlier in the alphabet (thus 'a' is less than 'C' and both are less than 'y') and 2) the index of the first occurrence of that character. When comparing letters in this problem, ignore case - i.e. 'e' and 'E' should be...
C Program Write a program to count the frequency of each alphabet letter (A-Z a-z, total...
C Program Write a program to count the frequency of each alphabet letter (A-Z a-z, total 52 case sensitive) and five special characters (‘.’, ‘,’, ‘:’, ‘;’ and ‘!’) in all the .txt files under a given directory. The program should include a header count.h, alphabetcount.c to count the frequency of alphabet letters; and specialcharcount.c to count the frequency of special characters. Please only add code to where it says //ADDCODEHERE and keep function names the same. I have also...
In Python: This will require you to write several functions, and then use them in a...
In Python: This will require you to write several functions, and then use them in a program. Logical Calculator The logical calculator does math, but with logical operators. In logic, we represent a bit with 0 as false and a bit with 1 as true. The logical operators are NOT, AND and OR. Bitwise logical calculations operate on each bit of the input. The NOT operator works on just one three-bit argument. NOT 011 = 100 The AND operator works...
Having a secure password is a very important practice, when much of our information is stored...
Having a secure password is a very important practice, when much of our information is stored online. Write a program that validates a new password, following these rules:5 pts The password must be at least 8 characters long The password must have at least one uppercase and one lowercase letter The password must have at least one digit The program must also ask for a user to enter it and then confirm it: Enter your password: Re-enter your password: If...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT