The document provides a series of questions and answers related to basic Python programming concepts. Key topics include the difference between random functions, the meaning of 'dir', assignment navigation in LMS, and the rationale behind 0-based indexing. It also addresses the flexibility of assignment deadlines and the use of the random module in Python.
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 ratings0% found this document useful (0 votes)
1 views
Basid Python Programming
The document provides a series of questions and answers related to basic Python programming concepts. Key topics include the difference between random functions, the meaning of 'dir', assignment navigation in LMS, and the rationale behind 0-based indexing. It also addresses the flexibility of assignment deadlines and the use of the random module in Python.
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
Basic Python Programming -6
1. What is the difference between .random() and .uniform()?
Answer: random.random() generates a random float between 0 and 1 random.uniform(a, b) generates a random float between a and b.
2. What is the full form of "dir" in Python?
Answer:In Python, "dir" stands for "directory"
3. How to find assignments on the LMS?
Answer:Please open the LMS and navigate to the Assignment section, where you will find all the assignments.
4. Why don't we use break after elif?
Answer:We don't use break after elif because if-elif-else is a conditional control structure, not a loop. The break statement is used to exit loops (for or while), whereas if-elif-else executes only one matching condition and moves forward in the program.
5. Can we get the recorded lectures if we miss a live session?
Answer: Once the lecture is over, the recording option will appear for each lecture. Click on the "VIEW RECORDING" option to access the recording of that lecture.
6. What happens if we fail to submit an assignment on time?
Answer: Attendance and assignments do not contain grades, but we recommend attending all the classes and completing all the assignments for better learning. You can practice the assignments any time, any number of times. The reason we keep deadlines is because if you do it within the timeline, it will be relevant to the sessions going on, and you will be on track. The program has been kept very flexible to adjust to the needs of the students.
7. What is import random?
Answer:import random is a statement in Python that allows you to use the random module, 8. What does double mean in Python? Does it use ‘d’ for initialization? Answer:n Python, there is no built-in double data type like in C or Java. Instead, Python uses float to represent floating-point numbers (decimal values).Python does not use 'd' for initialization. You can simply declare a float
9. Is slicing only possible in string data types?
Answer:No, slicing is not only possible in strings. It can be used with lists, tuples, and other sequence types like ranges.
10. Why does the index start from 0?
Answer:the index starts from 0 due to historical and technical reasons: 1. Memory Addressing – In low-level languages like C, an array’s index represents an offset from the base memory address. The first element is at offset 0, the second at 1, and so on. 2. Efficiency – Using 0-based indexing simplifies calculations, like accessing the nth element: ○ 0-based index: address + (index * size) ○ 1-based index: address + ((index - 1) * size), which adds an extra subtraction step. 3. Historical Influence – Many early programming languages (like C) used 0-based indexing, influencing later languages like Python, Java, and JavaScript.