In python.
Write a program that takes 2 string inputs and calculates the Hamming Distance. Hamming distance between two strings is the number of positions at which the corresponding symbols are different.
The program should output an integer representing this distance.
For example
a = XXWWZZ
b = ZZWWXX
answer = 4
More examples:
"Phone" and "PHOONE" = 3
"God" and "Dog" = 2
"Dog" and "House" = 4
s1 = input("Enter first string: ")
s2 = input("Enter second string: ")
distance = 0
for i in range(max(len(s1), len(s2))):
if i >= len(s1) or i >= len(s2) or s1[i] != s2[i]:
distance += 1
print("Hamming distance is", distance)
In python. Write a program that takes 2 string inputs and calculates the Hamming Distance. Hamming...
Write a program in PYTHON that takes a string and an integer as inputs from the user, and then prints a new string that contains the letters from the original string “rotated” by the given amount. For example, “cheer” rotated by 7 places gives the word “jolly” and “melon” rotated by -10 gives the word “cubed.” Use built-in function: ord() to convert a character to a numeric code and chr() to convert numeric code to character.
IN PYTHON Write a program that takes a user-input distance and speed and then calculates an ETA. Your program should work for ANY COMBINATION of distance and speed.
You are to design a circuit that calculates the Hamming distance between two 5-bit numbers. It takes two 5-bit binary numbers A4 A3 A2 A1 A0 and B4 B3B 2B1 B0 as inputs and returns the number of bits that are different between the two numbers as the 3-bit binary output O2 O1 O0. For example: *If the two input numbers were 10111 and 00001 then the output would be 011 as there are 3 bits different between them. *If...
Python question: Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is: As long as x is greater than 0 Output x modulo 2 (remainder is either 0 or 1) Assign x with x divided by 2
Python Programing : Convert to binary - functions Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is: As long as x is greater than 0 Output x % 2 (remainder is either 0 or 1) x = x // 2 Note: The above algorithm outputs the 0's and 1's in reverse order. You will need to write a...
Python 3:Write a program that inputs a text file. The program should print the unique words in the file in alphabetical order. Write a program that inputs a text file. The program should print the unique words in the file in alphabetical order An example file along with the correct output is shown below: example.txt the quick brown fox jumps over the lazy dog Enter the input file name: example.txt brown dog fox jumps lazy over quick the
Write a Python function, called counting, that takes two arguments (a string and an integer), and returns the number of digits in the string argument that are not the same as the integer argument. Include a main function that inputs the two values (string and integer) and outputs the result, with appropriate labelling. You are not permitted to use the Python string methods (such as count(), etc.). Sample input/output: Please enter a string of digits: 34598205 Please enter a 1-digit...
python
1. Write a function that takes in a string and returns the string sorted For example, "cat" becomes "act", "dog" becomes "dgo" Hint: You might need to use the functions join and sorted
C++ Program with 2 functions 1. Hamming Functions Tester Write a function that displays a menu to test the functions from 2 - 4. You must call the functions from 2 - 4 and cannot reimplement their functionality in this function. The menu is displayed as follows: 1) Enter a 4-bit message to encode into a 7-bit Hamming message. 2) Enter a 7-bit Hamming message to transmit through a noisy channel. 3) Enter a 7-bit Hamming message to receive and...
Write a function that takes an integer input n as a parameter and after it calculates the sum of 1+2+3+...+n, it returns the value to the main program. For example, if n=4, the output of the sum will be 10.