{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "###
San Jose State University
Department of Applied Data Science

**DATA 200
Computational Programming for Data Analytics**

Spring 2023
Instructor: Ron Mak
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 3.16 Boolean Operators `and`, `or` and `not` " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### We use the conditional operators `==`, `!=`, `<`, `<=`, `>`, and `>=` to form simple condition expressions such as `score >= 90`. **Boolean operators** `and`, `or`, and `not` allow us to form more complex conditional expressions." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Boolean Operator `and`" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "gender = 'Female'" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "age = 70" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "if gender == 'Female' and age >= 65:\n", " print('Senior female')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Redundant parentheses help clarify the `if` statement for human readers:\n", "####
`if (gender == 'Female) and (age >= 65):`