0% found this document useful (0 votes)
25 views3 pages

Lab 2

This document contains the code output from various Python programming exercises. It tests different string formatting methods, takes user input, performs type checking and conversions between numbers and characters. Various printing methods are also demonstrated.

Uploaded by

Amr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views3 pages

Lab 2

This document contains the code output from various Python programming exercises. It tests different string formatting methods, takes user input, performs type checking and conversions between numbers and characters. Various printing methods are also demonstrated.

Uploaded by

Amr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

================= Lab 2 ================

#print('========= lab2 Q4.(1) =========\n')


# s="My lucky number is %d, what is your?"%7
# print(s[3:8])
# print("the day, month, year")
# s="The date is %d/%d/%d"%(16, 2, 2024)
# print(s)
# #output=
# #lucky
# #the day, month, year
# #The date is 16/2/2024
#
# print('========= lab1 Q4.(2) =========\n')
#
# x="Eng:Ruqih Hussein Salman"
# print(x)
#
# s="My lucky number is %d what is yours?"%7
# print(s)
#
# s="My lucky number is " + str(7) +", what is yours?"
# print(s)
#
# print(x[0])
#
# print(x[0:3])
#
# #output=
# # Eng:Ruqih Hussein Salman
# # My lucky number is 7 what is yours?
# # My lucky number is 7, what is yours?
# # E
# # Eng
#
# print('========= lab2 Q4.(3) =========\n')
#
# num=458.54113
# print('%.2f'%num)
# #output=
# #458.54
#
# print('========= lab2 Q4.(4) =========\n')
#
# print(eval("34.5"))
# print(eval("3"))
# print(eval("4+4"))
# #print(eval("51 +(54 +(3+2))" # Error
# #print(eval(10)) # Error
# #print(eval(22.77)) # Error
# #print(eval(True)) # Error
#
# #output=
# #34.5
# #3
# #8
#
# print('========= lab2 Q4.(5) =========\n')
#
# string1="Hello"
# string2=string1
# string1 +=" World"

‫الم‬
‫ رقنة سلمان و سدى الورد‬/ ‫هندسيان‬ ‫ ضياء احمد علي الش فري‬/ ‫الطالب‬
================= Lab 2 ================

# print(string1)
# print(string2)
# # output=
# # Hello World
# # Hello
#
#
# print('========= lab2 Q5.(1) =========\n')
#
# print(type(5).__name__,) # int
# print(type(5.2).__name__,) # float
# print(type("python").__name__,) # str
# print(type(True).__name__,) # bool
# print(type(["a","b","c"]).__name__,) # list
# print(type(("a","b","c")).__name__,) # tuple
# print(type({"a","b","c"}).__name__) # set
#
#
# print('========= lab2 Q5.(2) =========\n')
#
# print('Welcome, dear user . ')
# print('My favorite Quran reciter is "Islam Sobhi" ^_^ .')
#
#
# print('========= lab2 Q5.(3) =========\n')
#
# num_phone=input("What is your phone number ? 'Enter' : ")
# print("Your phone number is : "+num_phone)
#
# print('========= lab2 Q5.(4) =========\n')
#
# name1="Name"
# name2="is"
# name3="Dyaa Ahmed"
#
# print(name1,name2,name3,sep="#") # Way 1
#
# print(name1,end="_") # Way 2
# print(name2,end=":")
# print(name3)
#
# print('========= lab2 Q5.(5) =========\n')
#
# language=input("What is your Preferred Programming languages ? 'Enter' : ")
# print("Your Preferred Programming language is : "+language)
#
# print('========= lab2 Q5.(6) =========\n')
#
# print('\n======== From char to number ========\n')
#
# char=input("Enter the char : ")
# char_num=ord(char)
# print(f"The char is : {char} \nThe ASCII is : {char_num}")
#
#
# print('\n======== From number to char ========\n')
#
# number=int(input("Enter the number : "))
# ascii_value=chr(number)
# print(f"The ascii value is : {number} \nThe char is : {ascii_value}")
#

‫الم‬
‫ رقنة سلمان و سدى الورد‬/ ‫هندسيان‬ ‫ ضياء احمد علي الش فري‬/ ‫الطالب‬
================= Lab 2 ================

#
# print('========= lab2 Q5.(7) =========\n')
#
# num2=458.541315
# print('%.2f'%num2)
#
# print('========= lab2 Q5.(8) =========\n')
#
# a,b,c=map(input,["a=","b=","c="]) # Way 1
# print(a,b,c)
#
# a,b,c=input("Enter (',') a= ,b= ,c= ").split(",") # Way 2
# print("a= ",a," b= ",b," c= ",c)
#
# print('========= lab2 Q5.(9) =========\n')
#
# d,e,f=map(str,input("enter 3 word ('/')").split("/"))
# print(d)
# print(e)
# print(f)
#
# print('========= lab2 Q5.(10) =========\n')
#
# totalMoney=1000
# quantity=3
# price=450
# print('I have {} dollars so I can buy {} football for {}
dollars.'.format(totalMoney,quantity,'%.2f'% price)) # 1
# print(f'I have {totalMoney} dollars so I can buy {quantity} football for {'%.2f'% price}
dollars.') # 2
# print('I have '+str(totalMoney) +' dollars so I can buy '+str(quantity)+ ' football for '+
str('%.2f'% price) +' dollars.') # 3
# print('I have',totalMoney,'dollars so I can buy',quantity,'football for','%.2f'%
price,'dollars.') #4
#
#
# print('\n\n========= lab2 Q5.(11) =========\n')
#
# name=input('What is your name? "Enter name:"')
# age=int(input('What is your old ? "Enter age:"'))
#
# ageAfter100=age+100
# print('\n-------------------------------')
# print("Hello, ",name,".","\nYour age now is: ",age,"years old.","\nYour age After 100
years is : ",ageAfter100,"years old.")
# print('-------------------------------')
#
#
# print("\n\nThank God, I finished LAB2")

‫الم‬
‫ رقنة سلمان و سدى الورد‬/ ‫هندسيان‬ ‫ ضياء احمد علي الش فري‬/ ‫الطالب‬

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy