




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
This introduction to python for how new in this area
Typology: Lecture notes
1 / 8
This page cannot be seen from the preview
Don't miss anything!
Go to the IDLE and open a new window (select New Window under the File Menu). Then => Type in the following code. Then, under the Run menu, choose Run Module Note : 1.the IDLE will ask you to save the file, and you should do so.
any input by default as string, but if we need input a number, we need use another function called eval. Each input value should store in variable, that’s why we need to give name of this value. This variable just memory location that used by our program. In our previous example this variable is a number that hold the value that entered by user. In line #2 , we have 2# print( 'Square Number of ' , number, '=' , numbernumber) The print function to print out the information that can help user to deal with program. The part in quotes is will appear to your program’s user exactly. The argument to the print function is the print the number that user entered, then print “=” , last print the numerical result of calculation numbernumber. Note: This above print function has 4 arguments
As we explained previous that the input function is a basic way to get user input Here is an example: The output will be Figure 2 print function with 4 arguments 1# name = input ( 'Enter your name: ' )) 2# print( ' Hello ' , name) Enter your name: Bill Hello Bill Process finished with exit code 0
Figure 1 The basic syntax of input function
output will be the output will be Note: In Python, print, Print, and PRINT are all different. Most of keyword in python with lowercase
The sum of 2 + 3 = 5 Process finished with exit code 0 num1= num2= print("The sum of ", num1, '+' , num2,'=',num1+num2)
the output will be
The default print function will end the print function to the next line which mean next
the output will be
the output will be name= "Bill" Age= 22 print( "name =" ,name , "Age=" ,Age, "Year =" , 2020 ) print( "name =" ,name , "Age=" ,Age, "Year =" , 2020 , sep= " * " ) name = Bill Age= 22 Year = 2020 name = * Bill * Age= * 22 * Year = * 2020 Process finished with exit code 0 Yourname= "BillSmith" print( "Your email" ,Yourname, end= "" ) print( "@MySchool.edu " )
Yourname= "BillSmith" print( "Your email" ,Yourname, end= "@" ) print( "MySchool.edu " )
%[
In previous our first program example we have used of a variable called number:
1- Write a program that Ask the user to enter three numbers then computes and prints the result of average of this number.
1# number = eval(input( 'Enter a Number: ' )) 2# print( 'Square Number of ' , number, '=' , number*number)