Question

Create a new program in Mu and save it as ps3.3.1.py and take the code below...

  1. Create a new program in Mu and save it as ps3.3.1.py and take the code below and fix it as indicated in the comments:

    mystery_int = 50
    
    # You may modify the lines of code above, but don't move them!
    # When you Submit your code, it should work with
    # different values for the variables.
    
    # Write a for loop that prints every third number from 1 to
    # mystery_int inclusive (meaning that if mystery_int is 7, it
    # prints 1, 4, and 7). Print each number on a separate line.
    #
    # Hint: There are multiple ways to do this! You might use the
    # modulus operators, or you could use the third argument for
    # range().
    
    # Add your code here!
  2. Create a new program in Mu and save it as ps3.3.2.py and take the code below and fix it as indicated in the comments:

    mystery_int = 50
    
    # You may modify the lines of code above, but don't move them!
    # When you Submit your code, it should work with 
    # different values for the variables.
    
    # Add some code below that will find and print the sum of
    # every odd number between 0 and mystery_int. This time,
    # exclude the bounds (e.g. if mystery_int was 51, add the odds
    # from 1 to 49, but not 51).
    #
    # Hint: There are multiple ways to do this!
    
    # Add your code here!
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program 1:

mystery_int = 50 #given number

for i in range(1, mystery_int+1, 3):#range works as of (start,stop,iteration)

print(i) #for printing line by line

Screenshot:

= >> RESTART: 3.1.py 1 4 7 10 13 16 mystery_int = 50 for i in range (1, mystery_int+1, 3): print (i) 19 22 25 28 31 34 37 40

program2:

mystery_int = 50
oddto=0# initialize to save odd

for i in range(1, mystery_int, 2):
oddto=oddto+i #to update sum of odd values for every iteration

print(oddto)

screenshot:

>>> mystery_int = 7 oddto=0# initialize to save odd = RESTART: 3.2.py 625 >>> for i in range (1, mystery_int, 2): oddto=oddto

Add a comment
Know the answer?
Add Answer to:
Create a new program in Mu and save it as ps3.3.1.py and take the code below...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a new program in Mu and save it as ps2.4.3.py Take the code below and...

    Create a new program in Mu and save it as ps2.4.3.py Take the code below and fix it as indicated in the comments: Level = 50 Attack = 125 Defense = 110 Power = 60 Modifier = 1 # You may modify the lines of code above, but don't move them! # Your code should work with different values for the variables. # In the Pokemon game franchise, damage is calculated using this formula found here: # https://bulbapedia.bulbagarden.net/wiki/Damage # #...

  • Create a new program in Mu and save it as ps2.4.1.py Take the code below and...

    Create a new program in Mu and save it as ps2.4.1.py Take the code below and fix it as indicated in the comments: dividend = 7 divisor = 3 # You may modify the lines of code above, but don't move them! # Your code should work with different values for the variables. # The variables above create a dividend and a divisor. Add # some code below that will print the quotient and remainder # of performing this operation....

  • Create a new program in Mu and save it as ps3.3.3.py and take the code below...

    Create a new program in Mu and save it as ps3.3.3.py and take the code below and fix it as indicated in the comments: mystery_int = 46 # You may modify the lines of code above, but don't move them! # When you Submit your code, it should work with # different values for the variables. # Use a while loop to create a countdown from mystery_int to # 0. Count down by 3s: if mystery_int is 46, then you...

  • Create a new program in Mu and save it as ps3.2.2.py and take the code below...

    Create a new program in Mu and save it as ps3.2.2.py and take the code below and fix it as indicated in the comments: egg = True milk = True butter = True flour = True # You may modify the lines of code above, but don't move them! # When you Submit your code, we'll change these lines to # assign different values to the variables. # Imagine you're deciding what you want to cook. The boolean # variables...

  • Create a new program in Mu and save it as ps2.3.3.py Take the code below and...

    Create a new program in Mu and save it as ps2.3.3.py Take the code below and fix it as indicated in the comments: busy = True hungry = False tired = True stressed = False # You may modify the lines of code above, but don't move them! # Your code should work with different values for the variables. # Logical operators get more complex when we start using them # with the results of other logical operators. So, let's...

  • Create a new program in Mu and save it as ps4.2.1.py and take the code below...

    Create a new program in Mu and save it as ps4.2.1.py and take the code below and fix it as indicated in the comments: # Write function called third_character that accepts a # string as an argument and returns the third character # of the string. If the user inputs a string with fewer than # 3 characters, return "Too short". # Write your function here! # Below are some lines of code that will test your function. # You...

  • Create a new program in Mu and save it as ps4.4.1.py and take the code below...

    Create a new program in Mu and save it as ps4.4.1.py and take the code below and fix it as indicated in the comments: # Write a function called "save_leaderboard" that accepts a # single list of tuples as a parameter. The tuples are of the # form (leader_name, score) # The function should open a file called "leaderboard.txt", # and write each of the tuples in the list to a line in the file. # The name and score...

  • Create a new program in Mu and save it as ps3.2.1.py and take the code below...

    Create a new program in Mu and save it as ps3.2.1.py and take the code below and fix it as indicated in the comments: hour = 3 minute = 45 # You may modify the lines of code above, but don't move them! # When you Submit your code, we'll change these lines to # assign different values to the variables. # Around Georgia Tech, there are plenty of places to get a # late night bite to eat. However,...

  • Create a new program in Mu and save it as ps3.4.2.py and take the code below...

    Create a new program in Mu and save it as ps3.4.2.py and take the code below and fix it as indicated in the comments: # A year is considered a leap year if it abides by the # following rules: # # - Every 4th year IS a leap year, EXCEPT... # - Every 100th year is NOT a leap year, EXCEPT... # - Every 400th year IS a leap year. # # This starts at year 0. For example:...

  • Create a new program in Mu and save it as ps3.4.3.py and take the code below...

    Create a new program in Mu and save it as ps3.4.3.py and take the code below and fix it as indicated in the comments: # Consult this blood pressures chart: http://bit.ly/2CloACs # # Write a function called check_blood_pressure that takes two # parameters: a systolic blood pressure and a diastolic blood # pressure, in that order. Your function should return "Low", # "Ideal", "Pre-high", or "High" -- whichever corresponds to # the given systolic and diastolic blood pressure. # #...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT