Simulation transcript_Generate code using IBM watsonx Prompt Lab
Simulation transcript_Generate code using IBM watsonx Prompt Lab
• Utilize the example set up in IBM watsonx Prompt Lab for generating Python code.
The Code pad provides all the input text you’ll need to complete the task. Type the input exactly as it is
displayed in the Code pad.
Select the field to start typing. When you finish typing the command, press Enter.
1. Ensure that the AI model codellama-34b-instruct-hf is selected and the Prompt Lab is set up
to generate Python code.
Which of the following is the best prompt to create this Python program?
Create a Python program that asks for my name and prints a greeting with it. After I enter my name,
the program should display "Hello, [my name]!"
Create a Python program that asks for my name and prints "Hello" followed by my name.
Create a Python program that asks for a name and prints "Hi, [name]!" after I enter it.
Create a Python program that asks for your name and prints a welcome message with your name.
1
Use Generative AI for Software Development
• Set up in IBM watsonx Prompt Lab for converting Python code to another language.
The Code pad provides all the input text you’ll need to complete the task. Type the input exactly as it is
displayed in the Code pad.
Select the field to start typing. When you finish typing the command, press Enter.
5. Set up the AI by typing the instruction exactly as it is displayed in the Code pad.
6. Remove the example by selecting the cross (). This example is not relevant for translation of code.
You do not have an example prompt and its output for converting Python code to HTML. So, leave it
blank and select the Next arrow to continue.
8. Copy and paste the input prompt from the Code pad.
2
Use Generative AI for Software Development
The Code pad provides all the input text you’ll need to complete the task. Type the input exactly as it is
displayed in the Code pad.
Select the field to start typing. When you finish typing the command, press Enter.
11. Copy the AI-generated code from the Code pad and paste in the file GreetByName.html.
12. Type the file location “D:\MyProject\GreetByName.html” in the address bar to view the file in
the browser.
14. Observe the greeting displayed. The AI-generated HTML code is working as expected.
3
Use Generative AI for Software Development
Conclusion
You have successfully generated code using prompts in IBM watsonx Prompt Lab.