Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 ) True or False. A tuple is an immutable list, meaning once it is defined it cannot be changed. 2 ) Which of the

1) True or False. A tuple is an immutable list, meaning once it is defined it cannot be changed.
2) Which of the following is a valid tuple in Python?
a) example_tuple =(1,2,3,4,5)
b) example_tuple ={1,2,3,4,5}
c) example_tuple =[1,2,3,4,5]
d) example_tuple =/1,2,3,4,5/
3)Which of the following is a valid tuple in Python?
b) my_tuple =(1)
a) my_tuple =(1,)
4) What is the proper way to save the contents of the following tuple as a list?
a) weekend_days = weekend_days.list()
b) weekend_days_list = list[weekend_days]
c )weekend_days_list = list(weekend_days)
5)How would you remove the following tuple?
a)weekend_days.del()
b) weekend_days.remove
c) remove(weekend_days)
d) del weekend_days
6) Suppose tuple1 is (3,4,5,6,5). What is returned by max(tuple1)?
a)3
b)4
c)5
d)6
7) Suppose tuple1 is (3,4,5,6,5). What is returned by min(tuple1)?
a)3
b)4
c)5
d)6
8) To open a file c:\test.txt for reading, use _____________.
a)test_file = open(c:\test.txt,read)
b) test_file = open(c:\test.txt,read-only)
c) test_file = open(c:\test.txt,ro)
d) test_file = open(c:\test.txt)
9) To read the entire remaining contents of the file as a string from a file object test_file use ____________.
a) test_file.read(2)
b) test_file.read()
c) test_file.readline()
d) test_file.readlines()
10) To return to the beginning of a file object named test_file, use _______.
a) test_file.reset()
b) test_fiile.restart()
c) test_file.seek()
d) test_file.seek(0)
11)To determine your current position in a file object named test_file, use _________.
a) test_file.position()
b) position(test_file)
c) test_file.tell()
d) tell(test_file)
12) How would you check to see if the file object named test_file is closed?
a) test_file.open?
b) test_file.open
c) test_file.closed?
d) test_file.closed
13) How would you open the /etc/hosts file so that it automatically gets closed?
a) hosts = open(/etc/hosts,autoclose)
b) hosts = open(/etc/hosts)
c) with open(/etc/hosts) as hosts
d) with open(/etc/hosts) as hosts:
14) Which of the following statements are true?
a) When you open a file for reading, if the file does not exist, an error occurs.
b) When you open a file for writing, if the file does not exist, and error occurs.
c) When you open a file for reading, if the file exist, the program will open an empty file.
15) Which of the following statements is false?
a) When you open a file for writing, if the file does not exist, a new file is created.
b)When you open a file for writing, if the file exists, the existing file is overwritten.
c) When you open a file for appending, if the file does not exist, an error occurs.
16) The write() file object method automatically adds a carriage return and line feed character to the end of each line.
a)True
b) False
17)How would you import the time module such that all of the methods in the time module are available to be called in your program?
a) import time:
b) import time.*
c) import time *
d) import time
18)How would you import just the asctime() method from the time module?
a) from time import asctime
b) from time import.asctime()
c) from time import asctime()
19) How would you import the asctime() and sleep() methods from the time module?
a) from time import asctime sleep
b) from time import asctime, sleep
c) from time import asctime() sleep()
d) from time import asctime(), sleep()
20) What built-in function allows you to see what attributes, methods, and classes exist within a module?
a) info()
b) methods()
c) dir()
d) list()
21) Which environment variable allows you to manipulate the module search path?
a) PATH
b) PYTHONPATH
c) PYTHON_PATH
d) PYTHONSEARCHPATH
22) True or False. Python is distributed with a large library of modules called the Python Standard Library that provide standardized solutions for many problems that occur in everyday programming.
a) True
b) False
23) Which special variable can you check to determine if your Python program was executed interactively or imported by another Python program?
a)_main_
b)_imported_
c)_interactive_
d)_name_

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications Dexa 2022 Workshops 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 In Computer And Information Science 33

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Alfred Taudes ,Atif Mashkoor ,Johannes Sametinger ,Jorge Martinez-Gil ,Florian Sobieczky ,Lukas Fischer ,Rudolf Ramler ,Maqbool Khan ,Gerald Czech

1st Edition

3031143426, 978-3031143427

More Books

Students also viewed these Databases questions