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
Temka [501]
3 years ago
13

Write a program that prints all the numbers from 0 to 6 except 3 and 6. Expected output: 0 1 2 4 5

Computers and Technology
1 answer:
stellarik [79]3 years ago
8 0
<h2>Answer:</h2><h2></h2>

for x in range(7):

   if (x == 3 or x==6):

       continue

   print(x, end=' ')

print("\n")

<h2>Output:</h2>

>> 0 1 2 4 5

<h2>Explanation:</h2><h2></h2>

The code above has been written in Python. The following explains each line of the code.

<em>Line 1:</em> for x in range(7):

The built-in function <em>range(7)</em>  generates integers between 0 and 7. 0 is included but not 7. i.e 0 - 6.

The for loop then iterates over the sequence of number being generated by the range() function. At each iteration, the value of x equals the number at that iteration. i.e

For the first iteration, x = 0

For the second iteration, x = 1

For the third iteration, x = 2 and so on up to x = 6 (since the last number, 7, is not included).

<em>Line 2:</em> if (x == 3 or x == 6):

This line checks for the value of x at each iteration. if the value of x is 3 or 6, then the next line, line 3 is executed.

<em>Line 3:</em> continue

The <em>continue</em> keyword is used to skip an iteration in a loop. In other words, when the continue statement is encountered in a loop, the loop skips to the next iteration without executing expressions that follow the <em>continue</em> statement in that iteration. In this case, the <em>print(x, end=' ')  </em>in line 4 will not be executed when x is 3 or 6. That means 3 and 6 will not be printed.

<em>Line 4:</em> print(x, end=' ')

This line prints the value of x at each iteration(loop) and then followed by a single space. i.e 0 1 2 ... will be printed. Bear in mind that 3 and 6 will not be printed though.

<em>Line 5:</em> print("\n")

This line will be printed after the loop has finished execution. This line prints a new line character.

You might be interested in
Visual Design includes 4 elements: shapes, texture, lines and form.
Alexxx [7]

Answer:

Explanation:

The answer is false

Because the 4 elements are shapes texture colour and size

6 0
3 years ago
How is the “conflict set” defined in Production systems?How conflict is resolved ?
Triss [41]

Answer:

The rules which could trigger at any period in time are referred to as the conflict set. A programming bug/conflict can occur when two programs compete for the same resource such as memory or register etc.

A Conflict Resolution Strategy is is a protocol which highlights which decision will be triggered first.

The best way to resolve conflict is to first determine the kind of conflict it is. Hardware conflicts can be resolved by first troubleshooting the hardware and in some instances unplugging the hardware causing the conflict.

When hardware creates conflicts it may be due to a driver issue. reverting to an old driver or updating the existing one may solve the problem.

Software conflicts can be resolved by installing updates or complete uninstallation.

Cheers!

5 0
2 years ago
Are brake and break pronounced the same way?​
erastova [34]

Answer:

one is correct and yes

Explanation:

4 0
3 years ago
To create a public key signature, you would use the ______ key.
olya-2409 [2.1K]

Answer:

To create a public key signature, you would use the <u>_private_</u> key.

Explanation:

To create a public key signature, a  private key is essential to enable authorization.

A private key uses one key to make data unreadable by intruders and for the data to be accessed the same key would be needed to do so.

The login details and some important credentials to access user data contains both the user's public key data and private key data. Both private key and public key are two keys that work together to accomplish security goals.

The public key uses different keys to make data readable and unreadable.

The public key is important to verify authorization to access encrypted data by making sure the access authorization came from someone who has the private key. In other words, it's a system put in place to cross-check the holder of the private key by providing the public key of the encrypted data that needed to be accessed. Though, it depends on the key used to encrypt the data as data encrypted with a public key would require a private key for the data to be readable.

4 0
3 years ago
What are the major differences between searching and sorting in Java? What are some of the differences in the techniques used in
Studentka2010 [4]

