1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
beks73 [17]
3 years ago
15

Given an initialized variable fileName, write a sequence of statements that create a file whose name is given by the variable an

d whose content is a single line consisting of "This Is File: " followed by the name of the file. Make sure that the data written to the file has been flushed from its buffer and that any system resources used during the course of running these statements have been released.
Computers and Technology
1 answer:
steposvetlana [31]3 years ago
6 0

Answer:

In Python:

fileName = "myfile.txt"

fname = open(fileName, "w")

fname.write("This Is File: "+str(fileName))

fname.close()

Explanation:

This initializes fileName

fileName = "myfile.txt"

This creates the file in write mode

fname = open(fileName, "w")

This writes the required string to the file

fname.write("This Is File: "+str(fileName))

This closes the file

fname.close()

You might be interested in
Write an if-else statement with multiple branches. If givenYear is 2101 or greater, print "Distant future" (without quotes). Els
kherson [118]

Answer:

// here is code in c.

#include <stdio.h>

// main function

int main()

{

// variable to store year

int year;

printf("enter year:");

// read the year

scanf("%d",&year);

// if year>=2101

if(year>=2101)

{

printf("Distant future");

}

//if year in 2001-2100

else if(year>=2001&&year<=2100)

{

   printf("21st century");

}

//if year in 19011-2000

else if(year>=1901&&year<=2000)

{

  printf("20th century");

}

// if year<=1900

else if(year<=1900)

{

  printf("Long ago");  

}

return 0;

}

Explanation:

Read the year from user.After this, check if year is greater or equal to 2101 then print "Distant future".If year is in between 2001-2100 then print "21st century".If year is in between 1901-2000 then print "20th century".Else if year is less or equal to 1900 then print "Long ago".

Output:

enter year:2018                                                                                                            

21st century

7 0
3 years ago
Read 2 more answers
I need help with this ​
almond37 [142]

Answer:

Answer is D

Explanation:

cameras did not use disks until the late 1990s  :D

