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
Stolb23 [73]
3 years ago
11

Write two statements to read in values for my_city followed by my_state. Do not provide a prompt. Assign log_entry with current_

time, my_city, and my_state. Values should be separated by a space. Sample output for given program if my_city is Houston and my_state is Texas: 2014-07-26 02:12:18: Houston Texas Note: Do not write a prompt for the input values. 1 current_time = '2014-07-26 02:12:18:' 2 my_city = "' 3 my_state = "" 4 log_entry - "' 1 test passed 6 print(log_entry) All tests passed Run Run

Computers and Technology
1 answer:
Ainat [17]3 years ago
7 0

Answer:

Here is the program:

current_time = '2014-07-26 02:12:18:'  

my_city = ''

my_state = ''

log_entry = ''

 

my_city = input("")   #reads in value for my_city

my_state = input("")  #reads in value for my_state

log_entry = current_time + ' ' + my_city + ' ' + my_state   #concatenates current_time, my_city and my_state values with ' ' empty space between them

 

print(log_entry)

Explanation:

You can also replace

log_entry = current_time + ' ' + my_city + ' ' + my_state  

with

log_entry = f'{current_time} {my_city} {my_state}'

it uses f-strings to format the strings

If you want to hard code the values for my_city and my_state then you can replace the above

my_city = input("")

my_state = input("")

with

my_city = "Houston"

my_state = "Texas"

but if you want to read these values at the console from user then use the input() method.

The screenshot of the program along with the output is attached.

You might be interested in
Which of the following would be the most appropriate way to address and greet your teacher, Mr. Joseph Herman, in an email? Hi J
Valentin [98]
To determine what would be the most appropriate way to address and greet your teacher during an email, we should eliminate some greetings, such as:
"Yo wassup?", "How  u doin?", or any other grammatical and socially inappropriate errors.
Let's look at our first option.
"Hi Joseph, How u doin??". This is incorrect as it is not appropriate to address anyone in such a manner and with grammatical errors.
Let's look at our second option.
"Dear Joseph Herman, how are you doing!!". This was on the right path, but didn't end well. The ending of the message, "how are you doing!!" is incorrect punctuation, and has too much excitement.
How about our third option?
"Dear Mr. Herman, I hope you're doing fine.". This is a great email. It has perfect punctuation, grammar, and is appropriate.
What about our fourth?
"Dear Joseph, i hope you are doing great.". This is a good email, but has incorrect punctuation.
Your answer is C.) Dear Mr. Herman, I hope you're doing fine.
8 0
3 years ago
Write a function called factor that determines for a pair of integers whether the second integer is a factor of the first. The f
Aleks04 [339]
<h2>Answer:</h2>

//import the Scanner class to allow for user's input

import java.util.Scanner;

//Declare the class and call it FactorClass

public class FactorClass {

   

   //Declare the function factor

   //It returns either true or false, therefore the return type is boolean

   //It receives two arguments - a and b

   public static boolean factor(int a, int b){

       

       //Check if a is divisible by b.

       //Return true if yes

       if(a % b == 0){

           return true;

       }

       

       //return false if a is not divisible by b

       return false;

   

   }  // End of method factor

   

   

   //The main method to test the function factor()

   public static void main(String[] args) {

       

       //Create an object of the Scanner class

       Scanner input = new Scanner(System.in);

       

       //Prompt the user to enter the pair of numbers

       System.out.println("Enter the pair of numbers (separated by a space)");

       

       //grab and store the first number in a variable

       int firstnum = input.nextInt();

       

       //grab and store the second number in another variable

       int secondnum = input.nextInt();

       

       

       //With the variables, call the factor() method

       //If it returns true, print the adequate message

       if(factor(firstnum, secondnum)){

           System.out.println(secondnum + " is a factor of " + firstnum);

       }

       

       //If it returns false, print the adequate message

       else{

           System.out.println(secondnum + " is NOT a factor of " + firstnum);

       }

   

 }            // End of main method

   

}    // End of class declaration

==============================================================

<h2>Sample Output 1:</h2>

>> Enter the pair of numbers  separated by a space

8 4

>> 4 is a factor of 8

==============================================================

<h2>Sample Output 2:</h2>

>> Enter the pair of numbers  separated by a space

9 4

>> 4 is NOT a factor of 9

==============================================================

<h2>Explanation:</h2>

The above code has been written in Java and it contains comments explaining every segment of the code. Kindly go through the comments for better understanding of the code.

For simplicity, the code is re-written as follows with little or no comments;

import java.util.Scanner;

//Declare the class and call it FactorClass

public class FactorClass {

   

   public static boolean factor(int a, int b) {

       if(a % b == 0){

           return true;

       }

       

       //return false if a is not divisible by b

       return false;

   

   }  // End of method factor

   

   

   //The main method to test the function factor()

   public static void main(String[] args) {

       

       //Create an object of the Scanner class

       Scanner input = new Scanner(System.in);

       

       //Prompt the user to enter the pair of numbers

       System.out.println("Enter the pair of numbers (separated by a space)");

       

       //grab and store the first number in a variable

       int firstnum = input.nextInt();

       

       //grab and store the second number in another variable

       int secondnum = input.nextInt();

       

       

       if(factor(firstnum, secondnum)){

           System.out.println(secondnum + " is a factor of " + firstnum);

       }

       

       else{

           System.out.println(secondnum + " is NOT a factor of " + firstnum);

       }

    }

   

}

3 0
3 years ago
What does the following code alert?
goldenfox [79]

It is just a declaration of an object variable, <em>person</em>, in JavaScript. Within a <em>person</em> object, there are key:value pairs. The code that you  shared has the following keys: name, age, and favouriteFood, whereas the values of those keys are: Mike, 25, and pizza.


There is <em>no</em> alert statement in this code snippet; therefore, it <em>will not alert </em>anything. This code contains only a variable called <em>person, </em>and that's it!

5 0
3 years ago
Read 2 more answers
Which pillar in the cisco iot system describes embedded networks that include compact form factor switch and router cards runnin
kolezko [41]
<span>The network connectivity pillar in the Cisco IoT system describes embedded networks that include compact form factor switch and router cards running Cisco IOS software to provide secure data, voice, and video communications.
</span>The network connectivity is one of the six pillars <span>supporting Cisco's IoT system. It </span>includes purpose-built routing, switching and wireless products;
8 0
3 years ago
The field of informatics helps bring the right information to healthcare teams and patients at the right time which may improve
zalisa [80]

Answer:

True

Explanation:

The word informatics is derived from the French word Informatique and it describes the science of using  information & communication technology (ICT),  to communicate, for the management of knowledge, prevention of errors and supporting of decision making. The application of effective informatics to health care delivery will definately lead to better results.

6 0
2 years ago
Other questions:
  • Differences between Quality of Services and a Service of Quality approach
    9·1 answer
  • HELP URGENT
    12·2 answers
  • Suppose there is a class Alarm. Alarm has two class variables, code which contains a String value representing the code that dea
    12·1 answer
  • Anyone know how to delete that I need ASAP
    13·1 answer
  • Hello Answerers it would be great if you could answer this:
    12·2 answers
  • Please hurry!
    15·2 answers
  • Which one way in which using infrared in game console controllers could affect the experience of a person playing the game?
    8·1 answer
  • Write the importance of program in computer​
    9·1 answer
  • High-level languages must be translated into machine language before they can be executed. _________________________
    10·1 answer
  • you want to be able to restrict values allowed in a cell and need to create a drop-down list of values from which users can choo
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!