Boolean logic is used to make more complicated conditions for if



Download 186,79 Kb.
Sana10.09.2021
Hajmi186,79 Kb.
#170468
Bog'liq
py


from math import*


num = 7
if num > 3:
print("3")
if num < 5:
print("5")
if num ==7:
print("7")

answer=3


Boolean logic is used to make more complicated conditions for if statements that rely on more than one condition.
Python's Boolean operators are andor, and not.
The and operator takes two arguments, and evaluates as True if, and only if, both of its arguments are True. Otherwise, it evaluates to False.

age = 15
money = 500
if age > 18



money > 100:


("Welcome")

from math import*


if not True:
print("1")
elif not (1 + 1 == 3):
print("2")
else:
print("3")

import random


import sys
import os
nums = [9, 8, 7, 6, 5]
nums.append(4)
nums.insert(2, 11)
print(len(nums))

=> 7


max(list): Returns the list item with the maximum value
min(list): Returns the list item with minimum value
list.count(item): Returns a count of how many times an item occurs in a list
list.remove(item): Removes an object from a list
list.reverse(): Reverses items in a list.

i = 1
while i <=8:


print(i)
i = i + 1

print("Finished!")

str (x) x sonini satrga aylantirish uchun ishlatiladi, shunda u biriktirish uchun ishlatilishi mumkin.

i = 0


while 1==1:

    print(i)

    i = i + 1

    if i >= 5:

        print("Breaking")

        break


print("Finished")

import random


import sys
import os
i = 5
while True:
print(i)
i = i - 1
if i <= 2:
break

i = 0


while True:

    i = i +1

    if i == 2:

        print("Skipping 2")

        continue

    if i == 5:

        print("Breaking")

        break

    print(i)
print("Finished")

words = ["hello", "world", "spam", "eggs"]

for word in words:

    print(word + "!")



import random


import sys
import os
numbers = list(range(5, 20, 2))
print(numbers)

import random


import sys
import os
nums = list(range(3, 15, 3))
print(nums[2])

import random


import sys
import os
list = [1, 1, 2, 3, 5, 8, 13]
print(list[list[4]]

for i in range(10):

if not i % 2 == 0:

print(i+1)

import random


import sys
import os
n = int(input())

for x in range(1, n):


if x % 3 == 0 and x % 5 == 0:
print("SoloLearn")
break
elif x % 3 == 0:
print("Solo")
continue
elif x % 5 == 0:
print("Learn")
else:
print(x)
Download 186,79 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish