[Python Programming Basics to Advanced]: Relational, Logical Operators Short-Circuiting | Lab -5 P-1

preview_player
Показать описание
This Python programming playlist is designed to take beginners with zero programming experience to an expert level. The course covers installation, basic syntax, practical scenarios, and efficient logic building. The course material includes PDF handouts, review questions, and covers a wide range of topics, from data types to advanced functions like Lambda and Recursive functions, Generators, and JSON data parsing.

In this lesson we will study relational operators, logical operators and short circuiting. We will discus about Boolean data type.

We will use the conditions discussed in this lesson in IF statement, which we will start from next lesson.

Complete Playlist:

If you have the basic programming knowledge and interested to learn Object-Oriented Programming in Python, check out this playlist:

Lab Manual 05 can be downloaded from here:

Review Questions:
1- Suppose variable x is holding a positive integer. I am interested to see if that integer is multiple of 4 or not.
Write a relational/logical statement that should print TRUE if the number is multiple of 4, and FALSE if not.

2- Again a variable x has an integer value. I am interested to see if the unit and the tenth digit of the number is same or not.
Write a relational/logical statement that should print TRUE if it is the case and FALSE otherwise.

#PythonProgramming #python #pythontutorial
Рекомендации по теме
Комментарии
Автор

#Question1
x=eval(input("Enter a positive integer: "))
y=x%4==0
print(f'The entered number is multiple of 4 is \'{y}\'')
#Question2
a=eval(input('Enter a positive integer: '))
b=a%10
c=(a//10)%10
z=b==c
print(f'The statement: Unit & Tenth digit of entered number is same is \'{z}\'')

shaheerahmadkhan
Автор

question no 1:
num = int(input("enetr a number :"))
check = num % 4 ==0
print(check)


Question no 2 :
x =int(input("enter a number :"))
a = x % 10
b = (x//10)%10
check = a==b
print(check)

usmantariq
Автор

question 1:
x=int(input('Enter a positive integer: '))
n=x%4==0
print(f'Given integer is the multiple of 4 is {n}')

question 2:
x=int(input('Enter a positive integer: '))
m=x%10
n=(x//10)%10
r=m==n
print(f'the unit and the tenth digit of the number are {m} and {n} \nSo the statement they are equal is {r}')

noorulhuda
Автор

Q-01:
x=eval(input("Enter a positive integer: "))
y=x%4
z=y==0
print(f"The statement that {x} is a multiple of 4 is {z}")
Q-02:
x=eval(input("Enter a positive integer: "))
y=x%10
z=(x//10)%10
N=y==z
print(f"The statement that is unit {y} and the tenth digit {z} of {x} are equal is {N}")

nukhbaiqbal
Автор

Q1):-
x=int(input('Please enter a positive integer: '))
a=x%4==0
print(f'The statement \'The number is multiple of 4\' is {a}')
Q2):-
x=int(input('Please enter an Integer: '))
a=x%10
b=(x//10)%10
c=a==b
print(f'The unit digit and tens digit are {a} and {b} respectively\nSo the statement \'They are equal\' is {c}')

abdul-hadi
Автор

Question:1
x=eval(input('Enter a positive integer= '))
y=x%4==0
print(y)
Question:2
x=eval(input('Enter a positive integer= '))
y=x%10
z=x%100
a=y==z
print(a)

SafiUllah-kgku
Автор

Q1:
x=eval(input("Enter positive integer"))
u=x%4
print(u==False)
Q2:
x=eval(input("Enter positive integer"))
h=x%100
j=x%10
y=h==j
print(y)

maleehasyed
Автор

A1:
x=eval(input("enter a positive integer:"))
y=x%4==0
print(f"entered integer is the multiple of 4 is{y})")
A2:
x=eval(input("enter a positive integer:"))
y=x%10
z=x%100
M=y==z
print(f"the statement that the unit and tenth of the number is equal is {M}")

shahwarsadaqat
Автор

Q1:
x=int(input('Enter a positive integer: '))
y=x%4==0
print(f'Given integer is the multiple of 4 is {y}')

Q2:
x=int(input('Enter a positive integer: '))
p=x%10
q=(x//10)%10
y=p==q
print(f'The Unit and the Tenth Digit of the number are {p} and {q} \nSo the statement they are equal is {y}')

MuhammadTalha-xmul
Автор

Question 1
y=int(input('Enter a positive integer:'))
b=y/4
Print (b==int(b))


Question 2
y=eval(input('Enter an integer:'))
g=y%10
x=y%100
b=int(x/10)
Print (b==g

zohaibkhalid
Автор

ANS1:
x=int(input("Enter a +ve integer: "))
a=x%4==False
print(a) #result is true if entered number is multiple of 4

ANS2:
x=int(input("Enter any integer: "))

a=x%10 #it gives unit digit
b=int((x%100)/10) #this gives 10th digit
d=a==b #or we can direct use print(a==b)
print(d) # true when unit and 10th digit is same

abdurrehmansarwar
Автор

Q1): x=int(input("Enter a positive integer:"))
print(x%4==0)

Q2): x=int(input("Enter an integer:"))
print(x%10==x//10)

MuhammadAhmad-dshu
Автор

P1:
x=eval(input("enter a positive integer:"))
y=x%4==0
print(f"entered integer is the multiple of 4 is{y})")
P2:
x=eval(input("enter a positive integer:"))
y=x%10
z=x%100
M=y==z
print(f"the statement that the unit and tenth of the number is equal is {M}")

dawood
Автор

Answer 1:
x = int(input('Enter a positive integer: '))
a = x/4
print(a==int(a))

Answer 2:
x = eval(input('Enter an integer: '))
b = x%10
y = x%100
a = int(y/10)
print(a==b)

ahmedimran
Автор

I) a=eval(input("Enter a positive interger : "))
b=a%4
print(f'The number is multiple of 4 is {a==0}')

II) m=eval(input("Enter a positive interger : "))
n=m%10
x=(m//10) % 10
print (f'The statement is {x==n}')

haris
Автор

Que: 1
z=eval(input('Enter a positive integer: '))
b=z%4==0
print(f'The statement of entered integer is multiple of 4 is: {b}')

Que: 2
c=eval(input('Enter an integer: '))
y=c%10
z=(c//10)%10
u=y==z
print(f'The statement of equality of unit digit and tenth digit is: {u}')

ahmadlatif
Автор

Q1=
x=int(input('Enter a positive integer: '))
y=x%4==0
print(f'Given integer is the multiple of 4 is {y}')

Q2=
x=int(input('Enter a positive integer: '))
p=x%10
q=(x//10)%10
y=p==q
print(f'The Unit and the Tenth Digit of the number are {p} and {q} \nSo the statement they are equal is {y}')

asmaabhatti
Автор

1-
a=int(input("Enter a Positive Integer:"))
print(a%4==0)

2-
x=int(input("Enter at least 2 digit number:"))
print(x%10==(x//10)%10)

fourcloversan
Автор

Unique video on Relational nd logical operators...easy to understand...keep on uploading more...thank u

Astromoola
Автор

Ans 1:
x=eval(input("Enter a positive interger : "))
y=x%4
print(f'The number is multiple of 4 is {y==0}')

Ans 2:
x=eval(input("Enter a positive interger : "))
y=x%10
z=(x//10) % 10
print (f'The statement is {z==y}')

hamzaubaid