Question

In: Computer Science

Create a new Python 3 Jupyter Notebook. At the top, be sure to name your notebook...

Create a new Python 3 Jupyter Notebook.

At the top, be sure to name your notebook as "*assignment 2.08 - Your Name Here.ipynb*" (obviously, replace the "Your Name Here" part with your actual name).

Create a single python cell to program the following specifications.

Use what you've learned on this page to:
1. Find the index of "lmno" in the English alphabet using an appropriate instruction and store it in a variable. (hint: you'll need to define a string that contains the letters of the alphabet in their proper order)
1. Find the length of "lmno" using an appropriate instruction and store it in a different variable.
1. Use those two variables to determine the index for the end of "lmno" within the alphabet and store that in a third variable. (hint: use math)
1. Use the two variables that are defined as indexes to get the corresponding slice of the alphabet and print it out using a format string.

You may use any other variables you determine are necessary or helpful. Also, be sure to use comments as needed to explain what is taking place.

Solutions

Expert Solution

alphabet = "abcdefghijklmnopqrstuvwxyz" #string that contains all the alphabets

#In first line I created a variable alpahbet and stored alphabets in order

#1.finding the index of the substring "lmno" in alphabet string using find() function. stringname.find(substring)
index1 = alphabet.find("lmno") #finds the substring "lmno" in the string alphabet and stores in index1

#1.finding the length of the word "lmno". Here I used len() function.
length = len("lmno") #finds length of the string "lmno"

#1.Next I have to find the index for the end of word "lmno" in string alphabet. So, I just added the initial index where I found it(index1). And then I used length of the word to find the end index. (index1+length)=end index


index2 = index1+length #adding the index1 (position of the string) and length of the string to get last index of
# the word

#Now Using two indexes I have to print the slice of string using format string. Here format(word) prints the word in the statement where {} are placed. And alphabet[index1:index2] slices the string from index1 to index2
print("The corresponding slice of the alphabet is {}".format(alphabet[index1:index2])) #printing the sliced
# alphabet using a format string

If you have any doubt comment me.


Related Solutions

Create a new Python 3 Jupyter Notebook. Create one python code cell for the problem below....
Create a new Python 3 Jupyter Notebook. Create one python code cell for the problem below. Use any additional variables and comments as needed to program a solution to the corresponding problem. All functions should be defined at the top of the code in alphabetical order. When done, download the ipynb file and submit it to the appropriate dropbox in the course's canvas page. Problem: Define a function with the following characteristics: The function's purpose will be calculating a factORRial...
create a new Python 3 Jupyter Notebook.. Create one python code cell for the problem below....
create a new Python 3 Jupyter Notebook.. Create one python code cell for the problem below. Use any additional variables and comments as needed to program a solution to the corresponding problem. All functions should be defined at the top of the code in alphabetical order. Problem: Define a function with the following characteristics: The function's purpose will be checking that a number matches another, so it should be named appropriately. It must accept one parameter, which is the number...
Python HW Open a new Jupyter notebook Create a new function named fibonacci() that takes one...
Python HW Open a new Jupyter notebook Create a new function named fibonacci() that takes one required parameter: maxint, an integer that will serve as the upper bound of the loop Following the example on the Python tutorial: https://docs.python.org/3/tutorial/introduction.html#first-steps-towards-programming Our implementation will have a few changes: While you will use a while loop to make a Fibonacci sequence, the upper bound of the sequence will be your maxint parameter. Store the results into a list and append each new generated...
Write a python programme in a Jupyter notebook which asks the user to input the number...
Write a python programme in a Jupyter notebook which asks the user to input the number of radioactive nuclei in a sample, the number at a later time, and the elapsed time. The programme should calculate and display the decay constant and the half-life. The decay is described by the equations: ? = ? ?−?? ?0 ?1/2 = ln (2) . Test your programme a sample that contains 4.00x108 nuclei initially and 1.57x107 nuclei after 150 seconds. SO THEREFORE A...
Focuses on the design, development, implementation, and testing of a Python program using Jupyter Notebook only...
Focuses on the design, development, implementation, and testing of a Python program using Jupyter Notebook only to solve the problem described below. You will write a program that simulates an Automatic Teller Machine (ATM). For this program, your code can have of user-defined functions only. However, the program must not call on any external functions or modules to handle any of the input, computational, and output requirements. Note, the program can be completed without the use of user-defined functions. Requirements:...
Python HW with Jupyter Notebook Declare a variable named DATA as a dictionary object. Assign the...
Python HW with Jupyter Notebook Declare a variable named DATA as a dictionary object. Assign the set of key/value pairs shown below. Create a function named iter_dict_funky_sum() that takes one dictionary argument.    Declare a running total integer variable. Extract the key/value pairs from DATA simultaneously in a loop. Do this with just one for loop and no additional forms of looping. Assign and append the product of the value minus the key to the running total variable. Return the funky...
python Create a new file name condition_quiz.py. Add a comment with your name and the date....
python Create a new file name condition_quiz.py. Add a comment with your name and the date. Prompt the user to enter the cost. Convert the input to a float. Prompt the user for a status. Convert the status to an integer Compute the special_fee based on the status. If the status is 0, the special_fee will be 0.03 of the cost. Else if the status is 1, the special_fee will be 0.04 of the cost. Else if the status is...
Write a program in Python jupyter notebook for following: Part1: Course grade calculation: Course grades for...
Write a program in Python jupyter notebook for following: Part1: Course grade calculation: Course grades for CIS 1100 are calculated based on two assignments, a midterm exam, and a final exam. Here are the weights of these. Assignments 25% Midterm exam 35% Final exam 40% Ask the user for the scores they received for the two assignments, midterm exam, and the final exam. Then calculate and display their total weighted score they received for the course. Based on the weighted...
Problem: Perform the word counter problem through MapReduce. Tools: Anaconda/Python 3/Jupyter Notebook Example word: “One a...
Problem: Perform the word counter problem through MapReduce. Tools: Anaconda/Python 3/Jupyter Notebook Example word: “One a penny, two a penny, hot cross buns.” Submitted files: (1) Source code (adding comments); (2) Supporting document for code comments
Please give me an example of how we import stock data in jupyter notebook(Python) and analyze...
Please give me an example of how we import stock data in jupyter notebook(Python) and analyze each step.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT