Lab 4
Lab 4
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";
1.
3.
DNA = "CTGACTG "
print(len(DNA)
d="TG";
DNA=DNA.strip()
n = DNA.find( d , 0)
n += 2;
new=DNA[n: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"