0% found this document useful (0 votes)
3 views4 pages

Lab 4

The document contains a series of programming tasks that involve correcting errors in provided code snippets, writing outputs for specific programs, and creating new programs based on given requirements. Tasks include string manipulation, user input handling, and DNA sequence processing. The document outlines various programming exercises aimed at enhancing coding skills and understanding of string operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Lab 4

The document contains a series of programming tasks that involve correcting errors in provided code snippets, writing outputs for specific programs, and creating new programs based on given requirements. Tasks include string manipulation, user input handling, and DNA sequence processing. The document outlines various programming exercises aimed at enhancing coding skills and understanding of string operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Lab 4

The following programs contain errors.


Rewrite the programs to correct the errors.

S = "HAEBLCLDO "
len = length (S)
print "The length is len \n";
i=0
new=""
while i<len
m1=s(i)
new1=new1.m1;
i++;
m2= s(i)
new2=new2.m2;
i++;
}

print "new1\n";
print "new2";

Write the output of the following programs

1.

fac= "Bio Faculty"


leng=len(fac)
str1 = fac.split(" ")
str2 =fac[space:leng]
st=str1[0]+"technology"+str2
print ("st")
print(st)
2.
STR = "SUCCESS SUCCESS..!! ";
STR1 = STR.replace( "C","A");
print(STR1 )

3.
DNA = "CTGACTG "
print(len(DNA)
d="TG";
DNA=DNA.strip()
n = DNA.find( d , 0)
n += 2;
new=DNA[n:n+2]

print (new , DNA[n:2])

Write a program to do
each of the following:

1. Write a program that accepts two strings representing the first and last name and then:
• Capitalize the letters of each string
• Write the full name on the same line
• Show the number of letters in the full name (not including the separating white space).
2. Ask the user to enter his name in one string (his name, his father name, his last name) then print
• his name and the last name
• his last name then his name
• his full name but after changing his father name

3. Write a program that accept a string of characters and then print each character in a separate
line.

4. Write a program that accept a string of characters and then print each 5 characters in a separate
line.
5. If you know that DNA sequence can contain only 4 different types of nucleotides: Guanine (G),
Cytosine (C), Adenine (A) and Thymine (T). Write a program that accepts a string of characters
representing a DNA sequence, capitalize it and remove any invalid letters.

6. Ask the user to enter a string, reverse this string in another string, and display both.

1. Write a program that reads 2 strings each one from a file, then it writes them in one string
such that the new string contains:
a. The first 2 characters from the first string then the first 2 characters from the second string,
then
b. The second 2 characters from the first string then the second 2 characters from the second
string, and so on.

For Example:

String1 = "ABCDEF"

String2 = "mnopqr"

Output New string


="ABmnCDopEFqr"

You might also like