Lab 1 2 ML

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Department of Computer Science HITEC

University, Taxila BS Computer Science


Program (Batch 2021)

CS-428 Introduction to Machine Learning


3(2+1)
Section B

Lab Report # 1 & 2


Muhammad Jahangir
21-cs-089
Basit Ali
21-cs-104
Instructor: Ms. Faiza Jahangir
TASK 1
Installation of Anacond3

Click Next

Click On I Agree
Click Next

Click Next
Click Install
Click Next

Click Next
Click Finish

Launch Jupyter Notebook


Click on new and then click python 3
Task 2
1 Write a program that asks the user for his name and then Hello him.
Code

Output

Explanation

This Python code asks the user for their name using the input() function, stores the entered name
in a variable called name, and then prints a welcome message that includes the user's name using
the print() function. It effectively greets the user with a personalized welcome message.
2 Write a program that prompts the user to input a Celsius temperature and
outputs the equivalent temperature in Fahrenheit.
Code

Output

Explanation

This Python code accepts a temperature in Celsius from the user, converts it to Fahrenheit using
the appropriate formula, and then displays the converted temperature in a user-friendly format with
one decimal place.
3 Write a program that accepts seconds from keyboard as integer. Your
program should converts seconds in hours, minutes and seconds.
Code

Output

Explanation

This Python code snippet takes a user-input number of seconds, converts it into hours, minutes,
and seconds, and then prints these converted values. It uses integer division and the modulo
operation to break down the total seconds into hours, minutes, and the remaining seconds. The
code then displays the calculated hours, minutes, and seconds to the user.
4 Write a program that prompts the user to enter number in two variables
and swap the contents of the variables.
Code

Output

Explanation

This program asks the user for two names, stores them in variables name and name2, and then
swaps their values using a temporary variable. It prints the original names and the names after the
swap.
5 Write a program that prompts the user to input the number and show table.
Code

Output

Explanation

In this program we uses a for loop to generate and print the multiplication table for the number
12. It iterates through the numbers from 1 to 10, calculating the product of 12 and each number in
the range and then printing the result in a formatted manner, such as "12 x 3 = 36". The program
does this for all values from 1 to 10, effectively displaying the multiplication table for 12.
Conclusion

In this Lab we learn about how to install the anaconda software and how to use this tool for python
language. We also do some programs these programs demonstrate a range of basic programming
concepts, including input/output, mathematical calculations, and variable manipulation. You can
adapt and use these programs for various purposes by replacing the provided inputs with your own
data or requirements.

You might also like