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

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...
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...
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...
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...
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.
​​​​Python Create a new file named compute_cost.py. Write your name and date in a comment. Create...
​​​​Python Create a new file named compute_cost.py. Write your name and date in a comment. Create a variable named base_fee and set the value to 5.5. Prompt the user for the zone. The zones can be an integer value from 1 to any value for the zone. Convert the zone to an integer. Display the zone on the SenseHat with a scroll speed of 0.3, make the text blue, and the background yellow. Scroll "The zone is " and the...
Please solve using jupyter notebook . 10.10- (Invoice Class) Create a class called Invoice that a...
Please solve using jupyter notebook . 10.10- (Invoice Class) Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as data attributes—a part number (a string), a part description (a string), a quantity of the item being purchased (an int) and a price per item (a Decimal). Your class should have an __init__ method that initializes the four data attributes....
Python: Using Jupyter Notebook 1. Write code to generate Fibonacci series. Fibonacci numbers – 1, 1,...
Python: Using Jupyter Notebook 1. Write code to generate Fibonacci series. Fibonacci numbers – 1, 1, 2, 3, 5, 8, … 2. Check if a number is an Armstrong number A positive integer is called an Armstrong number of order n if abcd... = a^n + b^n + c^n + d^n + ... In case of an Armstrong number of 3 digits, the sum of cubes of each digits is equal to the number itself. For example: 153 = 1*1*1...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT