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
tia_tia [17]
4 years ago
9

Write an expression that prints 'You must be rich!' if the variables young and famous are both True. Sample output with inputs:

'True' 'True' You must be rich!
Computers and Technology
1 answer:
Pavel [41]4 years ago
3 0

Answer:

Following are the expression in the Java language

public class Main

{

public static void main(String[] args) // Main method

{

boolean young= true; // variable declaration

boolean famous= true;// variable declaration

if(young && famous) // check the condition

System.out.println("You must be rich  "  );// display message

}

}

Output:

You must be rich

Explanation:

Following are the description of the above statement

  • Declared a variable "young " of the boolean type that is initialized with the "true" value.
  • Declared a variable "famous " of  the boolean type that is initialized with the "true" value.
  • Check the condition of if() block.If the condition is true then it executed the condition inside the if block.
  • Finally ,print the message  "You must be rich!"
You might be interested in
Implement the function is_maxheap which takes a list of integers and returns True if the list represents a valid max-heap, and F
harkovskaia [24]

Answer:

I am writing a Python function:

def is_maxheap(list):

   #finds the length of the list  

   size=len(list)

   #loop has a variable i which starts traversing from root til end of last #internal node

   for i in range(int((size - 2) / 2) + 1):  

       if list[2 * i + 1] > list[i]:  #If left child is greater than its parent then return #false  

               return False  

       if (2 * i + 2 < size and

           list[2 * i + 2] > list[i]):    #checks if right child is greater, if yes then #returns false  

               return False

   return True

Explanation:

The function is_maxheap() traverses through all the internal nodes of the list iteratively. While traversing it checks if the  node is greater than its children or not. To check the working of this function you can write a main() function to check the working on a given list. The main() function has a list of integers. It then calls is_maxheap() method by passing that list to the function. The program displays a message: "valid max heap" if the list represents valid max-heap otherwise it returns invalid max heap.

def main():

   list = [10,7,8]  

   size = len(list)  

   if is_maxheap(list):

       print("Valid Max Heap")  

   else:  

       print("Invalid Max Heap")          

main()

The program along with its output is attached in a screenshot.

5 0
4 years ago
What does the program print out as a result of the given snippet of code?
dexar [7]

Answer:

5

Explanation:

well the function len gives the length of the list

so the length of supplies is

5

7 0
3 years ago
Read 2 more answers
Answer is B because portrait is define that they take only photographs of people and like to communicate with people they are we
quester [9]
Ty ive been looking for that answer
5 0
3 years ago
Write a function called word_count that takes a string and returns a dictionary that maps every case-insensitive word in the str
Taya2010 [7]

Solution :

We need to write a function named ''$\text{word}$_$\text{count}$". The program takes a string and then returns a dictionary which maps the case insensitive word.

def $\text{word}$_$\text{count}$(s):

   $\text{words}$ = $\text{s.lower}$().split()

   $\text{result}$ = {}

   for $x$ in words:

       if $x$ in $\text{result}$.keys():

           $\text{result}$[x] += 1

       else:

           $\text{result}$[x] = 1

   return $\text{result}$

5 0
3 years ago
Flash drive DVD and hard drive are all examples of
oee [108]

Answer:

flash drive DVD and hard drive are all examples of storage device

8 0
3 years ago
Read 2 more answers
Other questions:
  • Osha requires employers pay for most required personal protective equipment including
    11·1 answer
  • Write a statement containing a logical expression that assigns true to the
    13·1 answer
  • There are two kinds of type that you can add to a document in Photoshop. You can add
    13·1 answer
  • A ________ is a powerful analytical tool to size up Apple Inc.'s competitive assets in order to determine whether or not those a
    9·1 answer
  • Clunker Motors Inc. is recalling all vehicles from model years 2001-2006. Given a variable modelYear write a statement that prin
    9·1 answer
  • Network administrators use _______ technology to get antivirus updates to be automatically downloaded on employees' workstations
    15·1 answer
  • which statement is true? O A Future games will be more context oriented. OB. Future games will be more product driven. Future ga
    13·2 answers
  • Write a function named minMax() that accepts three integers arguments from the keyboard and finds the smallest and largest integ
    5·1 answer
  • What is contained in the Open Files section of Shared Folders? ​
    13·1 answer
  • Best definition of wind
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!