Program outputs wrong output

formatted output in c
printf j
format specification in c
printf pound sign
c printf table
printf uppercase
printf lg
printf hd

I'm doing this for a school project and need to know why the output keeps spitting out "Estonia", even when the conditions don't meet. Also, why does the program put a "None" in some places? I'm not sure if I should include all my code or just a part though, so I'll put the whole thing just in case. I'm new, so please bare with my idocracy...

# Purpose: Create a program that suggests a vacation spot based on user input

# Here is the Input, or answers to the questions
print('Hello! This is your Dream Vacation Spot!')
answers = [input('Do you want a "hot" or "cold" place? '),
        input('Do you want a place that has a "huge" pop or "small" pop? '),
        input('Are you planning on getting wet? "y" or "n": ')]

# Create the intro that displays what they said. 
def intro():
    for i in range(2):
    print('Hi! Welcome to your Dream Vacation Spot!')
    print('Listed here, are your answers:')
    print('Hot or cold place? You said ' + answers[0])
    print('Huge population, or small towny place? You said ' + answers[1])
    print('Want to get wet? You said ' + answers[2])
    for i in range(2):

# Start using the if/ elif statements to decide places to go.
def main():
    if answers[0] == 'cold' and answers[1] == 'small' and answers[2] == 'wet' or 'Wet':
        one = 'Congrats!! You got... \n Estonia!'

    elif answers[0] == 'cold' or 'Cold' and answers[1] == 'big' or 'Big' and answers[2] == 'y' or 'Y':
        two = 'Congrats!! You got... \n Geirangerfjord, Norway!'

    elif answers[0] == 'cold' or 'Cold' and answers[1] == 'small' or 'Small' and answers[2] == 'n' or 'N':
        three = 'Congrats!! You got... \n Innsbruck, Austria!'

    elif answers[0] == 'cold' or 'Cold' and answers[1] == 'big' or 'Big' and answers[2] == 'n' or 'N':
        four = 'Congrats!! You got... \n Yellowknife, Canada!'

    elif answers[0] == 'hot' or 'Hot' and answers[1] == 'big' or 'Big' and answers[2] == 'n' or 'N':
        five = 'Congrats!! You got... \n Austin, Texas!'

    elif answers[0] == 'hot' or 'Hot' and answers[1] == 'small' or 'Small' and answers[2] == 'n' or 'N':
        six = 'Congrats!! You got... \n Bisbee, Arizona!'

    elif answers[0] == 'hot' or 'Hot' and answers[1] == 'small' or 'Small' and answers[2] == 'n' or 'N':
        seven = 'Congrats!! You got... \n Grand Junction, Colorado!'

    elif answers[0] == 'hot' or 'Hot' and answers[1] == 'small' or 'Small' and answers[2] == 'y' or 'Y':
        eight = 'Congrats!! You got... \n Muskogee, Oklahoma!'

def printAll():
    for i in range(2):
    print('Have a nice trip!!!')


Phew! that is a lot of code and there are probably some great lessons on how to deal with convoluted logic, lets see if we can't just make it work a bit better.

First I'd suggest you use list comprehension and the lower() function to simplify the number of possibilities in answers

answers_lowercase = [x.lower() for x in answers]

then why not use a single logical test in your if/elif statements, something like

def main():
    if answers_lowercase == ['cold', 'small', 'wet'] :
        print('Congrats!! You got... \n Estonia!')

There are probably even more concise, pythonic ways of writing out your code: i.e. looking up the correct answer from a table instead of using six "if" statements, and error handling if the user puts something wrong in the inputs. Good things to look into and learn from. Good luck!

Hybrid Learning and Education: First International Conference, , Stack overflow will occur if the program wrongly swapped the two variables. is wrong, some specific errors will trigger certain definite wrong outputs. annotations is based on analyzing the wrong output corresponding to the test case. When Students Are Done Developing Click "Run program". The output is wrong. Sometimes a program lacking input will produce wrong output (as in this case), Type 2 in the input box, then click "Run program", and note the output is 4. Type 3 in the input box instead, run, and note the output is

If you want you can change your conditions to use "in" keyword to avoid confusion between "and", "or" eg. answers[0] in ('cold','Cold') and answers[1] in ('big','Big') and answers[2] in ('y','Y')

Why Programs Fail: A Guide to Systematic Debugging, This is simple: Finding an error is not enough; we must also show that the the program outputs a = 0, we assume that compute_value() produces an infection. However, we have not shown that a being zero causes the program to output a = 0  If you had put commas (,) into your array, it would have output 0. Because you forgot the commas, 0234 leads with a 0, which denotes an octal number. 234 is 2 x (8 x 8) + 3 x 8 + 4 = 156

Your problem lies in the if statements. When you check for or condition surround it with a bracket.

eg. answers[0] == ('cold' or 'Cold') and answers[1] == ('big' or 'Big') and answers[2] == ('y' or 'Y')

getting wrong output from simple program, getting wrong output from simple program. Code: [View]. #include <stdio.h> int main() { int a=100; int c; printf("%d\n", c); c = a * a; }. the output  a) should be int main not void b)i would use std::vector or dynamic arrays instead of creating an array of 50 to hold two elements c) look at line 73: fil.write((char*)&S,sizeof(S));. your trying to convert an ACCOUNT to a char*, which wont work. you need to either a) overload the >> operator for ofstream, or b) write getters and setters and write it all to file manually

Add program C is showing wrong output, Hide Copy Code. printf("The addition of a and b is %d", c ); printf requires a value and not pointer. To the right of the volume slider for each app, click the “Output” or “Input” dropdowns to assign a different output or input device to the app. For example, you could have one app output sound to your headphones and other apps output sound to your speakers. Or you could use different recording devices for different applications.

Wrong Output - C++ Forum, Show(); cout<<endl; } } //void DisplayAll() closes. void main() { clrscr(); int n; do { cout<< "Enter the number of accounts you want to enter less  Outputs are necessary and not sufficient to determine if a program is being effective. The field of evaluation started with determining bean counts and satisfactions. Outcomes can be categorized as short term, medium/intermediate term, or long term. Long term outcomes are often called impacts.

C Tutorial – printf, Format Specifiers, Format Conversions and , We will look at how to use format specifiers to print formatted output onto the screen. from the standard library of functions that are accessible by C programs​. If you don't use enough arguments or if they are of the wrong type than printf will  Check the settings from tcode NACE -> Condition records -> output type -> The time should be set as 1. Now re-trigger output type from document and process it from RSNAST00, it will be processed without the error you have mentioned. An example for Billing output: Goto tcode VV32 - Fill in your own Output Type

  • This is still wrong, just in a slightly different way.