Python Assignment
Python Assignment
Python Assignment 1
Q2. Enlist the characteristics of Python and explain why it is considered user-friendly.
Ans. Python is a high-level, interpreted language with a syntax that is easier to read, thereby
friendly to beginners. It has dynamic typing, automatic memory management, and a large
standard library, all resulting in shorter development time. It is cross-platform and has
frameworks for web development (Django), data analysis (Pandas), and more, making it
versatile and widely used.
Q3. Write an if/else statement with the following condition: If the variable age is greater than 18,
output "Old enough", otherwise output "Too young".
Ans.
age = 20
if age > 18:
print("Old enough")
else:
print("Too young")
Q4. Write a program that
a) Store correct password in a variable.
b) Asks user to enter his/her password
c) Validate the two passwords: i. Check if user has entered password. If not, then give message
“Please enter your password” ii. Check if both passwords are same. If they are same, show
message “Correct! The password you entered matches the original password”. iii. Show
“Incorrect password” otherwise.
Ans.