Question

1. Using logical operators modify the following Python "if" statement to print ("AND operator condition worked")?...

1. Using logical operators modify the following Python "if" statement to print ("AND operator condition worked")?

x=2

y=3

if (x<=2 or y>=3) and (x>2 or y<2):

print("AND operator condition worked")

else: print("it doesn't work")

2. Write a program that asks user for five numbers and returns the largest of them. Do not use max function built in python.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

x=2
y=3
if (x<=2 or y>=3):
    print("AND operator condition worked")
else:
    print("it doesn't work")

AND operator condition worked

lst = []
for x in range(5):
    lst.append(eval(input("Enter number "+str(x)+": ")))
maxVal = lst[0]
for x in lst:
    if(maxVal < x):
        maxVal = x
print("Max value =",maxVal)

Add a comment
Know the answer?
Add Answer to:
1. Using logical operators modify the following Python "if" statement to print ("AND operator condition worked")?...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1) Translate the following equation into a Python assignment statement 2) Write Python code that prints...

    1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...

  • For 1 through 11, create an expression using the relational operators, the logical operators, and variable...

    For 1 through 11, create an expression using the relational operators, the logical operators, and variable names of your own choosing, no if or variable declaration is necessary. 1. is a person's age equal to 30? 2. is a body temperature greater than 98.6? 3. is a person's height less than 6 feet? 4. is the current month 12? 5. check if the letter input is m 6. is a person's age equal to 30 and is the person taller...

  • using python Write a program that asks the user to enter a month (1 for January,...

    using python Write a program that asks the user to enter a month (1 for January, 2 for February, and so on) and then prints the number of days in the month. For February, print “28 or 29 days”. Enter a month: 5 30 days Do not use a separate if/else branch for each month. Use Boolean operators.

  • s1 = 'Practice How to Use String Object' Write a python statement that splits the string,...

    s1 = 'Practice How to Use String Object' Write a python statement that splits the string, creating the following list: ['Practice', 'How', 'to', 'Use', 'String', 'Object'] 2. Assume reply references a string. The following if statement determines whether reply is equal to ‘Y’ or ‘y’: reply = input("Y or y to continue: ") if reply == "Y" and reply == "y":    print("Y --- <uppercase> has been selected. ") else:    print("y --- <lowercase> has been chosen. ") print("… continue...

  • computer Programming visual Basic 1-10 QUESTION 1 Which of the following is not a logical operator...

    computer Programming visual Basic 1-10 QUESTION 1 Which of the following is not a logical operator in Visual Basic? Not • or And Then QUESTION 2 Which of the following is a valid Visual Basic conditional statement? 2<n<5 2 <n or <5 0 2 <n<5 (2 <n) or (n <5) QUESTION 3 When Visual Basic stops evaluating a compound condition with the logical And operator because the first condition evaluates to False. It is called evaluation. short-circuit Pre- compound first...

  • 10) you will run/call the function with these given values. (b) Write a flow chart and the script file using conditional statements with logical operator if/else and if/elseif, to evaluate the fo...

    10) you will run/call the function with these given values. (b) Write a flow chart and the script file using conditional statements with logical operator if/else and if/elseif, to evaluate the following function, assuming that the scalar x has a value: y 2 sin(m) for-1 x < 5 y=10(X-5) + 1 for x 25 Use your file to evaluate y for x5,x 3 and x 15 by hand 10) you will run/call the function with these given values. (b) Write...

  • USING PYTHON PLEASE Write a program that calculates the factorial value of a number entered by...

    USING PYTHON PLEASE Write a program that calculates the factorial value of a number entered by the user. Remember that x! =x* (x-1)* (x-2)*... *3+ 2* 1. Your program should check the value input by the user to ensure it is valid (i.e., that it is a number > =1). To do this, consider looking at the is digit() function available in Python. If the user enters an incorrect input, your program should continue to ask them to enter a...

  • How can I modify my program to accept a list of integers (up to 20 entries)...

    How can I modify my program to accept a list of integers (up to 20 entries) from the user into a list and prints the numbers entered by the user in ascending order, their sum and their average. The program then stops when the user inputs -100 as a number to search. #function that returns largest number def max(numOne,numTwo,numThree): if(numOne > numTwo and numOne > numThree): return numOne elif(numTwo > numOne and numTwo > numThree): return numTwo elif(numThree > numOne...

  • Problem 1 1 def modify(word.ch). word == word + ch return word print('new word is', word)...

    Problem 1 1 def modify(word.ch). word == word + ch return word print('new word is', word) To run the function modify() defined above, we make the following call: result = modify('course', 's') Find and fix the errors in the function definition, lines (1) to (4), such that after the call is executed: • Variable result has the value 'courses' • 'new word is courses' is printed out. For each error found and fixed, you must indicate the following: • line...

  • using mips for assembly language WPte a program that asks the user for 2 numbers. the program should then add the 2 numbers bit by bit, using boolean operators no arithmetic operations ex: add, ad...

    using mips for assembly language WPte a program that asks the user for 2 numbers. the program should then add the 2 numbers bit by bit, using boolean operators no arithmetic operations ex: add, addi, sub, mult, div or arrays are permitted in this project. forming a new variable (in a register) with the solution. That solution is to be output bit by bit using the function that was written in class do not use syscall with a value 10...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT