I'm working on the first project/assignment "zero", .. it says write a program that asks for last name, asks for first name, then prints the first then last name. Does writing the program mean having all of those tasks run from one command (ie. all from one entry, only hit enter once, then prompts for last name, prompts for first name, and prints first then last name)??
I think the goal is to get you familiar with the programming environment, being able to save several lines of code at once instead of doing line by line will be needed in later assignments. If you're using Python 2.7 and open IDLE go to File > New Window you can then write several lines at a time and run at once.
thank you. What is the format for writing several lines at once? do you place a comma in between lines, enter to a new line? and then how do you run it in the python shell?
Enter to move to next line typically. Once you have your code written you can either hit F5 or go to Run > Run Module
awesome, got it working , thanks!!
I think if this is just a mere programming excercise then you can do it in the following two ways: a)for C programming: i)declare the first and last names as arrays of a defined size e.g let's take char f_name[20],l_name[20]; for instance and then use two printf() and two scanf() to get the input from the user,and then use the folowing to display the two names: printf("%s %s ",f_name,s_name); ii)you can also use the a single printf() and a single scanf() for inputting the two names,for instance: # include<stdio.h> void main() { char f_name[20],l_name[20]; printf("Enter your first name folowed by hte second name:\n"); scanf("%s %s",&f_name,&l_name); printf("Your names: %s %s",f_name,l_name); }//we note that the new line character('\n') must be included in order to input the two names b)for C++ programming ,the syntax is the same,but with just a few differences: i) #include<iostream.h> void main() { char f_name[20],l_name[20]; cout<<"Enter your firstn name:"<<endl; cin>>f_name; cout<<"Enter your second name:"<<endl; cin>>l_name; cout<<"Your names: "<<f_name<<" "<<l_name<<endl; } ii) #include<iostream.h> void main() { char f_name[20],l_name[20]; cout<<"Enter your first name followed by your last name:\n"; cin>>f_name>>l_name; cout<<"Your names: "<<f_name<<" "<<l_name<<endl; }
This class is done in Python and therefore the actual coding will be much simpler and more intuitive. This makes the class more about computer programming and less about a particular programming language.
Join our real-time social learning platform and learn together with your friends!