CSC 1200 Lecture : python notes cmsc 201 (4)

9 views8 pages
2 Apr 2023
School
Course
Professor

Document Summary

Booleans represent one of two values: true or false. In programming you often need to know if an expression is true or false. You can evaluate any expression in python, and get one of two answers, When you compare two values, the expression is evaluated and python returns the boolean answer: Get your own python server print(10 > 9) print(10 == 9) print(10 < 9) When you run a condition in an if statement, python returns true or false: Print a message based on whether the condition is true or false: a = 200. = 33 if b > a: print("b is greater than a") else: print("b is not greater than a") The bool() function allows you to evaluate any value, and give you true or. Evaluate a string and a number: print(bool("hello")) print(bool(15)) Evaluate two variables: x = "hello" y = 15 print(bool(x)) print(bool(y)) Almost any value is evaluated to true if it has some sort of content.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents

Related Questions