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

For example, if the given range is 2 to 11

odds numbers in the range are 3, 5, 7, 9, 11 then count is 5.

even numbers in the range are 2, 4, 6, 8, 10 then count is 5.


For example, if the given string is "Good Morning"

Vowels in the string "Good Morning" are "o, i" and their count is 4.

Remaining characters in the string are consonants their count is 7.

The First line of output is 4\nThe second line of output is 7.


For example, if the given number is 5, then read the inputs in the next 5 lines and print the sum of non-primes in the given five numbers. If the given input integers in the next five lines are 8, 11, 96, 49, and 25 the output should be 8 + 96 + 49 + 25 is 178.


import numpy as np

import scipy.linalg as la

import matplotlib.pyplot as plt

5. Use the np.linspace function to create a row vector called meshPoints

containing exactly 500 values with values evenly spaced between -1 and 1.

 

6. What expression will yield the value of the 53th element of meshPoints?

What is this value?

 

7. Produce a plot of a sinusoid on the interval [−1, 1] using the command

 

plt.plot(meshPoints,np.sin(2*pi*meshPoints))


import numpy as np

import scipy.linalg as la

import matplotlib.pyplot as plt

3. Choose an angle θ and set the variable theta to its value (a number).

 

4. What is sin θ?   cos θ?   Angles can be measured in degrees or radians.

Which of these are being used used?


import numpy as np

import scipy.linalg as la

import matplotlib.pyplot as plt

 

1. Choose a value and set the variable x to that value.

 

2. What is command to compute the square of x? Its cube?


# Looks great! # . I would come up with a better name for d

# test if the user wants to quit... 

# Is not quite right... Change this print('I thought of another number, try again')
#   to something more like "Not Quite, Please try again"



from random import randint




play = input('You want to start? y/n ')

def play_game():
    # Put the rules here
    # While loop goes here
    d = randint(7, 50)
    computer_num = randint(1, d)
    lives = d // 2
    while lives > 0:
        try:
            num = int(input(f'enter number from 1 to {d}, you have {lives} attempts left '))
            if num > d or num < 1:
                raise ValueError
        except:
            print('incorrect input, try again')
            continue
        if num == computer_num:
            print(f'you won, I thought number {computer_num}')
            return None
        else:
            lives -= 1
            if lives > 0:
                print('I thought of another number, try again')
    print(f'you lost, I thought number {computer_num}')

play = input('You want to start the game[y/n]: ')
while play.lower() == 'y':
    play_game()
    play = input('You want to play again? y/n ')

Given polynomial, write a program that prints polynomial in Cix^Pi + Ci-1x^Pi-1 + .... + C1x + C0 format.


input : 5

0 2

1 3

2 1

4 7


expected output : 7x^4 + 6x^3 + x^2 + 3x + 2
 your output: 7x^4 + 6x^3 + 1x^2 + 3 + 2


please explain this


Secret Message - 2

Given a string, write a program to print a secret message that replaces characters with numbers 'a' with 1, 'b' with 2, ..., 'z' with 26 where characters are separated by '-'.

a b c d e f g h i j k l m n o p q r s t u v w x y z

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26


Input

Input will be a string in single line containing spaces and letters both uppercase and lowercase.

Output

Output should be a single line containing secret message. All characters in output should be in lower case.

Explanation

For example, if input is "python", "p" should replaced with "16", similarly"y" with "25","t" with "20","h" with "8","o" with "15","n" with "14". So output be "16-25-20-8-15-14".

Sample Input 1

python


Sample Output 1

16-25-20-8-15-14

Sample Input 2

python learning


Sample Output 2

16-25-20-8-15-14 12-5-1-18-14-9-14-7

given a sentence in camel case and want to convert to snake case using for loop and indexing


LATEST TUTORIALS
APPROVED BY CLIENTS