Question

By using Python code answer the following parts: A) Write a program to ask the user...

By using Python code answer the following parts:

A) Write a program to ask the user to input their name and then output the type and length of the input.

B) Write a program to output the last 11 letters of 'Introduction to Indiana'.

C) Write a program to output the 3rd to the 11th letters of 'Introduction to Indiana'.

D) Write a program to ask the user to input a float number and output the rounded value of it using related

function.

E) Write a function to calculate the square root of the provided parameter using the Newton-Raphson

method. Print the difference between the square of the calculated value and the result of request.

Homework Answers

Answer #1

#1
name = input('Enter name: ')
print('Type of input:',type(name))
print('Length of input:',len(name))

#2
string = 'Introduction to Indiana'
print('Last 11 letters of',string,':',string[-11:])

#3
string = 'Introduction to Indiana'
print('3rd to 11th letters of',string,':',string[2:11])

#4
num = float(input('Enter a float number: '))
print('Rounded value of',num,':',round(num))

#5
def squareRoot_newton(num):
    x=num/2
    while abs(x*x-num)>.000001:#upto 5 decimal place accuracy
        x=x-(x*x-num)/(2*x)
    print('Difference between square of calculated value and the number: ',abs(x*x-num))
    return x

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a Python program to ask user input of a string, then ask user input of...
Write a Python program to ask user input of a string, then ask user input of what letters they want to remove from the string. User can either put in "odd", "even" or a number "n" that is greater than 2. When user input "odd", it will remove the characters which have odd numbers in the sequence of the string. When user input "even", it will remove the characters which have even numbers in the sequence of the string. When...
Provide Python code that does the following: 4) Write a program that asks the user to...
Provide Python code that does the following: 4) Write a program that asks the user to enter a 9 character password. Test to see if it is a valid password. The validity test is a) they enter exactly 9 characters AND b) that every 3rd character, starting with the 1st character is the letter z. If it is valid print out the message “valid password” otherwise print the message “invalid password”. Sample output. Please enter a password: zaazbbz12 valid password...
(8 marks) Write a program to ask user to input an integer and display the special...
Write a program to ask user to input an integer and display the special pattern accordingly. REQUIREMENTS The user input is always correct (input verification is not required). Your code must use loop statements (for, while or do-while). Your program should use only the following 3 output statements, one of EACH of the followings: System.out.print("-"); // print # System.out.print("+"); // print + System.out.println(); // print a newline Your code must work exactly like the following example (the text in bold...
Write a Python program to calculate the area of a circle. The user needs to input...
Write a Python program to calculate the area of a circle. The user needs to input the value of the radius of the circle. area = 3.14 x radius x radius You should use a function named circlearea to perform the calculation 3. Write a Python program to calculate the area of a square. The user needs to input the value of the length of the square. area = len*len You should use a function named squarearea to perform the...
Write a python code that will ask the user to enter an integer number n. Construct...
Write a python code that will ask the user to enter an integer number n. Construct a recursive function that prints numbers 1 to n in the form “11223344..nn”.
Using python, write the program below. Program Specifications: You are to write the source code and...
Using python, write the program below. Program Specifications: You are to write the source code and design tool for the following specification: A student enters an assignment score (as a floating-point value). The assignment score must be between 0 and 100. The program will enforce the domain of an assignment score. Once the score has been validated, the program will display the score followed by the appropriate letter grade (assume a 10-point grading scale). The score will be displayed as...
Write a Python program that asks users to input 10 float numbers (using a while statement),...
Write a Python program that asks users to input 10 float numbers (using a while statement), and print the minimum number.
IN PYTHON : Write a program that asks the user for a number. Write the number...
IN PYTHON : Write a program that asks the user for a number. Write the number to a file called total.txt. Then ask the user for a second number. Write the new number on line 2 with the total for both numbers next to it separated by a comma. Then ask the user for a third number and do the same. Keep asking for numbers until the person puts in a zero to terminate the program. Close the file. Be...
Write a Python program that will ask the user to enter the masses of two particles...
Write a Python program that will ask the user to enter the masses of two particles (particle one and particle two) and particle 1’s initial velocity (v1). Assume particle two is at rest. The program should calculate the scattering angle and velocity for particle 2 as a function of the scattering angle and resulting velocity of particle 1
Python The following program contains a number of minor typos. Write the correct code and comments...
Python The following program contains a number of minor typos. Write the correct code and comments about what was wrong. The type function returns the type for the value specified as a parameter. lex = {} lex{’a’} = ’hej’ lex[’b’] = [5 9] for k in lex.keys: print(’Information for key {k}’) print f’Val: {lex[k]}, Type: {type(lex[k])}’
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT