Question

In: Computer Science

What python codes should I use to solve this question below? Use input() function once to...

What python codes should I use to solve this question below?

Use input() function once to retrieve an input and assign that input value to a variable. Check if the input contains the string “an”. If so, use input() function one more time to retrieve an input and assign the new input value to a different variable. Now, replace “an” characters in the first variable with the first two characters of the second variable if only the second variable has at least two characters

Solutions

Expert Solution

var_1 = input("enter a string here:\t")
if(var_1.find("an") != -1):
   var_2 = input("enter another string here:\t")
   if(len(var_2) >= 2):
       var_1 = var_1.replace("an", var_2[0:2])
print(var_1)

If you have any doubts please comment and please don't dislike.


Related Solutions

Using Python Question 1 Write an input function. Then use it to supply the input to...
Using Python Question 1 Write an input function. Then use it to supply the input to following additional functions: i) Print multiplication table of the number from 1 to 12. ii) Print the sum of all the numbers from 1 to up the number given. iii) Print if the number supplied is odd or even. Question 2 Write function that asks for input from a user. If the user types 'end', the program exits, otherwise it just keeps going.
Use python write a function that translates the input string into Pig Latin. The translation should...
Use python write a function that translates the input string into Pig Latin. The translation should be done word by word, where all words will be separated by only one space. You may assume that each word must have at least one vowel (a,e,i,o,u and uppercased counterparts), and there will be no punctuation or other special characters in the input string. The Pig Latin rules are as follows: For words that begin with consonants, all letters before the initial vowel...
python codes question i need python codes to make robot tranverses the maze from its current...
python codes question i need python codes to make robot tranverses the maze from its current locations then returns to its current position. Then the robot marks the location with special token and the ones he has revisited with another special token.
This is python: #Write a function called count_positive_evens. This function #should take as input a list...
This is python: #Write a function called count_positive_evens. This function #should take as input a list of integers, and return as #output a single integer. The number the function returns #should be the count of numbers from the list that were both #positive and even. # #For example: # # count_positive_evens([5, 7, 9, 8, -1, -2, -3]) -> 1 # count_positive_evens([2, 4, 6, 8, 10, 12, 15]) -> 6 # count_positive_evens([-2, -4, -6, -8, -10, 1]) -> 0 # #0...
Solve by using python function. use loop Input; Crossing Times = { 10,15,20,25} 1.Firstly person '1'...
Solve by using python function. use loop Input; Crossing Times = { 10,15,20,25} 1.Firstly person '1' and '2' cross the path with total time about 15 min(maximum of 10, 15) 2.Now the person '1' will come back with total time of '10' minutes. 3. Now, person 1 and person 3 cross the path with total of about 20 minutes .(maximum of 10,20) 4. Now the person 1 will come back in 10 mintues 5. Lastly person 1 and person 4...
Python programming: Instructions: The python program should respond to user input on a command line Below...
Python programming: Instructions: The python program should respond to user input on a command line Below are the four options - if the user input is A, the program will quit -if the user input is B, the program will display the number of times the prompt has been displayed -if the user input is C, will display whatever is stored. -if the user inputs something else, it will store that user input as a string and append it to...
use python to solve Write a function called word_chain that repeatedly asks the user for a...
use python to solve Write a function called word_chain that repeatedly asks the user for a word until either (1) the user has entered ten words, or (2) the user types nothing and presses enter. Each time the user enters an actual word, your program should print all the words entered so far, in one long chain. For example, if the user just typed "orange", and the user has already entered "apple" and "banana", your program should print "applebananaorange" before...
I need the matlab codes for following question (1) (a). Solve the following second-order differential equations...
I need the matlab codes for following question (1) (a). Solve the following second-order differential equations by a pair of first-order equations, xyʹʹ − yʹ − 8x3y3 = 0; with initial conditions y = 0.5 and yʹ = −0.5 at x = 1. (b). Solve the problem in part (a) above using MATLAB built-in functions ode23 and ode45, within the range of 1 to 4, and compare with the exact solution of y = 1/(1 + x2) [Hint: ode23 à...
In Python Write a function to read a Sudoku board from an input string. The input...
In Python Write a function to read a Sudoku board from an input string. The input string must be exactly 81 characters long (plus the terminating null that marks the end of the string) and contains digits and dots (the `.` character represents an unmarked position). The input contains all 9 rows packed together. For example, a Sudoku board that looks like this: ``` ..7 ... ... 6.4 ... ..3 ... .54 ..2 ... .4. ... 9.. ... ..5 385...
In Python And Use List comprehension to solve this question Given a file like this: Blake...
In Python And Use List comprehension to solve this question Given a file like this: Blake 4 Bolt 1 De Grasse 3 Gatlin 2 Simbine 5 Youssef Meite 6 Your program when completed should produce output like this: >>> In the 2016 100 yard dash the top finishers were: Blake Bolt De Grasse Gatlin Simbine Youssef Meite The people with a two part name are: ['De Grasse', 'Youssef Meite'] The top three finishers were: ['Bolt', 'De Grasse', 'Gatlin'] Your mission...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT