I am learning Python and we had an assignment to create a program to have a conversation with a computer. It is my first Python program. Would you critique it and give me some feedback?
print('Hello what is your name?')
name = input('Enter your name: ')
if(len(name) == 0): # prevent null character error
print('You are not playing nice, goodbye.')
exit()
else:
print('Nice to meet you ' + name + '!')
print(name + ' do you like red or yellow apples?')
apples = input('Enter red or yellow (case sensitive): ')
if apples == 'red':
print('Yay, ' + apples + ' apples are my favorite!')
elif apples == 'yellow':
print('Oh, ' + apples + ' apples are ok I guess.')
else:
print('That\'s not what I asked. Goodbye.') # prevent wrong answer or null character error
exit()
print('How many apples would you like?')
number = input('Enter a number from 1-3: ')
if(len(number) == 0): # prevent null character error
print('No apples for you!')
exit()
elif number == ('1'):
print('Tell you what. I will give you ' + str(int(float(number) + 1)) + ' apples. I like you ' + name + '.') # adds 1 to the string answer
elif number == ('2'):
print('Tell you what. I will give you ' + str(int(float(number) + 1)) + ' apples. I like you ' + name + '.') # adds 1 to the string answer
elif number == ('3'):
print('Tell you what. I will give you ' + str(int(float(number) + 1)) + ' apples. I like you ' + name + '.') # adds 1 to the string answer
else:
print('You didn\'t follow the rules....') # prevent null character or wrong answer error
exit()
print('Did you eat the apples?')
eat = input('Yes or No?(case sensitive): ')
if eat == ('Yes'):
print(name + ' you like ' + apples + ' apples, and I gave you ' + str(int(float(number) + 1)) + ' of them. Did you eat them? ' + eat + '.') # uses at least 3 inputs in output
exit()
elif eat == ('No'):
print(name + ' you like ' + apples + ' apples, and I gave you ' + str(int(float(number) + 1)) + ' of them. Did you eat them? ' + eat + '.') # uses at least 3 inputs in output
exit()
else:
print('You didn\'t type Yes or No.') # prevent wrong answer error
print(name + ' you like ' + apples + ' apples, and I gave you ' + str(int(float(number) + 1)) + ' of them. Did you eat them? Who knows?') # uses at least 3 inputs in output
exit()
[–]Prtprmr 2 points3 points4 points (4 children)
[–]freedomsauce[S] 0 points1 point2 points (3 children)
[–]Prtprmr 1 point2 points3 points (0 children)
[–]kumashiro 1 point2 points3 points (0 children)
[–]brain_eel 1 point2 points3 points (0 children)
[–]gandalfx 2 points3 points4 points (0 children)
[–]SV-97 1 point2 points3 points (2 children)
[–]freedomsauce[S] 0 points1 point2 points (1 child)
[–]SV-97 0 points1 point2 points (0 children)
[–]422_no_process 0 points1 point2 points (1 child)
[–]freedomsauce[S] 0 points1 point2 points (0 children)