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:...
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...
Machine Learning do using python on jupyter notebook 1. Linear Regression Dataset used: Diabetes from sklearn...
Machine Learning do using python on jupyter notebook 1. Linear Regression Dataset used: Diabetes from sklearn You are asked to solve a regression problem in the Diabetes dataset. Please review the Diabetes dataset used before creating a program to decide which attributes will be used in the regression process. please use the cross-validation step to produce the best evaluation of the model. All you have to do is • Perform linear regression using the OLS (Ordinary Least Square) method (sklearn.linear_model.LinearRegression)...
please use Jupter notebook in python 3 to answer the following: Plot the hyperbolic paraboloid given...
please use Jupter notebook in python 3 to answer the following: Plot the hyperbolic paraboloid given by: z = x**2/a**2 - y**2/b**2. You may use any non-negative integer values for a and b.
In Python syntax, create a list of 10 numbers (any numbers). Create your list 3 times,...
In Python syntax, create a list of 10 numbers (any numbers). Create your list 3 times, each time using a different syntax to define the list. Write a while loop that prints the numbers from 1 to 10. Convert your previous loop into a for loop. Rewrite your for loop to only have one number in the range. Write a for loop to print out each item of your list of 10 numbers, all on the same line, separated by...
In IDLE - Python 3, do the following: 1. Create File --> New 2. Enter the...
In IDLE - Python 3, do the following: 1. Create File --> New 2. Enter the code below in the new file (you may omit the comments, I included them for explanation #Python Code Begin x = int(input("Enter a number: ")) y = int(input("Enter another number: ")) print ("Values before", "x:", x, "y:", y) #add code to swap variables here #you may not use Python libraries or built in swap functions #you must use only the operators you have learned...
PYTHON-- create a method that prints items from a stack in a top to bottom order
PYTHON-- create a method that prints items from a stack in a top to bottom order
In Python Create customer information system as follows: Python 3 Create customer information system as follows:...
In Python Create customer information system as follows: Python 3 Create customer information system as follows: Ask the user to enter name, phonenumber, email for each customer. Build a dictionary of dictionaries to hold 10 customers with each customer having a unique customer id. (random number generated) Take the keys of the above mentioned dictionary which are customer ids and make a list. Ask the use to enter a customer id and do a binary search to find if the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT