Question

In: Computer Science

Write if logic in Python that checks if a variable named number is either greater than,...

Write if logic in Python that checks if a variable named number is either greater than, less than , or equal to 10 and prints out the number with the appropriate message, for example, if number is 6 you would output: number,"less than 10" or 6 less than 10

Solutions

Expert Solution

Python code:

#accepting number from user
number=int(input())
#checking if number is greater than 10
if(number>10):
#printing greater than 10
print(str(number)+" greater than 10")
#checking if number is less than 10
elif(number<10):
#printing less than 10
print(str(number)+" less than 10")
else:
#printing equal to 10
print(str(number)+" equal to 10")

Screenshot:


Input and Output:


Related Solutions

Write a python program which asks the user to enter a positive number that is greater...
Write a python program which asks the user to enter a positive number that is greater than 30 called, “num2” and then does the following: o 1) Print all numbers between 1 and “num2” that are divisible by 2 and 3. o 2) Print all numbers between 1 and “num2” that are either divisible by 6 or 7. o 3) Print all numbers between 1 and “num3” that is not divisible by 5
Python please Write a function that takes a string as an argument checks whether it is...
Python please Write a function that takes a string as an argument checks whether it is a palindrome. A palindrome is a word that is the same spelt forwards or backwards. Use similar naming style e.g. name_pal. E.g. If we call the function as abc_pal(‘jason’) we should get FALSE and if we call it a abc_pal(‘pop’) we should get TRUE. Hint: define your function as abc_pal(str). This indicates that string will be passed. Next create two empty lists L1=[] and...
Python Question: Write a function that checks to see if an array of integers is sorted...
Python Question: Write a function that checks to see if an array of integers is sorted in an increasing fashion, returning true if it is, false otherwise. Test it with at least4 arrays - 2 sorted and 2 not sorted. Use a CSV formatted input file as described in the previous question to run your program through some tests, where again the filename is passed as an argument. Heres what I have so far: import sys # command line arguement...
write a program using the main method where the user enters a number greater than 0,...
write a program using the main method where the user enters a number greater than 0, and the program prints out a set of stairs. The stairs consist of 3 boxes stacked on top of each other where the length and width of the first box is the number, the length and width of the second box is the number plus 1, and the length and width of the third box is the number plus 2. The stairs should be...
implement the following logic in Python, use appropriate data types. Data types are represented as either...
implement the following logic in Python, use appropriate data types. Data types are represented as either numeric (num) or string. string name string address num item num quantity num price num SIZE = 6 num VALID_ITEM [SIZE] = 106, 108, 307, 405, 457, 688 num VALID_ITEM_PRICE [SIZE] = 0.59, 0.99, 4.50, 15.99, 17.50, 39.00 num sub string foundIt = “N” string MSG_YES = “Item available” string MSG_NO = “Item not found” get name, address, item, quantity sub = 0 while...
*Code in C* Write a function that checks if a number is a perfect cube. Write...
*Code in C* Write a function that checks if a number is a perfect cube. Write another function that calculates the integer cubic root. Under the main program: Prompt the user to input a number Tell the user if the number is a perfect cube or not Print the cubic root if the inputted number is a perfect cube.
Use python write a function that checks the result of the blackjack game, given the sum...
Use python write a function that checks the result of the blackjack game, given the sum of all cards in player 1’s and player 2’s hand in each round. For the i-th round, the i-th index of player1 list represents the sum of all cards of player1, and the i-th index of player2 list represents player2's card sum. The i-th index of the returned list should be the winner's card sum. If both players' card sums go over 21 in...
PYTHON Write a program that accepts a range of input from the user and checks whether...
PYTHON Write a program that accepts a range of input from the user and checks whether the input data is sorted or not. If the data series is already sorted your program should print “True” or should print “False” otherwise. You should not use any sort function for this program. Input: How many numbers you want to input: 3 # user input 3 Input the number: 5 Input the number: 2 Input the number: 7 Output: False
A prime number (or prime) is a natural number greater than 1 that has no posítive...
A prime number (or prime) is a natural number greater than 1 that has no posítive divisors other than 1 and itself. Write a Python program which takes a set of positive numbers from the input and returns the sum of the prime numbers in the given set. The sequence will be ended with a negative number.
write a method that returns the index of the second smallest element in an array of integers. If the number of such elements is greater than 1.
write a method that returns the index of the second smallest element in an array of integers. If the number of such elements is greater than 1. return the second smallest index. Use the following header:public static int index of seconds sma11eststenent tint array
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT