-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhw5.py
More file actions
47 lines (39 loc) · 1.35 KB
/
Copy pathhw5.py
File metadata and controls
47 lines (39 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'''Logical Operator Practice: Write a Python program that takes two numbers as input from the user and checks if:
'''
'''Both numbers are greater than 10 (using and).
At least one of the numbers is less than 5 (using or).
The first number is not greater than the second (using not).
'''
num1=int(input("enter num1: "))
num2=int(input("enter num2: "))
print((num1>10)and(num2>10))
print((num1<5)and(num2<5))
print(not(num2>10))
'''Comparison Operator Challenge: Create a Python program that asks the user for their age and prints:
"You are an adult" if the age is greater than or equal to 18.
"You are a minor" if the age is less than 18.
Use >= and < comparison operators.'''
age=int(input("enter your age>> "))
if age>=18:
print("you are adult")
if age<18:
print("you are minor")
'''Takes a string as input from the user.
Checks if the letter 'a' is in the string (using in).
Checks if the string doesn't contain the word "Python" (using not in).
'''
x=input("enter a string: ")
if "a" in x:
print("a is present in string")
else:
print("a is not in the string")
if "python" in x:
print("python is in the string")
else:
print("python is not in the string" )
"""Bitwise Operator Task: Given two integers, write a Python program that:
Prints the result of a & b, a | b"""
a=3 #011
b=2 #010
print(a&b) #010
print(a|b) #011