Python Answers

Questions answered by 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

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. 
  • 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

Create your own examples using python lists

  • 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. 

 

 



import time
nucleotides="ATGC"
nulength= len(nucleotides)
nucleostring=""
noofbase=0
inputbase= int(input("Enter the number of base: "))
while noofbase < inputbase:
rand=int(time.time_ns())
randomno=rand%nulength
nucleostring+=nucleotides[randomno]
noofbase+=1
print(nucleostring)
print("Forward: ")
print("DNA Seq")
if len(nucleostring)%3 == 0:
for i in range(0, len(nucleostring),3):
c= nucleostring[i: i+3]
print(c)
but i need output in horizontal line
output Enter the number of base: 6
TACGCTTCTCGTGCCTCCTCCGCTGCGATCCAACCA
Forward:
DNA Seq
TAC
GCT
Write a python code for below problem,
We have a list
Input = [5,'Unnamed: 1','Unnamed: 2','Unnamed: 3', 6, 'Unnamed: 5','Unnamed: 6']
want to convert it into: Output= [5,5,5,5,6,6,6]

Create a program that reads integers from the user until a blank line is entered. Once

all of the integers have been read your program should display all of the negative

numbers, followed by all of the zeros, followed by all of the positive numbers.Within

each group the numbers should be displayed in the same order that they were entered by the user. For example, if the user enters the values 3, -4, 1, 0, -1, 0, and -2 then

your program should output the values -4, -1, -2, 0, 0, 3, and 1.display each value on its own line.


I think it's already a given that two sentences combined will always be longer than a single sentence alone, but to prove just how long two sentences can be, why don't we let our program show the combined length of the two randomly inputted strings?

Let's get it on!


Input

Two lines containing a string on each.

Python·is·fun
I·love·CodeChum





 for i in range(0,len(displayList)):
                #Test if the fist item in the current sub-list contains the text "Price Level
                #Tip: Remeber that each sub-list is a (displayList). So you have
                #to access its items via displayList followed by TWO indexes.
                if i == "Price Level":

                    #Extract the second item from the current sub-list into variable called priceLevel
                    priceLevel = i
                #Test if priceLevel is between previousPrice and currentPrice OR
                #        pL == pP OR
                #    pL == cP
                if priceLevel >= previousPrice and priceLevel <= currentPrice or priceLevel == previousPrice or priceLevel == currentPrice:


                    if self.__currentPrice <= self.__previousPrice:
                        frequency = 400
                        duration = 700
                    #Sound the alarm. Pass in the frequency, duration.
                    else:
                        frequency = 800
                        duration = 700
                    winsound.Beep(frequency, duration)
                    #Print the text 'Alarm' 
                    #can go back and check when the alarm was sounded.
                    print(Back.GREEN + "Alarm" + Style.RESET_ALL)

if __name__ == '__main__':
    displayList = ['Price level']
    play = Play()
    # function call
    play.ls(0, 100)




celicus to Fahrenheit

In a right triangle, the square of the length of one side is equal to the sum of the squares of the lengths of the other two sides. Write a program that prompts the user to enter the length of the three sides of a triangle and then outputs a message indicating whether the triangle is a right triangle. Use functional programming paradigm on this problem.  


If Input coefficients are negative values, the output will be wrong.How to get output if coefficients are negative?

More distinct letters

you are given a list of strings, write a program to print the string with the maximum number of distinct letters. If there are more than one such strings, print the string which comes first in alphabetical order. Note: consider upper and lower case letters are different.

Input: The input is a single line containing the strings separated by a space.

Output: The output should be a single line containing the string with maximum distinct characters.

Explanation:

In the example, the given list of strings are raju , plays , golf. The word plays has the maximum number of distinct letters. So the output should be plays.


LATEST TUTORIALS
APPROVED BY CLIENTS