<jupyter_start><jupyter_text>Q1.What are the two values of the Boolean data type? How do you write them? Ans).The two values of Boolean data type are True and False and we write them asa = Truetype(a)b = Falsetype(b) Q2. What are the three different types of Boolean operators? Ans) and, or, not are the three different type of boolean operators Q3. Make a list of each Boolean operator's truth tables (i.e. every possible combination of Boolean values for the operator and what it evaluate ). Ans) i)   ANDA      B             AND resultTrue  True             TrueTrue  False           FalseFalse True            FalseFalse False           False  ii)  ORA        B             OR resultTrue   True             TrueTrue   False            TrueFalse  True             TrueFalse  False            False iii) NOTLogical NOT operator works with the single boolean value and returns the value as True if the boolean value is False and vice-versa (that is the opposite of it).  It is a unary operator, which means to return some value, it has to be operated on one operator only. (i.e, only operator is required)<jupyter_code># Example
x = 4
y = 5
x is not y<jupyter_output><empty_output><jupyter_text>Q4. What are the values of the following expressions?(5 > 4) and (3 == 5)not (5 > 4)(5 > 4) or (3 == 5)not ((5 > 4) or (3 == 5))(True and True) and (True == False)(not False) or (not True)<jupyter_code>Ans) 
(5 > 4) and (3 == 5) = False
not (5 > 4) = False
(5 > 4) or (3 == 5) = True
not ((5 > 4) or (3 == 5)) = False
(True and True) and (True == False) = False
(not False) or (not True) = True<jupyter_output><empty_output><jupyter_text>Q5. What are the six comparison operators?<jupyter_code>Ans) The 6 comarison Operators are
 comarison operator       Description/Meaning
 
a)        ==               is equals to
 

b)         >               is greater than

c)         >=              is greater than or equal to

d)          <              is lesser than

e)          <=             is lesser than or equal to

f)           !=            is not equal to<jupyter_output><empty_output><jupyter_text>Q6. How do you tell the difference between the equal to and assignment operators?Describe a condition and when you would use one. Ans)The “=” is an assignment operator is used to assign the value on the right to the variable on the left. The '==' operator checks whether the two given operands are equal or not. If so, it returns true.<jupyter_code>#Example of assignment operator

x = 5
y= 7

#Example of Equal operator

x == y<jupyter_output><empty_output><jupyter_text>Q7. Identify the three blocks in this code:spam = 0if spam == 10:print('eggs')if spam > 5:print('bacon')else:print('ham')print('spam')print('spam')<jupyter_code>spam = 0
if spam == 10:
    print('eggs')
elif spam > 5:
    print('bacon')
else:
    print('ham')
    print('spam')
    print('spam')<jupyter_output>ham
spam
spam<jupyter_text>Q8. Write code that prints Hello if 1 is stored in spam, prints Howdy if 2 is stored in spam, and prints Greetings! if anything else is stored in spam.<jupyter_code>spam = int(input("this is my input "))
if spam == 1:
    print('Hello')
    
elif spam == 2:
    print('howdy')
    
else:
    print('Greetings!')<jupyter_output>this is my input 5
Greetings!<jupyter_text>Q9.If your programme is stuck in an endless loop, what keys you’ll press? Ans) Ctrl+C 10. How can you tell the difference between break and continue? Break = 1)It eliminates the execution of remaining iteration of loop2) ‘break’ will resume control of program to the end of loop enclosing that ‘break’.3) It early terminates the loop4) The ‘break ‘stop the continuation of the loop.Continue = 1)It will terminate only the current iteration of loop.2) The ‘continue’ will resume the control of the program to next iteration of that loop enclosing ‘continue'3) It causes the early execution of the next iteration.4) The ‘continue’ does not stop the continuation of loop and it stops the current. Q11. In a for loop, what is the difference between range(10), range(0, 10), and range(0, 10, 1)?<jupyter_code>#Ans)
range(10)
for  i in range(0,10):
    print(i)
# Here 1 is the default step size
for  i in range(0,10,1):
    print(i)<jupyter_output>0
1
2
3
4
5
6
7
8
9<jupyter_text>Q12. Write a short program that prints the numbers 1 to 10 using a for loop. Then write an equivalent program that prints the numbers 1 to 10 using a while loop.<jupyter_code># For Loop, here I have taken 0,11 rang bcz we have to print from 1-10 so it will include 10 also
    
for i in range(1,11):
    print(i)   
# While loop

a = 1

while (a<=10):
    print(a)
    a+=1<jupyter_output>1
2
3
4
5
6
7
8
9
10
{'fraction_non_alphanumeric': 0.08595927116827438, 'fraction_numerical': 0.027867095391211148, 'mean_word_length': 3.226449275362319, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '518370', 'license': 'MIT', 'n_tokens_mistral': 1529, 'n_tokens_neox': 1431, 'n_words': 658, 'path': 'Assignment_2 Solutions.ipynb', 'repo_name': 'Heisenberg4u/Basic-Python-Assignment', 'size': '4665'}