0% found this document useful (0 votes)
12 views

Python week 1

The document outlines basic Python programming concepts including printing variables, concatenating strings, and formatting output. It also covers user input and provides examples of tasks such as calculating sums, finding the largest number, and checking for palindromes. Additional exercises include calculating square roots, areas, and temperature conversions.

Uploaded by

vj2932
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Python week 1

The document outlines basic Python programming concepts including printing variables, concatenating strings, and formatting output. It also covers user input and provides examples of tasks such as calculating sums, finding the largest number, and checking for palindromes. Additional exercises include calculating square roots, areas, and temperature conversions.

Uploaded by

vj2932
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Python Week 1:

1. Print Python Variables and Literals

number = -10.6

name = "Programiz"

# print literals

print(5)

# print variables

print(number)

print(name)

Output

5
-10.6
Programiz

2. Print Concatenated Strings

print('Programiz is ' + 'awesome.')

output
Programiz is awesome.

3. Output formatting

x=5
y = 10

print('The value of x is {} and y is {}'.format(x,y))

output
15

amount = 150.75
print("Amount: ${:.2f}".format(amount))

output
Amount: $150.75
4. Python User Input

# using input() to take user input


num = input('Enter a number: ')

print('You Entered:', num)

print('Data type of num:', type(num))

Output

Enter a number: 10
You Entered: 10
Data type of num: <class 'str'>

5. Calculate the sum of two numbers entered by the user.


6. Find the largest among three numbers entered by the user.
7. Write a Python program to print all even numbers from 1 to 20.
8. Calculate the sum of all numbers from 1 to a given number.
9. Write a Python program to check if a given string is a palindrome.
10. Count the number of vowels in a given string.
11. Find Square Root
12. Area Of Triangle
13. Fahrenheit To Celsius
14. Positive, Negative Or Zero
15. Odd Or Even

You might also like