1.Write definition of method COUNTNOW(PLACES) to find and display
those place names in which there are more than 5 characters.
2.What happens when python encounters an import statement in a
program? What would happen if there is one more import statement for
the same module, already imported in the same program?
Answers
Answer:
1.
def COUNTNOW(PLACES):
if len(PLACES)>5:
print(PLACES)
2.
If the import statement is found , the python imports the particular package to the file.
If same module is added more than once, nothing happens , the python doesnot throw any error.
Explanation:
Answer:
1)
Definition of method COUNTNOW(PLACES) to find and display those place names in which there are more than 5 characters:
public void COUNTNOW(String[] PLACES) {
for (String place : PLACES) {
if (place.length() > 5) {
System.out.println(place);
}
}
}
2)
When Python encounters an import statement in a program, it loads the specified module into the current program's namespace.
Explanation:
- This method takes in an array of place names as a parameter, and then uses a for-each loop to iterate through each place in the array. Inside the loop, an if statement checks the length of each place name. If the length is greater than 5, the place name is printed using the System.out.println() statement.
- This allows the program to access the functions and classes defined in the imported module. If there is one more import statement for the same module, already imported in the same program, Python will ignore the second import statement and use the module that was imported previously. This is done to avoid duplicating the same module multiple times in the program, which can cause errors and slow down the program's execution.
More questions and answers
https://brainly.in/question/50174186
https://brainly.in/question/33327955
#SPJ3