0% found this document useful (0 votes)
3 views2 pages

50_Python_Practice_Questions

The document contains 50 Python practice questions ranging from easy to tough, covering various topics such as basics, variables, strings, lists, loops, functions, conditionals, input, comments, and indentation. Each question includes a code example and an explanation of the concept being tested. It serves as a resource for learners to practice and enhance their Python programming skills.

Uploaded by

divy1908
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

50_Python_Practice_Questions

The document contains 50 Python practice questions ranging from easy to tough, covering various topics such as basics, variables, strings, lists, loops, functions, conditionals, input, comments, and indentation. Each question includes a code example and an explanation of the concept being tested. It serves as a resource for learners to practice and enhance their Python programming skills.

Uploaded by

divy1908
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

50 Python Practice Questions (Easy to Tough)

Q1 (Easy - Basics): What is the output of print(2 + 3 * 4)?

print(2 + 3 * 4)

Explanation: Python follows BODMAS, so multiplication is done before addition.

Q2 (Easy - Variables): How do you assign a value to a variable?

x = 10

print(x)

Explanation: Use the = operator to assign values to variables.

Q3 (Easy - Strings): How do you concatenate two strings?

a = 'Hello '

b = 'World'

print(a + b)

Explanation: Use the + operator to join strings.

Q4 (Easy - Lists): How do you access the first element in a list?

my_list = [1, 2, 3]

print(my_list[0])

Explanation: Use index 0 to access the first item.

Q5 (Easy - Loops): How do you print numbers from 1 to 5 using a loop?

for i in range(1, 6):

print(i)

Explanation: Use a for loop with range to iterate over numbers.

Q6 (Easy - Functions): How do you define a simple function in Python?

def greet():

print('Hello')

greet()

Explanation: Use the def keyword to define a function.


Q7 (Easy - Conditionals): How do you write an if-else condition in Python?

x = 10

if x > 5:

print('Greater')

else:

print('Smaller')

Explanation: Use if-else to perform conditional logic.

Q8 (Easy - Input): How do you take user input in Python?

name = input('Enter your name: ')

print(name)

Explanation: Use input() to take user input.

Q9 (Easy - Comments): How do you write comments in Python?

# This is a comment

print('Hello')

Explanation: Use # to write single-line comments.

Q10 (Easy - Indentation): Why is indentation important in Python?

if True:

print('Indented')

Explanation: Python uses indentation to define blocks of code.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy