What is the output of the following program?

This preview shows page 1 - 3 out of 3 pages.

1 Lab (4)-CPSC 111AV February 23, 2018 1. What is the output of the following program? students = [("John", ["CompSci", "Physics"]), ("Vusi", ["Maths", "CompSci", "Stats"]), ("Jess", ["CompSci", "Accounting", "Economics", "Management"])] for (name, subjects) in students: print(name, "takes", len(subjects), "courses") 2. What is the result of each of the following? a. ‘Python’[1] b. ‘Strings are sequences of characters.’[5] c. len(‘wonderful life’) d. ‘Mystery’[:4] e. ‘p’ in ‘Pineapple’ f. ‘apple’ in ‘Pineapple’ g. ‘pear’ not in ‘Pineapple’ h. ‘apple’ > ‘pineapple’ i. ‘pineapple’ < ‘Peach’ 3. Write a function that will return the number of digits in an integer
2 4. What is the output of the following program? 5. What is the output of the following program? Team up with a classmate and solve the following questions: 1. Write a program that simulates the guessing game. The program will generate a random number and then ask the user to guess a number between 1 and 10 (10 is included). If the user guessed a wrong number the

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture