Python

Python

University

5 Qs

quiz-placeholder

Similar activities

Untitled Quiz

Untitled Quiz

8th Grade - University

6 Qs

exception

exception

University

10 Qs

หลักการเขียนโปรแกรม

หลักการเขียนโปรแกรม

University

10 Qs

Pyflask2020

Pyflask2020

KG - Professional Development

10 Qs

Python debugging

Python debugging

University

10 Qs

Tuples and set

Tuples and set

University

10 Qs

for loops & while loops

for loops & while loops

University - Professional Development

10 Qs

Techno India University Python Quiz Contest

Techno India University Python Quiz Contest

University

10 Qs

Python

Python

Assessment

Quiz

Computers

University

Medium

Created by

Mohamed Ibrahim

Used 6+ times

FREE Resource

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

A program to print every character of a string entered by user in a new line using loop.

Choose the correct answer

a = raw_input()

for a in i:

print i

a = string_input()

for i in a:

print i

a = string_input()

for i in a:

print a

a = raw_input()

for i in a:

print i

2.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Choose the correct answer:

A program to find the length of the string "refrigerator" without using len function.

a = "refrigerator"

count = 1

for i in a:

count = count+1

print count

a = "refrigerator"

count = 0

for i in a:

count = count+1

print count

a = "refrigerator"

for i in a:

count = 0

count = count+1

print count

a = "refrigerator"

count = 1

for i in a:

count = count+a[i]

print count

3.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Choose the correct answer:

A program to check if the word 'orange' is present in the "This is orange juice".

a = "This is orange juice"

print 'orange' in a

a = "This is orange juice"

print 'Orange' in a.split()

a = "This is orange juice"

print 'orange' in a.split()

a = "This is orange juice"

print 'orange' is a.split()

4.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

What is the output for the following code:

def char_frequency(str1):

dict = {}

for n in str1:

keys = dict.keys()

if n in keys:

dict[n] += 1

else:

dict[n] = 1

return dict

print(char_frequency('google.com'))

{'o': 0, '.': 1, 'g': 2, 'l': 1, 'e': 1, 'c': 2, 'm': 0}

{'o': 5, '.': 1, 'g': 2, 'l': 1, 'e': 1, 'c': 2, 'm': 1}

{'o': 3, '.': 1, 'g': 2, 'l': 1, 'e': 1, 'c': 0, 'm': 0}

{'o': 3, '.': 1, 'g': 2, 'l': 1, 'e': 1, 'c': 1, 'm': 1}

5.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Given your function, what is the correct output:

def chars_mix_up(a, b):

new_a = b[:2] + a[2:]

new_b = a[:2] + b[2:]


return new_a + ' ' + new_b

print(chars_mix_up('abc', 'xyz'))

Sample String : 'abc', 'xyz'

Expected Result : 'xyc abz'

Sample String : 'abc', 'xyz'

Expected Result : 'xbc ayz'

Sample String : 'abc', 'xyz'

Expected Result : 'xyc abc'

Sample String : 'abc', 'xyz'

Expected Result : 'ayc xbz'