Which function is used to receive input from users

Assignment Help Python Programming
Reference no: EM132356343

Answer the Following Questions

1. In computation if operands of different types are involved, Python converts the operand with "smaller" type to the "larger" type. What is this called?

1 auto conversion
2 coercion
3 explicit conversion
4 (1) and (2)

2. Which function is used to receive input from users?

1 str()
2 type()
3 print()
4 input()

3. x=4
y=3
product = 4 * 3

What is the correct print statement to output the value of x, y and product?

1 print("The product of %d and %d is %d" %x,%y,%product)
2 print("The product of %d and %d is %d" %(x,y,product))
3 print("The product of %d and %d is %d" %x,y,product)
4 print("The product of %d and %d is %d", %(x,y,product))

4. Which is a valid python statement?

1 a,b=divmod(5,2)
2 x = 6.5>>2
3 m=int(input(‘Enter a number:\n'))
4 All the above are valid
5 Only 1 and 3 are valid

5. What is the for loop that will print the following output?

1 for i in range(1,5): for j in range(1,i+1): print(j, end=' ') print('')

1
1 2 2 for i in range(1,5):
for j in range(1,i+1): print(i)
print('')
1 2 3
1 2 3 4

3 for i in range(1,5):
for j in range(1,i): print(j, end=' ')
print('')

4 for i in range(1,5):
for j in range(1,i+1): print(j, end=' ')
print('')

6. What is the for loop that will print the following output? 1 for i in range(1,5): for j in range(1,i+1): print(i,end=' ')
print('')
1

2 2 2 for i in range(1,5):
for j in range(1,i+1): print(j,end=' ')
print('')
3 3 3
4 4 4 4
for i in range(1,5):
for j in range(1,i): print(i,end=' ')
print('')
3
4 None of these

7. x=not((1 or 0) and (1 and 1)). What is the value of x?

1 True
2 False

8. What is the output of the following code?
i=1;
while i < 10:
i = i+3
print(i,end=' ') 1 4 7
2 4 7 10
3 1 4 7 10
4 1 4 7

9. Which statement about Python is true?

1 In Python there is no need to define variable data type.
2 Python is a compiled language.
3 Python does not support object-oriented programming.
4 A Python variable name can start with a digit.

10.If a=5, b=10 and c=8, the boolean value stored in x after executing the statement
x=a<=b<=c

1 True
2 False

11. The statement a<=b<=c is equivalent to:

1 a<=b and a<=c
2 b<=c and b<=a
3 a<=b and b<=c
4 c<=b and c<=a

12. The if statement that validates variable x for a value between 100 and 1000(both included) is:

1 if(100<=x<=1000):
2 if(x>=100 and x<=1000):
3 if(x>100 and x<1000):
4 Only 2 and 3
5 Only 1 and 2

13. What would the following statement return?
list=[‘Mary', ‘John', 12, ‘Dog']
print (list[-3:-1])

1 ['Mary', 'Dog']
2 ['John', 'Dog']
3 ['John', 12]
4 ['Mary', '12']

14.What is the output of the following code snippet?
i=1
while i <=10: if i%2 == 0:
i=i+1 continue
print(i,end=' ')
i+=1

1 1 3 5 7 9
2 2 4 6 8 10
3 1 4 7 10
4 None of these

15. What is the output of the following code?
for i in(1,2,3,4,5):
if i//3 == 0: continue
print(i//3,end=' ')

1 0 0 0
2 3 4 5
3 1 2 3
4 None of these

16. What is the output of the following code?

for i in (3,6,9,12,15): if i==9:
break
print(i,end=' ')

1 3 6 12 15
2 3 6 9
3 3 6
4 None of these

17. Which of the code snippets will create an infinite loop? 1 a=1 while 1:

print(a) a+=1
if a==5:
break
2 a=1 while 1:
print(a) if a>10:
break
3 a=1
while a>=1:
a=a+1 print(a)
4 Only 1 and 3
5 Only 2 and 3

18. Which of the range functions will return a list that is not empty?

1 range(1,1)
2 range(10,1,2)
3 range(1,10,-2)
4 range(10,1,-2)
5 Options 2 and 4.

19. What is the type of value returned by the input() function?

1 Dependent on the value read from the console.
2 String
3 Integer
4 None of these.

20. Which is not a keyword in Python?

1 pass
2 break
3 continue
4 statement
5 and

Reference no: EM132356343

Questions Cloud

What is the value of y after the following code is executed : Which is the statement that declares and initialises with zero a two dimensional array variable m with 3 rows and 4 columns?
Challenges of international competition and expansion : BUMGT5920 - Management in a Global Business Environment - Describe, using academic references, the international challenges and possible opportunities
Detect emerging threats and strengthen countermeasures : How defense-in-depth (chapter 6) and awareness (chapter 10) are complimentary techniques to detect emerging threats and strengthen countermeasures
Calculate and prints the area of a rectangle : Create a Python program that calculates and prints the area of a rectangle. The length of the rectangle is 6 and the breadth is 4. No input is required.
Which function is used to receive input from users : In computation if operands of different types are involved, Python converts the operand with "smaller" type to the "larger" type. What is this called?
Create infographic on nurse practitioners reduce costs : Create infographic on 10 ways nurse practitioners reduce healthcare costs while improving quality: direct content to the patients for reading
Lightweight white paper for fictitious initial coin offering : You'll create a lightweight white paper for a fictitious Initial Coin Offering (ICO). You will use your imagination to create a brand new,
Develop complete disaster recovery plan : Develop a Complete Disaster Recovery Plan to be submitted to the executive board of your company.
Disaster recovery plan powerpoint presentation here : Disaster Recovery Plan PowerPoint Presentation here. Your PPT should reflect a summary of your DR Project Plan.

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd