Respuesta :
Answer:
G i v e s e v e r a l r e a s o n s w h y P y t h o n i s s u c h a gr e a t p r o g r a m m i n g l a n g u a g e. E x p l a i n h o w P y t h o n i s r e l a t e d t o f l o w c h a r t s.
P y t h o n i s s u c h a g r e a t p r o g r a m m i n g l a n g u a g e b e c a u s e i t i s s i m p l e, p o p u l a r, a n d p o w e r f u l e n o u g h t o c r e a t e s o m e a w e s o m e a p p s. P y t h o n i s r e l a t e d t o f l o w c h a r t s b e c a u s e F l o w c h a r t P y t h o n i s e s s e n t i a l l y t h e P y t h o n p r o g r a m m i n g l a n g u a g e i n v i s u a l f o r m.
C o n s i d e r t h i s p r o g r a m :
C o s t 1 = i n p u t ( " P l e a s e e n t e r t h e f i r s t e x p e n s e : " )
C o s t 2 = i n p u t ( " P l e a s e e n t e r t h e s e c o n d e x p e n se: ")
p r i n t ( " Y o u r t o t a l f o r b o t h e x p e n s e s w a s " , C o s t 1 + C o s t 2 )
I f t h e u s e r i n p u t s “ 1 0 ” f o r t h e f i r s t e x p e n s e a n d “ 2 0 ” f o r t h e s e c o n d e x p e n s e , w h a t w i l l t h e i n t e r p r e t e r s h o w i n t h e f i n a l l i n e w h e n t h i s p r o g r a m i s r u n ? I f t h i s r e s u l t i n n o t w h a t t h e p r o g r a m m e r i n t e n d e d , h o w w o u l d y o u e x p l a i n w h a t w e n t w r o n g ?
Y o u a r e w r i t i n g a l i n e o f c o d e t h a t s h o u l d a s k t h e u s e r t o i n p u t t h e b a l a n c e o f t h e i r b a n k a c c o u n t i n d o l l a r s a n d c e n t s . T h e p r o g r a m w i l l t h e n p e r f o r m a m u l t i p l i c a t i o n p r o b l e m t o t e l l t h e u s e r h o w m u c h i n t e r e s t t h e y c a n e a r n . I d e n t i f y t h r e e e r r o r s i n y o u r l i n e o f i n p u t c o d e a n d e x p l a i n w h y t h e y a r e i n c o r r e c t . I n c l u d e t h e c o r r e c t e d l i n e o f c o d e i n y o u r a n s w e r . H e r e i s t h e c o d e :
T h e f i r s t e r r o r i s t h a t t h e v a r i a b l e s t a r t s w i t h a n u m b e r , w h i c h i s a r u l e y o u c a n ’ t b r e a k , o r e l s e t h e c o m p u t e r w o n ’ t k n o w t h a t i t ’ s a v a r i a b l e . T h e n e x t e r r o r i s t h a t t h e y d i d n ’ t d e c l a r e t h e v a r i a b l e a s a f l o a t . T h e f i n a l e r r o r i s t h a t t h e r e a r e n o q u o t a t i o n m a r k s i n t h e p a r e n t h e s e s , w h i c h a r e n e e d e d t o t e l l t h e c o m p u t e r t o o u t p u t t h a t o u t t o t h e s c r e e n , o r e l s e i t s g o i n g t o t h i n k t h a t y o u w a n t t h e c o m p u t e r t o f i l l t h a t i n i t s e l f .
1 n u m = input(What is your balance?)
What are some kinds of comments that might be useful for a programmer to include in a program?
some kinds of comments that might be useful is when there is a bug, something that needs to be fixed, something that is easy to hack, and something the programmer needs to finish if the programmer released the program early.
If you were planning how to write a program, at what point would a flowchart be helpful? At what point would p s e u d o c o d e be helpful? Explain your reasoning.
A flowchart is helpful in the beginning of writing a program when you are planning what to do. The p s e u d o c o d e would be helpful before you start the coding. The reason is because flowcharts are helpful for planning out your course of action, while pseudocode helps you plan what you are going to write, so it should be right before you start coding, so you know everything that you were thinking about whilst writing the p s e u d o c o d e , and you know that if one thing doesn’t work, you still have all the previous thoughts on that line.
Explanation:
I have the same text questions so I don't want to get anything wrong. I also want to be a developer of M i n e c r a f t , so I pay attention in my coding class.