edit: sorry my previous answer was wrong, I apoligize for the mishap :(

3 0
3 years ago
Baby Boomers are an example of what type of trend?
Bond [772]
The baby boomers is a type of demographic group. The demographic groups are usually categorized by age, income bracket, social class and so on. Baby boomers are classified as a generation of a group of people and also therefore, by their age range. 
8 0
3 years ago
Read 2 more answers
Implement a method called bubbleSort, that takes an ArrayList, sorts it using bubble sort algorithm, and returns a sorted list;
boyakko [2]

Answer:

Java algorithm is given below

Explanation:

import java.util.ArrayList;

import java.util.Arrays;

import java.util.Random;

public class Temp {

   static void bubbleSort(ArrayList<Integer> list) {

       int n = list.size();

       for (int p = 0; p < n - 1; p++)

           for (int q = 0; q < n - p - 1; q++)

               if (list.get(q) > list.get(q + 1)) {

                   int temp = list.get(q);

                   list.set(q, list.get(q + 1));

                   list.set(q + 1, temp);

               }

   }

   static void selectionSort(ArrayList<Integer> list) {

       int n = list.size();

       for (int p = 0; p < n - 1; p++) {

           int minimumIndex = p;

           for (int q = p + 1; q < n; q++)

               if (list.get(q) < list.get(minimumIndex))

                   minimumIndex = q;

           int temp = list.get(p);

           list.set(p, list.get(minimumIndex));

           list.set(minimumIndex, temp);

       }

   }

   static void insertionSort(ArrayList<Integer> list) {

       int size = list.size();

       int p, val, q;

       for (p = 1; p < size; p++) {

           val = list.get(p);

           q = p - 1;

           while (q >= 0 && list.get(q) > val) {

               list.set(q + 1, list.get(q));

               q = q - 1;

           }

           list.set(q + 1, val);

       }

   }

   static void mergeSort(ArrayList<Integer> list, int low, int high) {

       if (low < high && (high - low) >= 1) {

           int mid = (high + low) / 2;

           mergeSort(list, low, mid);

           mergeSort(list, mid + 1, high);

           merger(list, low, mid, high);

       }

   }

   static void merger(ArrayList<Integer> list, int low, int mid, int high) {

       ArrayList<Integer> mergedArray = new ArrayList<Integer>();

       int left = low;

       int right = mid + 1;

       while (left <= mid && right <= high) {

           if (list.get(left) <= list.get(right)) {

               mergedArray.add(list.get(left));

               left++;

           } else {

               mergedArray.add(list.get(right));

               right++;

           }

       }

       while (left <= mid) {

           mergedArray.add(list.get(left));

           left++;

       }

       while (right <= high) {

           mergedArray.add(list.get(right));

           right++;

       }

       int i = 0;

       int j = low;

       while (i < mergedArray.size()) {

           list.set(j, mergedArray.get(i++));

           j++;

       }

   }

   public static void main(String[] args) throws Exception {

       ArrayList<Integer> list = new ArrayList<>();

       Random rand = new Random(System.currentTimeMillis());

       for (int i = 0; i < 10000; i++) {

           list.add(rand.nextInt(256));

       }

       long start = System.currentTimeMillis();

       selectionSort(list);

       int sel = (int) (System.currentTimeMillis() - start);

       System.out.println("Selection Sort time (in ms): " + sel);

       list.clear();

       // ------------------------

       rand = new Random(System.currentTimeMillis());

       for (int i = 0; i < 10000; i++) {

           list.add(rand.nextInt(256));

       }

       start = System.currentTimeMillis();

       insertionSort(list);

       int ins = (int) (System.currentTimeMillis() - start);

       System.out.println("Insertion Sort time (in ms): " + ins);

       list.clear();

       // ------------------------

       rand = new Random(System.currentTimeMillis());

       for (int i = 0; i < 10000; i++) {

           list.add(rand.nextInt(256));

       }

       start = System.currentTimeMillis();

       bubbleSort(list);

       int bub = (int) (System.currentTimeMillis() - start);

       System.out.println("Bubble Sort time (in ms): " + bub);

       list.clear();

       // ---------------------------

       rand = new Random(System.currentTimeMillis());

       for (int i = 0; i < 10000; i++) {

           list.add(rand.nextInt(256));

       }

       start = System.currentTimeMillis();

       mergeSort(list, 0, list.size() - 1);

       int mer = (int) (System.currentTimeMillis() - start);

       System.out.println("Merge Sort time (in ms): " + mer);

       long m = Math.min(Math.min(sel, ins), Math.min(bub, mer));

       if (m == sel)

           System.out.println("Selection Sort is fastest");

       else if (m == ins)

           System.out.println("insertion Sort is fastest");

       else if (mer == m)

           System.out.println("Merge Sort is fastest");

       else if (m == bub)

           System.out.println("Bubble Sort is fastest");

   }

}

6 0
3 years ago
____ is an act of malicious destruction to a computer or computer resource.
PtichkaEL [24]
The answer is going to be computer sabotage
7 0
3 years ago
Other questions:
  • Which of the following refers to a marketing metric that shows an event that occurs on a Web page met a predefined goal associat
    6·1 answer
  • The basic components of cartridges and shotshells are similar. Shot pellets and a bullet are examples of which basic component?
    13·1 answer
  • The ____________________ packet-filtering firewall allows only a particular packet with a particular source, destination, and po
    10·1 answer
  • Which of the following represents the TCP/IP four-layer reference model? Group of answer choices Application, Internet, transpor
    11·1 answer
  • QUESTION 56 Use the Windows ________ to check on a nonresponsive program. Backup utility Error-checking System Restore Task Mana
    6·1 answer
  • What is the number system that uses only the numbers 0 and 1?
    8·1 answer
  • What is CPU ????....................​
    7·2 answers
  • Question is attached as image, please help :&gt;
    15·1 answer
  • A group of two or more computer systems linked together via communication devices is called:.
    10·1 answer
  • How does a fully integrated Data and Analytics Platform enable organizations to convert data into consumable information and ins
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!