================= Lab 3 ================
#==================== Lab 3 ========================
#==================== Output =======================
#print(" Q8. What is the output of the following program?\n")
# print('========= lab3 Q8.(1) =========\n')
#
# import math
#
# print(math.sqrt(25)) #5.0
# print(math.pi) #3.141592653589793
# print(math.degrees(2)) #114.59155902616465
# print(math.radians(60)) #1.0471975511965976
# print(math.sin(2)) #0.9092974268256817
# print(math.cos(0.5)) #0.8775825618903728
# print(math.tan(0.23)) #0.23414336235146527
# print(math.factorial(4)) #24
#
# print("=============================================")
# print('========= lab3 Q8.(2) =========\n')
#
# import random
# print(random.randint(0,5)) #1
# print(random.random()) #0.07607634817310338
# print(random.random() * 100 ) #40.937658646256395
# list = [1, 4, True, 800, "python", 27, "hello"]
# print(random.choice(list)) #hello
# #formatted datetime ؟؟؟ وجوده سبب ما
#
# print("=============================================")
# print('========= lab3 Q8.(3) =========\n')
#
# import datetime
#
# current_datetime = datetime.datetime.now()
# print("-------------------------------------------------------------------------")
# print(' Format the output of the current date and time ')
# print("-------------------------------------------------------------------------")
# print('Current date and time : ',current_datetime)
# formatted_datetime = current_datetime.strftime("%Y-%m-%d %H:%M:%S")
# print("Formatted date and time : ",formatted_datetime)
# print("-------------------------------------------------------------------------")
# print(' Display the time in a 12-hour format instead of a 24-hour format ')
# print("-------------------------------------------------------------------------")
# #%I - Houe (12-hour clock) as a zero-padded decimal number (e.g,10)
# #p-AM/PM designation ()e.g.
# formatted_datetime = current_datetime.strftime("%Y-%m-%d %I:%M:%S %P")
# print("Formatted date and time : ",formatted_datetime)
# print("-------------------------------------------------------------------------")
# print(" customize the date and time format to include the day of the week ")
# print("-------------------------------------------------------------------------")
# formatted_datetime = current_datetime.strftime("%A, %B %d, %Y %I:%M:%S %P")
# print("-------------------------------------------------------------------------")
# print("Formatted date and time : ",formatted_datetime)
# formatted_datetime = current_datetime.strftime("%a, %b %d, %y %I:%M:%S %P")
الم
رقنة سلمان و سدى الورد/ هندسيان ضياء احمد علي الش فري/ الطالب
================= Lab 3 ================
# print("Formatted date and time : ",formatted_datetime)
#
# print("=============================================")
# print('========= lab3 Q8.(4) =========\n')
# from datetime import date
# today = date.today()
# d1 = today.strftime("%d/%m/%Y")
# print("P1 = ",d1)
#
# d2 = today.strftime("%B %d,%Y")
# print("P2 = ",d2)
#
# d3 = today.strftime("%m/%d/%y")
# print("P3 = ",d3)
#
# d4 = today.strftime("%b-%d-%Y")
# print("P4 = ",d3)
#
# print("=============================================")
#=================================================================
# print('========= lab3 Q9.(1) =========\n')
#print("Q9. Do these Programming Exercises with Python language to:")
# # 1. Write a program to perform different Arithmetic Operations on numbers in Python.
#
#
# def sum(num1,num2):
# return num1 + num2
#
#
# def sub(num1,num2):
# return num1 - num2
#
#
# def multi(num1,num2):
# return num1 * num2
#
#
# def div(num1,num2):
# if num2 != 0:
# return num1 / num2
# return "Error : Division by zero . "
#
#
# num1 = int(input("Enter num 1 : "))
الم
رقنة سلمان و سدى الورد/ هندسيان ضياء احمد علي الش فري/ الطالب
================= Lab 3 ================
# num2 = int(input("Enter num 2 : "))
#
# result = sum(num1,num2)
# print(f"'Sum' {num1} + {num2} = {result} ")
#
# result = sub(num1,num2)
# print(f"'Sub' {num1} - {num2} = {result} ")
#
# result = multi(num1,num2)
# print(f"'Multi' {num1} * {num2} = {result} ")
#
# result = div(num1,num2)
# print(f"'Div' {num1} / {num2} = {result} ")
# print("=============================================")
# print('========= lab3 Q9.(2) =========\n')
# #2. Write a program to create, concatenate and print a string and access.]ng sub-string
from a given string.
#
# string_1 = "Dyaa"
# string_2 = "Ahmed"
#
# new_string = string_1 + " " + string_2
#
# print("Curled text ", new_string)
#
# print("Sub-string (1) : ", new_string[0:5])
#
# print("Sub-string (2) : ", new_string[5:])
#
# print("=============================================")
# print('========= lab3 Q9.(3) =========\n')
# #3. Try to print the day, month, year in the form "Today is 2/2/2016".
#
#import datetime
# today = datetime.date.today()
# print(today)
#
# day = today.day
# month = today.month
# year = today.year
#
# print('Today is "{}/{}/{}"'.format(day,month,year))
#
# print("=============================================")
# print('========= lab3 Q9.(4) =========\n')
# #4. Make a Python program to find out what version of Python you are using Note
use: import sys
#import sys
# version = sys.version
# major_version = sys.version_info.major
# minor_version = sys.version_info.minor
# micro_version = sys.version_info.micro
#
# print("Python version : ", version)
# print("Major version : ", major_version)
الم
رقنة سلمان و سدى الورد/ هندسيان ضياء احمد علي الش فري/ الطالب
================= Lab 3 ================
# print("Minor version : ", minor_version)
# print("Micro version : ", micro_version)
# print("=============================================")
# print('========= lab3 Q9.(5) =========\n')
# #5. Write a program to get three values from the user and compute their average.
(Note: Use: eval())
#
# value_1 = eval(input("Enter the value 1 : "))
# value_2 = eval(input("Enter the value 2 : "))
# value_3 = eval(input("Enter the value 3 : "))
#
# avg = value_1 + value_2 + value_3 / 3
# print("Average = ",avg)
#
# print("=============================================")
# print('========= lab3 Q9.(6) =========\n')
# # 6. Write a program that takes 2 numbers as command line arguments and make a
Simple Calculator
# يفهم لم هذا المثال
#
# if len(sys.argv) != 3:
# print("Enter the tow numbers : ")
# sys.exit(1)
#
# num1 = int(sys.argv[1])
# num2 = int(sys.argv[2])
#
# addition = num1 + num2
# subtraction = num1 - num2
# multiplication = num1 * num2
# division = num1 / num2
#
# print("Addition :", addition)
# print("Subtraction :", subtraction)
# print("Multiplication :", multiplication)
# print("Division :", division)
#
# print("=============================================")
# print('========= lab3 Q9.(7) =========\n')
# # 7. Write a python program to define a module and import a specific function in that
module to another program.
#
# from my_module import *
# from my_module import box_data
# from my_module import welcome
# from my_module import emooji
# from my_module import arabic
# #from my_module import draw
#
# print("=============================================")
# print('========= lab3 Q9.(8) =========\n')
# #8. Create your own module with the function snakeo.
#import my_module2
# my_module2.snakeo() # include
#
# print("=============================================")
الم
رقنة سلمان و سدى الورد/ هندسيان ضياء احمد علي الش فري/ الطالب
================= Lab 3 ================
# print('========= lab3 Q9.(9) =========\n')
# #9. Importthe math module and call the sin function
#
# import math
# result = math.sin(0.5)
# print(result)
#
# print("=============================================")
# print('========= lab3 Q9.(10) =========\n')
# # Write a python program to get python version.
#
# import sys
#
# print('Current Python version is ',sys.version)
#
# print("=============================================")
# print('========= lab3 Q9.(11) =========\n')
# # 11. Write a python script to print the current date in the following format
''Sun May 29 02:26:23 lsT 2017"
#
# from datetime import datetime
#
# now = datetime.now()
# formatted_data = now.strftime("%a %b %d %H:%M:%S %Z %Y ")
# print(formatted_data)
#
# print("=============================================")
# print('========= lab3 Q9.(12) =========\n')
# # 12. Write a python program to add some days to your present date and print
the date added. Note: import datetime
#
# import datetime
#
# current_data = datetime.date.today()
# days_to_add = 20
# delta = datetime.timedelta(days=days_to_add)
# new_data = current_data + delta
#
# print("The data now is : ",current_data)
# print("The data new is : ",new_data)
#
# print("=============================================")
# print('========= lab3 Q9.(13) =========\n')
# # 13.Write programs to read in a value of x,then calculate the following expressions:
`a`.:2~+21, {b} 2-*+t {c) x-&
#
#
# print("========== program (a) ===========")
# x = eval(input("Enter the value (X) : "))
#
# result = (x - 2) / ((x ** 2) + 1)
الم
رقنة سلمان و سدى الورد/ هندسيان ضياء احمد علي الش فري/ الطالب
================= Lab 3 ================
# print(result)
#
#
# print("========== program (b) ===========")
# x = eval(input("Enter the value (X) : "))
#
# result = 2 ** (x + 1)
# print(result)
#
# print("========== program (c) ===========")
# x = eval(input("Enter the value (X) : "))
#
# result = x ** (-2 * x)
# print(result)
#
# print("=============================================")
# print('========= lab3 Q9.(14) =========\n')
# # 14. Create a program which converts temperature from Celsius to Fahrenheit
#
# c = eval(input("Enter the value (C) : "))
# fahrenheit = ((9 / 5) * c) + 32
# print("Fahrenheit is = ",fahrenheit)
#
# print("=============================================")
# print('========= lab3 Q9.(15) =========\n')
# #15. Write a program to compute distance between two points taking input
from the
# # user The Pythagorean theorem is the basis for computing distance between two points.
# # Let (xl,yl) and (x2,y2) be the co-ordinates of points on xy-plane. From
Pythagorean
# # theorem, the distance between two points js calculated using the formulae: math.sqrt(
# # (x2 -xl)**2 + (y2 -yl)**2 )
#
# # رقم السؤال يؤجل15
#
#
# print("=============================================")
# print('========= lab3 Q9.(16) =========\n')
# # 16. Write a program to convert U.S. dollars to Indian rupees.( Example exchange rate (1
USD = 74.5 lNR)
#
# USD = eval(input("Enter the dollar amount (USD) : "))
# exchange_to_INR = 74.5
# result = USD * exchange_to_INR
# print(f'The exchange rate of "{USD} $" equal to "{result} INR" .')
#
# print("=============================================")
# print('========= lab3 Q9.(17) =========\n')
# # 17. Write a program to convert bits to Megabytes, Gigabytes and Terabyte.
#
# def convert_bits_to_bytes(bits):
# bytes = bits / 8
# return bytes
الم
رقنة سلمان و سدى الورد/ هندسيان ضياء احمد علي الش فري/ الطالب
================= Lab 3 ================
#
# def convert_bytes_to_megabytes(bytes):
# megabytes = bytes / (1024 * 1024)
# return megabytes
#
# def convert_bytes_to_gigabytes(bytes):
# gigabytes = bytes / (1024 * 1024 * 1024)
# return gigabytes
#
# def convert_bytes_to_terabytes(bytes):
# terabytes = bytes / (1024 * 1024 * 1024 * 1024)
# return terabytes
#
# bits = int(input(" Enter the number of bits : "))
#
# bytes = convert_bits_to_bytes(bits)
# megabytes = convert_bytes_to_megabytes(bytes)
# gigabytes = convert_bytes_to_gigabytes(bytes)
# terabytes = convert_bytes_to_terabytes(bytes)
#
# print("The bits = ", bits)
# print("The byte = ", bytes)
# print("The megabytes = ", megabytes)
# print("The gigabytes = ", gigabytes)
# print("The terabytes = ", terabytes)
#
# print("=============================================")
# print('========= lab3 Q9.(18) =========\n')
# # 18. Write a program to find the square root of a number.
# import math
# num = eval(input("Enter the number : "))
# square_root = math.sqrt(num)
# print(f"The square root of a {num} = {square_root} ")
#
# print("=============================================")
# print('========= lab3 Q9.(19) =========\n')
# # 19. Write a program to calculate area and perimeter of the square.
#
# side_leangth = eval(input("Enter the side leangth of the square : "))
#
# area = side_leangth ** 2
# perimeter = 4 * side_leangth
#
# print("The area of the square is : ",area)
# print("The perimeter of the square is : ",perimeter)
#
# print("=============================================")
# print('========= lab3 Q9.(20) =========\n')
# #2o. Write a program to swap the value of two variables.
#
# def swap_values(var1, var2):
# temp = var1
# var1 = var2
# var2 = temp
# return var1, var2
الم
رقنة سلمان و سدى الورد/ هندسيان ضياء احمد علي الش فري/ الطالب
================= Lab 3 ================
#
# value1 = input("Enter the first value : ")
# value2 = input("Enter the second value : ")
#
# print("Original values : ")
# print("Value 1 = ", value1)
# print("Value 2 = ", value2)
#
# value1, value2 = swap_values(value1, value2)
#
# print("Swapped values:")
# print("Value 1 =", value1)
# print("Value 2 =", value2)
#
# print("=============================================")
# print('========= lab3 Q9.(21) =========\n')
# # 21. Python program to convert kilometers to miles
#
# kilometers = float(input("Enter the kilometers: "))
#
# miles = kilometers * 0.621371
#
# print("Converted kilometers = ", kilometers)
# print("Miles = ", miles)
#
# print("=============================================")
الم
رقنة سلمان و سدى الورد/ هندسيان ضياء احمد علي الش فري/ الطالب