Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Try to understand Boolean variables or expressions and the data type bool by writing a program for the following. a. Define a variable (var_a)

image text in transcribed
1. Try to understand Boolean variables or expressions and the data type bool by writing a program for the following. a. Define a variable (var_a) and assign 0 to it. What do you think will be displayed when you type bool(var_a)? Think aboit your answer before you type the expression. b. Assign to var_a, the value 4. What do you think will be displayed when you type bool(var_a)? Think about your answer before you type the expresion. c. Assign 34 to var_a. What do you think will be displayed when you type boollvar_al? Think about your answer before you type the expression. d. Assign 3.75 to var_a. What do you think will be dinplyyed when you type bool(var_a)? Think about your answer before you type the expression. e. Based on (a).(c), what are the Boolean values for zero, and non-sero numbers? f. Define three variables {x,y,z} and assign the values 2,5 and 30 to them, respectively. What do you think the following Boolean expressions will evaluate to? Using the print function. i. (15+x+y)>(z5) ii. x(x+4)z iv. (x2)=(y+5) v. (x2)y 2. Try to understand the if statement and if else (single and doal aternatives). a. Write a program that will prompt the user to enter a string and assign to variable astring. The program will display "Your" + astring + "did not match the hidden string" if astring does not match "Module" b. Write a progam that will prompt the user to enter a string and assign to variable astring. The program will display "Your" + astring + " matches the hidden string" if astring does matches "Module" c. Write a program that will prompt the user to two integess and assigh to variables aNum and bNum. The program will calculate and display the maimum of the two numbers. Do not use the built-in function, write you own function. d. Write a progam that will prompt the user to two integers and assign to variables aNum and bNum. The program will calculate and display the minimum of the two numbers. Do not use the built-in function, write you own function. e. Write a program that will prompt the user to enter a string representing the model of a car. If the string is " A " or " a ", the propram will display 51200 as the grice of the car, otherwise, display zero as the price. f. Write a function that will prompt the user to enter a string and assien to variable astring. The program will display "Your" + astring + "did not match the hidden string" if astring matches the string "Module" otherwise, the program will dinglay "Your" + string + "matches with the hidden string" g. Write a program that will prompt the user to enter two integen and assien to variables aNum and bNum. The program will display strf(aNum) + "is greater than " + str(bNum) if aNum is greater than bNum, otherwise, the program will diplay str(aNum) + " is less than

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

More Books

Students also viewed these Databases questions

Question

2. Should a disciplinary system be established at Carter Cleaning?

Answered: 1 week ago

Question

How will the members be held accountable?

Answered: 1 week ago

Question

a. Do team members trust each other?

Answered: 1 week ago