7. What is the value of s1 after the following code executes? s1= "heY" 1 2 s1 s1.capitalize() 3s1.lower () A. heY B. Hey C. hey D. HEY

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

please solve question 7 python

### Coding Quiz

#### 6. What is printed by the following when executed?
```python
str = "His shirt is red"
pos = str.find("is")
print(pos)
```
Options:
- A. 9
- B. 2
- C. pos
- D. 1
  
**Answer:** B. 2

#### 7. What is the value of `s1` after the following code executes?
```python
s1 = "heY"
s1 = s1.capitalize()
s1.lower()
```
Options:
- A. heY
- B. Hey
- C. hey
- D. HEY
  
**Answer:** B. Hey

#### 8. Which line of code correctly gets the value of the key 'apples' if it exists and returns 0 if it does not?
```python
fruits = {'bananas': 7, 'apples': 4, 'grapes': 19, 'pears': 4}
```
Options:
- A. fruits.get(apples)
- B. fruits.get(apples,0)
- C. fruits.get('apple')
- D. fruits.get('apples',0)
  
**Answer:** D. fruits.get('apples', 0)

#### 9. What is printed by the following statements?
```python
s = "ball"
r = ""
for item in s:
    r = item.upper() + r
print(r)
```
Options:
- A. Ball
- B. BALL
- C. LLAB
- D. TypeError
  
**Answer:** C. LLAB

#### 10. Which type of loop can be used to perform the following iteration: You choose a positive integer at random and then print the numbers from 1 up to and including the selected integer.

Options:
- A. Only FOR-loop
- B. Only WHILE-loop
- C. FOR and/or WHILE loops
- D. NONE

**Answer:** C. FOR and/or WHILE loops

#### 11. What will the following code print?
```python
for i in range(1, 4):
    for j in range(1, 4):
        print(i, j, end=" ")
```
Options:
- A. 112233
- B. 123123123
- C. 11213121 22 23
Transcribed Image Text:### Coding Quiz #### 6. What is printed by the following when executed? ```python str = "His shirt is red" pos = str.find("is") print(pos) ``` Options: - A. 9 - B. 2 - C. pos - D. 1 **Answer:** B. 2 #### 7. What is the value of `s1` after the following code executes? ```python s1 = "heY" s1 = s1.capitalize() s1.lower() ``` Options: - A. heY - B. Hey - C. hey - D. HEY **Answer:** B. Hey #### 8. Which line of code correctly gets the value of the key 'apples' if it exists and returns 0 if it does not? ```python fruits = {'bananas': 7, 'apples': 4, 'grapes': 19, 'pears': 4} ``` Options: - A. fruits.get(apples) - B. fruits.get(apples,0) - C. fruits.get('apple') - D. fruits.get('apples',0) **Answer:** D. fruits.get('apples', 0) #### 9. What is printed by the following statements? ```python s = "ball" r = "" for item in s: r = item.upper() + r print(r) ``` Options: - A. Ball - B. BALL - C. LLAB - D. TypeError **Answer:** C. LLAB #### 10. Which type of loop can be used to perform the following iteration: You choose a positive integer at random and then print the numbers from 1 up to and including the selected integer. Options: - A. Only FOR-loop - B. Only WHILE-loop - C. FOR and/or WHILE loops - D. NONE **Answer:** C. FOR and/or WHILE loops #### 11. What will the following code print? ```python for i in range(1, 4): for j in range(1, 4): print(i, j, end=" ") ``` Options: - A. 112233 - B. 123123123 - C. 11213121 22 23
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Control Structure
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education