Learn Python MEMBERSHIP OPERATORS in 8 minutes! 🔎
#python #pythontutorial #pythonprogramming
# Membership operators = used to test whether a value or variable is found in a sequence
# (string, list, tuple, set, or dictionary)
# 1. in
# 2. not in
# --------------------
# EXAMPLE 1
# --------------------
word = "APPLE"
letter = input("Guess a letter in the secret word: ")
if letter in word:
print(f"There is a {letter}")
else:
print(f"{letter} was not found")
# --------------------
# EXAMPLE 2
# --------------------
students = {"Spongebob", "Patrick", "Sandy"}
student = input("Enter the name of a student: ")
if student in students:
print(f"{student} is in this class")
else:
print(f"{student} is NOT in this class")
# --------------------
# EXAMPLE 3
# --------------------
grades = {
"Sandy": 'A',
"Squidward": 'B',
"Spongebob": 'C',
"Patrick": 'D'
}
student = input("Enter the name of a student: ")
if student in grades:
print(f"{student}'s grade is {grades[student]}.")
else:
print(f"{student} is not in the dictionary")
# --------------------
# EXAMPLE 4
# --------------------
email = "BroCode@gmail.com"
if "@" in email and "." in email:
print("Valid email")
else:
print("Invalid email")
Видео Learn Python MEMBERSHIP OPERATORS in 8 minutes! 🔎 канала Bro Code
# Membership operators = used to test whether a value or variable is found in a sequence
# (string, list, tuple, set, or dictionary)
# 1. in
# 2. not in
# --------------------
# EXAMPLE 1
# --------------------
word = "APPLE"
letter = input("Guess a letter in the secret word: ")
if letter in word:
print(f"There is a {letter}")
else:
print(f"{letter} was not found")
# --------------------
# EXAMPLE 2
# --------------------
students = {"Spongebob", "Patrick", "Sandy"}
student = input("Enter the name of a student: ")
if student in students:
print(f"{student} is in this class")
else:
print(f"{student} is NOT in this class")
# --------------------
# EXAMPLE 3
# --------------------
grades = {
"Sandy": 'A',
"Squidward": 'B',
"Spongebob": 'C',
"Patrick": 'D'
}
student = input("Enter the name of a student: ")
if student in grades:
print(f"{student}'s grade is {grades[student]}.")
else:
print(f"{student} is not in the dictionary")
# --------------------
# EXAMPLE 4
# --------------------
email = "BroCode@gmail.com"
if "@" in email and "." in email:
print("Valid email")
else:
print("Invalid email")
Видео Learn Python MEMBERSHIP OPERATORS in 8 minutes! 🔎 канала Bro Code
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
![What are logical operators? 🔣](https://i.ytimg.com/vi/UiF-QgCBOhM/default.jpg)
![Python timer ⏲️](https://i.ytimg.com/vi/ZMAvHHNZ7vw/default.jpg)
![Learn Python CLASS METHODS in 6 minutes! 🏫](https://i.ytimg.com/vi/g-qRKZD3FgE/default.jpg)
![What is a switch? 🔀](https://i.ytimg.com/vi/Bx9b12FCF5o/default.jpg)
![Learn Python ITERABLES in 6 minutes! 📃](https://i.ytimg.com/vi/VL_g3LjsFqs/default.jpg)
![C# method overloading 🤯](https://i.ytimg.com/vi/LjRyW-W4uDs/default.jpg)
![Python default arguments are awesome! 👍](https://i.ytimg.com/vi/m2uURZxex3c/default.jpg)
![Python filter 🍺](https://i.ytimg.com/vi/zwVywypN8LY/default.jpg)
![C reading files 🔎](https://i.ytimg.com/vi/Hzg3kCHJcxI/default.jpg)
![Python *args 📦](https://i.ytimg.com/vi/MNLy8atLI3k/default.jpg)
![What is the ternary operator ❓](https://i.ytimg.com/vi/dWsjatPhWHQ/default.jpg)
![Java final keyword ⛔](https://i.ytimg.com/vi/DezKSLQ0-ls/default.jpg)
![C typedef 📛](https://i.ytimg.com/vi/CI9dRTvzgqE/default.jpg)
![Python concession stand program 🍿](https://i.ytimg.com/vi/PbkIzW_70EI/default.jpg)
![Learn CSS pseudo classes in 5 minutes 👨👧👦](https://i.ytimg.com/vi/fWnXVwULqrE/default.jpg)
![Python multiple assignment 🔠](https://i.ytimg.com/vi/W9VOiVkUazA/default.jpg)
![MySQL: ON DELETE](https://i.ytimg.com/vi/vANfY96ccOY/default.jpg)
![MySQL ORDER BY clause is easy](https://i.ytimg.com/vi/R-5F3BF8IeY/default.jpg)
![Python GUI radiobuttons 🔘](https://i.ytimg.com/vi/5IVvj99yxsc/default.jpg)
![What are data structures and algorithms? 📈](https://i.ytimg.com/vi/xX5iOYCJmBI/default.jpg)