Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 515e0f7

Browse files
author
Amogh Singhal
authored
Update Python_Programming_Quiz.md
1 parent c842d03 commit 515e0f7

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

‎Python_Programming_Quiz.md‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,3 +335,40 @@ Because in the try block we got a __DivisionByZeroException__ and not ValueError
335335
# 1 C++
336336
# 2 Scala
337337
```
338+
#### 18. Evaluate the output of the last line in the following code snippet.
339+
```
340+
>>> A0= dict(zip(('a','b','c','d','e'),(1,2,3,4,5)))
341+
>>> A1= range(10)
342+
>>> A2= sorted([i for i in A1 if i in A0])
343+
>>> A3= sorted([A0[s] for s in A0])
344+
>>> A4= [i for i in A1 if i in A3]
345+
>>> A5= {i:i*i for i in A1}
346+
>>> A6= [[i,i*i] for i in A1]
347+
>>> A0,A1,A2,A3,A4,A5,A6
348+
```
349+
350+
#### 19. Implement a switch case function using Python.
351+
352+
#### 20. Write a program in Python to count the number of capital letter in a file.
353+
354+
```
355+
import os
356+
357+
dir_path = "C:\Users1090円\"
358+
filename = "blob.txt"
359+
360+
# change working directory to dir_path
361+
os.chdir(dir_path)
362+
363+
# open the file
364+
with open(filename) as f:
365+
cap_count = 0
366+
# read all characters of the file
367+
for char in f.read():
368+
if char.isupper():
369+
cap_count += 1
370+
371+
print(cap_count)
372+
for word in
373+
```
374+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /