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

Write an If/else statement to check whether host is online. If it is online, then print system is online otherwise print system

is unreachable.
Computers and Technology
1 answer:
Reika [66]3 years ago
4 0

Answer:

from socket import *

hostname = input('Enter the host to be scanned: ')

ip_add = gethostbyname(hostname)

connections = [ ]    

for i in range(133, 136):

   s = socket(AF_INET, SOCK_STREAM)

     

   conn = s.connect_ex((ip_add, i))

   print(conn)

   connections.append(conn)

if 0 in connections:

   print ('Host is online')

   s.close()

else:

   print ('system is unreachable')

Explanation:

The python source code above scans for all the available range of ports in the provided hostname, if any port is available, the host is online else the program print the error message "system is unreachable.

You might be interested in
Difference between implicit and explicit type casting
Lana71 [14]

Answer:

Implicit type casting means the type casting done by the compiler during compilation of program whereas Explicit type casting means the programmer explicitly type casts the variables. This is the difference implicit and explicit type casting.

Explanation:

Type casting means the conversion of one data type into another data type. There are two types of type casting. They are Implicit type casting and Explicit type casting.

<u>Implicit type casting:</u> The type casting which is done by the compiler during the compilation of a program. This occurs when we assigning smaller data type to larger data type and also both the data type are compatible. Below example clears the above concepts.

Ex: int \, i = 10;

long \, l = i;

In the above example " i "  is " int " data type whereas  " l " is long data type but as we assigned the value of " i " to " l ". Here " int " and " long " are compatible data types and we assigned smaller data type ( int - i ) to larger data type  ( long - l ) implicit type casting occurs.

<u>Explicit type casting:</u> The type casting which is done by the programmer explicitly to convert one data type into other data type. If we want to assign a value of larger data type to smaller data type explicit type casting is required. Below example clears the above concepts.

Ex: double \, d = 10.4;

long\, l = (long) d;

In the above example " d " is " double " data type whereas " l " is " long " data type. Here we are explicitly type casting to change larger data value ( double - d ) to smaller data value ( long - l ).  

7 0
3 years ago
Read 2 more answers
If a person communicates indirectly and attaches little value to
Mars2501 [29]

Answer: B. Low-context

5 0
2 years ago
Which of the following shows a list of Big-Oh running times in order from slowest to fastest?
Rufina [12.5K]

Answer:

O(N!), O(2N), O(N2), O(N), O(logN)

Explanation:

N! grows faster than any exponential functions, leave alone polynomials and logarithm. so O( N! ) would be slowest.

2^N would be bigger than N². Any exponential functions are slower than polynomial. So O( 2^N ) is next slowest.

Rest of them should be easier.

N² is slower than N and N is slower than logN as you can check in a graphing calculator.

NOTE: It is just nitpick but big-Oh is not necessary about speed / running time ( many programmers treat it like that anyway ) but rather how the time taken for an algorithm increase as the size of the input increases. Subtle difference.

5 0
3 years ago
Read 2 more answers
Do all light bulbs server a practical purpose?
Greeley [361]

Answer:

A light bulb produces light from electricity

6 0
3 years ago
What two Python data structures are already thread-safe, because they provide automatic support for synchronizing multiple reade
murzikaleks [220]

The  two Python data structures that are already thread-safe are list and tuples.

<h3>What are the data structures in Python?</h3>

Python is known to give room for its users to make  their own Data Structures.

It helps one to be able to  have total hold or control over their work or output functionality. Some key Data Structures are Stack, Queue, and others.

Learn more about Python from

brainly.com/question/26497128

#SJ1

6 0
2 years ago
Other questions:
  • 5. In Access, data is stored in a _______ once a form is completed. A. cell B. page C. record D. form
    13·1 answer
  • Wireless network devices use ________ to communicate with each other.
    9·2 answers
  • What daily life problems does the algorithm quicksort solve?
    14·1 answer
  • Which is most harmful computer virus define​
    15·1 answer
  • How can you create an illusion of spatial depth in a two-dimensional design?
    15·1 answer
  • / Looks up author of selected books
    15·1 answer
  • What is the second stage of information processing cycle​
    10·2 answers
  • Jackie created a poster for a rock band. Which file format will best preserve the graphics? 20PTS​
    14·2 answers
  • Explain to Alana why she might not want to blast her boss on social media just yet.<br>​
    6·1 answer
  • Consider the following code.
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!