Q1)
a)
CODE:
# take to user from user a = int(input("1st number: ")) b = int(input("2nd number: ")) # check if a is greater tha zero or not if a > 0: print("%d is positive" % a) else: print("%d is negative" % a) # check if b is greater tha zero or not if b > 0: print("%d is positive" % b) else: print("%d is negative" % b)
OUTPUT:
b)
CODE:
# take to user from user dividend = int(input("Dividend: ")) divisor = int(input("Divisor: ")) # divide it and get quotient print("Quotient: %f" % (dividend / divisor)) # use mod(%) to get the remainder print("Remainder: %d" % (dividend % divisor))
OUTPUT:
c)
CODE:
# take two numbers from user a = int(input("1st number: ")) b = int(input("2nd number: ")) # checking if a is equal to b or not if a == b: print("Same") else: print("Not same")
OUTPUT:
Q2)
Python variable naming rules are as follows:
Q3)
CODE:
a = 0 b = 1 print(a, end=" ") print(b, end=" ") # running till 14 because on index 15 the value exceeds 900 for i in range(14): c = a + b print(c, end=" ") a = b b = c
OUTPUT:
Q4)
# n need to be defined n=20 # instead of z y must be used y = 0 i = 5.0 # iterating from 5 to less than equal to n for i in range(5, n + 1, 10): # capital I replaced with small i y = y + 8 / i print(y)
Please upvote if you like my answer and comment below if you have any queries or need any further explanation.
Give the solution using Python programming for following with explanations: a. Take two numbers and display...
Write the PYTHON code that displays the following numbers: The program should have a header that displays "Number Doubled Tripled" above the start of the numbers. If putting all numbers on the same line, then they will need to be separated so you can see he individual number.(https://www.programiz.com/python-programming/methods/built-in/print) The program should display Every whole number from 1 through 35. The program should display that number doubled. The program should also display that number tripled. Make a working version of this...
Spring 2020 CSCI 2450: HW5 (Programming Assignment (10 points) Answer any ONE of the following problems. If you answer both of them, you will get bonus points. Use any instructions and Irvine procedures we covered till now. These problems might require instructions from chapter 07. Problem 1: Greatest Common Divisor ( GCD) Greatest Common Divisor (GCD): The greatest common divisor (GCD) of two integers is the largest integer that will evenly divide both integers. The GCD algorithm involves integer division...
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...
Python Programming language Write the following functions: getNumInRange(prompt, min, max) - gets a number from the user within the specified range, prompting with 'prompt' calcAvg(values) - calculates and returns the average from a supplied list of numeric values menu(somelist) - creates a numbered menu from a list of strings. Then, have the user select a valid choice (number), and return it. Use the getNumInRange() funtion to do this. getAlbum() - prompts the user for information to populate a dictionary representing...
You recently graduated college and you are applying for a programming job that requires the understanding of loops in Python. The manager you are interviewing with has asked you to take an assessment to prove your programming knowledge. Below are the requirements for the programming skills test. In Python, create a program that meets the following requirements: Take two integers from the user. Save the lower number as x. Save the largest integer as y. Write a loop that counts...
You recently graduated college and you are applying for a programming job that requires the understanding of loops in Python. The manager you are interviewing with has asked you to take an assessment to prove your programming knowledge. Below are the requirements for the programming skills test. In Python, create a program that meets the following requirements: Take two integers from the user. Save the lower number as x. Save the largest integer as y. Write a loop that counts...
PYTHON PROGRAMMING: DO NOT USE INPUT FUNCTION, use sys.argv Write a program that generates two random integer numbers between 1 and 100. Then, print out the numbers between the two randomly generated ones using a while loop. The output is shown below. Output: a) start:4, end:14 4 5 6 7 8 9 10 11 12 13 14 b) start:15, end:20 15 16 17 18 19 20
USING PYTHON *Write a program, in which the user enters two numbers, then divides the first number by the second, and prints the result to two decimal places. *Make sure that that the inputs are floats (with exception handling using the ValueError). *Make sure that there is no divide by zero error (with exception handling). *Then have a plain exception: That handles any other error. -Thank you in advance for your assistance-
- In python language doing a programming assignment that requires: 1-your calculateor must recieve two numbers from the user and one operator("+" for sum,"-" for sub,"*"for multiplication,"/" for division,"^" for exponentiation,@,for"root extraction and "% for modulo). 2-you must creat a code to find the n the fibonacci number, where n is a number input by the user. -Remember that a Fibonacci number is given by the sum of the two previous numbers in the sequence: Fib(n)=Fib(n-1)+fib(n-2)
Write a program using the LOOP instruction to sum all the even numbers from 20H to 80H. Write a program using the ADC (or add with carry) instruction to add these two 48 bit numbers. Assume the first number is store at an address starting 400H and that the second number is stored at an address starting at address 500H. Store the results in memory starting at address 600H. (Note that each number consists of three 16 bit words). Show...