Questions: 5 290

Answers by our Experts: 5 288

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Write a Python program that takes a string as an input from the user containing all small letters and then prints the next alphabet in sequence for each alphabet in the input.

Hint: You may need to use the functions ord() and chr(). The ASCII value of ‘a’ is 97 and ‘z’ is 122.

Write a Python program that will ask the user to input a string (containing exactly one word). Then your program should print subsequent substrings of the given string as shown in the examples below.

=====================================================================

Hints(1): You may use "for loop" for this task.

Hints(2): You may use print() function for printing newlines.

For example:

print(1)

print(2)

Output:

1

2

=====================================================================

We can use print(end = "") to skip printing the additional newline.

For example:

print(1, end ="")

print(2)

Output:(prints the following output right next to the previous one)

12

=====================================================================

Sample Input 1:

BANGLA

Sample Output 1:

B

BA

BAN

BANG

BANGL

BANGLA

.

=====================================================================

Sample Input 2:

DREAM

Sample Output 2:

D

DR

DRE

DREA

DREAM


Write a Python program that will ask the user to enter a word as an input.

  • If the length of the input string is less than 4, then your program should print the same string as an output.
  • If the input string’s length is greater than 3, then your program should add "er" at the end of the input string.
  • If the input string already ends with "er", then add "est" instead, regardless of the length of the input string
  • If the input string already ends with "est", then your program should print the same input string as an output.

Machine problem 2


Create a Python script that will generate random n integers from a given start and end of a range.


Sample Output:


Value for n:5


Value for start: 1


Value for end : 10


10 8 7 8 3

Create two numpy arrays and add the elements of both the arrays and store the result in sumArray.


Part 1

Write a Python program that does the following. 

  • Create a string that is a long series of words separated by spaces. The string is your own creative choice. It can be names, favorite foods, animals, anything. Just make it up yourself. Do not copy the string from another source. 
  • Turn the string into a list of words using split
  • Delete three words from the list, but delete each one using a different kind of Python operation. 
  • Sort the list. 
  • Add new words to the list (three or more) using three different kinds of Python operation. 
  • Turn the list of words back into a single string using join
  • Print the string. 

Part 2

Provide your own examples of the following using Python lists. Create your own examples. Do not copy them from another source. 

  • Nested lists 
  • The “*” operator 
  • List slices 
  • The “+=” operator 
  • A list filter 
  • A list operation that is legal but does the "wrong" thing, not what the programmer expects 

Provide the Python code and output for your program and all your examples.


Add methods to the classes and subclasses:


  • a Movie can calculate:
  • totalMinutes()
  • for example, a movie 1 hour and 40 minutes long = 100 minutes total
  • a Snack can calculate:
  • amtHarm()
  • = the #calories times the amount of sodium or sugar
  • an Employee can calculate:
  • employeeMonthlyPay()
  • assume Staff work 40hours/week and 4 weeks/month

In the main code:


  • make lists for movies, snacks, and employees
  • use loops to find:
  • the total length of all movies
  • the most dangerous snack
  • the poorest employee

1. In K-means algorithm, what is the most commonly used distance metric to calculate distance between centroid of each cluster and data points?

 

a)Chebyshev distance

b)Manhattan 

c)Euclidean

d)None of the above



1. Which of the following statement is not correct about k-means?

 


a)Accuracy of cluster are improved by scaling of attributes.

b)K-means clusters are affected by outliers.

c)K-Means clustering is NOT influenced by initial centroids which are called cluster seeds

d)Number of clusters to be built is typically an user input and it impacts the way clusters are created


1. The method / metric which is NOT useful to determine the optimal number of clusters in unsupervised clustering algorithms is

 a)Dendogram

 b)Elbow method

c) Scatter plot

d) None of the above



LATEST TUTORIALS
APPROVED BY CLIENTS