0% found this document useful (0 votes)
83 views

Python Assignment For Absolute Beginners

1) Python is case sensitive when dealing with identifiers. Valid variable names include letters, underscores, and numbers, but cannot start with a number. 2) A while loop that prints the value of a variable (number) initialized to 5 will print the value 5 times before terminating. 3) The correct operator for power (xy) in Python is x**y.

Uploaded by

Ameya Dikshit
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views

Python Assignment For Absolute Beginners

1) Python is case sensitive when dealing with identifiers. Valid variable names include letters, underscores, and numbers, but cannot start with a number. 2) A while loop that prints the value of a variable (number) initialized to 5 will print the value 5 times before terminating. 3) The correct operator for power (xy) in Python is x**y.

Uploaded by

Ameya Dikshit
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

1) Is Python case sensitive when dealing with identifiers?

A. yes
B. no
C. machine dependent
D. none of the mentioned

2) Which of the following can be used as a variable name?

A. ~variablename
B. varaiable-name
C. 5_variablename
D. Variable_name

3) Write the output of this code

Options: -
A. The program will loop indefinitely
B. The value of number will be printed exactly 1 time
C. The while loop will never get executed
D. The value of number will be printed exactly 5 times

4) Which is the correct operator for power(xy)?

A. x^y
B. x**y
C. x^^y
D. None of the mentioned
5) What is the output of this code?

Options: -
A. 021324
B. 012345
C. Error
D. 102435

6) Answer Carefully

Type your Ans:


7) What is the output of this code?

Option: -
A. TRUE

B. TRUE
FALSE

C. FALSE
TRUE

D. TRUE
FALSE
TRUE

8) What is the output of this code?

Options: -
A. 66
0

B. 36
0

C. 66
3

D. 36
3
9) Which of these is not a core data type?
A. Lists
B. Dictionary
C. Tuples
D. Class

10) The following code contains an infinite loop. Which is the best
explanation for why the loop does not terminate?

Options: -
A. n starts at 10 and is incremented by 1 each time through the loop,
so it will always be positive.
B. answer starts at 1 and is incremented by n each time, so it will
always be positive.
C. You cannot compare n to 0 in the while loop. You must compare it
to another variable.
D. In the while loop body, we must set n to False, and this code does
not do that.
Write the code for the following programs:

1) Write a program to take input from user for shopping amount. For
amount, greater than 1000 shopkeeper gives 10 percent discount
and for amount below 1000 he gives 5 percent discount. Write a
program to display percent discount and amount of discount
applicable

2) Write a program which repeatedly reads numbers until the user


enters “done”. Once “done” is entered, print out the total, count,
and maximum and minimum of the numbers. If the user enters
anything other than a number, detect their mistake using try and
except and print an error message and skip to the next numbers

3) Write a program to count the number of digits before and after


decimal point in the entered floating point number. Take atlease 4
decimal point floating number as input from user

You might also like