Python Crash Course Section 5 If Statements

Publicado em: 20 Junho 2022
no canal de: Cybersecurity Striker
66
like

You tube limits how much code I could put in the Description
Follow my github for all the code
https://github.com/C0deDefense/Python...

#################Part 1
#If statements
#simply we have take input and ran it through a loop
#now we will utilize if statements to set a conditional test
#if a condition is met perform these actions

#if test
#What if we had a list of brands
#if the brand is GAP we want all letters in the name to be captilized

brandslist = ['Nike','Adidas','Gap']
for brand in brandslist:
if brand == 'Gap':
print(brand.upper())
else:
print(brand.title())
#The loop checks if the item matchs Gap if so it performs an action

################End Part 1

################Part 2

#Conditional test
We could set a conditional test
if the value matchs a certain character the boolean value will be set to true or false

brand = "Nike" #here we are saying set the brand variable to Nike
print(brand == 'Nike') #Here we are asking does the brand equal nike? see == and ?
#returns true if the brand is Nike and false otherwise
##################end Part 2

#################Part 3
#Case matters Tie fighter in python doesn't equal tie fighter due to the lower case
fighter = 'Tie fighter'
print(fighter == 'tie fighter')
#################end Part 3

#################Part 4
#you could run the variable through a lower() method
#we take the value Tie fighter and run it throught the lower method
#the lower method will lower case the Tie to tie fighter
#this will cause the two to become equal
fighter = 'Tie fighter'
print(fighter.lower() == 'tie fighter')
################### END Part 4

##################Part 5
#Here
#fighter = 'Tie fighter'
#print(fighter.lower() == 'tie fighter') we checked if the value stored in the fighter value is
#equal to the 'tie fighter' if so prints true

#now print the ships variable does it change
#no the value is not altered. The lower() doesn't change the original value
fighter = 'Tie fighter'
print(fighter.lower() == 'tie fighter')
print(fighter)
#################END Part 5


Nesta página do site você pode assistir ao vídeo on-line Python Crash Course Section 5 If Statements duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Cybersecurity Striker 20 Junho 2022, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 66 vezes e gostou like espectadores. Boa visualização!