<jupyter_start><jupyter_text>Basics 1 Exercise 1a) Write some code to calculate the Fahrenheit value, given a Celsius value.b) Print out the results in a sentence.°F = °C * 9 / 5 + 32<jupyter_code>degree = input("Enter a celsius number: ")
try:
    degree = float(degree)
    F = degree * 9/5 + 32
    print("{} celsius are {} fahrenheit".format(degree,str(F)))
except ValueError:
    print("Please enter a number!")
def calculate_fahrenheit(celsius):
    fahrenheit = celsius * 9/5 + 32
    return fahrenheit
calculate_fahrenheit(10)<jupyter_output><empty_output><jupyter_text>Exercise 2a) Find out if the sequence is all alphabetic and upper case.b) Count all DNA nucleotides of a given sequence.c) Find out if the sequence contains a start codon and find the first position.d) Calculate the GC content and print the results.<jupyter_code>seq = 'ATACAGTCGATCGTAGCTATGATACGATCGTAGCTACGTATACGTACGTCGGCGAT'\
      'GCATGCTAACAAATCGATCGTACGTACTGATCGATCGTACGTACGTAGCTtgatcgtacgtcagttgac'
print(seq.isalpha())
print(seq.isupper())
#given sequence = any random sequence
#lets try "gat"
print(seq.count("gat"))
#but if the whole string has small characters the result is different
print(seq.lower().count("gat"))
print("Index of first occurence of start codon: {}".format(seq.index("ATG")))
seq[18:21]
seqUPPER = seq.upper()
gs = seqUPPER.count('G')
cs = seqUPPER.count('C')
gc_content = (gs + cs )/len(seqUPPER)
print("The GC content of the sequence is: {}%".format(round(gc_content*100,2)))<jupyter_output>The GC content of the sequence is: 46.4%<jupyter_text>Exercise 3a) Transcribe the DNA sequence into an RNA sequence.    ATG -> AUGb) Create the complementary strain of the DNA sequence.    ATG -> TAC<jupyter_code>seq
seqUPPER
seqRNA = seqUPPER.replace("T","U")
seqRNA
#using a loop over a seq as a list - a little bit more advanced 
seq = seq.upper()
seq_list = list(seq)
for i in range(len(seq_list)):
    if seq_list[i] == 'A':
        seq_list[i] = 'T'
    elif seq_list[i] == 'T':
        seq_list[i] = 'A'
    elif seq_list[i] == 'C':
        seq_list[i] = 'G'
    else:
        seq_list[i] = 'C'
seq_comp = ''.join(seq_list)<jupyter_output><empty_output><jupyter_text>Exercise 4a) Count the number of observations.b) Show the position of the Fuchs in the list. (Do some googling).c) Control this by printing the position you found out.d) Sort your observation list.e) Count the number of different animals.<jupyter_code>obser = 'Fuchs,Elefant,Hund,Hund,Mensch,Fuchs,Glurak'
lst = obser.split(',')
print("First occurence of Fuchs: {}".format(lst.index("Fuchs")))
lst.reverse()
print("Second occurence of Fuchs: {}".format(len(lst) - 1 - lst.index("Fuchs")))
lst = obser.split(',')
lst = obser.split(",")
lstR = lst.copy()
print("First ocurrence of Fuchs: {} : {}".format(lstR.index("Fuchs"),lst[lstR.index("Fuchs")]))
lstR.remove("Fuchs")
print("Second occurence of Fuchs: {} : {}".format(lstR.index("Fuchs")+1,lst[lstR.index("Fuchs")+1]))
print(lst)
lstSorted = lst.copy()
lstSorted.sort()
print(lstSorted)<jupyter_output>['Elefant', 'Fuchs', 'Fuchs', 'Glurak', 'Hund', 'Hund', 'Mensch']<jupyter_text>Exercise 5a) Create a list called organisms and store the Arabidopsis, Yeast and Synechocystis.b) Create a second list called genes and store the 27500, 5700, 2500.c) Combine the two lists into a dictionary.d) Print each key:value pair.<jupyter_code>organisms = ["Arabidopsis","Yeast","Synechocystis"]
genes = [27500,5700,2500]
for organism, gene in zip(organisms,genes):
    print(organism, gene)
dic = dict(zip(organisms,genes))
dic.keys()
dic.values()
for item in dic.items():
    print(item)<jupyter_output>('Arabidopsis', 27500)
('Yeast', 5700)
('Synechocystis', 2500)
{'fraction_non_alphanumeric': 0.1412275936990766, 'fraction_numerical': 0.019826181423139598, 'mean_word_length': 5.4052173913043475, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '222551', 'license': 'MIT', 'n_tokens_mistral': 1424, 'n_tokens_neox': 1311, 'n_words': 367, 'path': 'scripts/exercises/01_Exercise_Basics_Solutions.ipynb', 'repo_name': 'Kanomble/big_data', 'size': '3682'}