Python Crash Course #6 - More on Functions

preview_player
Показать описание
In this Python crash course tutorial series, you'll learn all the basics of Python from the ground up.

🚀🥷🏼Get access to the Python Crash Course on Net Ninja Pro:

🔥🥷🏼 Access Premium Courses with a Net Ninja Pro subscription:

🔗🥷🏼 Check out Clear Code for more of his own tutorials:

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

def shouter (string = "default", number = 5):
if number > 10:
print("you are too loud")
else:
counter = 0
while counter < number:
print(string.upper())
counter += 1
return "done"

stuff = shouter("custom", 11)
print(stuff)

tubeasjay
Автор

Thanks a lot for this lesson. I got pretty confused in this tutorial but I’ll rewatch it again to understand better

collinsprecius
Автор

i came up with this

def shouter(string_para = 'string', number_para = 1):
counter = 0
while counter <= number_para:
if number_para > 10:
print('you are too loud')
break
else:
print(string_para.upper())
counter += 1
return 'done'
string', number_para=1))

nik
Автор

def shouter(string = 'Iam here', counter = 0):
while counter < 10:
print(string.upper())
counter += 1
else:
counter > 10
print('You are too loud!')
return 'Done'

test = shouter()
print(test)

trevor-marloy
Автор

Excellent concept explanation! Do you have any more advanced python courses? Or do you plan provide some in the near future???

gurudaki
Автор

I feel like i did something wrong. It works though? I think your instructions for the exercise need to be clearer.

# exercise
def shouter(a_string = (input("A STRING ").upper()) or "DEFAULT", a_number = int(input("A NUMBER ") or 5)):
counter = 0
if a_number > 10:
print('you are too loud')
else:
while counter < a_number:
print(counter, a_string)
counter += 1
return 'done'

test = shouter()
print(test)

Can you tell me what I did wrong?

TwoPluzzTwo
Автор

The solution I came up with:

loop_str = input("What do you want to shout?")
loop = int(input("How many times do you want to shout?"))

def shout(input1, input2):
if input2 > 9:
print("You are obnoxious!")
else:
counter = 0
while counter < input2:
print(input1.upper())
counter += 1
if True:
print(f"You've just shouted {input1} {input2} times!")

shout(loop_str, loop)

simondanielssonmusic
Автор

def shouter (word_shouted, shout_count):
counter = 1
if(shout_count > 10 ):
print('you are too loud')
exit()
while counter <= shout_count:
print(word_shouted.upper())
counter += 1
return print('DONE')


shouter('Fuck my life', 9)

saifallahahmad
Автор

Why would a `for loop` be more efficient? I would think that using `range(..)` to create a list would consume more memory and processing time verses using a `while loop` and incrementing a counter.

SwankyMarrow
Автор

after getting the error 'int' object isn't itarable i just jump to the while loop(before watch solution)🥴
my solu was like this...

def shouter(text, num):
if num<10:
counter = 0
while counter < num:
print(text.capitalize())
counter+=1
else:
print('you are too loud'.capitalize())
return 'done'

var = shouter('this is funcation exerices', 6)
print(var)

ashikulislamdev
Автор

A mathematician will go crazy with the result of 1.41 :DDDD

nibi
Автор

return 'done' doesn't print anything except you put return print('done')

loginet
welcome to shbcf.ru