Answer:  

  • Searching is a technique to look for an item or target value in a data structure like searching for a phone number in a directory.Data structure can be an array,List etc. Searching algorithms are used for searching. Most common examples are Linear Search and Binary Search. Lets take the example Linear Search in order to explain it using JAVA. Its the simplest searching algorithm. To search for a specific element, look at each element in the data structure sequentially and check if it matches with the element being searched for.
  • Sorting is a technique of arranging the elements in a specific order e.g. numerical sorting, ordering students according to their exam score. This order can be ascending or descending or alphabetical order. Contrary to search it returns the data structure e.g. an array in which the elements of array are sorted in a particular order. Sorting algorithms are used to sort elements in a data structure. Some common examples of sorting algorithms are Bubble Sort, Insertion Sort, Selection Sort, Merge Sort, Quick Sort, Heap Sort etc. JAVA uses Array.Sort() built-in function for sorting an array. By default it sorts the input array in ascending order.
  • Selection Sort: It is a sorting technique which divides an array into two subarrays. One subarray in the left is sorted and the other one at right is unsorted. This is an in-place algorithm. It is not a good option for large data. Initially the sorted part is empty and all elements are placed in unsorted array. First the element which is the smallest in the unsorted array is selected and swapped with the leftmost array element and becomes part of the sorted array. In each iteration the smallest element from the unsorted array is selected and moved to sorted part of the array.The worst case time complexity of this algorithm is O(n)^2 as we have to find the smallest for every element in the array.
  • Merge Sort: It is a comparison based algorithm. It works on divide and conquer technique. It uses recursion approach for sorting. This means it breaks the problem(lets say array list to be sorted) into sub problems (smaller parts) and then solves (in this case sorts) each sub problem in a recursive manner. At the end it merges the solutions (hence the merged sorted array). Although selection sort works faster when data set is small merge sort outperforms it for larger data sets. Merge sort is a stable algorithm and works best for linked lists. Its not an in place algorithm. Time complexity of merge sort is O(n*log n) for best, average and worst cases because it always divides the array in two parts and takes linear time to merge these part. O(n(logn)) time complexity makes it better,more efficient and faster to sort large data sets.
  •  Big Oh O notation is an asymptotic annotation written as O(n) which is a mathematical way to represent the upper bound of the running time of   algorithm (sorting algorithm in this case). It computes the worst case time complexity. Worst case time complexity means that the longest amount of time or maximum number of operations that will be required for a sorting algorithm to complete. The time complexity mostly gets affected as the size of the input varies.
  • For example lets find out the worst-case time complexity of Bubble Sort for a list of n elements. Worst case is when the array is reversed sorted. At first iteration it would make n-1 comparisons. At iteration 1, for n-2 times and so total comparison will be O(n^)2. So the time to run program is proportional to the square of the input size.
  • Searching algorithms are used when there is a need to find a specific data item from bulk of data item. Searching algorithms make this hectic process easier. For example you want to find phone number of person from directory. without searching algorithm looking for each phone number in the directory manually can be very time consuming. For example you have to find address of a customer number 254 from database to deliver a product. Instead  of manually looking for customer numbers you can simply use  linear search algorithm that will start from customer 1 and sequentially searches for specific customer 254 number and provides the address in a shorter time.
  • Sorting reduces complexity of problems e.g reducing the searching complexity. It is easier to locate data elements in a sorted list than unsorted. For example comparing two large data sets containing millions of records. If both the data sets are ordered, the comparison gets easier. Moreover every sorting algorithm has certain usage. Like merge sort is useful for linked lists,heap sort is good with arrays and uses less memory. If data is small with large values, selections sort is better for this. It doesn’t require any additional space. Databases use merge sort to arrange data that is too large to be loaded completely into memory.  Heap sort is used in reading bar codes on plastic cards. Quick sort is used to maintain sports score on the basis of win-loss ratio.
5 0
3 years ago
Other questions:
  • _____ refer(s) to computer programs that provide instructions for a computer to execute a desired task. Answer .a.Software .b. I
    7·1 answer
  • These devices: monitor, earphone, speakers are examples of what? Input devices Storage devices Output devices All answer are cor
    10·2 answers
  • What is the Code of Conduct/Ethics for the company/of Department of Defense?
    7·1 answer
  • What to do when the tool bar for paint tool sai dissapears?
    12·1 answer
  • In Windows Vista, the Run command can be found in which application?
    6·1 answer
  • All of the following are challenges presented by changing technology as it relates to the special events field EXCEPT: A. the ab
    13·1 answer
  • Write a function that will alphabetize a string WITHOUT using the sort function :
    7·1 answer
  • Select a cybersecurity career that interests you. Describe the job duties and identify the skills required to excel in that care
    15·1 answer
  • Write a program that prompts the user to enter two positive integers less than 1,000,000,000 and the program outputs the sum of
    15·1 answer
  • 我对汉语的兴趣 làm đoạn văn theo đề trên​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!