Welcome to Lecture 6
Instructor: Prof. Dr. Amr Mossad. This lab connects variables, if-statements and loops (Lecture 5) to reusable functions.
Your name, answers and progress are kept on this device until you share or download your report. No automatic collection takes place.
Your progress
Mini-quiz not submitted · 10 questions
Why functions? Understand return
Compare the two functions below. Which lets another function reuse the calculated value?
def show_double(x):
print(x * 2)
def get_double(x):
return x * 2Build a temperature conversion function
Formula: F = C × 9/5 + 32. Use return to make the answer reusable.
def celsius_to_fahrenheit(c):
return c * 9/5 + 32Which pair matches the function's expected outputs?
DNA Sequence Analyzer
Enter DNA made of A, C, G and T. The analyzer cleans spaces, converts lowercase letters to uppercase, validates the sequence, then calculates base frequencies.
Validation rule: only a non-empty sequence of A/C/G/T is accepted. Demonstration only; GC% alone is not a biological diagnosis.
Modular processing: several samples
Four demo samples are evaluated with the same reusable functions, rather than duplicating code.
Extend the analyzer
For ATGCGC, find AT% and the number of G bases.
Python code playground
This tab runs actual Python in your browser using Pyodide. Internet is required the first time to download Python; it can take longer on a mobile connection. The rest of the lab does not depend on it. Run real Python after this site is published; local file mode may block workers.
Program output appears here.
Lecture 6 quick assessment
Select one answer per question. The score is saved on the device when you submit. A submitted quiz is locked unless the lab is reset.
Your submission receipt
Complete the activities, take the quiz, then prepare a receipt for your instructor.
A result file is not automatically delivered to the lecturer. You must send it or share the text yourself.
Submission preview
Please enter your name and student ID first.