Read the following program and answer the question.
import re
text = "CCIS-327E CCIS-227B CELS-112 SC-124B CCIS-328"
pattern = _____________
regex = re.compile(pattern)
regex.findall(text)
Which expression should be filled in the above program to get the following output:
[‘CCIS-327E’, ‘CCIS-227B’]
Group of answer choices
r'CCIS-[0-9A-Z]+'
r’CCIS-[0-9]+[A-Z]+'
r'CCIS-[0-9]+'
r'CCIS-[A-Z]+'
Ans:
# According to the question after looking at the different answer choices which are given
# we use the following regular expression rules to check which is the right option
# [] - Matches Characters in brackets
# [A-Z] Any single character in the range A-Z
# [0-9] Any Single digit in the range 0-9
# [0-9A-Z] Any single character in the range 0-9 or A-Z
# And the quantifier required to define how many characters need to be matched used here is
# ( the plus quantifier / Positive closure ) '+' - 1 or More of the pattern or character specified
# Thus Since all the given choices start with 'CCIS-' this is the common string which gets matched
# after which the pattern in the 2nd option would give us the required output
# REQUIRED ANSWER PROGRAM
import re # for importing and using the re module
# the text string which needs to be matched
# it can be a string, a line of sentences, paragraphs or even
streams of strings in the form of files
text = "CCIS-327E CCIS-227B CELS-112 SC-124B CCIS-328"
pattern = r'CCIS-[0-9]+[A-Z]+' # the pattern specified in the regular expression context
regex = re.compile(pattern) # the re.compile function changes the regex pattern or any other string into a python re object
print(regex.findall(text)) # the resultant matched output
# in the form of all the strings present in a list

# giving us our required output [‘CCIS-327E’, ‘CCIS-227B’]

# since only these two string patterns comprised of a combination of digits and alphabets
# it is our required correct answer
# CORRECT ANSWER - option B or - r’CCIS-[0-9]+[A-Z]+'
# PLEASE DO LIKE AND UPVOTE IF THIS WAS HELPFUL!
# THANK YOU SO MUCH IN ADVANCE
Read the following program and answer the question. import re text = "CCIS-327E CCIS-227B CELS-112 SC-124B...
Your mission in this programming assignment is to create a Python program that will take an input file, determine if the contents of the file contain email addresses and/or phone numbers, create an output file with any found email addresses and phone numbers, and then create an archive with the output file as its contents. Tasks Your program is to accomplish the following: ‐ Welcome the user to the program ‐ Prompt for and get an input filename, a .txt...
DESCRIPTION Complete the program using Java to read in values from a text file. The values will be the scores on several assignments by the students in a class. Each row of values represents a specific student's scores. Each column represents the scores of all students on a specific assignment. So a specific value is a specific student's score on a specific assignment. The first two values in the text file will give the number of students (number of rows)...
Q22 Consider the following 2 text files and Java program. 8 Points Answer the following questions keeping in mind that: • All three files are in the same directory, and there are no other files. • The program may crash. If the program crashes, answer the question with: "The program crashes" standings1.txt: 1 Valtteri Bottas 25 2 Charles Leclerc 18 3 Lando Norris 16 4 Lewis Hamilton 12 standings2.txt: 1 Valtteri Bottas 43 2 Lewis Hamilton 37 3 Lando Norris...
Using the MARIE computer assembly language, write a program that computes the following expression: z = a * b * c. The computer will read in the input values a, b, and c from the keyboard and the final result (z) have to be displayed. In addition, every time an input value is read in, it must be displayed on the screen. Remember that the instruction set does not have an instruction to execute multiplication. The program must be tested...
Question 7 Which of the following constructs is an example of selection? Group of answer choices IF COMPUTE WHILE ASSIGN GET Question & In the pseudocode language constructs, what category does Display come under? Group of answer choices Computation Assignment Repetition Declaration Input/Output Selection Question 9 For the algorithm at the start of section 5.3 of the reading material, what is the number output if the input is 4 927 Return? Your answer should be accurate to three decimal places....
composed the following java code to read a string from a text file but receiving compiling errors. The text file is MyNumData.txt. Included the original java script that generated the output file. Shown also in the required output results after running the java program. I can't seem to search for the string and output the results. Any assistance will be greatly appreciated. import java.io.BufferedReader; import java.io.FileReader; import java.util.ArrayList; public class Main { public static void main(String[] args) { System.out.print("Enter the...
2 Date:04/10/2019 3chapter 12.11 Find 4 Program nane: Text I/0 7 package cscl 8- import java. io.File; 9 import java.io.File 10 import java.util.Scanner; 11 public class SalesReportf 12 public static void main(Stringt1 ares) throws Exception (//main method-ai String name,line;//declare string variable-ai 14 16 18 int soldNum;//declare int variable-aj double costPerBottle,retailBottle,profit,percent;//declare multi variable-ai int totalSold-0;//declare and intialic its value-ai double totalCost-e;//declare and intialie its value-ai double totalRetail-0;//declare and intialie its value-ai double totalProfit -0;//declare and intialie its value-ai double totalPercent-8;//declare and...
Write a Python program named aIP.py which will read data from a file named wireShark.txt and extract all the pairs of source and destination ip addresses and output them in pairs to another file called IPAddresses.txt , one per line, listing source and destination. Example of output: Source Destination 192.168.1.180 239.255.255.250 Detailed Requirements: You will read from a file called wireShark.txt which, to avoid problems with finding paths, will be located in the same directory as your code You will...
Write a program named text_indexing.c that does the following: Reads text and stores it as one string called text. You can read from a file or from the user. (In my implementation, I read only one paragraph (up to new line) from the user. With this same code, I am able to read data from a file by using input redirection (executable < filename) when I run the program. See sample runs below). You can assume that the text will...
How do i write a program to read muliple files? i can read one
but i need to read 10: 0.txt - 9.txt
Here is the code for reading one but i need to read 10 text
files and print the frequencies of all the letters a - z, upper and
lowercase, in one take.
here is the output i should get
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <omp.h> int main() { double start_time = omp_get_wtime(); char str[1000); int...