Which one of these is NOT allowed as a key in a dictionary?
Anonymous Quiz
21%
integer
14%
String
50%
Tuple
14%
List
❤2
Which method returns all key-value pairs in a dictionary?
Anonymous Quiz
32%
.Values()
18%
.get()
25%
.items()
25%
.keys()
❤1
What will this code output?
info = {"name": "Alex", "age": 25} info["city"] = "New York" print("info")
info = {"name": "Alex", "age": 25} info["city"] = "New York" print("info")
Anonymous Quiz
35%
{'name': 'Alex', 'age': 25, 'city': 'New York'}
26%
{'city': 'New York'}
21%
info
18%
Error
❤1
What will be the output of this code ?
s = {1,2,3,2,4}
print(len(s))
s = {1,2,3,2,4}
print(len(s))
Anonymous Quiz
66%
5
26%
4
6%
3
3%
2
❤1
Today, Let’s move on to the next topic in the Python Coding Challenge:
🔹Day 6: Conditionals (if, elif, else)
In Python, conditional statements allow your code to make decisions.
💡 What Are Conditionals?
They help your program execute certain code blocks only when specific conditions are true.
✅ Syntax :
if condition:
# Code runs if condition is True
elif another_condition:
# Runs if previous conditions were False, this one is True
else:
# Runs if none of the above conditions are True
🧠 Example :
age = 18
if age >= 18:
print("You’re an adult.")
elif age > 13:
print("You’re a teenager.")
else:
print("You’re a child.")
Output:
You’re an adult.
🎯 Mini Project: Guess the Number Game
Let’s build a small game using what we’ve learned so far:
Python Code
import random
number = random.randint(1, 10)
guess = int(input("Guess a number between 1 and 10: "))
if guess == number:
print("🎉 Correct! You guessed it right.")
elif guess < number:
print("Too low! Try again.")
else:
print("Too high! Try again.")
print(f"The correct number was: {number}")
This project uses:
- if, elif, else
- User input
- Random module
React with ❤️ once you’re ready for the quiz
🔹Day 6: Conditionals (if, elif, else)
In Python, conditional statements allow your code to make decisions.
💡 What Are Conditionals?
They help your program execute certain code blocks only when specific conditions are true.
✅ Syntax :
if condition:
# Code runs if condition is True
elif another_condition:
# Runs if previous conditions were False, this one is True
else:
# Runs if none of the above conditions are True
🧠 Example :
age = 18
if age >= 18:
print("You’re an adult.")
elif age > 13:
print("You’re a teenager.")
else:
print("You’re a child.")
Output:
You’re an adult.
🎯 Mini Project: Guess the Number Game
Let’s build a small game using what we’ve learned so far:
Python Code
import random
number = random.randint(1, 10)
guess = int(input("Guess a number between 1 and 10: "))
if guess == number:
print("🎉 Correct! You guessed it right.")
elif guess < number:
print("Too low! Try again.")
else:
print("Too high! Try again.")
print(f"The correct number was: {number}")
This project uses:
- if, elif, else
- User input
- Random module
React with ❤️ once you’re ready for the quiz
❤3