Question

(PYTHON) I assigned a number to each month so that i could “add” to them, create...

(PYTHON) I assigned a number to each month so that i could “add” to them, create a new variable and then print the new month in letter form. However I get an error when i run the program. Is there a specific way i need to assign them numbers ?

for example i did
month = input (Enter the month”)
assigned january =1 february =2 etc
and then did
precedingMonth = month + 1

then tried to do
print( “the next month is”, precedingMonth)

Homework Answers

Answer #1

Answer: Dear student, Kindly find the code, i think after seeing this code your issues will be solved. You didn't mention full question means what you want in program i think that you want a program that prompts for month and add a number in this to find preceding month and print out the preceding month. This porgram is doing the same. you have to assign numbers for each variable in new line. If you have any queries , feel free to ask me. Thanks.

month = int(input("Enter the month:"))
january = 1
february = 2
march = 3
april = 4
may = 5
june = 6
july = 7
august = 8
september = 9
october = 10
november = 11
december = 12

precedingMonth = month+1
if precedingMonth == 2:
print("The preceding month is-February")
elif precedingMonth == 3:
print("The preceding month is-March")
elif precedingMonth == 4:
print("The preceding month is-April")
elif precedingMonth == 5:
print("The preceding month is-May")
elif precedingMonth == 6:
print("The preceding month is-June")
elif precedingMonth == 7:
print("The preceding month is-July")
elif precedingMonth == 8:
print("The preceding month is-August")
elif precedingMonth == 9:
print("The preceding month is-September")
elif precedingMonth == 10:
print("The preceding month is-October")
elif precedingMonth == 11:
print("The preceding month is-November")
elif precedingMonth == 12:
print("The preceding month is-December")

Know the answer?
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
Similar Questions
Create a Java Program/Class named MonthNames that will display the Month names using an array. 1....
Create a Java Program/Class named MonthNames that will display the Month names using an array. 1. Create an array of string named MONTHS and assign it the values "January - December". All 12 months need to be in the array with the first element being "January", then "February", etc. 2. Using a loop, prompt me to enter an int variable of 1-12 to display the Month of the Year. Once you have the value, the program needs to adjust the...
Create a Java Program/Class named MonthNames that will display the Month names using an array. 1....
Create a Java Program/Class named MonthNames that will display the Month names using an array. 1. Create an array of string named MONTHS and assign it the values "January" through "December". All 12 months need to be in the array with the first element being "January", then "February", etc. 2. Using a loop, prompt me to enter an int variable of 1-12 to display the Month of the Year. Once you have the value, the program needs to adjust the...
#include <iostream> #include <string> using namespace std; string STUDENT = "ckim84"; // Add your Blackboard login...
#include <iostream> #include <string> using namespace std; string STUDENT = "ckim84"; // Add your Blackboard login name extern string ASSIGNMENT; /** * Describe the purpose of your program here. * @return 0 for success. */ int run() { repeatChar(3, "abcde$"); return 0; } string repeatChar(int n, const string& pat) { string result; for (int i = 0; i < n; i++) { result += pat; } return result; } could you correct my code?? i got an error msg like...
Decisions, decisions, decisions. Computers are terrible at them, so as programmers we need to instruct them...
Decisions, decisions, decisions. Computers are terrible at them, so as programmers we need to instruct them on how to make good ones. In this lab you will write a program that accepts a date in the form “month/day/year” and prints whether or not the date is valid. For example 5/24/1962 is valid, but 9/31/2000 is not. (September has only 30 days.) Your program, in order to be correct, should be able to pass these simple (but far from complete!) test...
Create an add method for the BST (Binary Search Tree) class. add(self, new_value: object) -> None:...
Create an add method for the BST (Binary Search Tree) class. add(self, new_value: object) -> None: """This method adds new value to the tree, maintaining BST property. Duplicates must be allowed and placed in the right subtree.""" Example #1: tree = BST() print(tree) tree.add(10) tree.add(15) tree.add(5) print(tree) tree.add(15) tree.add(15) print(tree) tree.add(5) print(tree) Output: TREE in order { } TREE in order { 5, 10, 15 } TREE in order { 5, 10, 15, 15, 15 } TREE in order {...
The last thing we will learn about in python is functions. Functions are a great way...
The last thing we will learn about in python is functions. Functions are a great way to organize your program - we use them to write code that is executed only under certain circumstances - for instance when you're using Amazon, any of the following are likely functions within their program: - Add item to cart, determine arrival date,  create a new address, compute taxes, compute shipping charges, charge credit card Because you can write a task-specific function once, and ensure...
** Language Used : Python ** PART 2 : Create a list of unique words This...
** Language Used : Python ** PART 2 : Create a list of unique words This part of the project involves creating a function that will manage a List of unique strings. The function is passed a string and a list as arguments. It passes a list back. The function to add a word to a List if word does not exist in the List. If the word does exist in the List, the function does nothing. Create a test...
Create a simple Java class for a Month object with the following requirements:  This program...
Create a simple Java class for a Month object with the following requirements:  This program will have a header block comment with your name, the course and section, as well as a brief description of what the class does.  All methods will have comments concerning their purpose, their inputs, and their outputs  One integer property: monthNumber (protected to only allow values 1-12). This is a numeric representation of the month (e.g. 1 represents January, 2 represents February,...
*********JUST NEED JAVASCRIPT CODE************** I want you to create a Mad Libs game using the information...
*********JUST NEED JAVASCRIPT CODE************** I want you to create a Mad Libs game using the information from the lesson. There are a few requirements. The story must be printed out to the console. You must ask for a minimum of six (6) pieces of information. You must request at least three numbers add a number greater than one to each of them. What you decide to add is up to you but each value must be ADDED (not subtracted) to...
Assignment 2 Programming Language: Python 2 Preface: Create a new python file with a name of...
Assignment 2 Programming Language: Python 2 Preface: Create a new python file with a name of your choosing (ex: “assignment2.py”). At the top of the file paste the following: import numpy as np import random class Base_Obstacle_Map(object):     def __init__(self, length, width):         self.map = np.zeros((length, width), dtype=np.uint8)     def add_obstacle(self, x, y):         self.map[x, y] = 1     def remove_obstacle(self, x, y):         self.map[x, y] = 0     def display_map(self):         try:             import matplotlib.pyplot as plt             plt.imshow(self.map)...