Question

In: Computer Science

please use python to solve this problem. Math and String operations Write a script to perform...

please use python to solve this problem.

Math and String operations
Write a script to perform various basic math and string operations. Use some functions from Python's math module. Generate formatted output.

Basic math and string operations
Calculate and print the final value of each variable.

a equals 3 to the power of 2.5
b equals 2 b equals b + 3 (use +=)
c equals 12 c = c divided by 4 (use /=)
d equals the remainder of 5 divided by 3
Built-in functions abs, round, and min
Use abs, round, and min to calculate some values. These are all Python built in functions (see: BIF ).

Print the difference between 5 and 7.
Print 3.14159 rounded to 4 decimal places.
Print 186282 rounded to the nearest hundred.
Print the minimum of 6, -9, -3, 0
Functions from the math module
Use some functions from Pythons math module to perform some calculations.

Ask the user for a number (test with the value 7.6).
Print the square root of the number, rounded to two decimal places (include an appropriate description).
Print the base-10 log of the number, rounded to two decimal places (include an appropriate description)
(see https://docs.python.org/3/library/math.html).
Complex numbers
Do a calculation with complex numbers. Note that, while you might be familiar with the notation convention commonly used within mathematics for complex numbers (z = a + bi), Python uses the notation convention used in electromagnetism and electrical engineering (z = a + bj).

Assign z1 the value of 4 + 3j
Assign z2 the value of 2 + 2j
Assign z3 the value of z1 times z2
Print the value of z3
Add the following at the end of the script to show your results

Solutions

Expert Solution

OUTPUT :

CODE :

#a

a=3**2.5
print(a)

#b
b = 2
b += 3
print(b)

c=12
c/=4
print(c)

d=5%3

print(abs(5-7))

print(round(3.14159,2))
x = 186282

import math
print(int(math.ceil(x/100.0))*100)
print(min([6,-9,-3,0]))

n = float(input('Enter a number : '))
sq = math.sqrt(n)
print('Square root of ',n,' is ',sq)
print('log of ',n,' is ',math.log(n,10))

z1 = 4+3j
z2 = 2+2j
z3 = z1*z2
print(z3)


Related Solutions

Write the following Python script: Problem Statement A string X is an anagram of string Y...
Write the following Python script: Problem Statement A string X is an anagram of string Y if X can be obtained by arranging all characters of Y in some order, without removing any characters and without adding new characters. For example, each of the strings "baba", "abab", "aabb" and "abba" is an anagram of "aabb", and strings "aaab", "aab" and "aabc" are not anagrams of "aabb". A set of strings is anagram-free if it contains no pair of strings which...
Write a python script to solve the 4-queens problem using. The code should allow for random...
Write a python script to solve the 4-queens problem using. The code should allow for random starting, and for placed starting. "The 4-Queens Problem[1] consists in placing four queens on a 4 x 4 chessboard so that no two queens can capture each other. That is, no two queens are allowed to be placed on the same row, the same column or the same diagonal." Display the iterations until the final solution Hill Climbing (your choice of variant)
Write and Compile a python script to solve the 4-queens problem using Forward Checking algorithm ....
Write and Compile a python script to solve the 4-queens problem using Forward Checking algorithm . The code should allow for random starting, and for placed starting. Random Starting means randomly place a queen position on the chessboard. Placed Starting means asked for the user input to place a queen position on the chessboard. Display the iterations until the final solution "The 4-Queens Problem[1] consists in placing four queens on a 4 x 4 chessboard so that no two queens...
Write and Compile a python script to solve the 4-queens problem using. The code should allow...
Write and Compile a python script to solve the 4-queens problem using. The code should allow for random starting, and for placed starting using numpy "The 4-Queens Problem[1] consists in placing four queens on a 4 x 4 chessboard so that no two queens can capture each other. That is, no two queens are allowed to be placed on the same row, the same column or the same diagonal." Display the iterations until the final solution Arc consistency
(Use the string class to solve the problem) Write a program (in c++) that can be...
(Use the string class to solve the problem) Write a program (in c++) that can be used to train the user to use less sexist language by suggesting alternative versions of sentences given by the user. The program will ask for a sentence, read the sentence into a string variable, and replace all occurrences of masculine pronouns with gender-neutral pronouns. For example, it will replace “he” with “she or he”, and “him” with “her or him”. Be sure to preserve...
Write a Flask app in which a Python script prompts the user to enter a string...
Write a Flask app in which a Python script prompts the user to enter a string and then that string, as entered, gets displayed on an otherwise blank HTML file, called output.html. Show the Python/Flask code and the html code of the output.html file, one below the other as part of your answer.
Please use C programming to write the code to solve the following problem. Also, please use...
Please use C programming to write the code to solve the following problem. Also, please use the instructions, functions, syntax and any other required part of the problem. Thanks in advance. Use these functions below especially: void inputStringFromUser(char *prompt, char *s, int arraySize); void songNameDuplicate(char *songName); void songNameFound(char *songName); void songNameNotFound(char *songName); void songNameDeleted(char *songName); void artistFound(char *artist); void artistNotFound(char *artist); void printMusicLibraryEmpty(void); void printMusicLibraryTitle(void); const int MAX_LENGTH = 1024; You will write a program that maintains information about your...
Solve using PYTHON PROGRAMMING 9. Write a script that reads a file “ai_trends.txt”, into a list...
Solve using PYTHON PROGRAMMING 9. Write a script that reads a file “ai_trends.txt”, into a list of words, eliminates from the list of words the words in the file “stopwords_en.txt” and then a. Calculates the average occurrence of the words. Occurrence is the number of times a word is appearing in the text b. Calculates the longest word c. Calculates the average word length. This is based on the unique words: each word counts as one d. Create a bar...
Solve using PYTHON PROGRAMMING Write a script that reads a file “cars.csv”, into a pandas structure...
Solve using PYTHON PROGRAMMING Write a script that reads a file “cars.csv”, into a pandas structure and then print a. the first 3 rows and the last 3 of the dataset b. the 3 cars with the lowest average-mileage c. the 3 cars with the highest average-mileage. Solve using PYTHON PROGRAMMING
(Use the String Class to Solve This (and only the iostream, string and cctype libraries)) Write...
(Use the String Class to Solve This (and only the iostream, string and cctype libraries)) Write a program that can be used to train the user to use less sexist language by suggesting alternative versions of sentences given by the user. The program will ask for a sentence, read the sentence into a string variable, and replace all occurrences of masculine pronouns with gender-neutral pronouns. For example, it will replace “he” with “she or he”, and “him” with “her or...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT