Help for a newbie


Joined
Feb 13, 2023
Messages
7
Reaction score
0
I'm trying to learn to code but i'm not finding it easy

I'm up to here so far and i've hit a brick wall


The question is

'
'Using the trinket IDE below, write a program that asks a user to input their name and then displays a message that welcomes the user by name.

Example output for program: Welcome Mike!

Remember to use the input command to get information and the print command to output information to the user.'


If I copy and paste the answer they give, it would be

name = input("What is your name?")
print("Welcome " + name + "!")


Obviously i've got to arrange it to say 'welcome mike'

So far i've tried

name = input("Mike")
print("Welcome " + name + "!")

But the trinket says 'Mike' and nothing else


I Know it's my first post, so i'm not sure if it's okay to just ask for help straight away but I wondering if anyone could help out?

thanks
 
Ad

Advertisements

Joined
Sep 21, 2022
Messages
88
Reaction score
12
Someone on the forum might give a clear explanation about what "input" and "print" do. Which will stroke their ego but that will not help you in the long term.

Some things, you have to figure out yourself.

Programming is about problem solving.

I had trouble with the GOTO command in BASIC on a ZX81 home computer. I would change the number and the program would mysteriously behave in different ways.

Turns out that the number after GOTO was a line number, and GOTO is two words, GO TO.

Took a while to figure out. Feel free to mock me.
 
Joined
Dec 10, 2022
Messages
55
Reaction score
14
Some basic examples

Python:
name = input('>> ') or 'Mike'
print(f'Welcome {name}!')
 
Last edited:
Joined
Feb 13, 2023
Messages
7
Reaction score
0
If it was an exam my final answer would be

name = input('Welcome Mike!')

I think it might fail because I don't type 'print' ,but the trinket says exactly what the original question asked 'Welcome Mike!'
 
Joined
Dec 10, 2022
Messages
55
Reaction score
14
All this line is doing is saying if input is empty assign Mike. If input has a value then use the value.
 
Joined
Feb 13, 2023
Messages
7
Reaction score
0
Okay, i've settled on

name = " Mike"
print("Welcome" + name + "!")

I'm 90% certain i'm correct this time

I had to leave a space between the first " and the M otherwise it would look wrong on the trinket, if that isn't a big deal then I think i've done it right this time
 
Ad

Advertisements

Joined
Feb 6, 2023
Messages
42
Reaction score
2
No you are not getting an input? The problem wasn't with your code, but you weren't providing an input. But you could replace input("Mike") with input("What's your name?")
 
Joined
Feb 13, 2023
Messages
7
Reaction score
0
No you are not getting an input? The problem wasn't with your code, but you weren't providing an input. But you could replace input("Mike") with input("What's your name?")
If i type what I said the trinket says - 'Welcome Mike

If i change Mike for input the trinket says - Welcome input!

Surely it's better for it to say 'welcome mike'?
 
Joined
Feb 13, 2023
Messages
7
Reaction score
0
The sample code says

name = input("What is your name?")
print("Welcome " + name + "!")

But that doesn't ,make sense as they want the trinket to says 'welcome mike!'
 
Joined
Feb 6, 2023
Messages
42
Reaction score
2
You are supposed to give an input. When you use the function input, it propmts the user for an input, and when the input is mike, it prints hello mike. So just coding print(“hello mike”) doesnt make sense. That’s not how coding works. You wanna be as general as possible.
 
Joined
Feb 13, 2023
Messages
7
Reaction score
0
I've been at this question at least once a week since febuary and i can't get past it.

If I put
name = input("Mike")
print("Welcome " + name + "!")

The trinket says 'Welcome Mike'

and if i put
print("Welcome Mike")

The trinket also say 'Welcome Mike'

How do i understand which one is correct?

The sample they gave was

'
name = input("What is your name?")
print("Welcome " + name + "!").

But that seems different again, i'm close to quitting but what do you think guys? Maybe my brain isn't cut out for this?
 
Ad

Advertisements

Joined
Sep 21, 2022
Messages
88
Reaction score
12
Quit.

One variable.
One input function.
One print statement.

There are few programs that are as simple as this.

Are you really stuck?

Are you pulling the forum's legs?
 
Joined
Feb 13, 2023
Messages
7
Reaction score
0
Quit.

One variable.
One input function.
One print statement.

There are few programs that are as simple as this.

Are you really stuck?

Are you pulling the forum's legs?

Yeah I'm honestly stuck, I can't help it, sorry for being a dick but yeah :(
 
Ad

Advertisements

Joined
Sep 21, 2022
Messages
88
Reaction score
12
Back to basics.

step 1: load the program

This is called the source code.

Depending on your system this could be: typing it in (old school); copying and pasting into a window (web based IDE); selecting a file (pc based IDE).

step 2: run the program

step 3: interact with the program

If the program's source code has an input function, you will see some kind of prompt. Probably also a cursor.

Type something at the prompt, then press enter, or okay, or whatever your "trinket" is showing you.

Whatever you typed has now been stored, as a string, in a variable.

The program will do something with your string variable, and then print something.

+ when used with a string usually means concatenate.

step 4: the program will end

The prompt you saw is the text inside the input function's parentheses.

=input("Here is the prompt")

Sometimes the source code is displayed in the same window as the input and output.

Good luck.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top