Ad
Saturday, December 9, 2023
Chapter 2 Control Statements
-Give the purpose of selection statements in Python.
Selection statements (like if, elif, and else) in Python serve the purpose of making decisions in the code. They allow the program to choose different paths or actions based on the evaluation of conditions.- List the types of type conversion in Python.
Implicit Type Conversion (Coercion):
Automatically performed by the interpreter.
Example: Converting an integer to a float during arithmetic operations.
x = 5
y = 2.0
result = x + y # Implicitly converts x to float
Explicit Type Conversion (Casting):
Done by the programmer using predefined functions like int(), float(), str(), etc.
Example: Converting a string to an integer.
- Explain backward indexing in strings.
- Write a Python program to display power of 2 using an anonymous function.
About Abhishek Dhamdhere
Qna Library Is a Free Online Library of questions and answers where we want to provide all the solutions to problems that students are facing in their studies. Right now we are serving students from maharashtra state board by providing notes or exercise solutions for various academic subjects
No comments:
Post a Comment