Uploaded by Sat Adha

Python Questions

advertisement
1. a = 123
b = “Python”
print(a+b)
What will be the output?
a. 123
b. “123Python”
c. “123 Python”
d. Error
2. Which one of the following is not a Python reserved word?
a. iterate
b. else
c. break
d. pass
3. a = 42
b = 10
c = a%b
print(f”{c}, {a/c}, {b//c}”)
What is the output of the above code?
4. a = 50
print(“Hello to all” + a + “students of the class”)
This code returns an error because?
5. Why is the code given below wrong?
x = int(input())
if x < 5:
print(“Fail”)
elif x = 6:
print(“OK”)
else:
print(“Good”)
6. Write a program that takes an integer as an input and outputs
a. If the number is even or odd
b. If the number is divisible by 3 or not
c. If the number is divisible by 4 or not
d. If the number is greater than or less than 20
Eg: Input: 4
Output: Odd
No
Yes
Yes
7. Write a program to generate all the multiples of 17 less than 1000.
8. Take a number as an input from the user. Write a python program to generate
Fibonacci series upto that number.
9. Take a string as an input and then output a string that is the reverse of it.
Eg. If the input is “abcdef”, the output has to be “fedcba”.
10. Write a program that removes all the commas(“,”) from the string and replace
them with “and”.
11. Write a program that takes a number with at least 5 digits and returns the value
of all the digits summed. If the given number is less than 5 digits, print “Enter a
number with atleast 5 digits”. The program has to ask the user for an input until a
5 digit number is given.
Download