GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Quiz

Python 2

Lilian Sw 26 Fragen

Quiz starten

Dieses Quiz enthält Fragetypen, die sich im gewohnten Player öffnen.

Fragen in diesem Quiz (26)

  1. 1A company needs help updating their file system. You must create a simple
    file-manipulation program that performs the following actions:
    Creates a file using the specified name.
    Appends the phrase "End of listing" to the file.
    You need to complete the code to meet the requirements.
    Complete the code by selecting the correct code segment from each drop-down list.
    import os
    file = [blank_start]1[blank_end]
    [blank_start]2[blank_end] ("End of listing")
    file.close()
    1. Aopen("myFile.txt","a")
    2. Bfile.write
    3. Copen("myFile.txt","a")
    4. Dfile.write
  2. 2You are writing a program to randomly assign rooms (room_number) and team-building
    groups (group) for a company retreat.
    Complete the code by selecting the correct code segment from each drop-down list.

    import random
    roomsAssigned=[1]
    room_number=1
    groupList=["Ropes","Rafting","Obstacle","Wellness"]
    count=0
    print("Welcome to CompanyPro's Team-Building Weekend!")
    name=input("Please enter your name (q to quit)? ")
    while name.lower() != 'q' and count < 50:
    while room_number in roomsAssigned:

    [blank_start]1[blank_end]
    print(f"{name}, your room number is {room_number}")
    roomsAssigned.append(room_number)
    [blank_start]2[blank_end]
    print(f"You will meet with the {group} Group this afternoon.")
    count+=1
    name=input("Please enter your name (q to quit)? ")
    1. Aroom_number=random.randint(1,50)
    2. Broom_number=random.randint(50)
    3. Croom_number=random.range(1,50)
    4. Droom_number=random.choice(1,50)
    5. Egroup = random.chioce(groupList)
    6. Fgroup = random.randint(groupList)
    7. Ggroup = random.shuffle(groupList)
    8. Hgroup = groupList(random.randint(0,3))
  3. 3A company needs help updating their file system.
    You must create a simple file-manipulation program that performs the following actions:
    - Checks to see whether a file exists.
    - If the file exists, displays its contents.
    Complete the code by selecting the correct code segment from each drop-down list.
    import os
    if [blank_start]1[blank_end]
    file = open('myFile.txt')
    [blank_start]2[blank_end]
    file.close()
    1. Aos.exist("myFile.txt"):
    2. Bos.path("myFile.txt"):
    3. Cos.file.exists("myFile.txt"):
    4. Dos.find("myFile.txt"):
    5. Eprint(file.read())
    6. Fprint(read(file))
    7. Gprint(file.open())
    8. Hfile.write()
  4. 4You need to identify the results of performing various slicing operations on the
    following sequence structure:
    alph = "abcdefghijklmnopqrstuvwxyz"
    Move the appropriate results from the list on the left to the correct slicing operations
    on the right.
    You may use each result once, more than once, or not at all.
    alph[3:6] [blank_start]1[blank_end]
    alph[:6] [blank_start]2[blank_end]
    1. Adef
    2. Bcde
    3. Ccdef
    4. Ddefg
    5. Eabcde
    6. Fabcdef
  5. 5You find errors while evaluating the following code. Line numbers are included for
    reference only.
    01 numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    02 index = 0
    03 while(index < 0)
    04 print(numbers[index])
    05
    06 if numbers(index) = 6
    07 break
    08 else:
    09 index += 1
    You need to correct the code at line 03 and line 06.
    Evaluate the code and answer the questions by selecting the correct option from each
    drop-down list.
    Which code segment should use at line 03? [blank_start]1[blank_end]
    Which code segment should use at line 06? [blank_start]2[blank_end]
    1. Awhile (index < 10):
    2. Bwhile (index <= 10):
    3. Cwhile index < 10
    4. Duntil (index == 10):
    5. Eif numbers[index] == 6:
    6. Fif numbers[index] = 6:
    7. Gif numbers(index) == 6:
    8. Hif numbers[index] == 6
  6. 6A game development company needs a way to find the number of words in a list that
    contain a specific letter.
    Complete the code by selecting the correct code segment from each drop-down list.
    Note: You will receive partial credit for each correct selection.
    # Function accepts list of words and letter to search for.
    # Returns count of the number of words that contain that letter.
    def count_letter(letter, word_list):
    count = 0
    for [blank_start]1[blank_end]
    if [blank_start]2[blank_end]
    count += 1
    return count
    # word_list is populated by the readWords() function. Code not shown.
    word_list = readWords()
    letter = input("Which letter would you like to count")
    etter count = count letter(letter, word_list)
    print("There are: ", letter_count, " words that contain ", letter)
    1. Aword in word_list:
    2. Bword_list in word:
    3. Cword in range(word_list):
    4. Dword in word_list
    5. Eletter in word:
    6. Fword in letter:
    7. Gletter == word:
    8. Hletter.find(word):
  7. 7You are creating a Python program that will let a user guess a number from 1 to 10.
    The user is allowed up to three guesses. If the user guesses the correct number, the
    program must stop asking for guesses. Complete the code by moving the appropriate code
    segments from the list on the left to the correct locations on the right. You may use
    each code segment once, more than once, or not at all.
    from random import randint
    target= randint(1,10)
    chance = 1
    print("Guess an integer from 1 to 10. You will have 3chances.")
    [blank_start]1[blank_end]
    guess = int(input("Guess an integer: "))
    if guess > target:
    print("Guess is too high")
    elif guess < target:
    print("Guess is too low" )
    else:
    print("Guess is just right!" )
    [blank_start]2[blank_end]
    [blank_start]3[blank_end]
    1. Awhile chance <=3:
    2. Bwhile chance <3
    3. Cwhile chance < 3:
    4. Dpass
    5. Echance = 2
    6. Fbreak
    7. Gchance +=1
  8. 8A company asks you to debug some code that is causing problems with their payroll. They
    ask you to find the source of the payroll errors.
    The following variables have been declared:
    employee_pay =[15000, 120000, 35000, 45000]
    count = 0
    sum = 0
    There are two errors in the following code:
    for index in range(0, len(employee_pay)-1):
    count += 1
    sum += employee_pay[index]
    average = sum/count
    print("The total payroll is:", sum)
    print("The average salary is:", average)
    Which code should you use to fix the errors?
    To answer, select the appropriate code segments in the answer area.
    for index in range [blank_start]1[blank_end]
    count += 1
    sum += employee_pay[index]
    average = [blank_start]2[blank_end]
    print("The total payroll is:", sum)
    print("The average salary is:",average)

    1. A(len(employee_pay)):
    2. B(0, len(employee_pay) - 1):
    3. C(len(employee_pay) + 1):
    4. D(employee_pay):
    5. Esum/count
    6. Fcount/sum
    7. Gsum/len(range)
    8. Hemployee_pay/count
  9. 9You are creating a program to calculate the rental fee for DVDs. The fee structure is as
    follows:
    . The default cost ('cost_per_night') is $1.59 per night
    . If the customer returns the DVD after 8 PM, they are charged for an extra night.
    . Sunday DVD rentals receive a 30% discount for the full length of the rental.
    . Thursday DVD rentals receive a 50% discount for the full length of the rental.
    Complete the code to meet the requirements by selecting the correct code segment from
    each dropdown list.
    #DVD Rental Calculator
    ontime = input("Was the video returned before 8 PM? Y or N").lower()
    days_rented = int(input("How many days was the video rented?"))
    weekday = input("What day was the video rented?").capitalize()
    cost_per_night = 1.59
    if on time [blank_start]1[blank_end]
    days_rented +=1
    if weekday [blank_start]2[blank_end]
    total =(days_rented * cost_per_night) * 0.7
    elif weekday [blank_start]3[blank_end]
    total = (days_rented * cost_per_night) * 0.5
    else:
    total = days rented * cost per night
    print("Cost of the DVD rental is : $", total)
    1. A== "n":
    2. B= "n":
    3. C== "N":
    4. Dis "n"
    5. E== "Sunday":
    6. F== "sunday":
    7. Gin "Sunday":
    8. H= "Sunday":
    9. I== "Thursday"
    10. J== "thursday"
    11. K== "Thursday":
    12. L!= "Thursday"
  10. 10You need to write code that performs the following tasks:
    . Call the process() function.
    . If the process() function throws an error, call the logError() function.
    . Always call the displayResult() function after calling the process() function.
    Complete the code by moving the appropriate code segments from the list on the left to
    the correct locations on the right.
    [blank_start]1[blank_end] process()
    [blank_start]2[blank_end] logError
    [blank_start]3[blank_end] displayResult()
    1. Atry:
    2. Bassert:
    3. Craise:
    4. Dexcept:
    5. Efinally:

Informationen

Beschreibung
Quiz am Python 2, erstellt von Lilian Sw am 05/07/2026.
Sprache
English
Aufrufe
601
Bewertung
Noch keine Bewertungen
Bewerte dieses Quiz
Bewerte dieses Quiz

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck