Write the code to input a number and print the square root. Use the absolute value function to make sure that if the user enters a negative number, the program does not crash.
Write a program that reads in a line of text and replaces all four-letter words with the word “love”. For example,
the input string
I hate you, you dodo !
Should produce the output
I love you, you love!
Of course, the output will not always make sense. For example, the input string
John will run home.
Should produce the output
Love love run love.
If the four-letter word starts with a capital letter, it should be replaced by “Love”, not by “love”. You need not check capitalization, except for the first letter of a word. A word is any string consisting of the letters of the alphabet and delimited at each end by a blank, the end of a line, or any other character that is not a letter. Your program should repeat this action until the user says to quit.
Implement the following C++ expression in assembly language, using 32-bit unsigned operands:
ask the user to enter val2, val1, val3 by calling Readint
If (val2 ==0) then
{val2 = 1}
val1 = (val3 / val2) * (val1 + val3)
Val1 = 600
Val2 = 0
Val3 = 1000
Write an assembly language program that moves the number 2 to BL and 0 to AL. Add BL to AL ECX many times having AL as the destination. Move 10 into ECX before the loop. What will the value of AL when the loop is done?
Write an assembly language program that declares three integer variables called number1 initialized to 9, number2 initialized to 15 and number3 initialized to 23. The assembly language code must add the three numbers and move the result into ebx. The program also must find the difference between number2 and number3 (i.e. 15 – 23). The difference must be placed in edx.
Write a C++ program to calculate the sum of the numbers from 1 to 100. The formula for calculating this sum is sum = (n / 2) x (2 x a + (n - 1) x d), where n = number of terms to be added, a = the first number, and d = the difference between each number and the next number.
How big of a role do green issues such as energy efficiency, carbon footprint, garbage, waste, water, space and transit play in the value proportion that you pitch to prospective customers when they are looking at upgrading their data centre?
Is video conferencing really a viable green alternative to travel for most companies
Ask user to enter 10 numbers and write them in a file “Numbers.txt” (5). After writing, check the file and count all the even numbers and odd numbers written in the file (10). Display the count of even and odd numbers on the screen.
from Question #176919
REG = 'AATAA,ATTAAA,TATA,CAT,ATAGTCGC'
def find_reg(random_string_gen, reg = REG):
res = []
with open("random_string_gen.txt", 'r') as f:
text = f.read()
size = len(text) - len(reg)
for i in range(size):
for j in reg:
if text[i] != j:
break
else:
res.append([i,i+len(reg)])
file = input('Enter path and file name: ')
result = find_reg(file)
print('The pattern was found in the following positions [start, end]')
for i in result:
print(i)
what error I made
while compiling
python function3.py
The pattern was found in the following positions [start, end]
Traceback (most recent call last):
File "function3.py", line 22, in <module>
for i in result:
TypeError: 'NoneType' object is not iterable