Python Programming
The strip() method allows you to __________________.
remove characters |
||
insert characters |
||
replace characters |
||
none of the above |
QUESTION 2
Text files contain Unicode characters and are human readable.
True
False
QUESTION 3
Passing mutable objects does not allow a function to change values in the calling program.
True
False
QUESTION 4
Python uses an _______________ to execute each line of code one at a time.
compiler |
||
interpreter |
||
engraver |
||
importer |
QUESTION 5
The Intersection operator for a set is the || symbol.
True
False
QUESTION 6
The def statement creates an entry in the namespace, associating the function name with the executable code of the function.
True
False
QUESTION 7
A single line comment is represented by which of the following?
@ |
||
& |
||
* |
||
# |
QUESTION 8
Scope is defined at the set of program statements over which a variable exists.
True
False
QUESTION 9
Anagrams are two or more words that use different arrangements of the same set of letters to form words. An example would be cinema and iceman.
True
False
QUESTION 10
The symbol used to concatenate strings is _________
+ |
||
- |
||
== |
||
& |
QUESTION 11
Which of the following statements opens a file for reading?
file_handle = open("file_name", "w") |
||
file_handle = open("file_name","o") |
||
file_handle = open("file_name", "r") |
||
file_handle = open("file_name", "x") |
QUESTION 12
A file is a collection of bytes of information that usually resides permanently on a disk.
True
False
QUESTION 13
Leading whitespace at the beginning of a line in Python is ________________.
ignored by the compiler |
||
required for grouping |
||
not required in Python |
||
limited to 2 spaces |
QUESTION 14
Which of the following is a valid assignment statement to assign the value B to A?
A = B |
||
A == B |
||
B == A |
||
B = A |
QUESTION 15
Which data type would be used to represent the following, 123456
interger |
||
number |
||
int |
||
dollar |
QUESTION 1
The strip() method allows you to:
- remove characters (leading and trailing whitespace
characters)
QUESTION 2
Text files contain Unicode characters and are human readable.
- True
QUESTION 3
Passing mutable objects does not allow a function to change values
in the calling program.
- True
QUESTION 4
Python uses an _______________ to execute each line of code one at
a time.
- interpreter
QUESTION 5
The Intersection operator for a set is the || symbol.
- False
QUESTION 6
The def statement creates an entry in the namespace, associating
the function name with the executable code of the function.
- True
QUESTION 7
A single line comment is represented by which of the
following?
- #
QUESTION 8
Scope is defined at the set of program statements over which a
variable exists.
- True
QUESTION 9
Anagrams are two or more words that use different arrangements of
the same set of letters to form words. An example would be cinema
and iceman.
- True
QUESTION 10
The symbol used to concatenate strings is _________
- +
QUESTION 11
Which of the following statements opens a file for reading?
- file_handle = open("file_name", "r")
QUESTION 12
A file is a collection of bytes of information that usually resides
permanently on a disk.
- True
QUESTION 13
Leading whitespace at the beginning of a line in Python is
________________.
- required for grouping
QUESTION 14
Which of the following is a valid assignment statement to assign
the value B to A?
- A = B
QUESTION 15
Which data type would be used to represent the following,
123456
- int
Python Programming The strip() method allows you to __________________. remove characters insert characters replace characters none...
Python Programming QUESTION 16 Which of the following is an example of a Keyword in Python? elif class for All of the above QUESTION 17 Which of the following is not an acceptable variable name in Python? 2ndVar $amount Rich& ard None of the above are acceptable variable names QUESTION 18 The number 1 rule in creating programs is ___________________- Write the code first Think before you program Let the compiler find you syntax errors There are no rules just...
# DISCUSSION SECTION WORK: # # 1. STUDENTS: download this file, ds4.py, and wordsMany.txt, from # http://www.cs.uiowa.edu/~cremer/courses/cs1210/etc/ds4/ # Save both in the same folder. # # 2. TA (aloud) and STUDENTS: Read the comments from START HERE! (just after these instructions) # to definition of anagramInfo function. Discuss any questions about what the functions should do. # # 3. TA demonstrate running anagramInfo("wordsMany.txt") on this unchanged file, to # see that it behaves reasonably despite having incomplete anagram-testing functions. #...
IT PYTHON QUESTION1 Consider the following Python code, where infile.txt and outfile.txt both exist in the current directory 'z' ) 。1d = open ( ' infile. txt ' , for line in old: new.write (line) new.write') ne«.close () old.close) Which of the following options best describes the purpose or outcome of this code? O A copy of the file infile.txt is made (except in double line spacing) and saved as outfile.txt in the current directory. O A copy of the...
To insure that file output is written to the disk you need to execute what method? a. commit() b. write() c. close() d. complete() The following is called the ________ of a function. def myFunction(x,y) : a. header b. footer c. sentinel d. index True or False: A commonly used program that uses regular expressions is grep. True or False: In Python exception handling provides a mechanism for passing control from the point of the error detection to a handler...
Please write the following code as simple as possible in python: You will need to define a function with four arguments. Here is what I used: > def find_matches(file1.txt, output1.txt, strings, value): file1.txt will contain a list of various strings. The program must copy from the first argument, and it should be written in the second argument (the second file, "output1.txt"). The third and fourth arguments will determine which specific strings will be copied over to the second file. For...
I am stuck with this coding problem from edx coding python 4.4.6: #This is a long one -- our answer is 20 lines of code, but #yours will probably be longer. That's because it's one of the #more authentic problems we've done so far. This is a real #problem you'll start to face if you want to start creating #useful programs. # #One of the reasons that filetypes work is that everyone #agrees how they are structured. A ".png" file,...
A)) (Ransom Note Problem) in python A kidnapper kidnaps you and writes a ransom note. He does not write it by hand to avoid having his hand writing being recognized, so he uses a magazine to create a ransom note. We need to find out, given the ransom string and magazine string, is it possible to create a given ransom note. The kidnapper can use individual characters of words. Here is how your program should work to simulate the ransom...
Python Coding The script, `eparser.py`, should: 1. Open the file specified as the first argument to the script (see below) 2. Read the file one line at a time (i.e., for line in file--each line will be a separate email address) 3. Print (to the screen) a line that "interprets" the email address as described below 4. When finished, display the total number of email addresses and a count unique domain names Each email address will either be in the...
Not yet answered Marked out of 1.00 Flag question Question text What is the value of the following Python expression? not(True and False) Select one: True False Question 2 Not yet answered Marked out of 1.00 Flag question Question text Consider the following Python program. fin = open('words.txt') for line in fin: word = line.strip() print(word) What does the program loop over? Select one: a. Lines in a file b. Lines in a list c. Words in a dictionary d....
Could someone please help me write this in Python? If time allows, it you could include comments for your logic that would be of great help. This problem involves writing a program to analyze historical win-loss data for a single season of Division I NCAA women's basketball teams and compute from this the win ratio for each team as well as the conference(s) with the highest average win ratio. Background Whether it's football, basketball, lacrosse, or any other number of...